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
- ast, token:: TokenKind , tokenstream:: TokenTree , AttrKind , AttrStyle , Attribute , LitKind ,
9
- MetaItemKind , MetaItemLit , NestedMetaItem ,
13
+ ast, AttrKind , AttrStyle , Attribute , LitKind , MetaItemKind , MetaItemLit , NestedMetaItem ,
10
14
} ;
11
15
use rustc_data_structures:: fx:: FxHashMap ;
12
16
use rustc_errors:: { Applicability , DiagCtxtHandle , IntoDiagArg , MultiSpan , StashKey } ;
@@ -36,8 +40,6 @@ use rustc_target::spec::abi::Abi;
36
40
use rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ;
37
41
use rustc_trait_selection:: infer:: { TyCtxtInferExt , ValuePairs } ;
38
42
use rustc_trait_selection:: traits:: ObligationCtxt ;
39
- use std:: cell:: Cell ;
40
- use std:: collections:: hash_map:: Entry ;
41
43
use tracing:: debug;
42
44
43
45
use crate :: { errors, fluent_generated as fluent} ;
@@ -2360,7 +2362,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2360
2362
// Valid item for `instruction_set()` is:
2361
2363
// - arm::a32
2362
2364
// - arm::t32
2363
- let valid_attribute = match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
2365
+ match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
2364
2366
(
2365
2367
Some ( TokenTree :: Token ( first_token, _) ) ,
2366
2368
Some ( TokenTree :: Token ( second_token, _) ) ,
@@ -2369,18 +2371,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2369
2371
( Some ( first_ident) , TokenKind :: PathSep , Some ( third_ident) )
2370
2372
if first_ident. 0 . name == sym:: arm =>
2371
2373
{
2372
- third_ident. 0 . name == sym:: a32 || third_ident. 0 . name == sym:: t32
2374
+ if third_ident. 0 . name == sym:: a32 || third_ident. 0 . name == sym:: t32 {
2375
+ return ;
2376
+ } else {
2377
+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2378
+ }
2379
+ }
2380
+ _ => {
2381
+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2373
2382
}
2374
- _ => false ,
2375
2383
} ,
2376
- _ => false ,
2384
+ ( None , None , None ) => {
2385
+ self . dcx ( ) . emit_err ( errors:: EmptyInstructionSet { span : attr. span } ) ;
2386
+ }
2387
+ _ => {
2388
+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2389
+ }
2377
2390
} ;
2378
-
2379
- if !valid_attribute {
2380
- self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2381
- } else {
2382
- return ;
2383
- }
2384
2391
}
2385
2392
}
2386
2393
}
0 commit comments