4
4
//! conflicts between multiple such attributes attached to the same
5
5
//! item.
6
6
7
+ use std:: cell:: Cell ;
8
+ use std:: collections:: hash_map:: Entry ;
9
+
10
+ use rustc_ast:: token:: TokenKind ;
11
+ use rustc_ast:: tokenstream:: TokenTree ;
7
12
use rustc_ast:: {
8
13
AttrKind , AttrStyle , Attribute , LitKind , MetaItemInner , MetaItemKind , MetaItemLit , ast,
9
14
token:: TokenKind , tokenstream:: TokenTree , AttrKind , AttrStyle , Attribute , LitKind ,
@@ -38,8 +43,6 @@ use rustc_target::spec::abi::Abi;
38
43
use rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ;
39
44
use rustc_trait_selection:: infer:: { TyCtxtInferExt , ValuePairs } ;
40
45
use rustc_trait_selection:: traits:: ObligationCtxt ;
41
- use std:: cell:: Cell ;
42
- use std:: collections:: hash_map:: Entry ;
43
46
use tracing:: debug;
44
47
45
48
use crate :: { errors, fluent_generated as fluent} ;
@@ -2389,7 +2392,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2389
2392
// Valid item for `instruction_set()` is:
2390
2393
// - arm::a32
2391
2394
// - arm::t32
2392
- let valid_attribute = match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
2395
+ match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
2393
2396
(
2394
2397
Some ( TokenTree :: Token ( first_token, _) ) ,
2395
2398
Some ( TokenTree :: Token ( second_token, _) ) ,
@@ -2398,18 +2401,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2398
2401
( Some ( first_ident) , TokenKind :: PathSep , Some ( third_ident) )
2399
2402
if first_ident. 0 . name == sym:: arm =>
2400
2403
{
2401
- third_ident. 0 . name == sym:: a32 || third_ident. 0 . name == sym:: t32
2404
+ if third_ident. 0 . name == sym:: a32 || third_ident. 0 . name == sym:: t32 {
2405
+ return ;
2406
+ } else {
2407
+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2408
+ }
2409
+ }
2410
+ _ => {
2411
+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2402
2412
}
2403
- _ => false ,
2404
2413
} ,
2405
- _ => false ,
2414
+ ( None , None , None ) => {
2415
+ self . dcx ( ) . emit_err ( errors:: EmptyInstructionSet { span : attr. span } ) ;
2416
+ }
2417
+ _ => {
2418
+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2419
+ }
2406
2420
} ;
2407
-
2408
- if !valid_attribute {
2409
- self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2410
- } else {
2411
- return ;
2412
- }
2413
2421
}
2414
2422
}
2415
2423
}
0 commit comments