Skip to content

Commit 959d6de

Browse files
committedJun 9, 2025
refactor AttributeGate and rustc_attr! to emit notes during feature checking
1 parent 52882f6 commit 959d6de

26 files changed

+274
-195
lines changed
 

‎compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ macro_rules! gate_alt {
3636
feature_err(&$visitor.sess, $name, $span, $explain).emit();
3737
}
3838
}};
39+
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr, $notes: expr) => {{
40+
if !$has_feature && !$span.allows_unstable($name) {
41+
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
42+
let mut diag = feature_err(&$visitor.sess, $name, $span, $explain);
43+
for note in $notes {
44+
diag.note(*note);
45+
}
46+
diag.emit();
47+
}
48+
}};
3949
}
4050

4151
/// The case involving a multispan.
@@ -154,11 +164,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
154164
let attr_info = attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name));
155165
// Check feature gates for built-in attributes.
156166
if let Some(BuiltinAttribute {
157-
gate: AttributeGate::Gated(_, name, descr, has_feature),
167+
gate: AttributeGate::Gated { feature, message, check, notes, .. },
158168
..
159169
}) = attr_info
160170
{
161-
gate_alt!(self, has_feature(self.features), *name, attr.span, *descr);
171+
gate_alt!(self, check(self.features), *feature, attr.span, *message, *notes);
162172
}
163173
// Check unstable flavors of the `#[doc]` attribute.
164174
if attr.has_name(sym::doc) {

‎compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 120 additions & 89 deletions
Large diffs are not rendered by default.

‎compiler/rustc_lint/messages.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ lint_builtin_const_no_mangle = const items should never be `#[no_mangle]`
7272
lint_builtin_decl_unsafe_fn = declaration of an `unsafe` function
7373
lint_builtin_decl_unsafe_method = declaration of an `unsafe` method
7474
75-
lint_builtin_deprecated_attr_link = use of deprecated attribute `{$name}`: {$reason}. See {$link}
76-
.msg_suggestion = {$msg}
75+
lint_builtin_deprecated_attr_link = use of deprecated attribute `{$name}`: {$message}. See {$link}
76+
.msg_suggestion = {$suggestion}
7777
.default_suggestion = remove this attribute
7878
lint_builtin_deref_nullptr = dereferencing a null pointer
7979
.label = this code causes undefined behavior when executed

‎compiler/rustc_lint/src/builtin.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -818,25 +818,22 @@ impl EarlyLintPass for DeprecatedAttr {
818818
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
819819
for BuiltinAttribute { name, gate, .. } in &self.depr_attrs {
820820
if attr.ident().map(|ident| ident.name) == Some(*name) {
821-
if let &AttributeGate::Gated(
822-
Stability::Deprecated(link, suggestion),
823-
name,
824-
reason,
825-
_,
826-
) = gate
821+
if let &AttributeGate::Gated {
822+
stability: Stability::Deprecated(link, suggestion),
823+
message,
824+
..
825+
} = gate
827826
{
828827
let suggestion = match suggestion {
829-
Some(msg) => {
830-
BuiltinDeprecatedAttrLinkSuggestion::Msg { suggestion: attr.span, msg }
831-
}
832-
None => {
833-
BuiltinDeprecatedAttrLinkSuggestion::Default { suggestion: attr.span }
828+
Some(suggestion) => {
829+
BuiltinDeprecatedAttrLinkSuggestion::Msg { span: attr.span, suggestion }
834830
}
831+
None => BuiltinDeprecatedAttrLinkSuggestion::Default { span: attr.span },
835832
};
836833
cx.emit_span_lint(
837834
DEPRECATED,
838835
attr.span,
839-
BuiltinDeprecatedAttrLink { name, reason, link, suggestion },
836+
BuiltinDeprecatedAttrLink { name: *name, message, link, suggestion },
840837
);
841838
}
842839
return;

‎compiler/rustc_lint/src/lints.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub(crate) struct BuiltinAnonymousParams<'a> {
204204
#[diag(lint_builtin_deprecated_attr_link)]
205205
pub(crate) struct BuiltinDeprecatedAttrLink<'a> {
206206
pub name: Symbol,
207-
pub reason: &'a str,
207+
pub message: &'a str,
208208
pub link: &'a str,
209209
#[subdiagnostic]
210210
pub suggestion: BuiltinDeprecatedAttrLinkSuggestion<'a>,
@@ -215,13 +215,13 @@ pub(crate) enum BuiltinDeprecatedAttrLinkSuggestion<'a> {
215215
#[suggestion(lint_msg_suggestion, code = "", applicability = "machine-applicable")]
216216
Msg {
217217
#[primary_span]
218-
suggestion: Span,
219-
msg: &'a str,
218+
span: Span,
219+
suggestion: &'a str,
220220
},
221221
#[suggestion(lint_default_suggestion, code = "", applicability = "machine-applicable")]
222222
Default {
223223
#[primary_span]
224-
suggestion: Span,
224+
span: Span,
225225
},
226226
}
227227

‎compiler/rustc_session/src/parse.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_feature::{GateIssue, UnstableFeatures, find_feature_issue};
1717
use rustc_span::edition::Edition;
1818
use rustc_span::hygiene::ExpnId;
1919
use rustc_span::source_map::{FilePathMapping, SourceMap};
20-
use rustc_span::{Span, Symbol};
20+
use rustc_span::{Span, Symbol, sym};
2121

2222
use crate::Session;
2323
use crate::config::{Cfg, CheckCfg};
@@ -192,8 +192,11 @@ pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
192192
} else {
193193
err.subdiagnostic(FeatureDiagnosticHelp { feature });
194194
}
195-
196-
if sess.opts.unstable_opts.ui_testing {
195+
if feature == sym::rustc_attrs {
196+
// We're unlikely to stabilize something out of `rustc_attrs`
197+
// without at least renaming it, so pointing out how old
198+
// the compiler is will do little good.
199+
} else if sess.opts.unstable_opts.ui_testing {
197200
err.subdiagnostic(SuggestUpgradeCompiler::ui_testing());
198201
} else if let Some(suggestion) = SuggestUpgradeCompiler::new() {
199202
err.subdiagnostic(suggestion);
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#[rustc_do_not_const_check]
2-
//~^ ERROR this is an internal attribute that will never be stable
2+
//~^ ERROR use of an internal attribute [E0658]
3+
//~| NOTE the `#[rustc_do_not_const_check]` attribute is an internal implementation detail that will never be stable
4+
//~| NOTE `#[rustc_do_not_const_check]` skips const-check for this function's body
35
const fn foo() {}
46

57
fn main() {}

‎tests/ui/consts/gate-do-not-const-check.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
error[E0658]: this is an internal attribute that will never be stable
1+
error[E0658]: use of an internal attribute
22
--> $DIR/gate-do-not-const-check.rs:1:1
33
|
44
LL | #[rustc_do_not_const_check]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_do_not_const_check]` attribute is an internal implementation detail that will never be stable
9+
= note: `#[rustc_do_not_const_check]` skips const-check for this function's body
910

1011
error: aborting due to 1 previous error
1112

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// check that `pattern_complexity_limit` is feature-gated
22

33
#![pattern_complexity_limit = "42"]
4-
//~^ ERROR: the `#[pattern_complexity_limit]` attribute is just used for rustc unit tests
4+
//~^ ERROR: use of an internal attribute [E0658]
5+
//~| NOTE the `#[pattern_complexity_limit]` attribute is an internal implementation detail that will never be stable
6+
//~| NOTE: the `#[pattern_complexity_limit]` attribute is used for rustc unit tests
57

68
fn main() {}

‎tests/ui/feature-gates/feature-gate-pattern-complexity-limit.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
error[E0658]: the `#[pattern_complexity_limit]` attribute is just used for rustc unit tests and will never be stable
1+
error[E0658]: use of an internal attribute
22
--> $DIR/feature-gate-pattern-complexity-limit.rs:3:1
33
|
44
LL | #![pattern_complexity_limit = "42"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[pattern_complexity_limit]` attribute is an internal implementation detail that will never be stable
9+
= note: the `#[pattern_complexity_limit]` attribute is used for rustc unit tests
910

1011
error: aborting due to 1 previous error
1112

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate.
22

3-
#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
4-
#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
5-
3+
#[rustc_variance]
4+
//~^ ERROR use of an internal attribute [E0658]
5+
//~| NOTE the `#[rustc_variance]` attribute is an internal implementation detail that will never be stable
6+
//~| NOTE the `#[rustc_variance]` attribute is used for rustc unit tests
7+
#[rustc_nonnull_optimization_guaranteed]
8+
//~^ ERROR use of an internal attribute [E0658]
9+
//~| NOTE the `#[rustc_nonnull_optimization_guaranteed]` attribute is an internal implementation detail that will never be stable
10+
//~| NOTE the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in the standard library
11+
//~| NOTE the compiler does not even check whether the type indeed is being non-null-optimized; it is your responsibility to ensure that the attribute is only used on types that are optimized
612
fn main() {}

‎tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
error[E0658]: the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
1+
error[E0658]: use of an internal attribute
22
--> $DIR/feature-gate-rustc-attrs-1.rs:3:1
33
|
44
LL | #[rustc_variance]
55
| ^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_variance]` attribute is an internal implementation detail that will never be stable
9+
= note: the `#[rustc_variance]` attribute is used for rustc unit tests
910

10-
error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
11-
(note that the compiler does not even check whether the type indeed is being non-null-optimized; it is your responsibility to ensure that the attribute is only used on types that are optimized)
12-
--> $DIR/feature-gate-rustc-attrs-1.rs:4:1
11+
error[E0658]: use of an internal attribute
12+
--> $DIR/feature-gate-rustc-attrs-1.rs:7:1
1313
|
1414
LL | #[rustc_nonnull_optimization_guaranteed]
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616
|
1717
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
18-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
18+
= note: the `#[rustc_nonnull_optimization_guaranteed]` attribute is an internal implementation detail that will never be stable
19+
= note: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in the standard library
20+
= note: the compiler does not even check whether the type indeed is being non-null-optimized; it is your responsibility to ensure that the attribute is only used on types that are optimized
1921

2022
error: aborting due to 2 previous errors
2123

‎tests/ui/feature-gates/feature-gate-rustc-attrs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ mod unknown { pub macro rustc() {} }
88
#[rustc::unknown]
99
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
1010
//~| ERROR expected attribute, found macro `rustc::unknown`
11+
//~| NOTE not an attribute
1112
fn f() {}
1213

1314
#[unknown::rustc]
1415
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
1516
//~| ERROR expected attribute, found macro `unknown::rustc`
17+
//~| NOTE not an attribute
1618
fn g() {}
1719

1820
#[rustc_dummy]
19-
//~^ ERROR the `#[rustc_dummy]` attribute is just used for rustc unit tests
21+
//~^ ERROR use of an internal attribute [E0658]
22+
//~| NOTE the `#[rustc_dummy]` attribute is an internal implementation detail that will never be stable
23+
//~| NOTE the `#[rustc_dummy]` attribute is used for rustc unit tests
2024
#[rustc_unknown]
2125
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
2226
//~| ERROR cannot find attribute `rustc_unknown` in this scope

‎tests/ui/feature-gates/feature-gate-rustc-attrs.stderr

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,38 @@ LL | #[rustc::unknown]
1111
| ^^^^^^^^^^^^^^ not an attribute
1212

1313
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
14-
--> $DIR/feature-gate-rustc-attrs.rs:13:12
14+
--> $DIR/feature-gate-rustc-attrs.rs:14:12
1515
|
1616
LL | #[unknown::rustc]
1717
| ^^^^^
1818

1919
error: expected attribute, found macro `unknown::rustc`
20-
--> $DIR/feature-gate-rustc-attrs.rs:13:3
20+
--> $DIR/feature-gate-rustc-attrs.rs:14:3
2121
|
2222
LL | #[unknown::rustc]
2323
| ^^^^^^^^^^^^^^ not an attribute
2424

2525
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
26-
--> $DIR/feature-gate-rustc-attrs.rs:20:3
26+
--> $DIR/feature-gate-rustc-attrs.rs:24:3
2727
|
2828
LL | #[rustc_unknown]
2929
| ^^^^^^^^^^^^^
3030

3131
error: cannot find attribute `rustc_unknown` in this scope
32-
--> $DIR/feature-gate-rustc-attrs.rs:20:3
32+
--> $DIR/feature-gate-rustc-attrs.rs:24:3
3333
|
3434
LL | #[rustc_unknown]
3535
| ^^^^^^^^^^^^^
3636

37-
error[E0658]: the `#[rustc_dummy]` attribute is just used for rustc unit tests and will never be stable
38-
--> $DIR/feature-gate-rustc-attrs.rs:18:1
37+
error[E0658]: use of an internal attribute
38+
--> $DIR/feature-gate-rustc-attrs.rs:20:1
3939
|
4040
LL | #[rustc_dummy]
4141
| ^^^^^^^^^^^^^^
4242
|
4343
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
44-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
44+
= note: the `#[rustc_dummy]` attribute is an internal implementation detail that will never be stable
45+
= note: the `#[rustc_dummy]` attribute is used for rustc unit tests
4546

4647
error: aborting due to 7 previous errors
4748

‎tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
#![macro_export]
1313
//~^ ERROR: `macro_export` attribute cannot be used at crate level
14-
#![rustc_main] //~ ERROR: the `#[rustc_main]` attribute is used internally to specify
14+
#![rustc_main]
1515
//~^ ERROR: `rustc_main` attribute cannot be used at crate level
16-
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
16+
//~| ERROR: use of an internal attribute [E0658]
17+
//~| NOTE: the `#[rustc_main]` attribute is an internal implementation detail that will never be stable
18+
//~| NOTE: the `#[rustc_main]` attribute is used internally to specify test entry point function
1719
#![repr()]
1820
//~^ ERROR: `repr` attribute cannot be used at crate level
1921
#![path = "3800"]

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

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
error[E0658]: the `#[rustc_main]` attribute is used internally to specify test entry point function
1+
error[E0658]: use of an internal attribute
22
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1
33
|
44
LL | #![rustc_main]
55
| ^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_main]` attribute is an internal implementation detail that will never be stable
9+
= note: the `#[rustc_main]` attribute is used internally to specify test entry point function
910

1011
error: valid forms for the attribute are `#[inline]` and `#[inline(always|never)]`
11-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:44:5
12+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5
1213
|
1314
LL | #[inline = "2100"] fn f() { }
1415
| ^^^^^^^^^^^^^^^^^^
@@ -18,7 +19,7 @@ LL | #[inline = "2100"] fn f() { }
1819
= note: `#[deny(ill_formed_attribute_input)]` on by default
1920

2021
error[E0518]: attribute should be applied to function or closure
21-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1
22+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1
2223
|
2324
LL | #[inline]
2425
| ^^^^^^^^^
@@ -29,7 +30,7 @@ LL | | }
2930
| |_- not a function or closure
3031

3132
error: attribute should be applied to an `extern crate` item
32-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:63:1
33+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:65:1
3334
|
3435
LL | #[no_link]
3536
| ^^^^^^^^^^
@@ -43,7 +44,7 @@ LL | | }
4344
| |_- not an `extern crate` item
4445

4546
error: attribute should be applied to a free function, impl method or static
46-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:89:1
47+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:1
4748
|
4849
LL | #[export_name = "2200"]
4950
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -57,7 +58,7 @@ LL | | }
5758
| |_- not a free function, impl method or static
5859

