Rollup merge of #62133 - petrochenkov:norustc, r=eddyb

Feature gate `rustc` attributes harder

Fixes https://github.com/rust-lang/rust/issues/62116
This commit is contained in:
Mazdak Farrokhzad 2019-07-05 20:26:54 +02:00 committed by GitHub
commit 0224532493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 257 additions and 197 deletions

View File

@ -74,6 +74,7 @@
#![feature(concat_idents)] #![feature(concat_idents)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(const_fn_union)] #![feature(const_fn_union)]
#![feature(custom_inner_attributes)]
#![feature(doc_cfg)] #![feature(doc_cfg)]
#![feature(doc_spotlight)] #![feature(doc_spotlight)]
#![feature(extern_types)] #![feature(extern_types)]

View File

@ -19,9 +19,8 @@ use syntax::ext::base::{MacroKind, SyntaxExtension};
use syntax::ext::expand::{AstFragment, Invocation, InvocationKind}; use syntax::ext::expand::{AstFragment, Invocation, InvocationKind};
use syntax::ext::hygiene::Mark; use syntax::ext::hygiene::Mark;
use syntax::ext::tt::macro_rules; use syntax::ext::tt::macro_rules;
use syntax::feature_gate::{ use syntax::feature_gate::{feature_err, emit_feature_err, is_builtin_attr_name};
feature_err, is_builtin_attr_name, AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES, use syntax::feature_gate::{AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES};
};
use syntax::symbol::{Symbol, kw, sym}; use syntax::symbol::{Symbol, kw, sym};
use syntax::visit::Visitor; use syntax::visit::Visitor;
use syntax::util::lev_distance::find_best_match_for_name; use syntax::util::lev_distance::find_best_match_for_name;
@ -298,12 +297,25 @@ impl<'a> Resolver<'a> {
let res = self.resolve_macro_to_res_inner(path, kind, parent_scope, trace, force); let res = self.resolve_macro_to_res_inner(path, kind, parent_scope, trace, force);
// Report errors and enforce feature gates for the resolved macro. // Report errors and enforce feature gates for the resolved macro.
let features = self.session.features_untracked();
if res != Err(Determinacy::Undetermined) { if res != Err(Determinacy::Undetermined) {
// Do not report duplicated errors on every undetermined resolution. // Do not report duplicated errors on every undetermined resolution.
for segment in &path.segments { for segment in &path.segments {
if let Some(args) = &segment.args { if let Some(args) = &segment.args {
self.session.span_err(args.span(), "generic arguments in macro path"); self.session.span_err(args.span(), "generic arguments in macro path");
} }
if kind == MacroKind::Attr && !features.rustc_attrs &&
segment.ident.as_str().starts_with("rustc") {
let msg = "attributes starting with `rustc` are \
reserved for use by the `rustc` compiler";
emit_feature_err(
&self.session.parse_sess,
sym::rustc_attrs,
segment.ident.span,
GateIssue::Language,
msg,
);
}
} }
} }
@ -320,24 +332,15 @@ impl<'a> Resolver<'a> {
} }
Res::NonMacroAttr(attr_kind) => { Res::NonMacroAttr(attr_kind) => {
if kind == MacroKind::Attr { if kind == MacroKind::Attr {
let features = self.session.features_untracked();
if attr_kind == NonMacroAttrKind::Custom { if attr_kind == NonMacroAttrKind::Custom {
assert!(path.segments.len() == 1); assert!(path.segments.len() == 1);
let name = path.segments[0].ident.as_str(); if !features.custom_attribute {
if name.starts_with("rustc_") {
if !features.rustc_attrs {
let msg = "unless otherwise specified, attributes with the prefix \
`rustc_` are reserved for internal compiler diagnostics";
self.report_unknown_attribute(path.span, &name, msg,
sym::rustc_attrs);
}
} else if !features.custom_attribute {
let msg = format!("The attribute `{}` is currently unknown to the \ let msg = format!("The attribute `{}` is currently unknown to the \
compiler and may have meaning added to it in the \ compiler and may have meaning added to it in the \
future", path); future", path);
self.report_unknown_attribute( self.report_unknown_attribute(
path.span, path.span,
&name, &path.segments[0].ident.as_str(),
&msg, &msg,
sym::custom_attribute, sym::custom_attribute,
); );

View File

@ -1504,9 +1504,7 @@ impl<'feat> ExpansionConfig<'feat> {
} }
fn enable_custom_inner_attributes(&self) -> bool { fn enable_custom_inner_attributes(&self) -> bool {
self.features.map_or(false, |features| { self.features.map_or(false, |features| features.custom_inner_attributes)
features.custom_inner_attributes || features.custom_attribute || features.rustc_attrs
})
} }
} }

View File

@ -1296,6 +1296,18 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
attribute is just used for rustc unit \ attribute is just used for rustc unit \
tests and will never be stable", tests and will never be stable",
cfg_fn!(rustc_attrs))), cfg_fn!(rustc_attrs))),
(sym::rustc_dump_env_program_clauses, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"the `#[rustc_dump_env_program_clauses]` \
attribute is just used for rustc unit \
tests and will never be stable",
cfg_fn!(rustc_attrs))),
(sym::rustc_object_lifetime_default, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"the `#[rustc_object_lifetime_default]` \
attribute is just used for rustc unit \
tests and will never be stable",
cfg_fn!(rustc_attrs))),
(sym::rustc_test_marker, Normal, template!(Word), Gated(Stability::Unstable, (sym::rustc_test_marker, Normal, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs, sym::rustc_attrs,
"the `#[rustc_test_marker]` attribute \ "the `#[rustc_test_marker]` attribute \
@ -1357,6 +1369,26 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
"internal implementation detail", "internal implementation detail",
cfg_fn!(rustc_attrs))), cfg_fn!(rustc_attrs))),
(sym::rustc_allocator_nounwind, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"internal implementation detail",
cfg_fn!(rustc_attrs))),
(sym::rustc_doc_only_macro, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"internal implementation detail",
cfg_fn!(rustc_attrs))),
(sym::rustc_promotable, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"internal implementation detail",
cfg_fn!(rustc_attrs))),
(sym::rustc_allow_const_fn_ptr, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"internal implementation detail",
cfg_fn!(rustc_attrs))),
(sym::rustc_dummy, Normal, template!(Word /* doesn't matter*/), Gated(Stability::Unstable, (sym::rustc_dummy, Normal, template!(Word /* doesn't matter*/), Gated(Stability::Unstable,
sym::rustc_attrs, sym::rustc_attrs,
"used by the test suite", "used by the test suite",
@ -1643,6 +1675,14 @@ impl<'a> Context<'a> {
} }
debug!("check_attribute: {:?} is builtin, {:?}, {:?}", attr.path, ty, gateage); debug!("check_attribute: {:?} is builtin, {:?}, {:?}", attr.path, ty, gateage);
return; return;
} else {
for segment in &attr.path.segments {
if segment.ident.as_str().starts_with("rustc") {
let msg = "attributes starting with `rustc` are \
reserved for use by the `rustc` compiler";
gate_feature!(self, rustc_attrs, segment.ident.span, msg);
}
}
} }
for &(n, ty) in self.plugin_attributes { for &(n, ty) in self.plugin_attributes {
if attr.path == n { if attr.path == n {
@ -1653,19 +1693,13 @@ impl<'a> Context<'a> {
return; return;
} }
} }
if !attr::is_known(attr) { if !is_macro && !attr::is_known(attr) {
if attr.name_or_empty().as_str().starts_with("rustc_") { // Only run the custom attribute lint during regular feature gate
let msg = "unless otherwise specified, attributes with the prefix `rustc_` \ // checking. Macro gating runs before the plugin attributes are
are reserved for internal compiler diagnostics"; // registered, so we skip this in that case.
gate_feature!(self, rustc_attrs, attr.span, msg); let msg = format!("The attribute `{}` is currently unknown to the compiler and \
} else if !is_macro { may have meaning added to it in the future", attr.path);
// Only run the custom attribute lint during regular feature gate gate_feature!(self, custom_attribute, attr.span, &msg);
// checking. Macro gating runs before the plugin attributes are
// registered, so we skip this in that case.
let msg = format!("The attribute `{}` is currently unknown to the compiler and \
may have meaning added to it in the future", attr.path);
gate_feature!(self, custom_attribute, attr.span, &msg);
}
} }
} }
} }

