Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 351442b

Browse files
authoredJul 3, 2019
Rollup merge of rust-lang#62133 - petrochenkov:norustc, r=eddyb
Feature gate `rustc` attributes harder Fixes rust-lang#62116
2 parents 9763f8c + e4e7eb2 commit 351442b

25 files changed

+251
-191
lines changed
 

‎src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#![feature(concat_idents)]
7575
#![feature(const_fn)]
7676
#![feature(const_fn_union)]
77+
#![feature(custom_inner_attributes)]
7778
#![feature(doc_cfg)]
7879
#![feature(doc_spotlight)]
7980
#![feature(extern_types)]

‎src/librustc_resolve/macros.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ use syntax::ext::base::{MacroKind, SyntaxExtension};
1919
use syntax::ext::expand::{AstFragment, Invocation, InvocationKind};
2020
use syntax::ext::hygiene::Mark;
2121
use syntax::ext::tt::macro_rules;
22-
use syntax::feature_gate::{
23-
feature_err, is_builtin_attr_name, AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES,
24-
};
22+
use syntax::feature_gate::{feature_err, emit_feature_err, is_builtin_attr_name};
23+
use syntax::feature_gate::{AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES};
2524
use syntax::symbol::{Symbol, kw, sym};
2625
use syntax::visit::Visitor;
2726
use syntax::util::lev_distance::find_best_match_for_name;
@@ -298,12 +297,25 @@ impl<'a> Resolver<'a> {
298297
let res = self.resolve_macro_to_res_inner(path, kind, parent_scope, trace, force);
299298

300299
// Report errors and enforce feature gates for the resolved macro.
300+
let features = self.session.features_untracked();
301301
if res != Err(Determinacy::Undetermined) {
302302
// Do not report duplicated errors on every undetermined resolution.
303303
for segment in &path.segments {
304304
if let Some(args) = &segment.args {
305305
self.session.span_err(args.span(), "generic arguments in macro path");
306306
}
307+
if kind == MacroKind::Attr && !features.rustc_attrs &&
308+
segment.ident.as_str().starts_with("rustc") {
309+
let msg = "attributes starting with `rustc` are \
310+
reserved for use by the `rustc` compiler";
311+
emit_feature_err(
312+
&self.session.parse_sess,
313+
sym::rustc_attrs,
314+
segment.ident.span,
315+
GateIssue::Language,
316+
msg,
317+
);
318+
}
307319
}
308320
}
309321

@@ -320,24 +332,15 @@ impl<'a> Resolver<'a> {
320332
}
321333
Res::NonMacroAttr(attr_kind) => {
322334
if kind == MacroKind::Attr {
323-
let features = self.session.features_untracked();
324335
if attr_kind == NonMacroAttrKind::Custom {
325336
assert!(path.segments.len() == 1);
326-
let name = path.segments[0].ident.as_str();
327-
if name.starts_with("rustc_") {
328-
if !features.rustc_attrs {
329-
let msg = "unless otherwise specified, attributes with the prefix \
330-
`rustc_` are reserved for internal compiler diagnostics";
331-
self.report_unknown_attribute(path.span, &name, msg,
332-
sym::rustc_attrs);
333-
}
334-
} else if !features.custom_attribute {
337+
if !features.custom_attribute {
335338
let msg = format!("The attribute `{}` is currently unknown to the \
336339
compiler and may have meaning added to it in the \
337340
future", path);
338341
self.report_unknown_attribute(
339342
path.span,
340-
&name,
343+
&path.segments[0].ident.as_str(),
341344
&msg,
342345
sym::custom_attribute,
343346
);

‎src/libsyntax/ext/expand.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1525,9 +1525,7 @@ impl<'feat> ExpansionConfig<'feat> {
15251525
}
15261526

15271527
fn enable_custom_inner_attributes(&self) -> bool {
1528-
self.features.map_or(false, |features| {
1529-
features.custom_inner_attributes || features.custom_attribute || features.rustc_attrs
1530-
})
1528+
self.features.map_or(false, |features| features.custom_inner_attributes)
15311529
}
15321530
}
15331531

‎src/libsyntax/feature_gate.rs

+47-13
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,18 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
12921292
attribute is just used for rustc unit \
12931293
tests and will never be stable",
12941294
cfg_fn!(rustc_attrs))),
1295+
(sym::rustc_dump_env_program_clauses, Whitelisted, template!(Word), Gated(Stability::Unstable,
1296+
sym::rustc_attrs,
1297+
"the `#[rustc_dump_env_program_clauses]` \
1298+
attribute is just used for rustc unit \
1299+
tests and will never be stable",
1300+
cfg_fn!(rustc_attrs))),
1301+
(sym::rustc_object_lifetime_default, Whitelisted, template!(Word), Gated(Stability::Unstable,
1302+
sym::rustc_attrs,
1303+
"the `#[rustc_object_lifetime_default]` \
1304+
attribute is just used for rustc unit \
1305+
tests and will never be stable",
1306+
cfg_fn!(rustc_attrs))),
12951307
(sym::rustc_test_marker, Normal, template!(Word), Gated(Stability::Unstable,
12961308
sym::rustc_attrs,
12971309
"the `#[rustc_test_marker]` attribute \
@@ -1353,6 +1365,26 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
13531365
"internal implementation detail",
13541366
cfg_fn!(rustc_attrs))),
13551367

1368+
(sym::rustc_allocator_nounwind, Whitelisted, template!(Word), Gated(Stability::Unstable,
1369+
sym::rustc_attrs,
1370+
"internal implementation detail",
1371+
cfg_fn!(rustc_attrs))),
1372+
1373+
(sym::rustc_doc_only_macro, Whitelisted, template!(Word), Gated(Stability::Unstable,
1374+
sym::rustc_attrs,
1375+
"internal implementation detail",
1376+
cfg_fn!(rustc_attrs))),
1377+
1378+
(sym::rustc_promotable, Whitelisted, template!(Word), Gated(Stability::Unstable,
1379+
sym::rustc_attrs,
1380+
"internal implementation detail",
1381+
cfg_fn!(rustc_attrs))),
1382+
1383+
(sym::rustc_allow_const_fn_ptr, Whitelisted, template!(Word), Gated(Stability::Unstable,
1384+
sym::rustc_attrs,
1385+
"internal implementation detail",
1386+
cfg_fn!(rustc_attrs))),
1387+
13561388
(sym::rustc_dummy, Normal, template!(Word /* doesn't matter*/), Gated(Stability::Unstable,
13571389
sym::rustc_attrs,
13581390
"used by the test suite",
@@ -1639,6 +1671,14 @@ impl<'a> Context<'a> {
16391671
}
16401672
debug!("check_attribute: {:?} is builtin, {:?}, {:?}", attr.path, ty, gateage);
16411673
return;
1674+
} else {
1675+
for segment in &attr.path.segments {
1676+
if segment.ident.as_str().starts_with("rustc") {
1677+
let msg = "attributes starting with `rustc` are \
1678+
reserved for use by the `rustc` compiler";
1679+
gate_feature!(self, rustc_attrs, segment.ident.span, msg);
1680+
}
1681+
}
16421682
}
16431683
for &(n, ty) in self.plugin_attributes {
16441684
if attr.path == n {
@@ -1649,19 +1689,13 @@ impl<'a> Context<'a> {
16491689
return;
16501690
}
16511691
}
1652-
if !attr::is_known(attr) {
1653-
if attr.name_or_empty().as_str().starts_with("rustc_") {
1654-
let msg = "unless otherwise specified, attributes with the prefix `rustc_` \
1655-
are reserved for internal compiler diagnostics";
1656-
gate_feature!(self, rustc_attrs, attr.span, msg);
1657-
} else if !is_macro {
1658-
// Only run the custom attribute lint during regular feature gate
1659-
// checking. Macro gating runs before the plugin attributes are
1660-
// registered, so we skip this in that case.
1661-
let msg = format!("The attribute `{}` is currently unknown to the compiler and \
1662-
may have meaning added to it in the future", attr.path);
1663-
gate_feature!(self, custom_attribute, attr.span, &msg);
1664-
}
1692+
if !is_macro && !attr::is_known(attr) {
1693+
// Only run the custom attribute lint during regular feature gate
1694+
// checking. Macro gating runs before the plugin attributes are
1695+
// registered, so we skip this in that case.
1696+
let msg = format!("The attribute `{}` is currently unknown to the compiler and \
1697+
may have meaning added to it in the future", attr.path);
1698+
gate_feature!(self, custom_attribute, attr.span, &msg);
16651699
}
16661700
}
16671701
}

‎src/test/run-pass-fulldeps/issue-15778-pass.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// ignore-stage1
33
// compile-flags: -D crate-not-okay
44

5-
#![feature(plugin, rustc_attrs)]
5+
#![feature(plugin, custom_attribute, custom_inner_attributes, rustc_attrs)]
6+
67
#![plugin(lint_for_crate)]
78
#![rustc_crate_okay]
89
#![rustc_crate_blue]
910
#![rustc_crate_red]
1011
#![rustc_crate_grey]
1112
#![rustc_crate_green]
1213

13-
pub fn main() { }
14+
fn main() {}

‎src/test/run-pass/attr-on-generic-formals.rs

-52
This file was deleted.

‎src/test/ui/attributes/attrs-with-no-formal-in-generics-1.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77
struct RefIntPair<'a, 'b>(&'a u32, &'b u32);
88

9-
impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
9+
impl<#[rustc_dummy] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
1010
//~^ ERROR trailing attribute after generic parameter
1111
}
1212

13-
fn main() {
14-
15-
}
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: trailing attribute after generic parameter
2-
--> $DIR/attrs-with-no-formal-in-generics-1.rs:9:25
2+
--> $DIR/attrs-with-no-formal-in-generics-1.rs:9:29
33
|
4-
LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
5-
| ^^^^^^^ attributes must go before parameters
4+
LL | impl<#[rustc_dummy] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
5+
| ^^^^^^^ attributes must go before parameters
66

77
error: aborting due to previous error
88

‎src/test/ui/attributes/attrs-with-no-formal-in-generics-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
struct RefAny<'a, T>(&'a T);
88

9-
impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
9+
impl<#[rustc_dummy] 'a, #[rustc_dummy] T, #[oops]> RefAny<'a, T> {}
1010
//~^ ERROR trailing attribute after generic parameter
1111

1212
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: trailing attribute after generic parameter
2-
--> $DIR/attrs-with-no-formal-in-generics-2.rs:9:35
2+
--> $DIR/attrs-with-no-formal-in-generics-2.rs:9:43
33
|
4-
LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
5-
| ^^^^^^^ attributes must go before parameters
4+
LL | impl<#[rustc_dummy] 'a, #[rustc_dummy] T, #[oops]> RefAny<'a, T> {}
5+
| ^^^^^^^ attributes must go before parameters
66

77
error: aborting due to previous error
88

‎src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const fn error(_: fn()) {}
55

66
#[stable(feature = "rust1", since = "1.0.0")]
77
#[rustc_allow_const_fn_ptr]
8-
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved
8+
//~^ ERROR internal implementation detail
99
const fn compiles(_: fn()) {}
1010

1111
fn main() {}

‎src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics
2-
--> $DIR/allow_const_fn_ptr_feature_gate.rs:7:3
1+
error[E0658]: internal implementation detail
2+
--> $DIR/allow_const_fn_ptr_feature_gate.rs:7:1
33
|
44
LL | #[rustc_allow_const_fn_ptr]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
88
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate.
22

3-
#[rustc_foo]
4-
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved
3+
#![feature(decl_macro)]
54

5+
mod rustc { pub macro unknown() {} }
6+
mod unknown { pub macro rustc() {} }
7+
8+
#[rustc::unknown]
9+
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
10+
//~| ERROR macro `rustc::unknown` may not be used in attributes
11+
fn f() {}
12+
13+
#[unknown::rustc]
14+
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
15+
//~| ERROR macro `unknown::rustc` may not be used in attributes
16+
fn g() {}
17+
18+
#[rustc_dummy]
19+
//~^ ERROR used by the test suite
20+
#[rustc_unknown]
21+
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
22+
//~| ERROR attribute `rustc_unknown` is currently unknown
623
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,60 @@
1-
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics
2-
--> $DIR/feature-gate-rustc-attrs.rs:3:3
1+
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
2+
--> $DIR/feature-gate-rustc-attrs.rs:8:3
33
|
4-
LL | #[rustc_foo]
5-
| ^^^^^^^^^
4+
LL | #[rustc::unknown]
5+
| ^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
88
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
99

10-
error: aborting due to previous error
10+
error: macro `rustc::unknown` may not be used in attributes
11+
--> $DIR/feature-gate-rustc-attrs.rs:8:1
12+
|
13+
LL | #[rustc::unknown]
14+
| ^^^^^^^^^^^^^^^^^
15+
16+
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
17+
--> $DIR/feature-gate-rustc-attrs.rs:13:12
18+
|
19+
LL | #[unknown::rustc]
20+
| ^^^^^
21+
|
22+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
23+
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
24+
25+
error: macro `unknown::rustc` may not be used in attributes
26+
--> $DIR/feature-gate-rustc-attrs.rs:13:1
27+
|
28+
LL | #[unknown::rustc]
29+
| ^^^^^^^^^^^^^^^^^
30+
31+
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
32+
--> $DIR/feature-gate-rustc-attrs.rs:20:3
33+
|
34+
LL | #[rustc_unknown]
35+
| ^^^^^^^^^^^^^
36+
|
37+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
38+
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
39+
40+
error[E0658]: The attribute `rustc_unknown` is currently unknown to the compiler and may have meaning added to it in the future
41+
--> $DIR/feature-gate-rustc-attrs.rs:20:3
42+
|
43+
LL | #[rustc_unknown]
44+
| ^^^^^^^^^^^^^
45+
|
46+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
47+
= help: add #![feature(custom_attribute)] to the crate attributes to enable
48+
49+
error[E0658]: used by the test suite
50+
--> $DIR/feature-gate-rustc-attrs.rs:18:1
51+
|
52+
LL | #[rustc_dummy]
53+
| ^^^^^^^^^^^^^^
54+
|
55+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
56+
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
57+
58+
error: aborting due to 7 previous errors
1159

1260
For more information about this error, try `rustc --explain E0658`.
+19-25
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
11
// This test previously ensured that attributes on formals in generic parameter
22
// lists are rejected without a feature gate.
3-
//
4-
// (We are prefixing all tested features with `rustc_`, to ensure that
5-
// the attributes themselves won't be rejected by the compiler when
6-
// using `rustc_attrs` feature. There is a separate compile-fail/ test
7-
// ensuring that the attribute feature-gating works in this context.)
83

94
// compile-pass
105

116
#![feature(rustc_attrs)]
12-
#![allow(dead_code)]
13-
14-
struct StLt<#[rustc_lt_struct] 'a>(&'a u32);
15-
struct StTy<#[rustc_ty_struct] I>(I);
16-
enum EnLt<#[rustc_lt_enum] 'b> { A(&'b u32), B }
17-
enum EnTy<#[rustc_ty_enum] J> { A(J), B }
18-
trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
19-
trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); }
20-
type TyLt<#[rustc_lt_type] 'd> = &'d u32;
21-
type TyTy<#[rustc_ty_type] L> = (L, );
22-
23-
impl<#[rustc_lt_inherent] 'e> StLt<'e> { }
24-
impl<#[rustc_ty_inherent] M> StTy<M> { }
25-
impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> {
7+
8+
struct StLt<#[rustc_dummy] 'a>(&'a u32);
9+
struct StTy<#[rustc_dummy] I>(I);
10+
enum EnLt<#[rustc_dummy] 'b> { A(&'b u32), B }
11+
enum EnTy<#[rustc_dummy] J> { A(J), B }
12+
trait TrLt<#[rustc_dummy] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
13+
trait TrTy<#[rustc_dummy] K> { fn foo(&self, _: K); }
14+
type TyLt<#[rustc_dummy] 'd> = &'d u32;
15+
type TyTy<#[rustc_dummy] L> = (L, );
16+
17+
impl<#[rustc_dummy] 'e> StLt<'e> { }
18+
impl<#[rustc_dummy] M> StTy<M> { }
19+
impl<#[rustc_dummy] 'f> TrLt<'f> for StLt<'f> {
2620
fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } }
2721
}
28-
impl<#[rustc_ty_impl_for] N> TrTy<N> for StTy<N> {
22+
impl<#[rustc_dummy] N> TrTy<N> for StTy<N> {
2923
fn foo(&self, _: N) { }
3024
}
3125

