Skip to content

Commit 4787834

Browse files
Fix target list of link_section
Signed-off-by: Jonathan Brouwer <[email protected]>
1 parent 3d8c1c1 commit 4787834

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,14 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
467467
const PATH: &[Symbol] = &[sym::link_section];
468468
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
469469
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
470-
const ALLOWED_TARGETS: AllowedTargets =
471-
AllowedTargets::AllowListWarnRest(&[Allow(Target::Static), Allow(Target::Fn)]);
470+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
471+
Allow(Target::Static),
472+
Allow(Target::Fn),
473+
Allow(Target::Method(MethodKind::Inherent)),
474+
Allow(Target::Method(MethodKind::Trait { body: false })),
475+
Allow(Target::Method(MethodKind::Trait { body: true })),
476+
Allow(Target::Method(MethodKind::TraitImpl)),
477+
]);
472478
const TEMPLATE: AttributeTemplate = template!(
473479
NameValueStr: "name",
474480
"https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute"

tests/ui/attributes/attr-on-mac-call.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ LL | #[link_section = "x"]
8282
| ^^^^^^^^^^^^^^^^^^^^^
8383
|
8484
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
85-
= help: `#[link_section]` can be applied to statics and functions
85+
= help: `#[link_section]` can be applied to functions and statics
8686

8787
warning: `#[link_ordinal]` attribute cannot be used on macro calls
8888
--> $DIR/attr-on-mac-call.rs:33:5

tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ LL | #[link_section = "1800"]
12361236
| ^^^^^^^^^^^^^^^^^^^^^^^^
12371237
|
12381238
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1239-
= help: `#[link_section]` can be applied to statics and functions
1239+
= help: `#[link_section]` can be applied to functions and statics
12401240

12411241
warning: `#[link_section]` attribute cannot be used on modules
12421242
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:683:17
@@ -1245,7 +1245,7 @@ LL | mod inner { #![link_section="1800"] }
12451245
| ^^^^^^^^^^^^^^^^^^^^^^^
12461246
|
12471247
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1248-
= help: `#[link_section]` can be applied to statics and functions
1248+
= help: `#[link_section]` can be applied to functions and statics
12491249

12501250
warning: `#[link_section]` attribute cannot be used on structs
12511251
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5
@@ -1254,7 +1254,7 @@ LL | #[link_section = "1800"] struct S;
12541254
| ^^^^^^^^^^^^^^^^^^^^^^^^
12551255
|
12561256
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1257-
= help: `#[link_section]` can be applied to statics and functions
1257+
= help: `#[link_section]` can be applied to functions and statics
12581258

12591259
warning: `#[link_section]` attribute cannot be used on type aliases
12601260
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5
@@ -1263,7 +1263,7 @@ LL | #[link_section = "1800"] type T = S;
12631263
| ^^^^^^^^^^^^^^^^^^^^^^^^
12641264
|
12651265
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1266-
= help: `#[link_section]` can be applied to statics and functions
1266+
= help: `#[link_section]` can be applied to functions and statics
12671267

12681268
warning: `#[link_section]` attribute cannot be used on inherent impl blocks
12691269
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5
@@ -1272,7 +1272,7 @@ LL | #[link_section = "1800"] impl S { }
12721272
| ^^^^^^^^^^^^^^^^^^^^^^^^
12731273
|
12741274
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1275-
= help: `#[link_section]` can be applied to statics and functions
1275+
= help: `#[link_section]` can be applied to functions and statics
12761276

12771277
warning: `#[must_use]` attribute cannot be used on modules
12781278
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:764:1
@@ -1572,7 +1572,7 @@ LL | #![link_section = "1800"]
15721572
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15731573
|
15741574
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1575-
= help: `#[link_section]` can be applied to statics and functions
1575+
= help: `#[link_section]` can be applied to functions and statics
15761576

15771577
warning: `#[must_use]` attribute cannot be used on crates
15781578
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:84:1

0 commit comments

Comments
 (0)