5960
error[E0517]: attribute should be applied to a struct, enum, or union
60-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:8
61+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:125:8
6162
|
6263
LL | #[repr(C)]
6364
| ^
@@ -70,7 +71,7 @@ LL | | }
7071
| |_- not a struct, enum, or union
7172

7273
error[E0517]: attribute should be applied to a struct, enum, or union
73-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:147:8
74+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:149:8
7475
|
7576
LL | #[repr(Rust)]
7677
| ^^^^
@@ -83,19 +84,19 @@ LL | | }
8384
| |_- not a struct, enum, or union
8485

8586
error: attribute should be applied to an `extern crate` item
86-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:24:1
87+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1
8788
|
8889
LL | #![no_link]
8990
| ^^^^^^^^^^^ not an `extern crate` item
9091

9192
error: attribute should be applied to a free function, impl method or static
92-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1
93+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1
9394
|
9495
LL | #![export_name = "2200"]
9596
| ^^^^^^^^^^^^^^^^^^^^^^^^ not a free function, impl method or static
9697

9798
error[E0518]: attribute should be applied to function or closure
98-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1
99+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1
99100
|
100101
LL | #![inline]
101102
| ^^^^^^^^^^ not a function or closure
@@ -131,7 +132,7 @@ LL + #[rustc_main]
131132
|
132133

