Skip to content

Commit 15843ff

Browse files
JonathanBrouwercuviper
authored andcommitted
Fix target list of link_section
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com> (cherry picked from commit 4787834)
1 parent 91163a9 commit 15843ff

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
@@ -466,8 +466,14 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
466466
const PATH: &[Symbol] = &[sym::link_section];
467467
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
468468
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
469-
const ALLOWED_TARGETS: AllowedTargets =
470-
AllowedTargets::AllowListWarnRest(&[Allow(Target::Static), Allow(Target::Fn)]);
469+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
470+
Allow(Target::Static),
471+
Allow(Target::Fn),
472+
Allow(Target::Method(MethodKind::Inherent)),
473+
Allow(Target::Method(MethodKind::Trait { body: false })),
474+
Allow(Target::Method(MethodKind::Trait { body: true })),
475+
Allow(Target::Method(MethodKind::TraitImpl)),
476+
]);
471477
const TEMPLATE: AttributeTemplate = template!(
472478
NameValueStr: "name",
473479
"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
@@ -1219,7 +1219,7 @@ LL | #[link_section = "1800"]
12191219
| ^^^^^^^^^^^^^^^^^^^^^^^^
12201220
|
12211221
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1222-
= help: `#[link_section]` can be applied to statics and functions
1222+
= help: `#[link_section]` can be applied to functions and statics
12231223

12241224
warning: `#[link_section]` attribute cannot be used on modules
12251225
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:17
@@ -1228,7 +1228,7 @@ LL | mod inner { #![link_section="1800"] }
12281228
| ^^^^^^^^^^^^^^^^^^^^^^^
12291229
|
12301230
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1231-
= help: `#[link_section]` can be applied to statics and functions
1231+
= help: `#[link_section]` can be applied to functions and statics
12321232

12331233
warning: `#[link_section]` attribute cannot be used on structs
12341234
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:5
@@ -1237,7 +1237,7 @@ LL | #[link_section = "1800"] struct S;
12371237
| ^^^^^^^^^^^^^^^^^^^^^^^^
12381238
|
12391239
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1240-
= help: `#[link_section]` can be applied to statics and functions
1240+
= help: `#[link_section]` can be applied to functions and statics
12411241

12421242
warning: `#[link_section]` attribute cannot be used on type aliases
12431243
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:5
@@ -1246,7 +1246,7 @@ LL | #[link_section = "1800"] type T = S;
12461246
| ^^^^^^^^^^^^^^^^^^^^^^^^
12471247
|
12481248
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1249-
= help: `#[link_section]` can be applied to statics and functions
1249+
= help: `#[link_section]` can be applied to functions and statics
12501250

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

12601260
warning: `#[must_use]` attribute cannot be used on modules
12611261
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:1
@@ -1555,7 +1555,7 @@ LL | #![link_section = "1800"]
15551555
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15561556
|
15571557
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1558-
= help: `#[link_section]` can be applied to statics and functions
1558+
= help: `#[link_section]` can be applied to functions and statics
15591559

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

0 commit comments

Comments
 (0)