32-
fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
33-
fn f_ty<#[rustc_ty_fn] O>(_: O) { }
26+
fn f_lt<#[rustc_dummy] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
27+
fn f_ty<#[rustc_dummy] O>(_: O) { }
3428

3529
impl<I> StTy<I> {
36-
fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
37-
fn m_ty<#[rustc_ty_meth] P>(_: P) { }
30+
fn m_lt<#[rustc_dummy] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
31+
fn m_ty<#[rustc_dummy] P>(_: P) { }
3832
}
3933

4034
fn hof_lt<Q>(_: Q)
41-
where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32
35+
where Q: for <#[rustc_dummy] 'i> Fn(&'i [u32]) -> &'i u32
4236
{}
4337

4438
fn main() {}

‎src/test/ui/nll/ty-outlives/projection-implied-bounds.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// compile-flags:-Zborrowck=mir -Zverbose
2-
31
// Test that we can deduce when projections like `T::Item` outlive the
42
// function body. Test that this does not imply that `T: 'a` holds.
53

6-
#![allow(warnings)]
7-
#![feature(rustc_attrs)]
4+
// compile-flags:-Zborrowck=mir -Zverbose
85

96
use std::cell::Cell;
107

@@ -18,7 +15,6 @@ where
1815
f(&value, Cell::new(&n));
1916
}
2017