133134
error: `path` attribute cannot be used at crate level
134-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1
135+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1
135136
|
136137
LL | #![path = "3800"]
137138
| ^^^^^^^^^^^^^^^^^
@@ -146,7 +147,7 @@ LL + #[path = "3800"]
146147
|
147148

148149
error: `automatically_derived` attribute cannot be used at crate level
149-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1
150+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:23:1
150151
|
151152
LL | #![automatically_derived]
152153
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -161,7 +162,7 @@ LL + #[automatically_derived]
161162
|
162163

163164
error: `repr` attribute cannot be used at crate level
164-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1
165+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1
165166
|
166167
LL | #![repr()]
167168
| ^^^^^^^^^^
@@ -176,139 +177,139 @@ LL + #[repr()]
176177
|
177178

178179
error[E0518]: attribute should be applied to function or closure
179-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:17
180+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:42:17
180181
|
181182
LL | mod inner { #![inline] }
182183
| ------------^^^^^^^^^^-- not a function or closure
183184

184185
error[E0518]: attribute should be applied to function or closure
185-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:50:5
186+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:52:5
186187
|
187188
LL | #[inline] struct S;
188189
| ^^^^^^^^^ --------- not a function or closure
189190

190191
error[E0518]: attribute should be applied to function or closure
191-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:54:5
192+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:56:5
192193
|
193194
LL | #[inline] type T = S;
194195
| ^^^^^^^^^ ----------- not a function or closure
195196

196197
error[E0518]: attribute should be applied to function or closure
197-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:58:5
198+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:60:5
198199
|
199200
LL | #[inline] impl S { }
200201
| ^^^^^^^^^ ---------- not a function or closure
201202

202203
error: attribute should be applied to an `extern crate` item
203-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:68:17
204+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:17
204205
|
205206
LL | mod inner { #![no_link] }
206207
| ------------^^^^^^^^^^^-- not an `extern crate` item
207208

208209
error: attribute should be applied to an `extern crate` item
209-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:72:5
210+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:74:5
210211
|
211212
LL | #[no_link] fn f() { }
212213
| ^^^^^^^^^^ ---------- not an `extern crate` item
213214

214215
error: attribute should be applied to an `extern crate` item
215-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:76:5
216+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:78:5
216217
|
217218
LL | #[no_link] struct S;
218219
| ^^^^^^^^^^ --------- not an `extern crate` item
219220

220221
error: attribute should be applied to an `extern crate` item
221-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:80:5
222+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:5
222223
|
223224
LL | #[no_link]type T = S;
224225
| ^^^^^^^^^^----------- not an `extern crate` item
225226

226227
error: attribute should be applied to an `extern crate` item
227-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:84:5
228+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5
228229
|
229230
LL | #[no_link] impl S { }
230231
| ^^^^^^^^^^ ---------- not an `extern crate` item
231232

232233
error: attribute should be applied to a free function, impl method or static
233-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:94:17
234+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:17
234235
|
235236
LL | mod inner { #![export_name="2200"] }
236237
| ------------^^^^^^^^^^^^^^^^^^^^^^-- not a free function, impl method or static
237238

238239
error: attribute should be applied to a free function, impl method or static
239-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:100:5
240+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:102:5
240241
|
241242
LL | #[export_name = "2200"] struct S;
242243
| ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static
243244

244245
error: attribute should be applied to a free function, impl method or static
245-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:104:5
246+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:106:5
246247
|
247248
LL | #[export_name = "2200"] type T = S;
248249
| ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static
249250

250251
error: attribute should be applied to a free function, impl method or static
251-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:108:5
252+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:110:5
252253
|
253254
LL | #[export_name = "2200"] impl S { }
254255
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a free function, impl method or static
255256

256257
error: attribute should be applied to a free function, impl method or static
257-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:113:9
258+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:115:9
258259
|
259260
LL | #[export_name = "2200"] fn foo();
260261
| ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static
261262

262263
error: attribute should be applied to a free function, impl method or static
263-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:117:9
264+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:119:9
264265
|
265266
LL | #[export_name = "2200"] fn bar() {}
266267
| ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static
267268

268269
error[E0517]: attribute should be applied to a struct, enum, or union
269-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:127:25
270+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:129:25
270271
|
271272
LL | mod inner { #![repr(C)] }
272273
| --------------------^---- not a struct, enum, or union
273274

274275
error[E0517]: attribute should be applied to a struct, enum, or union
275-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:131:12
276+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:133:12
276277
|
277278
LL | #[repr(C)] fn f() { }
278279
| ^ ---------- not a struct, enum, or union
279280

280281
error[E0517]: attribute should be applied to a struct, enum, or union
281-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:12
282+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:139:12
282283
|
283284
LL | #[repr(C)] type T = S;
284285
| ^ ----------- not a struct, enum, or union
285286

286287
error[E0517]: attribute should be applied to a struct, enum, or union
287-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:141:12
288+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:143:12
288289
|
289290
LL | #[repr(C)] impl S { }
290291
| ^ ---------- not a struct, enum, or union
291292

292293
error[E0517]: attribute should be applied to a struct, enum, or union
293-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:151:25
294+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:153:25
294295
|
295296
LL | mod inner { #![repr(Rust)] }
296297
| --------------------^^^^---- not a struct, enum, or union
297298

298299
error[E0517]: attribute should be applied to a struct, enum, or union
299-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:155:12
300+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:157:12
300301
|
301302
LL | #[repr(Rust)] fn f() { }
302303
| ^^^^ ---------- not a struct, enum, or union
303304

304305
error[E0517]: attribute should be applied to a struct, enum, or union
305-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:161:12
306+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:163:12
306307
|
307308
LL | #[repr(Rust)] type T = S;
308309
| ^^^^ ----------- not a struct, enum, or union
309310

310311
error[E0517]: attribute should be applied to a struct, enum, or union
311-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:165:12
312+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:167:12
312313
|
313314
LL | #[repr(Rust)] impl S { }
314315
| ^^^^ ---------- not a struct, enum, or union

‎tests/ui/force-inlining/gate.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
#![allow(internal_features)]
33

44
#[rustc_force_inline]
5-
//~^ ERROR #[rustc_force_inline] forces a free function to be inlined
5+
//~^ ERROR use of an internal attribute [E0658]
6+
//~| NOTE the `#[rustc_force_inline]` attribute is an internal implementation detail that will never be stable
7+
//~| NOTE `#[rustc_force_inline]` forces a free function to be inlined
68
pub fn bare() {
79
}
810

911
#[rustc_force_inline = "the test requires it"]
10-
//~^ ERROR #[rustc_force_inline] forces a free function to be inlined
12+
//~^ ERROR use of an internal attribute [E0658]
13+
//~| NOTE the `#[rustc_force_inline]` attribute is an internal implementation detail that will never be stable
14+
//~| NOTE `#[rustc_force_inline]` forces a free function to be inlined
1115
pub fn justified() {
1216
}

‎tests/ui/force-inlining/gate.stderr

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
error[E0658]: #[rustc_force_inline] forces a free function to be inlined
1+
error[E0658]: use of an internal attribute
22
--> $DIR/gate.rs:4:1
33
|
44
LL | #[rustc_force_inline]
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_force_inline]` attribute is an internal implementation detail that will never be stable
9+
= note: `#[rustc_force_inline]` forces a free function to be inlined
910

10-
error[E0658]: #[rustc_force_inline] forces a free function to be inlined
11-
--> $DIR/gate.rs:9:1
11+
error[E0658]: use of an internal attribute
12+
--> $DIR/gate.rs:11:1
1213
|
1314
LL | #[rustc_force_inline = "the test requires it"]
1415
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1516
|
1617
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
17-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
18+
= note: the `#[rustc_force_inline]` attribute is an internal implementation detail that will never be stable
19+
= note: `#[rustc_force_inline]` forces a free function to be inlined
1820

1921
error: aborting due to 2 previous errors
2022

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Test that `#[rustc_on_unimplemented]` is gated by `rustc_attrs` feature gate.
22

33
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}`"]
4-
//~^ ERROR this is an internal attribute that will never be stable
5-
trait Foo<Bar>
6-
{}
4+
//~^ ERROR use of an internal attribute [E0658]
5+
//~| NOTE the `#[rustc_on_unimplemented]` attribute is an internal implementation detail that will never be stable
6+
//~| NOTE see `#[diagnostic::on_unimplemented]` for the stable equivalent of this attribute
7+
trait Foo<Bar> {}
78

89
fn main() {}

‎tests/ui/on-unimplemented/feature-gate-on-unimplemented.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
error[E0658]: this is an internal attribute that will never be stable
1+
error[E0658]: use of an internal attribute
22
--> $DIR/feature-gate-on-unimplemented.rs:3:1
33
|
44
LL | #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}`"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_on_unimplemented]` attribute is an internal implementation detail that will never be stable
9+
= note: see `#[diagnostic::on_unimplemented]` for the stable equivalent of this attribute
910

1011
error: aborting due to 1 previous error
1112

‎tests/ui/rustdoc/feature-gate-doc_primitive.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#[rustc_doc_primitive = "usize"]
2-
//~^ ERROR `rustc_doc_primitive` is a rustc internal attribute
2+
//~^ ERROR use of an internal attribute [E0658]
3+
//~| NOTE the `#[rustc_doc_primitive]` attribute is an internal implementation detail that will never be stable
4+
//~| NOTE the `#[rustc_doc_primitive]` attribute is used by the standard library to provide a way to generate documentation for primitive types
35
/// Some docs
46
mod usize {}
57

‎tests/ui/rustdoc/feature-gate-doc_primitive.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
error[E0658]: `rustc_doc_primitive` is a rustc internal attribute
1+
error[E0658]: use of an internal attribute
22
--> $DIR/feature-gate-doc_primitive.rs:1:1
33
|
44
LL | #[rustc_doc_primitive = "usize"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_doc_primitive]` attribute is an internal implementation detail that will never be stable
9+
= note: the `#[rustc_doc_primitive]` attribute is used by the standard library to provide a way to generate documentation for primitive types
910

1011
error: aborting due to 1 previous error
1112

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
#[rustc_diagnostic_item = "foomp"] //~ ERROR compiler internal support for linting
1+
#[rustc_diagnostic_item = "foomp"]
2+
//~^ ERROR use of an internal attribute [E0658]
3+
//~| NOTE the `#[rustc_diagnostic_item]` attribute allows the compiler to reference types from the standard library for diagnostic purposes
24
struct Foomp;
35
fn main() {}

‎tests/ui/tool-attributes/diagnostic_item.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0658]: diagnostic items compiler internal support for linting
1+
error[E0658]: use of an internal attribute
22
--> $DIR/diagnostic_item.rs:1:1
33
|
44
LL | #[rustc_diagnostic_item = "foomp"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_diagnostic_item]` attribute allows the compiler to reference types from the standard library for diagnostic purposes
99

1010
error: aborting due to 1 previous error
1111

‎tests/ui/traits/default-method/rustc_must_implement_one_of_gated.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#[rustc_must_implement_one_of(eq, neq)]
2-
//~^ ERROR the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete definition of a trait, it's currently in experimental form and should be changed before being exposed outside of the std
2+
//~^ ERROR use of an internal attribute [E0658]
3+
//~| NOTE the `#[rustc_must_implement_one_of]` attribute is an internal implementation detail that will never be stable
4+
//~| NOTE the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete definition of a trait. Its syntax and semantics are highly experimental and will be subject to change before stabilization
35
trait Equal {
46
fn eq(&self, other: &Self) -> bool {
57
!self.neq(other)

‎tests/ui/traits/default-method/rustc_must_implement_one_of_gated.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
error[E0658]: the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete definition of a trait, it's currently in experimental form and should be changed before being exposed outside of the std
1+
error[E0658]: use of an internal attribute
22
--> $DIR/rustc_must_implement_one_of_gated.rs:1:1
33
|
44
LL | #[rustc_must_implement_one_of(eq, neq)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8+
= note: the `#[rustc_must_implement_one_of]` attribute is an internal implementation detail that will never be stable
9+
= note: the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete definition of a trait. Its syntax and semantics are highly experimental and will be subject to change before stabilization
910

1011
error: aborting due to 1 previous error
1112

0 commit comments

Comments
 (0)
Please sign in to comment.