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} ;
@@ -2412,7 +2415,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
24122415 // Valid item for `instruction_set()` is:
24132416 // - arm::a32
24142417 // - arm::t32
2415- let valid_attribute = match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
2418+ match ( tokens. next ( ) , tokens. next ( ) , tokens. next ( ) ) {
24162419 (
24172420 Some ( TokenTree :: Token ( first_token, _) ) ,
24182421 Some ( TokenTree :: Token ( second_token, _) ) ,
@@ -2421,18 +2424,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
24212424 ( Some ( first_ident) , TokenKind :: PathSep , Some ( third_ident) )
24222425 if first_ident. 0 . name == sym:: arm =>
24232426 {
2424- third_ident. 0 . name == sym:: a32 || third_ident. 0 . name == sym:: t32
2427+ if third_ident. 0 . name == sym:: a32 || third_ident. 0 . name == sym:: t32 {
2428+ return ;
2429+ } else {
2430+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2431+ }
2432+ }
2433+ _ => {
2434+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
24252435 }
2426- _ => false ,
24272436 } ,
2428- _ => false ,
2437+ ( None , None , None ) => {
2438+ self . dcx ( ) . emit_err ( errors:: EmptyInstructionSet { span : attr. span } ) ;
2439+ }
2440+ _ => {
2441+ self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2442+ }
24292443 } ;
2430-
2431- if !valid_attribute {
2432- self . dcx ( ) . emit_err ( errors:: InvalidInstructionSet { span : attr. span } ) ;
2433- } else {
2434- return ;
2435- }
24362444 }
24372445 }
24382446}
0 commit comments