21-
#[rustc_errors]
2218
fn generic1<T: Iterator>(value: T) {
2319
// No error here:
2420
twice(value, |value_ref, item| invoke1(item));
@@ -30,7 +26,6 @@ where
3026
{
3127
}
3228

33-
#[rustc_errors]
3429
fn generic2<T: Iterator>(value: T) {
3530
twice(value, |value_ref, item| invoke2(value_ref, item));
3631
//~^ ERROR the parameter type `T` may not live long enough

‎src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0310]: the parameter type `T` may not live long enough
2-
--> $DIR/projection-implied-bounds.rs:35:18
2+
--> $DIR/projection-implied-bounds.rs:30:18
33
|
44
LL | twice(value, |value_ref, item| invoke2(value_ref, item));
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎src/test/ui/nll/ty-outlives/ty-param-implied-bounds.rs

-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// Test that we assume that universal types like `T` outlive the
55
// function body.
66

7-
#![allow(warnings)]
8-
#![feature(rustc_attrs)]
9-
107
use std::cell::Cell;
118

129
fn twice<F, T>(value: T, mut f: F)
@@ -17,7 +14,6 @@ where
1714
f(Cell::new(&value));
1815
}
1916

20-
#[rustc_errors]
2117
fn generic<T>(value: T) {
2218
// No error here:
2319
twice(value, |r| invoke(r));
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
error: 'a,Ambiguous
2-
--> $DIR/object-lifetime-default.rs:24:1
1+
error: BaseDefault
2+
--> $DIR/object-lifetime-default.rs:6:1
33
|
4-
LL | struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | struct A<T>(T);
5+
| ^^^^^^^^^^^^^^^
66

7-
error: 'a,'b
8-
--> $DIR/object-lifetime-default.rs:21:1
7+
error: BaseDefault
8+
--> $DIR/object-lifetime-default.rs:9:1
99
|
10-
LL | struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U);
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | struct B<'a,T>(&'a (), T);
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: 'b
14-
--> $DIR/object-lifetime-default.rs:18:1
13+
error: 'a
14+
--> $DIR/object-lifetime-default.rs:12:1
1515
|
16-
LL | struct E<'a,'b:'a,T:'b>(&'a T, &'b T);
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
LL | struct C<'a,T:'a>(&'a T);
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: Ambiguous
2020
--> $DIR/object-lifetime-default.rs:15:1
2121
|
2222
LL | struct D<'a,'b,T:'a+'b>(&'a T, &'b T);
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424

25-
error: 'a
26-
--> $DIR/object-lifetime-default.rs:12:1
25+
error: 'b
26+
--> $DIR/object-lifetime-default.rs:18:1
2727
|
28-
LL | struct C<'a,T:'a>(&'a T);
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
28+
LL | struct E<'a,'b:'a,T:'b>(&'a T, &'b T);
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030

31-
error: BaseDefault
32-
--> $DIR/object-lifetime-default.rs:9:1
31+
error: 'a,'b
32+
--> $DIR/object-lifetime-default.rs:21:1
3333
|
34-
LL | struct B<'a,T>(&'a (), T);
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
LL | struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U);
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

