File tree Expand file tree Collapse file tree 5 files changed +7
-6
lines changed
compiler/rustc_attr_parsing/src/attributes Expand file tree Collapse file tree 5 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,6 @@ impl<S: Stage> CombineAttributeParser<S> for AllowConstFnUnstableParser {
6161 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
6262 Allow ( Target :: Fn ) ,
6363 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
64- Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
6564 Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
6665 Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
6766 ] ) ;
Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for ColdParser {
5757 Allow ( Target :: Fn ) ,
5858 Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
5959 Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
60- Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
6160 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
6261 Allow ( Target :: ForeignFn ) ,
6362 Allow ( Target :: Closure ) ,
@@ -343,7 +342,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for TrackCallerParser {
343342 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
344343 Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
345344 Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
346- Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
345+ Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) , // `#[track_caller]` is inherited from trait methods
347346 Allow ( Target :: ForeignFn ) ,
348347 Allow ( Target :: Closure ) ,
349348 Warn ( Target :: MacroDef ) ,
Original file line number Diff line number Diff line change @@ -469,7 +469,6 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
469469 Allow ( Target :: Static ) ,
470470 Allow ( Target :: Fn ) ,
471471 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
472- Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
473472 Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
474473 Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
475474 ] ) ;
@@ -587,12 +586,12 @@ impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
587586 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
588587 Allow ( Target :: Fn ) ,
589588 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
590- Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
591589 Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
592590 Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
593591 Allow ( Target :: Static ) ,
594592 Allow ( Target :: ForeignStatic ) ,
595593 Allow ( Target :: ForeignFn ) ,
594+ Warn ( Target :: Method ( MethodKind :: Trait { body : false } ) ) , // Not inherited
596595 ] ) ;
597596
598597 const TEMPLATE : AttributeTemplate = template ! ( NameValueStr : [
Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ impl<S: Stage> AttributeParser<S> for AlignParser {
315315 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
316316 Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
317317 Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
318- Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
318+ Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) , // `#[align]` is inherited from trait methods
319319 Allow ( Target :: ForeignFn ) ,
320320 ] ) ;
321321
Original file line number Diff line number Diff line change @@ -680,6 +680,10 @@ mod link_section {
680680 //~| HELP remove the attribute
681681 trait Tr {
682682 #[ link_section = "1800" ]
683+ //~^ WARN attribute cannot be used on
684+ //~| WARN previously accepted
685+ //~| HELP can be applied to
686+ //~| HELP remove the attribute
683687 fn inside_tr_no_default ( & self ) ;
684688
685689 #[ link_section = "1800" ]
You can’t perform that action at this time.
0 commit comments