View File

@ -2,7 +2,8 @@
// ignore-stage1 // ignore-stage1
// compile-flags: -D crate-not-okay // compile-flags: -D crate-not-okay
#![feature(plugin, rustc_attrs)] #![feature(plugin, custom_attribute, custom_inner_attributes, rustc_attrs)]
#![plugin(lint_for_crate)] #![plugin(lint_for_crate)]
#![rustc_crate_okay] #![rustc_crate_okay]
#![rustc_crate_blue] #![rustc_crate_blue]
@ -10,4 +11,4 @@
#![rustc_crate_grey] #![rustc_crate_grey]
#![rustc_crate_green] #![rustc_crate_green]
pub fn main() { } fn main() {}

View File

@ -1,52 +0,0 @@
#![allow(unused_attributes)]
// This test ensures we can attach attributes to the formals in all
// places where generic parameter lists occur, assuming appropriate
// feature gates are enabled.
//
// (We are prefixing all tested features with `rustc_`, to ensure that
// the attributes themselves won't be rejected by the compiler when
// using `rustc_attrs` feature. There is a separate compile-fail/ test
// ensuring that the attribute feature-gating works in this context.)
#![feature(rustc_attrs)]
#![allow(dead_code)]
struct StLt<#[rustc_lt_struct] 'a>(&'a u32);
struct StTy<#[rustc_ty_struct] I>(I);
enum EnLt<#[rustc_lt_enum] 'b> { A(&'b u32), B }
enum EnTy<#[rustc_ty_enum] J> { A(J), B }
trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); }
type TyLt<#[rustc_lt_type] 'd> = &'d u32;
type TyTy<#[rustc_ty_type] L> = (L, );
impl<#[rustc_lt_inherent] 'e> StLt<'e> { }
impl<#[rustc_ty_inherent] M> StTy<M> { }
impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> {
fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } }
}
impl<#[rustc_ty_impl_for] N> TrTy<N> for StTy<N> {
fn foo(&self, _: N) { }
}
fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
fn f_ty<#[rustc_ty_fn] O>(_: O) { }
impl<I> StTy<I> {
fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
fn m_ty<#[rustc_ty_meth] P>(_: P) { }
}
fn hof_lt<Q>(_: Q)
where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32
{
}
fn main() {
}