37-
error: BaseDefault
38-
--> $DIR/object-lifetime-default.rs:6:1
37+
error: 'a,Ambiguous
38+
--> $DIR/object-lifetime-default.rs:24:1
3939
|
40-
LL | struct A<T>(T);
41-
| ^^^^^^^^^^^^^^^
40+
LL | struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U);
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4242

4343
error: aborting due to 7 previous errors
4444

‎src/test/ui/proc-macro/expand-to-unstable-2.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// aux-build:derive-unstable-2.rs
22

3-
#![allow(warnings)]
4-
53
#[macro_use]
64
extern crate derive_unstable_2;
75

86
#[derive(Unstable)]
9-
//~^ ERROR: reserved for internal compiler
7+
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
8+
//~| ERROR attribute `rustc_foo` is currently unknown to the compiler
9+
1010
struct A;
1111

1212
fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics
2-
--> $DIR/expand-to-unstable-2.rs:8:10
1+
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
2+
--> $DIR/expand-to-unstable-2.rs:6:10
33
|
44
LL | #[derive(Unstable)]
55
| ^^^^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
88
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
99

10-
error: aborting due to previous error
10+
error[E0658]: The attribute `rustc_foo` is currently unknown to the compiler and may have meaning added to it in the future
11+
--> $DIR/expand-to-unstable-2.rs:6:10
12+
|
13+
LL | #[derive(Unstable)]
14+
| ^^^^^^^^
15+
|
16+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
17+
= help: add #![feature(custom_attribute)] to the crate attributes to enable
18+
19+
error: aborting due to 2 previous errors
1120

