Fix target list of link_section

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
(cherry picked from commit 4787834eda)
This commit is contained in:
Jonathan Brouwer 2025-10-06 22:31:38 +02:00 committed by Josh Stone
parent 91163a9e1e
commit 15843ffde1
3 changed files with 15 additions and 9 deletions

View file

@ -466,8 +466,14 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
const PATH: &[Symbol] = &[sym::link_section];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
const ALLOWED_TARGETS: AllowedTargets =
AllowedTargets::AllowListWarnRest(&[Allow(Target::Static), Allow(Target::Fn)]);
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
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)),
]);
const TEMPLATE: AttributeTemplate = template!(
NameValueStr: "name",
"https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute"

View file

@ -82,7 +82,7 @@ LL | #[link_section = "x"]
| ^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[link_section]` can be applied to statics and functions
= help: `#[link_section]` can be applied to functions and statics
warning: `#[link_ordinal]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:33:5

View file

@ -1219,7 +1219,7 @@ LL | #[link_section = "1800"]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[link_section]` can be applied to statics and functions
= help: `#[link_section]` can be applied to functions and statics
warning: `#[link_section]` attribute cannot be used on modules
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:17
@ -1228,7 +1228,7 @@ LL | mod inner { #![link_section="1800"] }
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[link_section]` can be applied to statics and functions
= help: `#[link_section]` can be applied to functions and statics
warning: `#[link_section]` attribute cannot be used on structs
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:5
@ -1237,7 +1237,7 @@ LL | #[link_section = "1800"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[link_section]` can be applied to statics and functions
= help: `#[link_section]` can be applied to functions and statics
warning: `#[link_section]` attribute cannot be used on type aliases
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:5
@ -1246,7 +1246,7 @@ LL | #[link_section = "1800"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[link_section]` can be applied to statics and functions
= help: `#[link_section]` can be applied to functions and statics
warning: `#[link_section]` attribute cannot be used on inherent impl blocks
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:5
@ -1255,7 +1255,7 @@ LL | #[link_section = "1800"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[link_section]` can be applied to statics and functions
= help: `#[link_section]` can be applied to functions and statics
warning: `#[must_use]` attribute cannot be used on modules
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:1
@ -1555,7 +1555,7 @@ LL | #![link_section = "1800"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[link_section]` can be applied to statics and functions
= help: `#[link_section]` can be applied to functions and statics
warning: `#[must_use]` attribute cannot be used on crates
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:84:1