File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
compiler/rustc_codegen_gcc Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -63,3 +63,6 @@ codegen_gcc_invalid_monomorphization_unsupported_operation =
6363
6464codegen_gcc_invalid_minimum_alignment =
6565 invalid minimum global alignment: { $err }
66+
67+ codegen_gcc_tied_target_features = the target features { $features } must all be either enabled or disabled together
68+ .help = add the missing features in a `target_feature` attribute
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use rustc_session::Session;
99use rustc_span:: symbol:: sym;
1010use smallvec:: { smallvec, SmallVec } ;
1111
12- use crate :: context:: CodegenCx ;
12+ use crate :: { context:: CodegenCx , errors :: TiedTargetFeatures } ;
1313
1414// Given a map from target_features to whether they are enabled or disabled,
1515// ensure only valid combinations are allowed.
@@ -84,10 +84,11 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
8484 let span = cx. tcx
8585 . get_attr ( instance. def_id ( ) , sym:: target_feature)
8686 . map_or_else ( || cx. tcx . def_span ( instance. def_id ( ) ) , |a| a. span ) ;
87- let msg = format ! ( "the target features {} must all be either enabled or disabled together" , features. join( ", " ) ) ;
88- let mut err = cx. tcx . sess . struct_span_err ( span, & msg) ;
89- err. help ( "add the missing features in a `target_feature` attribute" ) ;
90- err. emit ( ) ;
87+ cx. tcx . sess . create_err ( TiedTargetFeatures {
88+ features : features. join ( ", " ) ,
89+ span,
90+ } )
91+ . emit ( ) ;
9192 return ;
9293 }
9394
Original file line number Diff line number Diff line change @@ -227,3 +227,12 @@ pub(crate) struct UnwindingInlineAsm {
227227pub ( crate ) struct InvalidMinimumAlignment {
228228 pub err : String ,
229229}
230+
231+ #[ derive( Diagnostic ) ]
232+ #[ diag( codegen_gcc_tied_target_features) ]
233+ #[ help]
234+ pub ( crate ) struct TiedTargetFeatures {
235+ #[ primary_span]
236+ pub span : Span ,
237+ pub features : String ,
238+ }
You can’t perform that action at this time.
0 commit comments