1221
For more information about this error, try `rustc --explain E0658`.

‎src/test/ui/reserved/reserved-attr-on-macro.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#[rustc_attribute_should_be_reserved]
2-
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved
2+
//~^ ERROR attribute `rustc_attribute_should_be_reserved` is currently unknown
3+
//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
4+
35
macro_rules! foo {
46
() => (());
57
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics
1+
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
22
--> $DIR/reserved-attr-on-macro.rs:1:3
33
|
44
LL | #[rustc_attribute_should_be_reserved]
@@ -7,14 +7,23 @@ LL | #[rustc_attribute_should_be_reserved]
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
88
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
99

10+
error[E0658]: The attribute `rustc_attribute_should_be_reserved` is currently unknown to the compiler and may have meaning added to it in the future
11+
--> $DIR/reserved-attr-on-macro.rs:1:3
12+
|
13+
LL | #[rustc_attribute_should_be_reserved]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
17+
= help: add #![feature(custom_attribute)] to the crate attributes to enable
18+
1019
error: cannot determine resolution for the macro `foo`
11-
--> $DIR/reserved-attr-on-macro.rs:8:5
20+
--> $DIR/reserved-attr-on-macro.rs:10:5
1221
|
1322
LL | foo!();
1423
| ^^^
1524
|
1625
= note: import resolution is stuck, try simplifying macro imports
1726

18-
error: aborting due to 2 previous errors
27+
error: aborting due to 3 previous errors
1928

2029
For more information about this error, try `rustc --explain E0658`.
+9-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
#[deprcated] //~ ERROR E0658
2-
fn foo() {} //~| HELP a built-in attribute with a similar name exists
3-
//~| SUGGESTION deprecated
4-
//~| HELP add #![feature(custom_attribute)] to the crate attributes to enable
1+
#[deprcated] //~ ERROR attribute `deprcated` is currently unknown
2+
fn foo() {}
53

6-
#[tests] //~ ERROR E0658
7-
fn bar() {} //~| HELP a built-in attribute with a similar name exists
8-
//~| SUGGESTION test
9-
//~| HELP add #![feature(custom_attribute)] to the crate attributes to enable
4+
#[tests] //~ ERROR attribute `tests` is currently unknown to the compiler
5+
fn bar() {}
106

11-
#[rustc_err] //~ ERROR E0658
12-
fn main() {} //~| HELP add #![feature(rustc_attrs)] to the crate attributes to enable
13-
// don't suggest rustc attributes
7+
#[rustc_err]
8+
//~^ ERROR attribute `rustc_err` is currently unknown
9+
//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
10+
11+
fn main() {}

‎src/test/ui/suggestions/attribute-typos.stderr

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics
2-
--> $DIR/attribute-typos.rs:11:3
1+
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
2+
--> $DIR/attribute-typos.rs:7:3
33
|
44
LL | #[rustc_err]
55
| ^^^^^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
88
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
99

10+
error[E0658]: The attribute `rustc_err` is currently unknown to the compiler and may have meaning added to it in the future
11+
--> $DIR/attribute-typos.rs:7:3
12+
|
13+
LL | #[rustc_err]
14+
| ^^^^^^^^^
15+
|
16+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
17+
= help: add #![feature(custom_attribute)] to the crate attributes to enable
18+
1019
error[E0658]: The attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future
11-
--> $DIR/attribute-typos.rs:6:3
20+
--> $DIR/attribute-typos.rs:4:3
1221
|
1322
LL | #[tests]
1423
| ^^^^^ help: a built-in attribute with a similar name exists: `test`
@@ -25,6 +34,6 @@ LL | #[deprcated]
2534
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
2635
= help: add #![feature(custom_attribute)] to the crate attributes to enable
2736

28-
error: aborting due to 3 previous errors
37+
error: aborting due to 4 previous errors
2938

3039
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)
Please sign in to comment.