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:: {
813 AttrKind , AttrStyle , Attribute , LitKind , MetaItemInner , MetaItemKind , MetaItemLit , ast,
914 token:: TokenKind , tokenstream:: TokenTree , AttrKind , AttrStyle , Attribute , LitKind ,
@@ -38,8 +43,6 @@ use rustc_target::spec::abi::Abi;
3843use rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ;
3944use rustc_trait_selection:: infer:: { TyCtxtInferExt , ValuePairs } ;
4045use rustc_trait_selection:: traits:: ObligationCtxt ;
41- use std:: cell:: Cell ;
42- use std:: collections:: hash_map:: Entry ;
4346use tracing:: debug;
4447
4548use crate :: { errors, fluent_generated as fluent} ;
@@ -2389,7 +2392,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23892392 // Valid item for `instruction_set()` is:
23902393 // - arm::a32
23912394 // - arm::t32
2392- let valid_attribute = match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
2395+ match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
23932396 (
23942397 Some ( TokenTree :: Token ( first_token, _) ) ,
23952398 Some ( TokenTree :: Token ( second_token, _) ) ,
@@ -2398,18 +2401,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23982401 ( Some ( first_ident) , TokenKind :: PathSep , Some ( third_ident) )
23992402 if first_ident. 0 . name == sym:: arm =>
24002403 {
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 } ) ;
24022412 }
2403- _ => false ,
24042413 } ,
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+ }
24062420 } ;
2407-
2408- if !valid_attribute {
2409- self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2410- } else {
2411- return ;
2412- }
24132421 }
24142422 }
24152423}
0 commit comments