View File

@ -6,10 +6,8 @@
struct RefIntPair<'a, 'b>(&'a u32, &'b u32); struct RefIntPair<'a, 'b>(&'a u32, &'b u32);
impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { impl<#[rustc_dummy] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
//~^ ERROR trailing attribute after generic parameter //~^ ERROR trailing attribute after generic parameter
} }
fn main() { fn main() {}
}

View File

@ -1,8 +1,8 @@
error: trailing attribute after generic parameter error: trailing attribute after generic parameter
--> $DIR/attrs-with-no-formal-in-generics-1.rs:9:25 --> $DIR/attrs-with-no-formal-in-generics-1.rs:9:29
| |
LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { LL | impl<#[rustc_dummy] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
| ^^^^^^^ attributes must go before parameters | ^^^^^^^ attributes must go before parameters
error: aborting due to previous error error: aborting due to previous error

View File

@ -6,7 +6,7 @@
struct RefAny<'a, T>(&'a T); struct RefAny<'a, T>(&'a T);
impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} impl<#[rustc_dummy] 'a, #[rustc_dummy] T, #[oops]> RefAny<'a, T> {}
//~^ ERROR trailing attribute after generic parameter //~^ ERROR trailing attribute after generic parameter
fn main() {} fn main() {}

View File

@ -1,8 +1,8 @@
error: trailing attribute after generic parameter error: trailing attribute after generic parameter
--> $DIR/attrs-with-no-formal-in-generics-2.rs:9:35 --> $DIR/attrs-with-no-formal-in-generics-2.rs:9:43
| |
LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} LL | impl<#[rustc_dummy] 'a, #[rustc_dummy] T, #[oops]> RefAny<'a, T> {}
| ^^^^^^^ attributes must go before parameters | ^^^^^^^ attributes must go before parameters
error: aborting due to previous error error: aborting due to previous error

View File

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

View File

@ -1,8 +1,8 @@
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics error[E0658]: internal implementation detail
--> $DIR/allow_const_fn_ptr_feature_gate.rs:7:3 --> $DIR/allow_const_fn_ptr_feature_gate.rs:7:1
| |
LL | #[rustc_allow_const_fn_ptr] LL | #[rustc_allow_const_fn_ptr]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 = note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable = help: add #![feature(rustc_attrs)] to the crate attributes to enable

View File

@ -1,6 +1,23 @@
// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate. // Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate.
#[rustc_foo] #![feature(decl_macro)]
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved
mod rustc { pub macro unknown() {} }
mod unknown { pub macro rustc() {} }
#[rustc::unknown]
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
//~| ERROR macro `rustc::unknown` may not be used in attributes
fn f() {}
#[unknown::rustc]
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
//~| ERROR macro `unknown::rustc` may not be used in attributes
fn g() {}
#[rustc_dummy]
//~^ ERROR used by the test suite
#[rustc_unknown]
//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
//~| ERROR attribute `rustc_unknown` is currently unknown
fn main() {} fn main() {}

View File

@ -1,12 +1,60 @@
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
--> $DIR/feature-gate-rustc-attrs.rs:3:3 --> $DIR/feature-gate-rustc-attrs.rs:8:3
| |
LL | #[rustc_foo] LL | #[rustc::unknown]
| ^^^^^^^^^ | ^^^^^
| |
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 = note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable = help: add #![feature(rustc_attrs)] to the crate attributes to enable
error: aborting due to previous error error: macro `rustc::unknown` may not be used in attributes
--> $DIR/feature-gate-rustc-attrs.rs:8:1
|
LL | #[rustc::unknown]
| ^^^^^^^^^^^^^^^^^
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
--> $DIR/feature-gate-rustc-attrs.rs:13:12
|
LL | #[unknown::rustc]
| ^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
error: macro `unknown::rustc` may not be used in attributes
--> $DIR/feature-gate-rustc-attrs.rs:13:1
|
LL | #[unknown::rustc]
| ^^^^^^^^^^^^^^^^^
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
--> $DIR/feature-gate-rustc-attrs.rs:20:3
|
LL | #[rustc_unknown]
| ^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
error[E0658]: The attribute `rustc_unknown` is currently unknown to the compiler and may have meaning added to it in the future
--> $DIR/feature-gate-rustc-attrs.rs:20:3
|
LL | #[rustc_unknown]
| ^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: used by the test suite
--> $DIR/feature-gate-rustc-attrs.rs:18:1
|
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View File

@ -1,44 +1,38 @@
// This test previously ensured that attributes on formals in generic parameter // This test previously ensured that attributes on formals in generic parameter
// lists are rejected without a feature gate. // lists are rejected without a feature gate.
//
// (We are prefixing all tested features with `rustc_`, to ensure that
// the attributes themselves won't be rejected by the compiler when
// using `rustc_attrs` feature. There is a separate compile-fail/ test
// ensuring that the attribute feature-gating works in this context.)
// build-pass (FIXME(62277): could be check-pass?) // build-pass (FIXME(62277): could be check-pass?)
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)]
struct StLt<#[rustc_lt_struct] 'a>(&'a u32); struct StLt<#[rustc_dummy] 'a>(&'a u32);
struct StTy<#[rustc_ty_struct] I>(I); struct StTy<#[rustc_dummy] I>(I);
enum EnLt<#[rustc_lt_enum] 'b> { A(&'b u32), B } enum EnLt<#[rustc_dummy] 'b> { A(&'b u32), B }
enum EnTy<#[rustc_ty_enum] J> { A(J), B } enum EnTy<#[rustc_dummy] J> { A(J), B }
trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } trait TrLt<#[rustc_dummy] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); } trait TrTy<#[rustc_dummy] K> { fn foo(&self, _: K); }
type TyLt<#[rustc_lt_type] 'd> = &'d u32; type TyLt<#[rustc_dummy] 'd> = &'d u32;
type TyTy<#[rustc_ty_type] L> = (L, ); type TyTy<#[rustc_dummy] L> = (L, );
impl<#[rustc_lt_inherent] 'e> StLt<'e> { } impl<#[rustc_dummy] 'e> StLt<'e> { }
impl<#[rustc_ty_inherent] M> StTy<M> { } impl<#[rustc_dummy] M> StTy<M> { }
impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> { impl<#[rustc_dummy] 'f> TrLt<'f> for StLt<'f> {
fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } } fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } }
} }
impl<#[rustc_ty_impl_for] N> TrTy<N> for StTy<N> { impl<#[rustc_dummy] N> TrTy<N> for StTy<N> {
fn foo(&self, _: N) { } fn foo(&self, _: N) { }
} }
fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } fn f_lt<#[rustc_dummy] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
fn f_ty<#[rustc_ty_fn] O>(_: O) { } fn f_ty<#[rustc_dummy] O>(_: O) { }
impl<I> StTy<I> { impl<I> StTy<I> {
fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } fn m_lt<#[rustc_dummy] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
fn m_ty<#[rustc_ty_meth] P>(_: P) { } fn m_ty<#[rustc_dummy] P>(_: P) { }
} }
fn hof_lt<Q>(_: Q) fn hof_lt<Q>(_: Q)
where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 where Q: for <#[rustc_dummy] 'i> Fn(&'i [u32]) -> &'i u32
{} {}
fn main() {} fn main() {}

View File

@ -1,10 +1,7 @@
// compile-flags:-Zborrowck=mir -Zverbose
// Test that we can deduce when projections like `T::Item` outlive the // Test that we can deduce when projections like `T::Item` outlive the
// function body. Test that this does not imply that `T: 'a` holds. // function body. Test that this does not imply that `T: 'a` holds.
#![allow(warnings)] // compile-flags:-Zborrowck=mir -Zverbose
#![feature(rustc_attrs)]
use std::cell::Cell; use std::cell::Cell;
@ -18,7 +15,6 @@ where
f(&value, Cell::new(&n)); f(&value, Cell::new(&n));
} }
#[rustc_errors]
fn generic1<T: Iterator>(value: T) { fn generic1<T: Iterator>(value: T) {
// No error here: // No error here:
twice(value, |value_ref, item| invoke1(item)); twice(value, |value_ref, item| invoke1(item));
@ -30,7 +26,6 @@ where
{ {
} }
#[rustc_errors]
fn generic2<T: Iterator>(value: T) { fn generic2<T: Iterator>(value: T) {
twice(value, |value_ref, item| invoke2(value_ref, item)); twice(value, |value_ref, item| invoke2(value_ref, item));
//~^ ERROR the parameter type `T` may not live long enough //~^ ERROR the parameter type `T` may not live long enough

View File

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

View File

@ -4,9 +4,6 @@
// Test that we assume that universal types like `T` outlive the // Test that we assume that universal types like `T` outlive the
// function body. // function body.
#![allow(warnings)]
#![feature(rustc_attrs)]
use std::cell::Cell; use std::cell::Cell;
fn twice<F, T>(value: T, mut f: F) fn twice<F, T>(value: T, mut f: F)
@ -17,7 +14,6 @@ where
f(Cell::new(&value)); f(Cell::new(&value));
} }
#[rustc_errors]
fn generic<T>(value: T) { fn generic<T>(value: T) {
// No error here: // No error here:
twice(value, |r| invoke(r)); twice(value, |r| invoke(r));

View File

@ -1,32 +1,8 @@
error: 'a,Ambiguous error: BaseDefault
--> $DIR/object-lifetime-default.rs:24:1 --> $DIR/object-lifetime-default.rs:6:1
| |
LL | struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); LL | struct A<T>(T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: 'a,'b
--> $DIR/object-lifetime-default.rs:21:1
|
LL | struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 'b
--> $DIR/object-lifetime-default.rs:18:1
|
LL | struct E<'a,'b:'a,T:'b>(&'a T, &'b T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: Ambiguous
--> $DIR/object-lifetime-default.rs:15:1
|
LL | struct D<'a,'b,T:'a+'b>(&'a T, &'b T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 'a
--> $DIR/object-lifetime-default.rs:12:1
|
LL | struct C<'a,T:'a>(&'a T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: BaseDefault error: BaseDefault
--> $DIR/object-lifetime-default.rs:9:1 --> $DIR/object-lifetime-default.rs:9:1
@ -34,11 +10,35 @@ error: BaseDefault
LL | struct B<'a,T>(&'a (), T); LL | struct B<'a,T>(&'a (), T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: BaseDefault error: 'a
--> $DIR/object-lifetime-default.rs:6:1 --> $DIR/object-lifetime-default.rs:12:1
| |
LL | struct A<T>(T); LL | struct C<'a,T:'a>(&'a T);
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error: Ambiguous
--> $DIR/object-lifetime-default.rs:15:1
|
LL | struct D<'a,'b,T:'a+'b>(&'a T, &'b T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 'b
--> $DIR/object-lifetime-default.rs:18:1
|
LL | struct E<'a,'b:'a,T:'b>(&'a T, &'b T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 'a,'b
--> $DIR/object-lifetime-default.rs:21:1
|
LL | struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 'a,Ambiguous
--> $DIR/object-lifetime-default.rs:24:1
|
LL | struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 7 previous errors error: aborting due to 7 previous errors

View File

@ -1,12 +1,12 @@
// aux-build:derive-unstable-2.rs // aux-build:derive-unstable-2.rs
#![allow(warnings)]
#[macro_use] #[macro_use]
extern crate derive_unstable_2; extern crate derive_unstable_2;
#[derive(Unstable)] #[derive(Unstable)]
//~^ ERROR: reserved for internal compiler //~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
//~| ERROR attribute `rustc_foo` is currently unknown to the compiler
struct A; struct A;
fn main() { fn main() {

View File

@ -1,5 +1,5 @@
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
--> $DIR/expand-to-unstable-2.rs:8:10 --> $DIR/expand-to-unstable-2.rs:6:10
| |
LL | #[derive(Unstable)] LL | #[derive(Unstable)]
| ^^^^^^^^ | ^^^^^^^^
@ -7,6 +7,15 @@ LL | #[derive(Unstable)]
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 = note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable = help: add #![feature(rustc_attrs)] to the crate attributes to enable
error: aborting due to previous error error[E0658]: The attribute `rustc_foo` is currently unknown to the compiler and may have meaning added to it in the future
--> $DIR/expand-to-unstable-2.rs:6:10
|
LL | #[derive(Unstable)]
| ^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View File

@ -1,5 +1,7 @@
#[rustc_attribute_should_be_reserved] #[rustc_attribute_should_be_reserved]
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved //~^ ERROR attribute `rustc_attribute_should_be_reserved` is currently unknown
//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
macro_rules! foo { macro_rules! foo {
() => (()); () => (());
} }

View File

@ -1,4 +1,4 @@
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
--> $DIR/reserved-attr-on-macro.rs:1:3 --> $DIR/reserved-attr-on-macro.rs:1:3
| |
LL | #[rustc_attribute_should_be_reserved] LL | #[rustc_attribute_should_be_reserved]
@ -7,14 +7,23 @@ LL | #[rustc_attribute_should_be_reserved]
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 = note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable = help: add #![feature(rustc_attrs)] to the crate attributes to enable
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
--> $DIR/reserved-attr-on-macro.rs:1:3
|
LL | #[rustc_attribute_should_be_reserved]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error: cannot determine resolution for the macro `foo` error: cannot determine resolution for the macro `foo`
--> $DIR/reserved-attr-on-macro.rs:8:5 --> $DIR/reserved-attr-on-macro.rs:10:5
| |
LL | foo!(); LL | foo!();
| ^^^ | ^^^
| |
= note: import resolution is stuck, try simplifying macro imports = note: import resolution is stuck, try simplifying macro imports
error: aborting due to 2 previous errors error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View File

@ -1,13 +1,11 @@
#[deprcated] //~ ERROR E0658 #[deprcated] //~ ERROR attribute `deprcated` is currently unknown
fn foo() {} //~| HELP a built-in attribute with a similar name exists fn foo() {}
//~| SUGGESTION deprecated
//~| HELP add #![feature(custom_attribute)] to the crate attributes to enable
#[tests] //~ ERROR E0658 #[tests] //~ ERROR attribute `tests` is currently unknown to the compiler
fn bar() {} //~| HELP a built-in attribute with a similar name exists fn bar() {}
//~| SUGGESTION test
//~| HELP add #![feature(custom_attribute)] to the crate attributes to enable
#[rustc_err] //~ ERROR E0658 #[rustc_err]
fn main() {} //~| HELP add #![feature(rustc_attrs)] to the crate attributes to enable //~^ ERROR attribute `rustc_err` is currently unknown
// don't suggest rustc attributes //~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
fn main() {}

View File

@ -1,5 +1,5 @@
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
--> $DIR/attribute-typos.rs:11:3 --> $DIR/attribute-typos.rs:7:3
| |
LL | #[rustc_err] LL | #[rustc_err]
| ^^^^^^^^^ | ^^^^^^^^^
@ -7,8 +7,17 @@ LL | #[rustc_err]
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 = note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(rustc_attrs)] to the crate attributes to enable = help: add #![feature(rustc_attrs)] to the crate attributes to enable
error[E0658]: The attribute `rustc_err` is currently unknown to the compiler and may have meaning added to it in the future
--> $DIR/attribute-typos.rs:7:3
|
LL | #[rustc_err]
| ^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error[E0658]: The attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future error[E0658]: The attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future
--> $DIR/attribute-typos.rs:6:3 --> $DIR/attribute-typos.rs:4:3
| |
LL | #[tests] LL | #[tests]
| ^^^^^ help: a built-in attribute with a similar name exists: `test` | ^^^^^ help: a built-in attribute with a similar name exists: `test`
@ -25,6 +34,6 @@ LL | #[deprcated]
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 = note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable = help: add #![feature(custom_attribute)] to the crate attributes to enable
error: aborting due to 3 previous errors error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.