44//! conflicts between multiple such attributes attached to the same
55//! item.
66
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 ;
712use 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 ,
1014} ;
1115use rustc_data_structures:: fx:: FxHashMap ;
1216use rustc_errors:: { Applicability , DiagCtxtHandle , IntoDiagArg , MultiSpan , StashKey } ;
@@ -36,8 +40,6 @@ use rustc_target::spec::abi::Abi;
3640use rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ;
3741use rustc_trait_selection:: infer:: { TyCtxtInferExt , ValuePairs } ;
3842use rustc_trait_selection:: traits:: ObligationCtxt ;
39- use std:: cell:: Cell ;
40- use std:: collections:: hash_map:: Entry ;
4143use tracing:: debug;
4244
4345use crate :: { errors, fluent_generated as fluent} ;
@@ -2360,7 +2362,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23602362 // Valid item for `instruction_set()` is:
23612363 // - arm::a32
23622364 // - arm::t32
2363- let valid_attribute = match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
2365+ match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
23642366 (
23652367 Some ( TokenTree :: Token ( first_token, _) ) ,
23662368 Some ( TokenTree :: Token ( second_token, _) ) ,
@@ -2369,18 +2371,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23692371 ( Some ( first_ident) , TokenKind :: PathSep , Some ( third_ident) )
23702372 if first_ident. 0 . name == sym:: arm =>
23712373 {
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 } ) ;
23732382 }
2374- _ => false ,
23752383 } ,
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+ }
23772390 } ;
2378-
2379- if !valid_attribute {
2380- self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2381- } else {
2382- return ;
2383- }
23842391 }
23852392 }
23862393}
0 commit comments