Don't allow codegen attributes on trait methods
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
parent
ce63e5d9ea
commit
ddcd55fa66
5 changed files with 7 additions and 6 deletions
|
|
@ -61,7 +61,6 @@ impl<S: Stage> CombineAttributeParser<S> for AllowConstFnUnstableParser {
|
|||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
|
||||
Allow(Target::Fn),
|
||||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for ColdParser {
|
|||
Allow(Target::Fn),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })),
|
||||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::ForeignFn),
|
||||
Allow(Target::Closure),
|
||||
|
|
@ -343,7 +342,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for TrackCallerParser {
|
|||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })), // `#[track_caller]` is inherited from trait methods
|
||||
Allow(Target::ForeignFn),
|
||||
Allow(Target::Closure),
|
||||
Warn(Target::MacroDef),
|
||||
|
|
|
|||
|
|
@ -469,7 +469,6 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
|
|||
Allow(Target::Static),
|
||||
Allow(Target::Fn),
|
||||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
]);
|
||||
|
|
@ -587,12 +586,12 @@ impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
|
|||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
|
||||
Allow(Target::Fn),
|
||||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
Allow(Target::Static),
|
||||
Allow(Target::ForeignStatic),
|
||||
Allow(Target::ForeignFn),
|
||||
Warn(Target::Method(MethodKind::Trait { body: false })), // Not inherited
|
||||
]);
|
||||
|
||||
const TEMPLATE: AttributeTemplate = template!(NameValueStr: [
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ impl<S: Stage> AttributeParser<S> for AlignParser {
|
|||
Allow(Target::Method(MethodKind::Inherent)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: true })),
|
||||
Allow(Target::Method(MethodKind::TraitImpl)),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })),
|
||||
Allow(Target::Method(MethodKind::Trait { body: false })), // `#[align]` is inherited from trait methods
|
||||
Allow(Target::ForeignFn),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -680,6 +680,10 @@ mod link_section {
|
|||
//~| HELP remove the attribute
|
||||
trait Tr {
|
||||
#[link_section = "1800"]
|
||||
//~^ WARN attribute cannot be used on
|
||||
//~| WARN previously accepted
|
||||
//~| HELP can be applied to
|
||||
//~| HELP remove the attribute
|
||||
fn inside_tr_no_default(&self);
|
||||
|
||||
#[link_section = "1800"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue