Auto merge of #57321 - petrochenkov:atokens, r=nikomatsakis

Implement basic input validation for built-in attributes

Correct top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is enforced for built-in attributes, built-in attributes must also fit into the "meta-item" syntax (aka the "classic attribute syntax").

For some subset of attributes (found by crater run), errors are lowered to deprecation warnings.

NOTE: This PR previously included https://github.com/rust-lang/rust/pull/57367 as well.
This commit is contained in:
bors 2019-01-16 15:01:20 +00:00
commit ceb2512144
106 changed files with 1463 additions and 1690 deletions

View File

@ -1180,27 +1180,6 @@ fn main() {
```
"##,
E0296: r##"
This error indicates that the given recursion limit could not be parsed. Ensure
that the value provided is a positive integer between quotes.
Erroneous code example:
```compile_fail,E0296
#![recursion_limit]
fn main() {}
```
And a working example:
```
#![recursion_limit="1000"]
fn main() {}
```
"##,
E0308: r##"
This error occurs when the compiler was unable to infer the concrete type of a
variable. It can occur for several cases, the most common of which is a
@ -2093,20 +2072,6 @@ trait Foo { }
```
"##,
E0702: r##"
This error indicates that a `#[non_exhaustive]` attribute had a value. The
`#[non_exhaustive]` should be empty.
Examples of erroneous code:
```compile_fail,E0702
# #![feature(non_exhaustive)]
#[non_exhaustive(anything)]
struct Foo;
```
"##,
E0718: r##"
This error indicates that a `#[lang = ".."]` attribute was placed
on the wrong type of item.
@ -2138,6 +2103,7 @@ register_diagnostics! {
E0280, // requirement is not satisfied
E0284, // cannot resolve type
// E0285, // overflow evaluation builtin bounds
// E0296, // replaced with a generic attribute input check
// E0300, // unexpanded macro
// E0304, // expected signed integer constant
// E0305, // expected constant
@ -2180,4 +2146,5 @@ register_diagnostics! {
E0709, // multiple different lifetimes used in arguments of `async fn`
E0710, // an unknown tool name found in scoped lint
E0711, // a feature has been declared with conflicting stability attributes
// E0702, // replaced with a generic attribute input check
}

View File

@ -142,15 +142,6 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
return;
}
}
if attr.meta_item_list().is_some() || attr.value_str().is_some() {
struct_span_err!(self.tcx.sess,
attr.span,
E0702,
"attribute should be empty")
.span_label(item.span, "not empty")
.emit();
}
}
/// Check if the `#[marker]` attribute on an `item` is valid.
@ -165,12 +156,6 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
return;
}
}
if !attr.is_word() {
self.tcx.sess
.struct_span_err(attr.span, "attribute should be empty")
.emit();
}
}
/// Check if the `#[repr]` attributes on `item` are valid.

View File

@ -204,12 +204,6 @@ declare_lint! {
"trait-object types were treated as different depending on marker-trait order"
}
declare_lint! {
pub BAD_REPR,
Warn,
"detects incorrect use of `repr` attribute"
}
declare_lint! {
pub DEPRECATED,
Warn,
@ -359,6 +353,12 @@ pub mod parser {
Allow,
"detects the use of `?` as a macro separator"
}
declare_lint! {
pub ILL_FORMED_ATTRIBUTE_INPUT,
Warn,
"ill-formed attribute inputs that were previously accepted and used in practice"
}
}
declare_lint! {
@ -431,6 +431,7 @@ impl LintPass for HardwiredLints {
MACRO_USE_EXTERN_CRATE,
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
parser::QUESTION_MARK_MACRO_SEP,
parser::ILL_FORMED_ATTRIBUTE_INPUT,
DEPRECATED_IN_FUTURE,
)
}

View File

@ -204,8 +204,6 @@ impl<'a> LintLevelsBuilder<'a> {
let mut metas = if let Some(metas) = meta.meta_item_list() {
metas
} else {
let mut err = bad_attr(meta.span);
err.emit();
continue;
};

View File

@ -28,7 +28,7 @@ use hir::def_id::{CrateNum, LOCAL_CRATE};
use hir::intravisit;
use hir;
use lint::builtin::BuiltinLintDiagnostics;
use lint::builtin::parser::QUESTION_MARK_MACRO_SEP;
use lint::builtin::parser::{QUESTION_MARK_MACRO_SEP, ILL_FORMED_ATTRIBUTE_INPUT};
use session::{Session, DiagnosticMessageId};
use std::{hash, ptr};
use syntax::ast;
@ -82,6 +82,7 @@ impl Lint {
pub fn from_parser_lint_id(lint_id: BufferedEarlyLintId) -> &'static Self {
match lint_id {
BufferedEarlyLintId::QuestionMarkMacroSep => QUESTION_MARK_MACRO_SEP,
BufferedEarlyLintId::IllFormedAttributeInput => ILL_FORMED_ATTRIBUTE_INPUT,
}
}

View File

@ -11,14 +11,11 @@ use syntax::ast;
use rustc_data_structures::sync::Once;
pub fn update_limits(sess: &Session, krate: &ast::Crate) {
update_limit(sess, krate, &sess.recursion_limit, "recursion_limit",
"recursion limit", 64);
update_limit(sess, krate, &sess.type_length_limit, "type_length_limit",
"type length limit", 1048576);
update_limit(krate, &sess.recursion_limit, "recursion_limit", 64);
update_limit(krate, &sess.type_length_limit, "type_length_limit", 1048576);
}
fn update_limit(sess: &Session, krate: &ast::Crate, limit: &Once<usize>,
name: &str, description: &str, default: usize) {
fn update_limit(krate: &ast::Crate, limit: &Once<usize>, name: &str, default: usize) {
for attr in &krate.attrs {
if !attr.check_name(name) {
continue;
@ -30,10 +27,6 @@ fn update_limit(sess: &Session, krate: &ast::Crate, limit: &Once<usize>,
return;
}
}
span_err!(sess, attr.span, E0296,
"malformed {} attribute, expected #![{}=\"N\"]",
description, name);
}
limit.set(default);
}

View File

@ -157,10 +157,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
note: None,
}))
} else {
return Err(parse_error(tcx, attr.span,
"`#[rustc_on_unimplemented]` requires a value",
"value required here",
Some(r#"eg `#[rustc_on_unimplemented(message="foo")]`"#)));
return Err(ErrorReported);
};
debug!("of_item({:?}/{:?}) = {:?}", trait_def_id, impl_def_id, result);
result

View File

@ -1070,15 +1070,6 @@ where
)
});
// Add all buffered lints from the `ParseSess` to the `Session`.
sess.parse_sess.buffered_lints.with_lock(|buffered_lints| {
info!("{} parse sess buffered_lints", buffered_lints.len());
for BufferedEarlyLint{id, span, msg, lint_id} in buffered_lints.drain(..) {
let lint = lint::Lint::from_parser_lint_id(lint_id);
sess.buffer_lint(lint, id, span, &msg);
}
});
// Done with macro expansion!
after_expand(&krate)?;
@ -1114,6 +1105,15 @@ where
);
});
// Add all buffered lints from the `ParseSess` to the `Session`.
sess.parse_sess.buffered_lints.with_lock(|buffered_lints| {
info!("{} parse sess buffered_lints", buffered_lints.len());
for BufferedEarlyLint{id, span, msg, lint_id} in buffered_lints.drain(..) {
let lint = lint::Lint::from_parser_lint_id(lint_id);
sess.buffer_lint(lint, id, span, &msg);
}
});
// Lower ast -> hir.
// First, we need to collect the dep_graph.
let dep_graph = match future_dep_graph {
@ -1530,13 +1530,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
}
None
}
None => {
session
.struct_span_err(a.span, "`crate_type` requires a value")
.note("for example: `#![crate_type=\"lib\"]`")
.emit();
None
}
None => None
}
} else {
None

View File

@ -35,7 +35,8 @@ use syntax::ast::Expr;
use syntax::attr;
use syntax::source_map::Spanned;
use syntax::edition::Edition;
use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes};
use syntax::feature_gate::{AttributeGate, AttributeTemplate, AttributeType};
use syntax::feature_gate::{Stability, deprecated_attributes};
use syntax_pos::{BytePos, Span, SyntaxContext};
use syntax::symbol::keywords;
use syntax::errors::{Applicability, DiagnosticBuilder};
@ -689,86 +690,12 @@ impl EarlyLintPass for AnonymousParameters {
}
}
/// Checks for incorrect use of `repr` attributes.
#[derive(Clone)]
pub struct BadRepr;
impl LintPass for BadRepr {
fn get_lints(&self) -> LintArray {
lint_array!()
}
}
impl EarlyLintPass for BadRepr {
fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) {
if attr.name() == "repr" {
let list = attr.meta_item_list();
let repr_str = |lit: &str| { format!("#[repr({})]", lit) };
// Emit warnings with `repr` either has a literal assignment (`#[repr = "C"]`) or
// no hints (``#[repr]`)
let has_hints = list.as_ref().map(|ref list| !list.is_empty()).unwrap_or(false);
if !has_hints {
let mut suggested = false;
let mut warn = if let Some(ref lit) = attr.value_str() {
// avoid warning about empty `repr` on `#[repr = "foo"]`
let mut warn = cx.struct_span_lint(
BAD_REPR,
attr.span,
"`repr` attribute isn't configurable with a literal",
);
match lit.to_string().as_ref() {
| "C" | "packed" | "rust" | "transparent"
| "u8" | "u16" | "u32" | "u64" | "u128" | "usize"
| "i8" | "i16" | "i32" | "i64" | "i128" | "isize" => {
// if the literal could have been a valid `repr` arg,
// suggest the correct syntax
warn.span_suggestion_with_applicability(
attr.span,
"give `repr` a hint",
repr_str(&lit.as_str()),
Applicability::MachineApplicable
);
suggested = true;
}
_ => { // the literal wasn't a valid `repr` arg
warn.span_label(attr.span, "needs a hint");
}
};
warn
} else {
let mut warn = cx.struct_span_lint(
BAD_REPR,
attr.span,
"`repr` attribute must have a hint",
);
warn.span_label(attr.span, "needs a hint");
warn
};
if !suggested {
warn.help(&format!(
"valid hints include `{}`, `{}`, `{}` and `{}`",
repr_str("C"),
repr_str("packed"),
repr_str("rust"),
repr_str("transparent"),
));
warn.note("for more information, visit \
<https://doc.rust-lang.org/reference/type-layout.html>");
}
warn.emit();
}
}
}
}
/// Checks for use of attributes which have been deprecated.
#[derive(Clone)]
pub struct DeprecatedAttr {
// This is not free to compute, so we want to keep it around, rather than
// compute it for every attribute.
depr_attrs: Vec<&'static (&'static str, AttributeType, AttributeGate)>,
depr_attrs: Vec<&'static (&'static str, AttributeType, AttributeTemplate, AttributeGate)>,
}
impl DeprecatedAttr {
@ -787,7 +714,7 @@ impl LintPass for DeprecatedAttr {
impl EarlyLintPass for DeprecatedAttr {
fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) {
for &&(n, _, ref g) in &self.depr_attrs {
for &&(n, _, _, ref g) in &self.depr_attrs {
if attr.name() == n {
if let &AttributeGate::Gated(Stability::Deprecated(link, suggestion),
ref name,

View File

@ -48,7 +48,8 @@ use rustc::lint::builtin::{
INTRA_DOC_LINK_RESOLUTION_FAILURE,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
parser::QUESTION_MARK_MACRO_SEP
parser::QUESTION_MARK_MACRO_SEP,
parser::ILL_FORMED_ATTRIBUTE_INPUT,
};
use rustc::session;
use rustc::util;
@ -114,7 +115,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
UnsafeCode,
AnonymousParameters,
UnusedDocComment,
BadRepr,
EllipsisInclusiveRangePatterns,
NonCamelCaseTypes,
);
@ -336,6 +336,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(ILL_FORMED_ATTRIBUTE_INPUT),
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
edition: None,
},
]);
// Register renamed and removed lints.
@ -385,4 +390,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
"no longer a warning, #[no_mangle] functions always exported");
store.register_removed("private_no_mangle_statics",
"no longer a warning, #[no_mangle] statics always exported");
store.register_removed("bad_repr",
"replaced with a generic attribute input check");
}

View File

@ -232,7 +232,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {
fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) {
debug!("checking attribute: {:?}", attr);
// Note that check_name() marks the attribute as used if it matches.
for &(ref name, ty, _) in BUILTIN_ATTRIBUTES {
for &(name, ty, ..) in BUILTIN_ATTRIBUTES {
match ty {
AttributeType::Whitelisted if attr.check_name(name) => {
debug!("{:?} is Whitelisted", name);
@ -256,7 +256,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
// Is it a builtin attribute that must be used at the crate level?
let known_crate = BUILTIN_ATTRIBUTES.iter()
.find(|&&(builtin, ty, _)| name == builtin && ty == AttributeType::CrateLevel)
.find(|&&(builtin, ty, ..)| name == builtin && ty == AttributeType::CrateLevel)
.is_some();
// Has a plugin registered this attribute as one that must be used at

View File

@ -50,10 +50,7 @@ pub fn load_plugins(sess: &Session,
let plugins = match attr.meta_item_list() {
Some(xs) => xs,
None => {
call_malformed_plugin_attribute(sess, attr.span);
continue;
}
None => continue,
};
for plugin in plugins {

View File

@ -2144,12 +2144,7 @@ fn from_target_feature(
) {
let list = match attr.meta_item_list() {
Some(list) => list,
None => {
let msg = "#[target_feature] attribute must be of the form \
#[target_feature(..)]";
tcx.sess.span_err(attr.span, &msg);
return;
}
None => return,
};
let rust_features = tcx.features();
for item in list {
@ -2347,14 +2342,6 @@ fn codegen_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> Codegen
).emit();
}
codegen_fn_attrs.export_name = Some(s);
} else {
struct_span_err!(
tcx.sess,
attr.span,
E0558,
"`export_name` attribute has invalid format"
).span_label(attr.span, "did you mean #[export_name=\"*\"]?")
.emit();
}
} else if attr.check_name("target_feature") {
if tcx.fn_sig(id).unsafety() == Unsafety::Normal {

View File

@ -3611,29 +3611,6 @@ For more information about the inline attribute, https:
read://doc.rust-lang.org/reference.html#inline-attributes
"##,
E0558: r##"
The `export_name` attribute was malformed.
Erroneous code example:
```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
#[export_name] // error: `export_name` attribute has invalid format
pub fn something() {}
fn main() {}
```
The `export_name` attribute expects a string in order to determine the name of
the exported symbol. Example:
```
#[export_name = "some_function"] // ok!
pub fn something() {}
fn main() {}
```
"##,
E0559: r##"
An unknown field was specified into an enum's structure variant.
@ -4722,6 +4699,7 @@ register_diagnostics! {
// E0372, // coherence not object safe
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
// between structures with the same definition
// E0558, // replaced with a generic attribute input check
E0533, // `{}` does not name a unit variant, unit struct or a constant
// E0563, // cannot determine a type for this `impl Trait`: {} // removed in 6383de15
E0564, // only named lifetimes are allowed in `impl Trait`,

View File

@ -436,9 +436,6 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
}
_ => unreachable!()
}
} else {
span_err!(diagnostic, attr.span(), E0548, "incorrect stability attribute type");
continue
}
}

View File

@ -481,28 +481,33 @@ impl MetaItem {
{
// FIXME: Share code with `parse_path`.
let ident = match tokens.next() {
Some(TokenTree::Token(span, Token::Ident(ident, _))) => {
if let Some(TokenTree::Token(_, Token::ModSep)) = tokens.peek() {
let mut segments = vec![PathSegment::from_ident(ident.with_span_pos(span))];
tokens.next();
loop {
if let Some(TokenTree::Token(span,
Token::Ident(ident, _))) = tokens.next() {
segments.push(PathSegment::from_ident(ident.with_span_pos(span)));
} else {
return None;
}
if let Some(TokenTree::Token(_, Token::ModSep)) = tokens.peek() {
tokens.next();
} else {
break;
}
Some(TokenTree::Token(span, token @ Token::Ident(..))) |
Some(TokenTree::Token(span, token @ Token::ModSep)) => 'arm: {
let mut segments = if let Token::Ident(ident, _) = token {
if let Some(TokenTree::Token(_, Token::ModSep)) = tokens.peek() {
tokens.next();
vec![PathSegment::from_ident(ident.with_span_pos(span))]
} else {
break 'arm Path::from_ident(ident.with_span_pos(span));
}
let span = span.with_hi(segments.last().unwrap().ident.span.hi());
Path { span, segments }
} else {
Path::from_ident(ident.with_span_pos(span))
vec![PathSegment::path_root(span)]
};
loop {
if let Some(TokenTree::Token(span,
Token::Ident(ident, _))) = tokens.next() {
segments.push(PathSegment::from_ident(ident.with_span_pos(span)));
} else {
return None;
}
if let Some(TokenTree::Token(_, Token::ModSep)) = tokens.peek() {
tokens.next();
} else {
break;
}
}
let span = span.with_hi(segments.last().unwrap().ident.span.hi());
Path { span, segments }
}
Some(TokenTree::Token(_, Token::Interpolated(ref nt))) => match nt.0 {
token::Nonterminal::NtIdent(ident, _) => Path::from_ident(ident),

View File

@ -166,12 +166,9 @@ impl<'a> StripUnconfigured<'a> {
true
};
let meta_item = if let Some(meta_item) = attr.meta() {
meta_item
} else {
// Not a well-formed meta-item. Why? We don't know.
return error(attr.span, "`cfg` is not a well-formed meta-item",
"#[cfg(/* predicate */)]");
let meta_item = match attr.parse_meta(self.sess) {
Ok(meta_item) => meta_item,
Err(mut err) => { err.emit(); return true; }
};
let nested_meta_items = if let Some(nested_meta_items) = meta_item.meta_item_list() {
nested_meta_items

View File

@ -389,12 +389,12 @@ register_diagnostics! {
E0545, // incorrect 'issue'
E0546, // missing 'feature'
E0547, // missing 'issue'
E0548, // incorrect stability attribute type
// E0548, // replaced with a generic attribute input check
E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
E0550, // multiple deprecated attributes
E0551, // incorrect meta item
E0553, // multiple rustc_const_unstable attributes
E0555, // malformed feature attribute, expected #![feature(...)]
// E0555, // replaced with a generic attribute input check
E0556, // malformed feature, expected just one word
E0584, // file for module `..` found at both .. and ..
E0629, // missing 'feature' (rustc_const_unstable)

View File

@ -11,6 +11,7 @@ use syntax_pos::MultiSpan;
pub enum BufferedEarlyLintId {
/// Usage of `?` as a macro separator is deprecated.
QuestionMarkMacroSep,
IllFormedAttributeInput,
}
/// Stores buffered lint info which can later be passed to `librustc`.

View File

@ -15,6 +15,11 @@ pub fn collect_derives(cx: &mut ExtCtxt, attrs: &mut Vec<ast::Attribute>) -> Vec
if attr.path != "derive" {
return true;
}
if !attr.is_meta_item_list() {
cx.span_err(attr.span,
"attribute must be of the form `#[derive(Trait1, Trait2, ...)]`");
return false;
}
match attr.parse_list(cx.parse_sess,
|parser| parser.parse_path_allowing_meta(PathStyle::Mod)) {

View File

@ -19,6 +19,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_target::spec::abi::Abi;
use ast::{self, NodeId, PatKind, RangeEnd};
use attr;
use early_buffered_lints::BufferedEarlyLintId;
use source_map::Spanned;
use edition::{ALL_EDITIONS, Edition};
use syntax_pos::{Span, DUMMY_SP};
@ -715,6 +716,47 @@ pub enum AttributeGate {
Ungated,
}
/// A template that the attribute input must match.
/// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now.
#[derive(Clone, Copy)]
pub struct AttributeTemplate {
word: bool,
list: Option<&'static str>,
name_value_str: Option<&'static str>,
}
impl AttributeTemplate {
/// Check that the given meta-item is compatible with this template.
fn compatible(&self, meta_item_kind: &ast::MetaItemKind) -> bool {
match meta_item_kind {
ast::MetaItemKind::Word => self.word,
ast::MetaItemKind::List(..) => self.list.is_some(),
ast::MetaItemKind::NameValue(lit) if lit.node.is_str() => self.name_value_str.is_some(),
ast::MetaItemKind::NameValue(..) => false,
}
}
}
/// A convenience macro for constructing attribute templates.
/// E.g. `template!(Word, List: "description")` means that the attribute
/// supports forms `#[attr]` and `#[attr(description)]`.
macro_rules! template {
(Word) => { template!(@ true, None, None) };
(List: $descr: expr) => { template!(@ false, Some($descr), None) };
(NameValueStr: $descr: expr) => { template!(@ false, None, Some($descr)) };
(Word, List: $descr: expr) => { template!(@ true, Some($descr), None) };
(Word, NameValueStr: $descr: expr) => { template!(@ true, None, Some($descr)) };
(List: $descr1: expr, NameValueStr: $descr2: expr) => {
template!(@ false, Some($descr1), Some($descr2))
};
(Word, List: $descr1: expr, NameValueStr: $descr2: expr) => {
template!(@ true, Some($descr1), Some($descr2))
};
(@ $word: expr, $list: expr, $name_value_str: expr) => { AttributeTemplate {
word: $word, list: $list, name_value_str: $name_value_str
} };
}
impl AttributeGate {
fn is_deprecated(&self) -> bool {
match *self {
@ -752,225 +794,241 @@ macro_rules! cfg_fn {
}}
}
pub fn deprecated_attributes() -> Vec<&'static (&'static str, AttributeType, AttributeGate)> {
BUILTIN_ATTRIBUTES.iter().filter(|a| a.2.is_deprecated()).collect()
pub fn deprecated_attributes() -> Vec<&'static (&'static str, AttributeType,
AttributeTemplate, AttributeGate)> {
BUILTIN_ATTRIBUTES.iter().filter(|(.., gate)| gate.is_deprecated()).collect()
}
pub fn is_builtin_attr_name(name: ast::Name) -> bool {
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| name == builtin_name)
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, ..)| name == builtin_name)
}
pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.path == builtin_name)
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, ..)| attr.path == builtin_name)
}
// Attributes that have a special meaning to rustc or rustdoc
pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeGate)] = &[
pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, AttributeGate)] = &[
// Normal attributes
("warn", Normal, Ungated),
("allow", Normal, Ungated),
("forbid", Normal, Ungated),
("deny", Normal, Ungated),
("warn", Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), Ungated),
("allow", Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), Ungated),
("forbid", Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), Ungated),
("deny", Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), Ungated),
("macro_use", Normal, Ungated),
("macro_export", Normal, Ungated),
("plugin_registrar", Normal, Ungated),
("macro_use", Normal, template!(Word, List: "name1, name2, ..."), Ungated),
("macro_export", Normal, template!(Word, List: "local_inner_macros"), Ungated),
("plugin_registrar", Normal, template!(Word), Ungated),
("cfg", Normal, Ungated),
("cfg_attr", Normal, Ungated),
("main", Normal, Ungated),
("start", Normal, Ungated),
("repr", Normal, Ungated),
("path", Normal, Ungated),
("abi", Normal, Ungated),
("automatically_derived", Normal, Ungated),
("no_mangle", Normal, Ungated),
("no_link", Normal, Ungated),
("derive", Normal, Ungated),
("should_panic", Normal, Ungated),
("ignore", Normal, Ungated),
("no_implicit_prelude", Normal, Ungated),
("reexport_test_harness_main", Normal, Ungated),
("link_args", Normal, Gated(Stability::Unstable,
("cfg", Normal, template!(List: "predicate"), Ungated),
("cfg_attr", Normal, template!(List: "predicate, attr1, attr2, ..."), Ungated),
("main", Normal, template!(Word), Ungated),
("start", Normal, template!(Word), Ungated),
("repr", Normal, template!(List: "C, packed, ..."), Ungated),
("path", Normal, template!(NameValueStr: "file"), Ungated),
("automatically_derived", Normal, template!(Word), Ungated),
("no_mangle", Normal, template!(Word), Ungated),
("no_link", Normal, template!(Word), Ungated),
("derive", Normal, template!(List: "Trait1, Trait2, ..."), Ungated),
("should_panic", Normal, template!(Word, List: r#"expected = "reason"#, NameValueStr: "reason"),
Ungated),
("ignore", Normal, template!(Word, NameValueStr: "reason"), Ungated),
("no_implicit_prelude", Normal, template!(Word), Ungated),
("reexport_test_harness_main", Normal, template!(NameValueStr: "name"), Ungated),
("link_args", Normal, template!(NameValueStr: "args"), Gated(Stability::Unstable,
"link_args",
"the `link_args` attribute is experimental and not \
portable across platforms, it is recommended to \
use `#[link(name = \"foo\")] instead",
cfg_fn!(link_args))),
("macro_escape", Normal, Ungated),
("macro_escape", Normal, template!(Word), Ungated),
// RFC #1445.
("structural_match", Whitelisted, Gated(Stability::Unstable,
("structural_match", Whitelisted, template!(Word), Gated(Stability::Unstable,
"structural_match",
"the semantics of constant patterns is \
not yet settled",
cfg_fn!(structural_match))),
// RFC #2008
("non_exhaustive", Whitelisted, Gated(Stability::Unstable,
("non_exhaustive", Whitelisted, template!(Word), Gated(Stability::Unstable,
"non_exhaustive",
"non exhaustive is an experimental feature",
cfg_fn!(non_exhaustive))),
// RFC #1268
("marker", Normal, Gated(Stability::Unstable,
("marker", Normal, template!(Word), Gated(Stability::Unstable,
"marker_trait_attr",
"marker traits is an experimental feature",
cfg_fn!(marker_trait_attr))),
("plugin", CrateLevel, Gated(Stability::Unstable,
("plugin", CrateLevel, template!(List: "name|name(args)"), Gated(Stability::Unstable,
"plugin",
"compiler plugins are experimental \
and possibly buggy",
cfg_fn!(plugin))),
("no_std", CrateLevel, Ungated),
("no_core", CrateLevel, Gated(Stability::Unstable,
("no_std", CrateLevel, template!(Word), Ungated),
("no_core", CrateLevel, template!(Word), Gated(Stability::Unstable,
"no_core",
"no_core is experimental",
cfg_fn!(no_core))),
("lang", Normal, Gated(Stability::Unstable,
("lang", Normal, template!(NameValueStr: "name"), Gated(Stability::Unstable,
"lang_items",
"language items are subject to change",
cfg_fn!(lang_items))),
("linkage", Whitelisted, Gated(Stability::Unstable,
("linkage", Whitelisted, template!(NameValueStr: "external|internal|..."),
Gated(Stability::Unstable,
"linkage",
"the `linkage` attribute is experimental \
and not portable across platforms",
cfg_fn!(linkage))),
("thread_local", Whitelisted, Gated(Stability::Unstable,
("thread_local", Whitelisted, template!(Word), Gated(Stability::Unstable,
"thread_local",
"`#[thread_local]` is an experimental feature, and does \
not currently handle destructors.",
cfg_fn!(thread_local))),
("rustc_on_unimplemented", Normal, Gated(Stability::Unstable,
("rustc_on_unimplemented", Normal, template!(List:
r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
NameValueStr: "message"),
Gated(Stability::Unstable,
"on_unimplemented",
"the `#[rustc_on_unimplemented]` attribute \
is an experimental feature",
cfg_fn!(on_unimplemented))),
("rustc_const_unstable", Normal, Gated(Stability::Unstable,
("rustc_const_unstable", Normal, template!(List: r#"feature = "name""#),
Gated(Stability::Unstable,
"rustc_const_unstable",
"the `#[rustc_const_unstable]` attribute \
is an internal feature",
cfg_fn!(rustc_const_unstable))),
("global_allocator", Normal, Ungated),
("default_lib_allocator", Whitelisted, Gated(Stability::Unstable,
("global_allocator", Normal, template!(Word), Ungated),
("default_lib_allocator", Whitelisted, template!(Word), Gated(Stability::Unstable,
"allocator_internals",
"the `#[default_lib_allocator]` \
attribute is an experimental feature",
cfg_fn!(allocator_internals))),
("needs_allocator", Normal, Gated(Stability::Unstable,
("needs_allocator", Normal, template!(Word), Gated(Stability::Unstable,
"allocator_internals",
"the `#[needs_allocator]` \
attribute is an experimental \
feature",
cfg_fn!(allocator_internals))),
("panic_runtime", Whitelisted, Gated(Stability::Unstable,
("panic_runtime", Whitelisted, template!(Word), Gated(Stability::Unstable,
"panic_runtime",
"the `#[panic_runtime]` attribute is \
an experimental feature",
cfg_fn!(panic_runtime))),
("needs_panic_runtime", Whitelisted, Gated(Stability::Unstable,
("needs_panic_runtime", Whitelisted, template!(Word), Gated(Stability::Unstable,
"needs_panic_runtime",
"the `#[needs_panic_runtime]` \
attribute is an experimental \
feature",
cfg_fn!(needs_panic_runtime))),
("rustc_outlives", Normal, Gated(Stability::Unstable,
("rustc_outlives", Normal, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_outlives]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_variance", Normal, Gated(Stability::Unstable,
("rustc_variance", Normal, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_variance]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_regions", Normal, Gated(Stability::Unstable,
("rustc_regions", Normal, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_regions]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_error", Whitelisted, Gated(Stability::Unstable,
("rustc_error", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_error]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_dump_user_substs", Whitelisted, Gated(Stability::Unstable,
("rustc_dump_user_substs", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"this attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_if_this_changed", Whitelisted, Gated(Stability::Unstable,
("rustc_if_this_changed", Whitelisted, template!(Word, List: "DepNode"),
Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_if_this_changed]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_then_this_would_need", Whitelisted, Gated(Stability::Unstable,
("rustc_then_this_would_need", Whitelisted, template!(List: "DepNode"),
Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_if_this_changed]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_dirty", Whitelisted, Gated(Stability::Unstable,
("rustc_dirty", Whitelisted, template!(List: r#"cfg = "...", /*opt*/ label = "...",
/*opt*/ except = "...""#),
Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_dirty]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_clean", Whitelisted, Gated(Stability::Unstable,
("rustc_clean", Whitelisted, template!(List: r#"cfg = "...", /*opt*/ label = "...",
/*opt*/ except = "...""#),
Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_clean]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_partition_reused", Whitelisted, Gated(Stability::Unstable,
("rustc_partition_reused", Whitelisted, template!(List: r#"cfg = "...", module = "...""#),
Gated(Stability::Unstable,
"rustc_attrs",
"this attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_partition_codegened", Whitelisted, Gated(Stability::Unstable,
("rustc_partition_codegened", Whitelisted, template!(List: r#"cfg = "...", module = "...""#),
Gated(Stability::Unstable,
"rustc_attrs",
"this attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_expected_cgu_reuse", Whitelisted, Gated(Stability::Unstable,
("rustc_expected_cgu_reuse", Whitelisted, template!(List: r#"cfg = "...", module = "...",
kind = "...""#),
Gated(Stability::Unstable,
"rustc_attrs",
"this attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_synthetic", Whitelisted, Gated(Stability::Unstable,
("rustc_synthetic", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"this attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_symbol_name", Whitelisted, Gated(Stability::Unstable,
("rustc_symbol_name", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"internal rustc attributes will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_item_path", Whitelisted, Gated(Stability::Unstable,
("rustc_item_path", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"internal rustc attributes will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_mir", Whitelisted, Gated(Stability::Unstable,
("rustc_mir", Whitelisted, template!(List: "arg1, arg2, ..."), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_mir]` attribute \
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_inherit_overflow_checks", Whitelisted, Gated(Stability::Unstable,
("rustc_inherit_overflow_checks", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_inherit_overflow_checks]` \
attribute is just used to control \
@ -979,41 +1037,35 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeGate)] = &[
across crates and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_dump_program_clauses", Whitelisted, Gated(Stability::Unstable,
("rustc_dump_program_clauses", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_dump_program_clauses]` \
attribute is just used for rustc unit \
tests and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_test_marker", Normal, Gated(Stability::Unstable,
("rustc_test_marker", Normal, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"the `#[rustc_test_marker]` attribute \
is used internally to track tests",
cfg_fn!(rustc_attrs))),
("rustc_transparent_macro", Whitelisted, Gated(Stability::Unstable,
("rustc_transparent_macro", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"used internally for testing macro hygiene",
cfg_fn!(rustc_attrs))),
// RFC #2094
("nll", Whitelisted, Gated(Stability::Unstable,
"nll",
"Non lexical lifetimes",
cfg_fn!(nll))),
("compiler_builtins", Whitelisted, Gated(Stability::Unstable,
("compiler_builtins", Whitelisted, template!(Word), Gated(Stability::Unstable,
"compiler_builtins",
"the `#[compiler_builtins]` attribute is used to \
identify the `compiler_builtins` crate which \
contains compiler-rt intrinsics and will never be \
stable",
cfg_fn!(compiler_builtins))),
("sanitizer_runtime", Whitelisted, Gated(Stability::Unstable,
("sanitizer_runtime", Whitelisted, template!(Word), Gated(Stability::Unstable,
"sanitizer_runtime",
"the `#[sanitizer_runtime]` attribute is used to \
identify crates that contain the runtime of a \
sanitizer and will never be stable",
cfg_fn!(sanitizer_runtime))),
("profiler_runtime", Whitelisted, Gated(Stability::Unstable,
("profiler_runtime", Whitelisted, template!(Word), Gated(Stability::Unstable,
"profiler_runtime",
"the `#[profiler_runtime]` attribute is used to \
identify the `profiler_builtins` crate which \
@ -1021,55 +1073,58 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeGate)] = &[
stable",
cfg_fn!(profiler_runtime))),
("allow_internal_unstable", Normal, Gated(Stability::Unstable,
("allow_internal_unstable", Normal, template!(Word), Gated(Stability::Unstable,
"allow_internal_unstable",
EXPLAIN_ALLOW_INTERNAL_UNSTABLE,
cfg_fn!(allow_internal_unstable))),
("allow_internal_unsafe", Normal, Gated(Stability::Unstable,
("allow_internal_unsafe", Normal, template!(Word), Gated(Stability::Unstable,
"allow_internal_unsafe",
EXPLAIN_ALLOW_INTERNAL_UNSAFE,
cfg_fn!(allow_internal_unsafe))),
("fundamental", Whitelisted, Gated(Stability::Unstable,
("fundamental", Whitelisted, template!(Word), Gated(Stability::Unstable,
"fundamental",
"the `#[fundamental]` attribute \
is an experimental feature",
cfg_fn!(fundamental))),
("proc_macro_derive", Normal, Ungated),
("proc_macro_derive", Normal, template!(List: "TraitName, \
/*opt*/ attributes(name1, name2, ...)"),
Ungated),
("rustc_copy_clone_marker", Whitelisted, Gated(Stability::Unstable,
("rustc_copy_clone_marker", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"internal implementation detail",
cfg_fn!(rustc_attrs))),
// FIXME: #14408 whitelist docs since rustdoc looks at them
("doc", Whitelisted, Ungated),
("doc", Whitelisted, template!(List: "hidden|inline|...", NameValueStr: "string"), Ungated),
// FIXME: #14406 these are processed in codegen, which happens after the
// lint pass
("cold", Whitelisted, Ungated),
("naked", Whitelisted, Gated(Stability::Unstable,
("cold", Whitelisted, template!(Word), Ungated),
("naked", Whitelisted, template!(Word), Gated(Stability::Unstable,
"naked_functions",
"the `#[naked]` attribute \
is an experimental feature",
cfg_fn!(naked_functions))),
("target_feature", Whitelisted, Ungated),
("export_name", Whitelisted, Ungated),
("inline", Whitelisted, Ungated),
("link", Whitelisted, Ungated),
("link_name", Whitelisted, Ungated),
("link_section", Whitelisted, Ungated),
("no_builtins", Whitelisted, Ungated),
("no_mangle", Whitelisted, Ungated),
("no_debug", Whitelisted, Gated(
("target_feature", Whitelisted, template!(List: r#"enable = "name""#), Ungated),
("export_name", Whitelisted, template!(NameValueStr: "name"), Ungated),
("inline", Whitelisted, template!(Word, List: "always|never"), Ungated),
("link", Whitelisted, template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...",
/*opt*/ cfg = "...""#), Ungated),
("link_name", Whitelisted, template!(NameValueStr: "name"), Ungated),
("link_section", Whitelisted, template!(NameValueStr: "name"), Ungated),
("no_builtins", Whitelisted, template!(Word), Ungated),
("no_mangle", Whitelisted, template!(Word), Ungated),
("no_debug", Whitelisted, template!(Word), Gated(
Stability::Deprecated("https://github.com/rust-lang/rust/issues/29721", None),
"no_debug",
"the `#[no_debug]` attribute was an experimental feature that has been \
deprecated due to lack of demand",
cfg_fn!(no_debug))),
("omit_gdb_pretty_printer_section", Whitelisted, Gated(Stability::Unstable,
("omit_gdb_pretty_printer_section", Whitelisted, template!(Word), Gated(Stability::Unstable,
"omit_gdb_pretty_printer_section",
"the `#[omit_gdb_pretty_printer_section]` \
attribute is just used for the Rust test \
@ -1077,6 +1132,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeGate)] = &[
cfg_fn!(omit_gdb_pretty_printer_section))),
("unsafe_destructor_blind_to_params",
Normal,
template!(Word),
Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/34761",
Some("replace this attribute with `#[may_dangle]`")),
"dropck_parametricity",
@ -1085,93 +1141,91 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeGate)] = &[
cfg_fn!(dropck_parametricity))),
("may_dangle",
Normal,
template!(Word),
Gated(Stability::Unstable,
"dropck_eyepatch",
"may_dangle has unstable semantics and may be removed in the future",
cfg_fn!(dropck_eyepatch))),
("unwind", Whitelisted, Gated(Stability::Unstable,
("unwind", Whitelisted, template!(List: "allowed"), Gated(Stability::Unstable,
"unwind_attributes",
"#[unwind] is experimental",
cfg_fn!(unwind_attributes))),
("used", Whitelisted, Ungated),
("used", Whitelisted, template!(Word), Ungated),
// used in resolve
("prelude_import", Whitelisted, Gated(Stability::Unstable,
("prelude_import", Whitelisted, template!(Word), Gated(Stability::Unstable,
"prelude_import",
"`#[prelude_import]` is for use by rustc only",
cfg_fn!(prelude_import))),
// FIXME: #14407 these are only looked at on-demand so we can't
// guarantee they'll have already been checked
("rustc_deprecated", Whitelisted, Ungated),
("must_use", Whitelisted, Ungated),
("stable", Whitelisted, Ungated),
("unstable", Whitelisted, Ungated),
("deprecated", Normal, Ungated),
("rustc_deprecated", Whitelisted, template!(List: r#"since = "version", reason = "...""#),
Ungated),
("must_use", Whitelisted, template!(Word, NameValueStr: "reason"), Ungated),
("stable", Whitelisted, template!(List: r#"feature = "name", since = "version""#), Ungated),
("unstable", Whitelisted, template!(List: r#"feature = "name", reason = "...", issue = "N""#),
Ungated),
("deprecated", Normal, template!(Word, List: r#"/*opt*/ since = "version",
/*opt*/ note = "reason"#,
NameValueStr: "reason"), Ungated),
("rustc_paren_sugar", Normal, Gated(Stability::Unstable,
("rustc_paren_sugar", Normal, template!(Word), Gated(Stability::Unstable,
"unboxed_closures",
"unboxed_closures are still evolving",
cfg_fn!(unboxed_closures))),
("windows_subsystem", Whitelisted, Ungated),
("windows_subsystem", Whitelisted, template!(NameValueStr: "windows|console"), Ungated),
("proc_macro_attribute", Normal, Ungated),
("proc_macro", Normal, Ungated),
("proc_macro_attribute", Normal, template!(Word), Ungated),
("proc_macro", Normal, template!(Word), Ungated),
("rustc_proc_macro_decls", Normal, Gated(Stability::Unstable,
("rustc_proc_macro_decls", Normal, template!(Word), Gated(Stability::Unstable,
"rustc_proc_macro_decls",
"used internally by rustc",
cfg_fn!(rustc_attrs))),
("allow_fail", Normal, Gated(Stability::Unstable,
("allow_fail", Normal, template!(Word), Gated(Stability::Unstable,
"allow_fail",
"allow_fail attribute is currently unstable",
cfg_fn!(allow_fail))),
("rustc_std_internal_symbol", Whitelisted, Gated(Stability::Unstable,
("rustc_std_internal_symbol", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"this is an internal attribute that will \
never be stable",
cfg_fn!(rustc_attrs))),
// whitelists "identity-like" conversion methods to suggest on type mismatch
("rustc_conversion_suggestion", Whitelisted, Gated(Stability::Unstable,
("rustc_conversion_suggestion", Whitelisted, template!(Word), Gated(Stability::Unstable,
"rustc_attrs",
"this is an internal attribute that will \
never be stable",
cfg_fn!(rustc_attrs))),
("rustc_args_required_const", Whitelisted, Gated(Stability::Unstable,
("rustc_args_required_const", Whitelisted, template!(List: "N"), Gated(Stability::Unstable,
"rustc_attrs",
"never will be stable",
cfg_fn!(rustc_attrs))),
// RFC #2093
("infer_static_outlives_requirements", Normal, Gated(Stability::Unstable,
"infer_static_outlives_requirements",
"infer 'static lifetime requirements",
cfg_fn!(infer_static_outlives_requirements))),
// RFC 2070
("panic_handler", Normal, Ungated),
("panic_handler", Normal, template!(Word), Ungated),
("alloc_error_handler", Normal, Gated(Stability::Unstable,
("alloc_error_handler", Normal, template!(Word), Gated(Stability::Unstable,
"alloc_error_handler",
"#[alloc_error_handler] is an unstable feature",
cfg_fn!(alloc_error_handler))),
// Crate level attributes
("crate_name", CrateLevel, Ungated),
("crate_type", CrateLevel, Ungated),
("crate_id", CrateLevel, Ungated),
("feature", CrateLevel, Ungated),
("no_start", CrateLevel, Ungated),
("no_main", CrateLevel, Ungated),
("no_builtins", CrateLevel, Ungated),
("recursion_limit", CrateLevel, Ungated),
("type_length_limit", CrateLevel, Ungated),
("test_runner", CrateLevel, Gated(Stability::Unstable,
("crate_name", CrateLevel, template!(NameValueStr: "name"), Ungated),
("crate_type", CrateLevel, template!(NameValueStr: "bin|lib|..."), Ungated),
("crate_id", CrateLevel, template!(NameValueStr: "ignored"), Ungated),
("feature", CrateLevel, template!(List: "name1, name1, ..."), Ungated),
("no_start", CrateLevel, template!(Word), Ungated),
("no_main", CrateLevel, template!(Word), Ungated),
("no_builtins", CrateLevel, template!(Word), Ungated),
("recursion_limit", CrateLevel, template!(NameValueStr: "N"), Ungated),
("type_length_limit", CrateLevel, template!(NameValueStr: "N"), Ungated),
("test_runner", CrateLevel, template!(List: "path"), Gated(Stability::Unstable,
"custom_test_frameworks",
EXPLAIN_CUSTOM_TEST_FRAMEWORKS,
cfg_fn!(custom_test_frameworks))),
@ -1247,7 +1301,7 @@ impl<'a> Context<'a> {
fn check_attribute(&self, attr: &ast::Attribute, is_macro: bool) {
debug!("check_attribute(attr = {:?})", attr);
let name = attr.name().as_str();
for &(n, ty, ref gateage) in BUILTIN_ATTRIBUTES {
for &(n, ty, _template, ref gateage) in BUILTIN_ATTRIBUTES {
if name == n {
if let Gated(_, name, desc, ref has_feature) = *gateage {
gate_feature_fn!(self, has_feature, attr.span, name, desc, GateStrength::Hard);
@ -1482,6 +1536,52 @@ impl<'a> PostExpansionVisitor<'a> {
Abi::System => {}
}
}
fn check_builtin_attribute(&mut self, attr: &ast::Attribute, name: &str,
template: AttributeTemplate) {
// Some special attributes like `cfg` must be checked
// before the generic check, so we skip them here.
let should_skip = |name| name == "cfg";
// Some of previously accepted forms were used in practice,
// report them as warnings for now.
let should_warn = |name| name == "doc" || name == "ignore" ||
name == "inline" || name == "link";
match attr.parse_meta(self.context.parse_sess) {
Ok(meta) => if !should_skip(name) && !template.compatible(&meta.node) {
let mut msg = "attribute must be of the form ".to_owned();
let mut first = true;
if template.word {
first = false;
msg.push_str(&format!("`#[{}{}]`", name, ""));
}
if let Some(descr) = template.list {
if !first {
msg.push_str(" or ");
}
first = false;
msg.push_str(&format!("`#[{}({})]`", name, descr));
}
if let Some(descr) = template.name_value_str {
if !first {
msg.push_str(" or ");
}
msg.push_str(&format!("`#[{} = \"{}\"]`", name, descr));
}
if should_warn(name) {
self.context.parse_sess.buffer_lint(
BufferedEarlyLintId::IllFormedAttributeInput,
meta.span,
ast::CRATE_NODE_ID,
&msg,
);
} else {
self.context.parse_sess.span_diagnostic.span_err(meta.span, &msg);
}
}
Err(mut err) => err.emit(),
}
}
}
impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
@ -1517,12 +1617,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
}
if !self.context.features.unrestricted_attribute_tokens {
// Unfortunately, `parse_meta` cannot be called speculatively
// because it can report errors by itself, so we have to call it
// only if the feature is disabled.
if let Err(mut err) = attr.parse_meta(self.context.parse_sess) {
err.help("try enabling `#![feature(unrestricted_attribute_tokens)]`").emit()
match BUILTIN_ATTRIBUTES.iter().find(|(name, ..)| attr.path == name) {
Some(&(name, _, template, _)) => self.check_builtin_attribute(attr, name, template),
None => if !self.context.features.unrestricted_attribute_tokens {
// Unfortunately, `parse_meta` cannot be called speculatively
// because it can report errors by itself, so we have to call it
// only if the feature is disabled.
if let Err(mut err) = attr.parse_meta(self.context.parse_sess) {
err.help("try enabling `#![feature(unrestricted_attribute_tokens)]`").emit()
}
}
}
}
@ -1926,11 +2029,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
let list = match attr.meta_item_list() {
Some(list) => list,
None => {
span_err!(span_handler, attr.span, E0555,
"malformed feature attribute, expected #![feature(...)]");
continue
}
None => continue,
};
for mi in list {

View File

@ -10,6 +10,7 @@
test(attr(deny(warnings))))]
#![feature(crate_visibility_modifier)]
#![feature(label_break_value)]
#![feature(nll)]
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]

View File

@ -428,14 +428,11 @@ fn is_test_case(i: &ast::Item) -> bool {
fn get_test_runner(sd: &errors::Handler, krate: &ast::Crate) -> Option<ast::Path> {
let test_attr = attr::find_by_name(&krate.attrs, "test_runner")?;
if let Some(meta_list) = test_attr.meta_item_list() {
test_attr.meta_item_list().map(|meta_list| {
if meta_list.len() != 1 {
sd.span_fatal(test_attr.span(),
"#![test_runner(..)] accepts exactly 1 argument").raise()
}
Some(meta_list[0].word().as_ref().unwrap().ident.clone())
} else {
sd.span_fatal(test_attr.span(),
"test_runner must be of the form #[test_runner(..)]").raise()
}
meta_list[0].word().as_ref().unwrap().ident.clone()
})
}

View File

@ -105,12 +105,7 @@ impl<'a> CollectProcMacros<'a> {
// `#[proc_macro_derive(Foo, attributes(A, ..))]`
let list = match attr.meta_item_list() {
Some(list) => list,
None => {
self.handler.span_err(attr.span(),
"attribute must be of form: \
#[proc_macro_derive(TraitName)]");
return
}
None => return,
};
if list.len() != 1 && list.len() != 2 {
self.handler.span_err(attr.span(),
@ -182,13 +177,7 @@ impl<'a> CollectProcMacros<'a> {
}
}
fn collect_attr_proc_macro(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) {
if !attr.is_word() {
self.handler.span_err(attr.span, "`#[proc_macro_attribute]` attribute \
does not take any arguments");
return;
}
fn collect_attr_proc_macro(&mut self, item: &'a ast::Item) {
if self.in_root && item.vis.node.is_pub() {
self.attr_macros.push(ProcMacroDef {
span: item.span,
@ -205,13 +194,7 @@ impl<'a> CollectProcMacros<'a> {
}
}
fn collect_bang_proc_macro(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) {
if !attr.is_word() {
self.handler.span_err(attr.span, "`#[proc_macro]` attribute \
does not take any arguments");
return;
}
fn collect_bang_proc_macro(&mut self, item: &'a ast::Item) {
if self.in_root && item.vis.node.is_pub() {
self.bang_macros.push(ProcMacroDef {
span: item.span,
@ -308,9 +291,9 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
if attr.check_name("proc_macro_derive") {
self.collect_custom_derive(item, attr);
} else if attr.check_name("proc_macro_attribute") {
self.collect_attr_proc_macro(item, attr);
self.collect_attr_proc_macro(item);
} else if attr.check_name("proc_macro") {
self.collect_bang_proc_macro(item, attr);
self.collect_bang_proc_macro(item);
};
let prev_in_root = mem::replace(&mut self.in_root, false);

View File

@ -214,20 +214,8 @@ fn should_panic(cx: &ExtCtxt, i: &ast::Item) -> ShouldPanic {
match attr::find_by_name(&i.attrs, "should_panic") {
Some(attr) => {
let ref sd = cx.parse_sess.span_diagnostic;
if attr.is_value_str() {
sd.struct_span_warn(
attr.span(),
"attribute must be of the form: \
`#[should_panic]` or \
`#[should_panic(expected = \"error message\")]`"
).note("Errors in this attribute were erroneously allowed \
and will become a hard error in a future release.")
.emit();
return ShouldPanic::Yes(None);
}
match attr.meta_item_list() {
// Handle #[should_panic]
None => ShouldPanic::Yes(None),
// Handle #[should_panic(expected = "foo")]
Some(list) => {
let msg = list.iter()
@ -247,6 +235,8 @@ fn should_panic(cx: &ExtCtxt, i: &ast::Item) -> ShouldPanic {
ShouldPanic::Yes(msg)
}
},
// Handle #[should_panic] and #[should_panic = "expected"]
None => ShouldPanic::Yes(attr.value_str())
}
}
None => ShouldPanic::No,

View File

@ -66,7 +66,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<PathBuf> {
}
#[test]
#[ignore(reason = "buildbots don't have ncurses installed and I can't mock everything I need")]
#[ignore = "buildbots don't have ncurses installed and I can't mock everything I need"]
fn test_get_dbpath_for_term() {
// woefully inadequate test coverage
// note: current tests won't work with non-standard terminfo hierarchies (e.g., macOS's)

View File

@ -27,7 +27,8 @@ struct S9;
macro_rules! generate_s10 {
($expr: expr) => {
#[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item
#[cfg(feature = $expr)]
//~^ ERROR expected unsuffixed literal or identifier, found concat!("nonexistent")
struct S10;
}
}

View File

@ -52,11 +52,11 @@ error[E0565]: literal in `cfg` predicate value must be a string
LL | #[cfg(a = b"hi")] //~ ERROR literal in `cfg` predicate value must be a string
| ^^^^^ help: consider removing the prefix: `"hi"`
error: `cfg` is not a well-formed meta-item
--> $DIR/cfg-attr-syntax-validation.rs:30:9
error: expected unsuffixed literal or identifier, found concat!("nonexistent")
--> $DIR/cfg-attr-syntax-validation.rs:30:15
|
LL | #[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item
| ^^^^^^^^^^^^^^^^^^^^^^^ help: expected syntax is: `#[cfg(/* predicate */)]`
LL | #[cfg(feature = $expr)]
| ^^^^^^^
...
LL | generate_s10!(concat!("nonexistent"));
| -------------------------------------- in this macro invocation

View File

@ -1,9 +1,4 @@
// run-pass
#![allow(dead_code)]
#[derive] //~ WARNING empty trait list in `derive`
struct Foo;
// compile-pass
#[derive()] //~ WARNING empty trait list in `derive`
struct Bar;

View File

@ -1,11 +1,5 @@
warning: empty trait list in `derive`
--> $DIR/deriving-meta-empty-trait-list.rs:5:1
|
LL | #[derive] //~ WARNING empty trait list in `derive`
| ^^^^^^^^^
warning: empty trait list in `derive`
--> $DIR/deriving-meta-empty-trait-list.rs:8:1
--> $DIR/deriving-meta-empty-trait-list.rs:3:1
|
LL | #[derive()] //~ WARNING empty trait list in `derive`
| ^^^^^^^^^^^

View File

@ -1,8 +0,0 @@
#![feature(on_unimplemented)]
#[rustc_on_unimplemented]
//~^ ERROR E0232
trait Bar {}
fn main() {
}

View File

@ -1,11 +0,0 @@
error[E0232]: `#[rustc_on_unimplemented]` requires a value
--> $DIR/E0232.rs:3:1
|
LL | #[rustc_on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ value required here
|
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0232`.

View File

@ -1,3 +0,0 @@
#![recursion_limit] //~ ERROR E0296
fn main() {}

View File

@ -1,9 +0,0 @@
error[E0296]: malformed recursion limit attribute, expected #![recursion_limit="N"]
--> $DIR/E0296.rs:1:1
|
LL | #![recursion_limit] //~ ERROR E0296
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0296`.

View File

@ -1,6 +0,0 @@
#[export_name]
//~^ ERROR E0558
pub fn something() {}
fn main() {}

View File

@ -1,9 +0,0 @@
error[E0558]: `export_name` attribute has invalid format
--> $DIR/E0558.rs:1:1
|
LL | #[export_name]
| ^^^^^^^^^^^^^^ did you mean #[export_name="*"]?
error: aborting due to previous error
For more information about this error, try `rustc --explain E0558`.

View File

@ -30,75 +30,71 @@
// inputs are handled by each, and (2.) to ease searching for related
// occurrences in the source text.
// skip-codegen
#![warn(unused_attributes, unknown_lints)]
#![allow(dead_code)]
#![allow(stable_features)]
// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
#![warn (x5400)] //~ WARN unknown lint: `x5400`
#![allow (x5300)] //~ WARN unknown lint: `x5300`
#![forbid (x5200)] //~ WARN unknown lint: `x5200`
#![deny (x5100)] //~ WARN unknown lint: `x5100`
#![warn(x5400)] //~ WARN unknown lint: `x5400`
#![allow(x5300)] //~ WARN unknown lint: `x5300`
#![forbid(x5200)] //~ WARN unknown lint: `x5200`
#![deny(x5100)] //~ WARN unknown lint: `x5100`
#![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
#![macro_export = "4800"] //~ WARN unused attribute
#![plugin_registrar = "4700"] //~ WARN unused attribute
#![macro_export] //~ WARN unused attribute
#![plugin_registrar] //~ WARN unused attribute
// skipping testing of cfg
// skipping testing of cfg_attr
#![main = "x4400"] //~ WARN unused attribute
#![start = "x4300"] //~ WARN unused attribute
#![main] //~ WARN unused attribute
#![start] //~ WARN unused attribute
// see issue-43106-gating-of-test.rs for crate-level; but non crate-level is below at "4200"
// see issue-43106-gating-of-bench.rs for crate-level; but non crate-level is below at "4100"
#![repr = "3900"]
#![repr()]
//~^ WARN unused attribute
//~| WARN `repr` attribute isn't configurable with a literal
#![path = "3800"] //~ WARN unused attribute
#![abi = "3700"] //~ WARN unused attribute
#![automatically_derived = "3600"] //~ WARN unused attribute
#![no_mangle = "3500"]
#![no_link = "3400"] //~ WARN unused attribute
#![path = "3800"] //~ WARN unused attribute
#![automatically_derived] //~ WARN unused attribute
#![no_mangle]
#![no_link] //~ WARN unused attribute
// see issue-43106-gating-of-derive.rs
#![should_panic = "3200"] //~ WARN unused attribute
#![ignore = "3100"] //~ WARN unused attribute
#![no_implicit_prelude = "3000"]
#![should_panic] //~ WARN unused attribute
#![ignore] //~ WARN unused attribute
#![no_implicit_prelude]
#![reexport_test_harness_main = "2900"]
// see gated-link-args.rs
// see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
#![proc_macro_derive = "2500"] //~ WARN unused attribute
#![doc = "2400"]
#![cold = "2300"]
#![export_name = "2200"]
#![proc_macro_derive()] //~ WARN unused attribute
#![doc = "2400"]
#![cold]
#![export_name = "2200"]
// see issue-43106-gating-of-inline.rs
#![link = "2000"]
#![link_name = "1900"]
#![link_section = "1800"]
#![no_builtins = "1700"] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "0300")
#![no_mangle = "1600"] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "3500")
#![link()]
#![link_name = "1900"]
#![link_section = "1800"]
#![no_builtins] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "0300")
#![no_mangle] // Yikes, dupe'd on BUILTIN_ATTRIBUTES list (see "3500")
// see issue-43106-gating-of-rustc_deprecated.rs
#![must_use = "1400"]
#![must_use]
// see issue-43106-gating-of-stable.rs
// see issue-43106-gating-of-unstable.rs
// see issue-43106-gating-of-deprecated.rs
#![windows_subsystem = "1000"]
#![windows_subsystem = "1000"]
// UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES
#![crate_name = "0900"]
#![crate_type = "bin"] // cannot pass "0800" here
#![crate_name = "0900"]
#![crate_type = "bin"] // cannot pass "0800" here
// For #![crate_id], see issue #43142. (I cannot bear to enshrine current behavior in a test)
// FIXME(#44232) we should warn that this isn't used.
#![feature ( rust1)]
#![feature(rust1)]
// For #![no_start], see issue #43144. (I cannot bear to enshrine current behavior in a test)
// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
#![no_builtins = "0300"]
#![recursion_limit = "0200"]
#![type_length_limit = "0100"]
#![no_builtins]
#![recursion_limit = "0200"]
#![type_length_limit = "0100"]
// USES OF BUILT-IN ATTRIBUTES IN OTHER ("UNUSUAL") PLACES
@ -195,84 +191,84 @@ mod macro_use {
//~^ WARN unused attribute
}
#[macro_export = "4800"]
#[macro_export]
//~^ WARN unused attribute
mod macro_export {
mod inner { #![macro_export="4800"] }
mod inner { #![macro_export] }
//~^ WARN unused attribute
#[macro_export = "4800"] fn f() { }
#[macro_export] fn f() { }
//~^ WARN unused attribute
#[macro_export = "4800"] struct S;
#[macro_export] struct S;
//~^ WARN unused attribute
#[macro_export = "4800"] type T = S;
#[macro_export] type T = S;
//~^ WARN unused attribute
#[macro_export = "4800"] impl S { }
#[macro_export] impl S { }
//~^ WARN unused attribute
}
#[plugin_registrar = "4700"]
#[plugin_registrar]
//~^ WARN unused attribute
mod plugin_registrar {
mod inner { #![plugin_registrar="4700"] }
mod inner { #![plugin_registrar] }
//~^ WARN unused attribute
// for `fn f()` case, see gated-plugin_registrar.rs
#[plugin_registrar = "4700"] struct S;
#[plugin_registrar] struct S;
//~^ WARN unused attribute
#[plugin_registrar = "4700"] type T = S;
#[plugin_registrar] type T = S;
//~^ WARN unused attribute
#[plugin_registrar = "4700"] impl S { }
#[plugin_registrar] impl S { }
//~^ WARN unused attribute
}
#[main = "4400"]
#[main]
//~^ WARN unused attribute
mod main {
mod inner { #![main="4300"] }
mod inner { #![main] }
//~^ WARN unused attribute
// for `fn f()` case, see feature-gate-main.rs
#[main = "4400"] struct S;
#[main] struct S;
//~^ WARN unused attribute
#[main = "4400"] type T = S;
#[main] type T = S;
//~^ WARN unused attribute
#[main = "4400"] impl S { }
#[main] impl S { }
//~^ WARN unused attribute
}
#[start = "4300"]
#[start]
//~^ WARN unused attribute
mod start {
mod inner { #![start="4300"] }
mod inner { #![start] }
//~^ WARN unused attribute
// for `fn f()` case, see feature-gate-start.rs
#[start = "4300"] struct S;
#[start] struct S;
//~^ WARN unused attribute
#[start = "4300"] type T = S;
#[start] type T = S;
//~^ WARN unused attribute
#[start = "4300"] impl S { }
#[start] impl S { }
//~^ WARN unused attribute
}
// At time of unit test authorship, if compiling without `--test` then
// non-crate-level #[test] attributes seem to be ignored.
#[test = "4200"]
mod test { mod inner { #![test="4200"] }
#[test]
mod test { mod inner { #![test] }
fn f() { }
@ -286,41 +282,31 @@ mod test { mod inner { #![test="4200"] }
// At time of unit test authorship, if compiling without `--test` then
// non-crate-level #[bench] attributes seem to be ignored.
#[bench = "4100"]
#[bench]
mod bench {
mod inner { #![bench="4100"] }
mod inner { #![bench] }
#[bench = "4100"]
#[bench]
struct S;
#[bench = "4100"]
#[bench]
type T = S;
#[bench = "4100"]
#[bench]
impl S { }
}
#[repr = "3900"]
//~^ WARN unused attribute
//~| WARN `repr` attribute isn't configurable with a literal
#[repr()]
mod repr {
mod inner { #![repr="3900"] }
//~^ WARN unused attribute
//~| WARN `repr` attribute isn't configurable with a literal
mod inner { #![repr()] }
#[repr = "3900"] fn f() { }
//~^ WARN unused attribute
//~| WARN `repr` attribute isn't configurable with a literal
#[repr()] fn f() { }
struct S;
#[repr = "3900"] type T = S;
//~^ WARN unused attribute
//~| WARN `repr` attribute isn't configurable with a literal
#[repr()] type T = S;
#[repr = "3900"] impl S { }
//~^ WARN unused attribute
//~| WARN `repr` attribute isn't configurable with a literal
#[repr()] impl S { }
}
#[path = "3800"]
@ -340,130 +326,111 @@ mod path {
//~^ WARN unused attribute
}
#[abi = "3700"]
//~^ WARN unused attribute
mod abi {
mod inner { #![abi="3700"] }
//~^ WARN unused attribute
#[abi = "3700"] fn f() { }
//~^ WARN unused attribute
#[abi = "3700"] struct S;
//~^ WARN unused attribute
#[abi = "3700"] type T = S;
//~^ WARN unused attribute
#[abi = "3700"] impl S { }
//~^ WARN unused attribute
}
#[automatically_derived = "3600"]
#[automatically_derived]
//~^ WARN unused attribute
mod automatically_derived {
mod inner { #![automatically_derived="3600"] }
mod inner { #![automatically_derived] }
//~^ WARN unused attribute
#[automatically_derived = "3600"] fn f() { }
#[automatically_derived] fn f() { }
//~^ WARN unused attribute
#[automatically_derived = "3600"] struct S;
#[automatically_derived] struct S;
//~^ WARN unused attribute
#[automatically_derived = "3600"] type T = S;
#[automatically_derived] type T = S;
//~^ WARN unused attribute
#[automatically_derived = "3600"] impl S { }
#[automatically_derived] impl S { }
//~^ WARN unused attribute
}
#[no_mangle = "3500"]
#[no_mangle]
mod no_mangle {
mod inner { #![no_mangle="3500"] }
mod inner { #![no_mangle] }
#[no_mangle = "3500"] fn f() { }
#[no_mangle] fn f() { }
#[no_mangle = "3500"] struct S;
#[no_mangle] struct S;
#[no_mangle = "3500"] type T = S;
#[no_mangle] type T = S;
#[no_mangle = "3500"] impl S { }
#[no_mangle] impl S { }
}
#[no_link = "3400"]
#[no_link]
//~^ WARN unused attribute
mod no_link {
mod inner { #![no_link="3400"] }
mod inner { #![no_link] }
//~^ WARN unused attribute
#[no_link = "3400"] fn f() { }
#[no_link] fn f() { }
//~^ WARN unused attribute
#[no_link = "3400"] struct S;
#[no_link] struct S;
//~^ WARN unused attribute
#[no_link = "3400"]type T = S;
#[no_link]type T = S;
//~^ WARN unused attribute
#[no_link = "3400"] impl S { }
#[no_link] impl S { }
//~^ WARN unused attribute
}
#[should_panic = "3200"]
#[should_panic]
//~^ WARN unused attribute
mod should_panic {
mod inner { #![should_panic="3200"] }
mod inner { #![should_panic] }
//~^ WARN unused attribute
#[should_panic = "3200"] fn f() { }
#[should_panic] fn f() { }
//~^ WARN unused attribute
#[should_panic = "3200"] struct S;
#[should_panic] struct S;
//~^ WARN unused attribute
#[should_panic = "3200"] type T = S;
#[should_panic] type T = S;
//~^ WARN unused attribute
#[should_panic = "3200"] impl S { }
#[should_panic] impl S { }
//~^ WARN unused attribute
}
#[ignore = "3100"]
#[ignore]
//~^ WARN unused attribute
mod ignore {
mod inner { #![ignore="3100"] }
mod inner { #![ignore] }
//~^ WARN unused attribute
#[ignore = "3100"] fn f() { }
#[ignore] fn f() { }
//~^ WARN unused attribute
#[ignore = "3100"] struct S;
#[ignore] struct S;
//~^ WARN unused attribute
#[ignore = "3100"] type T = S;
#[ignore] type T = S;
//~^ WARN unused attribute
#[ignore = "3100"] impl S { }
#[ignore] impl S { }
//~^ WARN unused attribute
}
#[no_implicit_prelude = "3000"]
#[no_implicit_prelude]
//~^ WARN unused attribute
mod no_implicit_prelude {
mod inner { #![no_implicit_prelude="3000"] }
mod inner { #![no_implicit_prelude] }
//~^ WARN unused attribute
#[no_implicit_prelude = "3000"] fn f() { }
#[no_implicit_prelude] fn f() { }
//~^ WARN unused attribute
#[no_implicit_prelude = "3000"] struct S;
#[no_implicit_prelude] struct S;
//~^ WARN unused attribute
#[no_implicit_prelude = "3000"] type T = S;
#[no_implicit_prelude] type T = S;
//~^ WARN unused attribute
#[no_implicit_prelude = "3000"] impl S { }
#[no_implicit_prelude] impl S { }
//~^ WARN unused attribute
}
@ -506,27 +473,27 @@ mod macro_escape {
//~^ WARN unused attribute
}
#[no_std = "2600"]
#[no_std]
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
mod no_std {
mod inner { #![no_std="2600"] }
mod inner { #![no_std] }
//~^ WARN unused attribute
//~| WARN crate-level attribute should be in the root module
#[no_std = "2600"] fn f() { }
#[no_std] fn f() { }
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
#[no_std = "2600"] struct S;
#[no_std] struct S;
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
#[no_std = "2600"] type T = S;
#[no_std] type T = S;
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
#[no_std = "2600"] impl S { }
#[no_std] impl S { }
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
}
@ -548,17 +515,17 @@ mod doc {
#[doc = "2400"] impl S { }
}
#[cold = "2300"]
#[cold]
mod cold {
mod inner { #![cold="2300"] }
mod inner { #![cold] }
#[cold = "2300"] fn f() { }
#[cold] fn f() { }
#[cold = "2300"] struct S;
#[cold] struct S;
#[cold = "2300"] type T = S;
#[cold] type T = S;
#[cold = "2300"] impl S { }
#[cold] impl S { }
}
#[export_name = "2200"]
@ -579,17 +546,17 @@ mod export_name {
// out that we allow them at non-crate-level (though I do not know
// whether they have the same effect here as at crate-level).
#[link = "2000"]
#[link()]
mod link {
mod inner { #![link="2000"] }
mod inner { #![link()] }
#[link = "2000"] fn f() { }
#[link()] fn f() { }
#[link = "2000"] struct S;
#[link()] struct S;
#[link = "2000"] type T = S;
#[link()] type T = S;
#[link = "2000"] impl S { }
#[link()] impl S { }
}
#[link_name = "1900"]
@ -620,30 +587,30 @@ mod link_section {
struct StructForDeprecated;
#[deprecated = "1500"]
#[deprecated]
mod deprecated {
mod inner { #![deprecated="1500"] }
mod inner { #![deprecated] }
#[deprecated = "1500"] fn f() { }
#[deprecated] fn f() { }
#[deprecated = "1500"] struct S1;
#[deprecated] struct S1;
#[deprecated = "1500"] type T = super::StructForDeprecated;
#[deprecated] type T = super::StructForDeprecated;
#[deprecated = "1500"] impl super::StructForDeprecated { }
#[deprecated] impl super::StructForDeprecated { }
}
#[must_use = "1400"]
#[must_use]
mod must_use {
mod inner { #![must_use="1400"] }
mod inner { #![must_use] }
#[must_use = "1400"] fn f() { }
#[must_use] fn f() { }
#[must_use = "1400"] struct S;
#[must_use] struct S;
#[must_use = "1400"] type T = S;
#[must_use] type T = S;
#[must_use = "1400"] impl S { }
#[must_use] impl S { }
}
#[windows_subsystem = "1000"]
@ -737,42 +704,42 @@ mod feature {
}
#[no_main = "0400"]
#[no_main]
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
mod no_main_1 {
mod inner { #![no_main="0400"] }
mod inner { #![no_main] }
//~^ WARN unused attribute
//~| WARN crate-level attribute should be in the root module
#[no_main = "0400"] fn f() { }
#[no_main] fn f() { }
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
#[no_main = "0400"] struct S;
#[no_main] struct S;
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
#[no_main = "0400"] type T = S;
#[no_main] type T = S;
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
#[no_main = "0400"] impl S { }
#[no_main] impl S { }
//~^ WARN unused attribute
//~| WARN crate-level attribute should be an inner attribute
}
#[no_builtins = "0300"]
#[no_builtins]
mod no_builtins {
mod inner { #![no_builtins="0200"] }
mod inner { #![no_builtins] }
#[no_builtins = "0300"] fn f() { }
#[no_builtins] fn f() { }
#[no_builtins = "0300"] struct S;
#[no_builtins] struct S;
#[no_builtins = "0300"] type T = S;
#[no_builtins] type T = S;
#[no_builtins = "0300"] impl S { }
#[no_builtins] impl S { }
}
#[recursion_limit="0200"]
@ -825,12 +792,4 @@ mod type_length_limit {
//~| WARN crate-level attribute should be an inner attribute
}
fn main() {
println!("Hello World");
}
fn main() {}

View File

@ -7,15 +7,7 @@
// compile-pass
// skip-codegen
#![allow(dead_code)]
#![deprecated = "1100"]
// Since we expect for the mix of attributes used here to compile
// successfully, and we are just testing for the expected warnings of
// various (mis)uses of attributes, we use the `rustc_error` attribute
// on the `fn main()`.
#![deprecated]
fn main() {
println!("Hello World");
}
fn main() {}

View File

@ -6,23 +6,25 @@
// issue-43106-gating-of-builtin-attrs.rs)
// Crate-level is accepted, though it is almost certainly unused?
#![inline = "2100"]
#![inline]
#[inline = "2100"]
#[inline]
//~^ ERROR attribute should be applied to function or closure
mod inline {
mod inner { #![inline="2100"] }
mod inner { #![inline] }
//~^ ERROR attribute should be applied to function or closure
#[inline = "2100"] fn f() { }
//~^ WARN attribute must be of the form
//~| WARN this was previously accepted
#[inline = "2100"] struct S;
#[inline] struct S;
//~^ ERROR attribute should be applied to function or closure
#[inline = "2100"] type T = S;
#[inline] type T = S;
//~^ ERROR attribute should be applied to function or closure
#[inline = "2100"] impl S { }
#[inline] impl S { }
//~^ ERROR attribute should be applied to function or closure
}

View File

@ -1,11 +1,21 @@
warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
--> $DIR/issue-43106-gating-of-inline.rs:17:5
|
LL | #[inline = "2100"] fn f() { }
| ^^^^^^^^^^^^^^^^^^
|
= note: #[warn(ill_formed_attribute_input)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:11:1
|
LL | #[inline = "2100"]
| ^^^^^^^^^^^^^^^^^^
LL | #[inline]
| ^^^^^^^^^
LL | //~^ ERROR attribute should be applied to function or closure
LL | / mod inline {
LL | | mod inner { #![inline="2100"] }
LL | | mod inner { #![inline] }
LL | | //~^ ERROR attribute should be applied to function or closure
LL | |
... |
@ -16,26 +26,26 @@ LL | | }
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:14:17
|
LL | mod inner { #![inline="2100"] }
| ------------^^^^^^^^^^^^^^^^^-- not a function or closure
LL | mod inner { #![inline] }
| ------------^^^^^^^^^^-- not a function or closure
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:19:5
--> $DIR/issue-43106-gating-of-inline.rs:21:5
|
LL | #[inline = "2100"] struct S;
| ^^^^^^^^^^^^^^^^^^ --------- not a function or closure
LL | #[inline] struct S;
| ^^^^^^^^^ --------- not a function or closure
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:22:5
--> $DIR/issue-43106-gating-of-inline.rs:24:5
|
LL | #[inline = "2100"] type T = S;
| ^^^^^^^^^^^^^^^^^^ ----------- not a function or closure
LL | #[inline] type T = S;
| ^^^^^^^^^ ----------- not a function or closure
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43106-gating-of-inline.rs:25:5
--> $DIR/issue-43106-gating-of-inline.rs:27:5
|
LL | #[inline = "2100"] impl S { }
| ^^^^^^^^^^^^^^^^^^ ---------- not a function or closure
LL | #[inline] impl S { }
| ^^^^^^^^^ ---------- not a function or closure
error: aborting due to 5 previous errors

View File

@ -3,21 +3,23 @@
// corresponds to cases where the attribute is currently unused, so we
// get that warning; see issue-43106-gating-of-builtin-attrs.rs
#![macro_use = "4900"] //~ ERROR arguments to macro_use are not allowed here
#![macro_use(my_macro)]
//~^ ERROR arguments to macro_use are not allowed here
#[macro_use = "2700"]
#[macro_use(my_macro)]
//~^ ERROR arguments to macro_use are not allowed here
mod macro_escape {
mod inner { #![macro_use="2700"] }
mod inner { #![macro_use(my_macro)] }
//~^ ERROR arguments to macro_use are not allowed here
#[macro_use = "2700"] fn f() { }
#[macro_use = "2700"] struct S;
//~^ ERROR attribute must be of the form
#[macro_use = "2700"] type T = S;
#[macro_use] fn f() { }
#[macro_use = "2700"] impl S { }
#[macro_use] type T = S;
#[macro_use] impl S { }
}
fn main() { }

View File

@ -1,20 +1,26 @@
error: arguments to macro_use are not allowed here
--> $DIR/issue-43106-gating-of-macro_use.rs:6:1
|
LL | #![macro_use = "4900"] //~ ERROR arguments to macro_use are not allowed here
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![macro_use(my_macro)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: arguments to macro_use are not allowed here
--> $DIR/issue-43106-gating-of-macro_use.rs:8:1
--> $DIR/issue-43106-gating-of-macro_use.rs:9:1
|
LL | #[macro_use = "2700"]
| ^^^^^^^^^^^^^^^^^^^^^
LL | #[macro_use(my_macro)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: arguments to macro_use are not allowed here
--> $DIR/issue-43106-gating-of-macro_use.rs:11:17
--> $DIR/issue-43106-gating-of-macro_use.rs:12:17
|
LL | mod inner { #![macro_use="2700"] }
| ^^^^^^^^^^^^^^^^^^^^
LL | mod inner { #![macro_use(my_macro)] }
| ^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors
error: attribute must be of the form `#[macro_use]` or `#[macro_use(name1, name2, ...)]`
--> $DIR/issue-43106-gating-of-macro_use.rs:15:5
|
LL | #[macro_use = "2700"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors

View File

@ -7,27 +7,27 @@
// signal errors, making it incompatible with the "warnings only"
// nature of issue-43106-gating-of-builtin-attrs.rs
#[proc_macro_derive = "2500"]
#[proc_macro_derive()]
//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
mod proc_macro_derive1 {
mod inner { #![proc_macro_derive="2500"] }
mod inner { #![proc_macro_derive()] }
// (no error issued here if there was one on outer module)
}
mod proc_macro_derive2 {
mod inner { #![proc_macro_derive="2500"] }
mod inner { #![proc_macro_derive()] }
//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
#[proc_macro_derive = "2500"] fn f() { }
#[proc_macro_derive()] fn f() { }
//~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro`
#[proc_macro_derive = "2500"] struct S;
#[proc_macro_derive()] struct S;
//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
#[proc_macro_derive = "2500"] type T = S;
#[proc_macro_derive()] type T = S;
//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
#[proc_macro_derive = "2500"] impl S { }
#[proc_macro_derive()] impl S { }
//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
}

View File

@ -1,38 +1,38 @@
error: the `#[proc_macro_derive]` attribute may only be used on bare functions
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:10:1
|
LL | #[proc_macro_derive = "2500"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[proc_macro_derive()]
| ^^^^^^^^^^^^^^^^^^^^^^
error: the `#[proc_macro_derive]` attribute may only be used on bare functions
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:18:17
|
LL | mod inner { #![proc_macro_derive="2500"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | mod inner { #![proc_macro_derive()] }
| ^^^^^^^^^^^^^^^^^^^^^^^
error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:21:5
|
LL | #[proc_macro_derive = "2500"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[proc_macro_derive()] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
error: the `#[proc_macro_derive]` attribute may only be used on bare functions
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:24:5
|
LL | #[proc_macro_derive = "2500"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[proc_macro_derive()] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
error: the `#[proc_macro_derive]` attribute may only be used on bare functions
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:27:5
|
LL | #[proc_macro_derive = "2500"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[proc_macro_derive()] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
error: the `#[proc_macro_derive]` attribute may only be used on bare functions
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:30:5
|
LL | #[proc_macro_derive = "2500"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[proc_macro_derive()] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors

View File

@ -4,25 +4,25 @@
// this test incompatible with the "warnings only" nature of
// issue-43106-gating-of-builtin-attrs.rs
#![rustc_deprecated = "1500"]
#![rustc_deprecated()]
//~^ ERROR stability attributes may not be used outside of the standard library
#[rustc_deprecated = "1500"]
#[rustc_deprecated()]
//~^ ERROR stability attributes may not be used outside of the standard library
mod rustc_deprecated {
mod inner { #![rustc_deprecated="1500"] }
mod inner { #![rustc_deprecated()] }
//~^ ERROR stability attributes may not be used outside of the standard library
#[rustc_deprecated = "1500"] fn f() { }
#[rustc_deprecated()] fn f() { }
//~^ ERROR stability attributes may not be used outside of the standard library
#[rustc_deprecated = "1500"] struct S;
#[rustc_deprecated()] struct S;
//~^ ERROR stability attributes may not be used outside of the standard library
#[rustc_deprecated = "1500"] type T = S;
#[rustc_deprecated()] type T = S;
//~^ ERROR stability attributes may not be used outside of the standard library
#[rustc_deprecated = "1500"] impl S { }
#[rustc_deprecated()] impl S { }
//~^ ERROR stability attributes may not be used outside of the standard library
}

View File

@ -1,44 +1,44 @@
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:7:1
|
LL | #![rustc_deprecated = "1500"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![rustc_deprecated()]
| ^^^^^^^^^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:10:1
|
LL | #[rustc_deprecated = "1500"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_deprecated()]
| ^^^^^^^^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:13:17
|
LL | mod inner { #![rustc_deprecated="1500"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | mod inner { #![rustc_deprecated()] }
| ^^^^^^^^^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:16:5
|
LL | #[rustc_deprecated = "1500"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_deprecated()] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:19:5
|
LL | #[rustc_deprecated = "1500"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_deprecated()] struct S;
| ^^^^^^^^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:22:5
|
LL | #[rustc_deprecated = "1500"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_deprecated()] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:25:5
|
LL | #[rustc_deprecated = "1500"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_deprecated()] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 7 previous errors

View File

@ -4,25 +4,25 @@
// this test incompatible with the "warnings only" nature of
// issue-43106-gating-of-builtin-attrs.rs
#![stable = "1300"]
#![stable()]
//~^ ERROR stability attributes may not be used outside of the standard library
#[stable = "1300"]
#[stable()]
//~^ ERROR stability attributes may not be used outside of the standard library
mod stable {
mod inner { #![stable="1300"] }
mod inner { #![stable()] }
//~^ ERROR stability attributes may not be used outside of the standard library
#[stable = "1300"] fn f() { }
#[stable()] fn f() { }
//~^ ERROR stability attributes may not be used outside of the standard library
#[stable = "1300"] struct S;
#[stable()] struct S;
//~^ ERROR stability attributes may not be used outside of the standard library
#[stable = "1300"] type T = S;
#[stable()] type T = S;
//~^ ERROR stability attributes may not be used outside of the standard library
#[stable = "1300"] impl S { }
#[stable()] impl S { }
//~^ ERROR stability attributes may not be used outside of the standard library
}

View File

@ -1,44 +1,44 @@
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:7:1
|
LL | #![stable = "1300"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![stable()]
| ^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:10:1
|
LL | #[stable = "1300"]
| ^^^^^^^^^^^^^^^^^^
LL | #[stable()]
| ^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:13:17
|
LL | mod inner { #![stable="1300"] }
| ^^^^^^^^^^^^^^^^^
LL | mod inner { #![stable()] }
| ^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:16:5
|
LL | #[stable = "1300"] fn f() { }
| ^^^^^^^^^^^^^^^^^^
LL | #[stable()] fn f() { }
| ^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:19:5
|
LL | #[stable = "1300"] struct S;
| ^^^^^^^^^^^^^^^^^^
LL | #[stable()] struct S;
| ^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:22:5
|
LL | #[stable = "1300"] type T = S;
| ^^^^^^^^^^^^^^^^^^
LL | #[stable()] type T = S;
| ^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:25:5
|
LL | #[stable = "1300"] impl S { }
| ^^^^^^^^^^^^^^^^^^
LL | #[stable()] impl S { }
| ^^^^^^^^^^^
error: aborting due to 7 previous errors

View File

@ -4,25 +4,25 @@
// this test incompatible with the "warnings only" nature of
// issue-43106-gating-of-builtin-attrs.rs
#![unstable = "1200"]
#![unstable()]
//~^ ERROR stability attributes may not be used outside of the standard library
#[unstable = "1200"]
#[unstable()]
//~^ ERROR stability attributes may not be used outside of the standard library
mod unstable {
mod inner { #![unstable="1200"] }
mod inner { #![unstable()] }
//~^ ERROR stability attributes may not be used outside of the standard library
#[unstable = "1200"] fn f() { }
#[unstable()] fn f() { }
//~^ ERROR stability attributes may not be used outside of the standard library
#[unstable = "1200"] struct S;
#[unstable()] struct S;
//~^ ERROR stability attributes may not be used outside of the standard library
#[unstable = "1200"] type T = S;
#[unstable()] type T = S;
//~^ ERROR stability attributes may not be used outside of the standard library
#[unstable = "1200"] impl S { }
#[unstable()] impl S { }
//~^ ERROR stability attributes may not be used outside of the standard library
}

View File

@ -1,44 +1,44 @@
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
|
LL | #![unstable = "1200"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![unstable()]
| ^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
|
LL | #[unstable = "1200"]
| ^^^^^^^^^^^^^^^^^^^^
LL | #[unstable()]
| ^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:13:17
|
LL | mod inner { #![unstable="1200"] }
| ^^^^^^^^^^^^^^^^^^^
LL | mod inner { #![unstable()] }
| ^^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:16:5
|
LL | #[unstable = "1200"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^
LL | #[unstable()] fn f() { }
| ^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:19:5
|
LL | #[unstable = "1200"] struct S;
| ^^^^^^^^^^^^^^^^^^^^
LL | #[unstable()] struct S;
| ^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:22:5
|
LL | #[unstable = "1200"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^
LL | #[unstable()] type T = S;
| ^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:25:5
|
LL | #[unstable = "1200"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^
LL | #[unstable()] impl S { }
| ^^^^^^^^^^^^^
error: aborting due to 7 previous errors

View File

@ -8,7 +8,7 @@ extern {
fn extern_fn();
// CHECK-NOT: Function Attrs: nounwind
// CHECK: declare void @unwinding_extern_fn
#[unwind] //~ ERROR #[unwind] is experimental
#[unwind(allowed)] //~ ERROR #[unwind] is experimental
fn unwinding_extern_fn();
}

View File

@ -1,8 +1,8 @@
error[E0658]: #[unwind] is experimental
--> $DIR/feature-gate-unwind-attributes.rs:11:5
|
LL | #[unwind] //~ ERROR #[unwind] is experimental
| ^^^^^^^^^
LL | #[unwind(allowed)] //~ ERROR #[unwind] is experimental
| ^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(unwind_attributes)] to the crate attributes to enable

View File

@ -6,8 +6,8 @@
//~^^^ ERROR: malformed feature
//~^^^ ERROR: malformed feature
#![feature] //~ ERROR: malformed feature
#![feature = "foo"] //~ ERROR: malformed feature
#![feature] //~ ERROR: attribute must be of the form
#![feature = "foo"] //~ ERROR: attribute must be of the form
#![feature(test_removed_feature)] //~ ERROR: feature has been removed

View File

@ -10,25 +10,25 @@ error[E0556]: malformed feature, expected just one word
LL | foo = "baz"
| ^^^^^^^^^^^
error[E0555]: malformed feature attribute, expected #![feature(...)]
--> $DIR/gated-bad-feature.rs:9:1
|
LL | #![feature] //~ ERROR: malformed feature
| ^^^^^^^^^^^
error[E0555]: malformed feature attribute, expected #![feature(...)]
--> $DIR/gated-bad-feature.rs:10:1
|
LL | #![feature = "foo"] //~ ERROR: malformed feature
| ^^^^^^^^^^^^^^^^^^^
error[E0557]: feature has been removed
--> $DIR/gated-bad-feature.rs:12:12
|
LL | #![feature(test_removed_feature)] //~ ERROR: feature has been removed
| ^^^^^^^^^^^^^^^^^^^^
error: attribute must be of the form `#[feature(name1, name1, ...)]`
--> $DIR/gated-bad-feature.rs:9:1
|
LL | #![feature] //~ ERROR: attribute must be of the form
| ^^^^^^^^^^^
error: attribute must be of the form `#[feature(name1, name1, ...)]`
--> $DIR/gated-bad-feature.rs:10:1
|
LL | #![feature = "foo"] //~ ERROR: attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors
Some errors occurred: E0555, E0556, E0557.
For more information about an error, try `rustc --explain E0555`.
Some errors occurred: E0556, E0557.
For more information about an error, try `rustc --explain E0556`.

View File

@ -1,5 +1,5 @@
// regression test for issue 16974
#![crate_type(lib)] //~ ERROR `crate_type` requires a value
#![crate_type(lib)] //~ ERROR attribute must be of the form
fn my_lib_fn() {}

View File

@ -1,10 +1,8 @@
error: `crate_type` requires a value
error: attribute must be of the form `#[crate_type = "bin|lib|..."]`
--> $DIR/invalid_crate_type_syntax.rs:2:1
|
LL | #![crate_type(lib)] //~ ERROR `crate_type` requires a value
LL | #![crate_type(lib)] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^
|
= note: for example: `#![crate_type="lib"]`
error: aborting due to previous error

View File

@ -24,8 +24,7 @@ fn main() {
#[repr]
let _y = "123";
//~^^ ERROR attribute should not be applied to a statement
//~| WARN `repr` attribute must have a hint
//~| ERROR attribute must be of the form
fn foo() {}
@ -35,5 +34,5 @@ fn main() {
let _z = #[repr] 1;
//~^ ERROR attribute should not be applied to an expression
//~| WARN `repr` attribute must have a hint
//~| ERROR attribute must be of the form
}

View File

@ -1,21 +1,14 @@
warning: `repr` attribute must have a hint
error: attribute must be of the form `#[repr(C, packed, ...)]`
--> $DIR/issue-43988.rs:24:5
|
LL | #[repr]
| ^^^^^^^ needs a hint
|
= note: #[warn(bad_repr)] on by default
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
| ^^^^^^^
warning: `repr` attribute must have a hint
--> $DIR/issue-43988.rs:36:14
error: attribute must be of the form `#[repr(C, packed, ...)]`
--> $DIR/issue-43988.rs:35:14
|
LL | let _z = #[repr] 1;
| ^^^^^^^ needs a hint
|
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
| ^^^^^^^
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43988.rs:5:5
@ -60,7 +53,7 @@ LL | let _y = "123";
| --------------- not a struct, enum or union
error[E0518]: attribute should be applied to function or closure
--> $DIR/issue-43988.rs:32:5
--> $DIR/issue-43988.rs:31:5
|
LL | #[inline(ABC)]
| ^^^^^^^^^^^^^^
@ -68,12 +61,12 @@ LL | foo();
| ----- not a function or closure
error[E0517]: attribute should not be applied to an expression
--> $DIR/issue-43988.rs:36:14
--> $DIR/issue-43988.rs:35:14
|
LL | let _z = #[repr] 1;
| ^^^^^^^ - not defining a struct, enum or union
error: aborting due to 7 previous errors
error: aborting due to 9 previous errors
Some errors occurred: E0517, E0518.
For more information about an error, try `rustc --explain E0517`.

View File

@ -1,4 +1,4 @@
#![deny = "foo"] //~ ERROR malformed lint attribute
#![deny = "foo"] //~ ERROR attribute must be of the form
#![allow(bar = "baz")] //~ ERROR malformed lint attribute
fn main() { }

View File

@ -1,15 +1,15 @@
error[E0452]: malformed lint attribute
--> $DIR/lint-malformed.rs:1:1
|
LL | #![deny = "foo"] //~ ERROR malformed lint attribute
| ^^^^^^^^^^^^^^^^
error[E0452]: malformed lint attribute
--> $DIR/lint-malformed.rs:2:10
|
LL | #![allow(bar = "baz")] //~ ERROR malformed lint attribute
| ^^^^^^^^^^^
error: attribute must be of the form `#[deny(lint1, lint2, ..., /*opt*/ reason = "...")]`
--> $DIR/lint-malformed.rs:1:1
|
LL | #![deny = "foo"] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0452`.

View File

@ -0,0 +1,4 @@
#[derive(::Absolute)] //~ ERROR failed to resolve
struct S;
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0433]: failed to resolve: maybe a missing `extern crate Absolute;`?
--> $DIR/meta-item-absolute-path.rs:1:12
|
LL | #[derive(::Absolute)] //~ ERROR failed to resolve
| ^^^^^^^^ maybe a missing `extern crate Absolute;`?
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.

View File

@ -11,7 +11,7 @@ struct Test2;
struct Test3;
#[derive]
//~^ WARNING empty trait list
//~^ ERROR attribute must be of the form
struct Test4;
fn main() {}

View File

@ -16,11 +16,11 @@ warning: empty trait list in `derive`
LL | #[derive()]
| ^^^^^^^^^^^
warning: empty trait list in `derive`
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
--> $DIR/malformed-derive-entry.rs:13:1
|
LL | #[derive]
| ^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

View File

@ -1,4 +1,4 @@
#![feature(plugin)]
#![plugin] //~ ERROR malformed plugin attribute
#![plugin] //~ ERROR attribute must be of the form
fn main() {}

View File

@ -1,9 +1,8 @@
error[E0498]: malformed plugin attribute
error: attribute must be of the form `#[plugin(name|name(args))]`
--> $DIR/malformed-plugin-1.rs:2:1
|
LL | #![plugin] //~ ERROR malformed plugin attribute
LL | #![plugin] //~ ERROR attribute must be of the form
| ^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0498`.

View File

@ -1,4 +1,4 @@
#![feature(plugin)]
#![plugin="bleh"] //~ ERROR malformed plugin attribute
#![plugin="bleh"] //~ ERROR attribute must be of the form
fn main() {}

View File

@ -1,9 +1,8 @@
error[E0498]: malformed plugin attribute
error: attribute must be of the form `#[plugin(name|name(args))]`
--> $DIR/malformed-plugin-2.rs:2:1
|
LL | #![plugin="bleh"] //~ ERROR malformed plugin attribute
LL | #![plugin="bleh"] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0498`.

View File

@ -0,0 +1,8 @@
// compile-pass
#[doc] //~ WARN attribute must be of the form
#[ignore()] //~ WARN attribute must be of the form
#[inline = ""] //~ WARN attribute must be of the form
#[link] //~ WARN attribute must be of the form
#[link = ""] //~ WARN attribute must be of the form
fn main() {}

View File

@ -0,0 +1,48 @@
warning: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]`
--> $DIR/malformed-regressions.rs:3:1
|
LL | #[doc] //~ WARN attribute must be of the form
| ^^^^^^
|
= note: #[warn(ill_formed_attribute_input)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]`
--> $DIR/malformed-regressions.rs:4:1
|
LL | #[ignore()] //~ WARN attribute must be of the form
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
--> $DIR/malformed-regressions.rs:5:1
|
LL | #[inline = ""] //~ WARN attribute must be of the form
| ^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...",
/*opt*/ cfg = "...")]`
--> $DIR/malformed-regressions.rs:6:1
|
LL | #[link] //~ WARN attribute must be of the form
| ^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...",
/*opt*/ cfg = "...")]`
--> $DIR/malformed-regressions.rs:7:1
|
LL | #[link = ""] //~ WARN attribute must be of the form
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

View File

@ -0,0 +1,13 @@
#[cfg_attr] //~ ERROR expected `(`, found `<eof>`
struct S1;
#[cfg_attr = ""] //~ ERROR expected `(`, found `=`
struct S2;
#[derive] //~ ERROR attribute must be of the form
struct S3;
#[derive = ""] //~ ERROR attribute must be of the form
struct S4;
fn main() {}

View File

@ -0,0 +1,25 @@
error: expected `(`, found `<eof>`
error: expected `(`, found `=`
--> $DIR/malformed-special-attrs.rs:4:12
|
LL | #[cfg_attr] //~ ERROR expected `(`, found `<eof>`
| - expected `(`
...
LL | #[cfg_attr = ""] //~ ERROR expected `(`, found `=`
| ^ unexpected token
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
--> $DIR/malformed-special-attrs.rs:7:1
|
LL | #[derive] //~ ERROR attribute must be of the form
| ^^^^^^^^^
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
--> $DIR/malformed-special-attrs.rs:10:1
|
LL | #[derive = ""] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^
error: aborting due to 4 previous errors

View File

@ -3,14 +3,14 @@
#[marker(always)]
trait Marker1 {}
//~^^ ERROR attribute should be empty
//~^^ ERROR attribute must be of the form
#[marker("never")]
trait Marker2 {}
//~^^ ERROR attribute should be empty
//~^^ ERROR attribute must be of the form
#[marker(key = value)]
trait Marker3 {}
//~^^ ERROR attribute should be empty
//~^^ ERROR expected unsuffixed literal or identifier, found value
fn main() {}

View File

@ -1,20 +1,20 @@
error: attribute should be empty
error: attribute must be of the form `#[marker]`
--> $DIR/marker-attribute-with-values.rs:4:1
|
LL | #[marker(always)]
| ^^^^^^^^^^^^^^^^^
error: attribute should be empty
error: attribute must be of the form `#[marker]`
--> $DIR/marker-attribute-with-values.rs:8:1
|
LL | #[marker("never")]
| ^^^^^^^^^^^^^^^^^^
error: attribute should be empty
--> $DIR/marker-attribute-with-values.rs:12:1
error: expected unsuffixed literal or identifier, found value
--> $DIR/marker-attribute-with-values.rs:12:10
|
LL | #[marker(key = value)]
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^
error: aborting due to 3 previous errors

View File

@ -2,7 +2,6 @@
// after normalization.
#![feature(nll)]
#![ignore(unused)]
trait Foo { type Out; }
impl Foo for () { type Out = &'static u32; }

View File

@ -1,5 +1,5 @@
error[E0597]: `a` does not live long enough
--> $DIR/normalization.rs:12:31
--> $DIR/normalization.rs:11:31
|
LL | let b: <() as Foo>::Out = &a; //~ ERROR
| ---------------- ^^ borrowed value does not live long enough

View File

@ -1,5 +1,5 @@
// regression test for issue 11256
#![crate_type] //~ ERROR `crate_type` requires a value
#![crate_type] //~ ERROR attribute must be of the form
fn main() {
return

View File

@ -1,10 +1,8 @@
error: `crate_type` requires a value
error: attribute must be of the form `#[crate_type = "bin|lib|..."]`
--> $DIR/no_crate_type.rs:2:1
|
LL | #![crate_type] //~ ERROR `crate_type` requires a value
LL | #![crate_type] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^
|
= note: for example: `#![crate_type="lib"]`
error: aborting due to previous error

View File

@ -14,7 +14,8 @@ trait MyFromIterator<A> {
fn my_from_iter<T: Iterator<Item=A>>(iterator: T) -> Self;
}
#[rustc_on_unimplemented] //~ ERROR `#[rustc_on_unimplemented]` requires a value
#[rustc_on_unimplemented]
//~^ ERROR attribute must be of the form
trait BadAnnotation1
{}

View File

@ -1,25 +1,23 @@
error[E0232]: `#[rustc_on_unimplemented]` requires a value
error: attribute must be of the form `#[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")]` or `#[rustc_on_unimplemented = "message"]`
--> $DIR/bad-annotation.rs:17:1
|
LL | #[rustc_on_unimplemented] //~ ERROR `#[rustc_on_unimplemented]` requires a value
| ^^^^^^^^^^^^^^^^^^^^^^^^^ value required here
|
= note: eg `#[rustc_on_unimplemented(message="foo")]`
LL | #[rustc_on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0230]: there is no parameter `C` on trait `BadAnnotation2`
--> $DIR/bad-annotation.rs:21:1
--> $DIR/bad-annotation.rs:22:1
|
LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0231]: only named substitution parameters are allowed
--> $DIR/bad-annotation.rs:26:1
--> $DIR/bad-annotation.rs:27:1
|
LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0232]: this attribute must have a valid value
--> $DIR/bad-annotation.rs:31:26
--> $DIR/bad-annotation.rs:32:26
|
LL | #[rustc_on_unimplemented(lorem="")]
| ^^^^^^^^ expected value here
@ -27,7 +25,7 @@ LL | #[rustc_on_unimplemented(lorem="")]
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error[E0232]: this attribute must have a valid value
--> $DIR/bad-annotation.rs:35:26
--> $DIR/bad-annotation.rs:36:26
|
LL | #[rustc_on_unimplemented(lorem(ipsum(dolor)))]
| ^^^^^^^^^^^^^^^^^^^ expected value here
@ -35,7 +33,7 @@ LL | #[rustc_on_unimplemented(lorem(ipsum(dolor)))]
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error[E0232]: this attribute must have a valid value
--> $DIR/bad-annotation.rs:39:39
--> $DIR/bad-annotation.rs:40:39
|
LL | #[rustc_on_unimplemented(message="x", message="y")]
| ^^^^^^^^^^^ expected value here
@ -43,7 +41,7 @@ LL | #[rustc_on_unimplemented(message="x", message="y")]
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error[E0232]: this attribute must have a valid value
--> $DIR/bad-annotation.rs:43:39
--> $DIR/bad-annotation.rs:44:39
|
LL | #[rustc_on_unimplemented(message="x", on(desugared, message="y"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here
@ -51,13 +49,13 @@ LL | #[rustc_on_unimplemented(message="x", on(desugared, message="y"))]
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error[E0232]: empty `on`-clause in `#[rustc_on_unimplemented]`
--> $DIR/bad-annotation.rs:47:26
--> $DIR/bad-annotation.rs:48:26
|
LL | #[rustc_on_unimplemented(on(), message="y")]
| ^^^^ empty on-clause here
error[E0232]: this attribute must have a valid value
--> $DIR/bad-annotation.rs:51:26
--> $DIR/bad-annotation.rs:52:26
|
LL | #[rustc_on_unimplemented(on="x", message="y")]
| ^^^^^^ expected value here
@ -65,7 +63,7 @@ LL | #[rustc_on_unimplemented(on="x", message="y")]
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error[E0232]: this attribute must have a valid value
--> $DIR/bad-annotation.rs:58:40
--> $DIR/bad-annotation.rs:59:40
|
LL | #[rustc_on_unimplemented(on(desugared, on(desugared, message="x")), message="y")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here

View File

@ -4,7 +4,7 @@
#![feature(on_unimplemented)]
#[rustc_on_unimplemented( //~ ERROR `#[rustc_on_unimplemented]` requires a value
#[rustc_on_unimplemented(
message="the message"
label="the label" //~ ERROR expected one of `)` or `,`, found `label`
)]

View File

@ -6,17 +6,5 @@ LL | message="the message"
LL | label="the label" //~ ERROR expected one of `)` or `,`, found `label`
| ^^^^^ unexpected token
error[E0232]: `#[rustc_on_unimplemented]` requires a value
--> $DIR/expected-comma-found-token.rs:7:1
|
LL | / #[rustc_on_unimplemented( //~ ERROR `#[rustc_on_unimplemented]` requires a value
LL | | message="the message"
LL | | label="the label" //~ ERROR expected one of `)` or `,`, found `label`
LL | | )]
| |__^ value required here
|
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0232`.

View File

@ -2,5 +2,6 @@
fn main() {}
#![lang(foo)] //~ ERROR an inner attribute is not permitted in this context
#![lang = "foo"] //~ ERROR an inner attribute is not permitted in this context
//~| ERROR definition of an unknown language item: `foo`
fn foo() {}

View File

@ -1,10 +1,17 @@
error: an inner attribute is not permitted in this context
--> $DIR/attr.rs:5:3
|
LL | #![lang(foo)] //~ ERROR an inner attribute is not permitted in this context
LL | #![lang = "foo"] //~ ERROR an inner attribute is not permitted in this context
| ^
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
error: aborting due to previous error
error[E0522]: definition of an unknown language item: `foo`
--> $DIR/attr.rs:5:1
|
LL | #![lang = "foo"] //~ ERROR an inner attribute is not permitted in this context
| ^^^^^^^^^^^^^^^^ definition of unknown language item `foo`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0522`.

View File

@ -6,13 +6,13 @@
extern crate proc_macro;
#[proc_macro_derive]
//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)]
//~^ ERROR: attribute must be of the form
pub fn foo1(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
input
}
#[proc_macro_derive = "foo"]
//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)]
//~^ ERROR: attribute must be of the form
pub fn foo2(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
input
}

View File

@ -1,15 +1,3 @@
error: attribute must be of form: #[proc_macro_derive(TraitName)]
--> $DIR/attribute.rs:8:1
|
LL | #[proc_macro_derive]
| ^^^^^^^^^^^^^^^^^^^^
error: attribute must be of form: #[proc_macro_derive(TraitName)]
--> $DIR/attribute.rs:14:1
|
LL | #[proc_macro_derive = "foo"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: must only be one word
--> $DIR/attribute.rs:21:5
|
@ -46,5 +34,17 @@ error: attribute must have either one or two arguments
LL | #[proc_macro_derive(l, attributes(m), n)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: attribute must be of the form `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]`
--> $DIR/attribute.rs:8:1
|
LL | #[proc_macro_derive]
| ^^^^^^^^^^^^^^^^^^^^
error: attribute must be of the form `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]`
--> $DIR/attribute.rs:14:1
|
LL | #[proc_macro_derive = "foo"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors

View File

@ -7,20 +7,20 @@ extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro = "test"] //~ ERROR: does not take any arguments
#[proc_macro = "test"] //~ ERROR attribute must be of the form
pub fn a(a: TokenStream) -> TokenStream { a }
#[proc_macro()] //~ ERROR: does not take any arguments
#[proc_macro()] //~ ERROR attribute must be of the form
pub fn c(a: TokenStream) -> TokenStream { a }
#[proc_macro(x)] //~ ERROR: does not take any arguments
#[proc_macro(x)] //~ ERROR attribute must be of the form
pub fn d(a: TokenStream) -> TokenStream { a }
#[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments
#[proc_macro_attribute = "test"] //~ ERROR attribute must be of the form
pub fn e(_: TokenStream, a: TokenStream) -> TokenStream { a }
#[proc_macro_attribute()] //~ ERROR: does not take any arguments
#[proc_macro_attribute()] //~ ERROR attribute must be of the form
pub fn g(_: TokenStream, a: TokenStream) -> TokenStream { a }
#[proc_macro_attribute(x)] //~ ERROR: does not take any arguments
#[proc_macro_attribute(x)] //~ ERROR attribute must be of the form
pub fn h(_: TokenStream, a: TokenStream) -> TokenStream { a }

View File

@ -1,37 +1,37 @@
error: `#[proc_macro]` attribute does not take any arguments
error: attribute must be of the form `#[proc_macro]`
--> $DIR/invalid-attributes.rs:10:1
|
LL | #[proc_macro = "test"] //~ ERROR: does not take any arguments
LL | #[proc_macro = "test"] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro]` attribute does not take any arguments
error: attribute must be of the form `#[proc_macro]`
--> $DIR/invalid-attributes.rs:13:1
|
LL | #[proc_macro()] //~ ERROR: does not take any arguments
LL | #[proc_macro()] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^
error: `#[proc_macro]` attribute does not take any arguments
error: attribute must be of the form `#[proc_macro]`
--> $DIR/invalid-attributes.rs:16:1
|
LL | #[proc_macro(x)] //~ ERROR: does not take any arguments
LL | #[proc_macro(x)] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
error: attribute must be of the form `#[proc_macro_attribute]`
--> $DIR/invalid-attributes.rs:19:1
|
LL | #[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments
LL | #[proc_macro_attribute = "test"] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
error: attribute must be of the form `#[proc_macro_attribute]`
--> $DIR/invalid-attributes.rs:22:1
|
LL | #[proc_macro_attribute()] //~ ERROR: does not take any arguments
LL | #[proc_macro_attribute()] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
error: attribute must be of the form `#[proc_macro_attribute]`
--> $DIR/invalid-attributes.rs:25:1
|
LL | #[proc_macro_attribute(x)] //~ ERROR: does not take any arguments
LL | #[proc_macro_attribute(x)] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors

View File

@ -1,15 +1,13 @@
// compile-pass
#[repr]
//^ WARN `repr` attribute must have a hint
//~^ ERROR attribute must be of the form
struct _A {}
#[repr = "B"]
//^ WARN `repr` attribute isn't configurable with a literal
//~^ ERROR attribute must be of the form
struct _B {}
#[repr = "C"]
//^ WARN `repr` attribute isn't configurable with a literal
//~^ ERROR attribute must be of the form
struct _C {}
#[repr(C)]

View File

@ -1,25 +1,20 @@
warning: `repr` attribute must have a hint
--> $DIR/repr.rs:3:1
error: attribute must be of the form `#[repr(C, packed, ...)]`
--> $DIR/repr.rs:1:1
|
LL | #[repr]
| ^^^^^^^ needs a hint
|
= note: #[warn(bad_repr)] on by default
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
| ^^^^^^^
warning: `repr` attribute isn't configurable with a literal
--> $DIR/repr.rs:7:1
error: attribute must be of the form `#[repr(C, packed, ...)]`
--> $DIR/repr.rs:5:1
|
LL | #[repr = "B"]
| ^^^^^^^^^^^^^ needs a hint
|
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
| ^^^^^^^^^^^^^
warning: `repr` attribute isn't configurable with a literal
--> $DIR/repr.rs:11:1
error: attribute must be of the form `#[repr(C, packed, ...)]`
--> $DIR/repr.rs:9:1
|
LL | #[repr = "C"]
| ^^^^^^^^^^^^^ help: give `repr` a hint: `#[repr(C)]`
| ^^^^^^^^^^^^^
error: aborting due to 3 previous errors

View File

@ -1,7 +1,7 @@
#![feature(non_exhaustive)]
#[non_exhaustive(anything)]
//~^ ERROR attribute should be empty [E0702]
//~^ ERROR attribute must be of the form
struct Foo;
#[non_exhaustive]

View File

@ -1,11 +1,8 @@
error[E0702]: attribute should be empty
error: attribute must be of the form `#[non_exhaustive]`
--> $DIR/invalid-attribute.rs:3:1
|
LL | #[non_exhaustive(anything)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | //~^ ERROR attribute should be empty [E0702]
LL | struct Foo;
| ----------- not empty
error[E0701]: attribute can only be applied to a struct or enum
--> $DIR/invalid-attribute.rs:7:1
@ -30,5 +27,4 @@ LL | | }
error: aborting due to 3 previous errors
Some errors occurred: E0701, E0702.
For more information about an error, try `rustc --explain E0701`.
For more information about this error, try `rustc --explain E0701`.

View File

@ -1,6 +1,6 @@
// compile-flags:-Zforce-unstable-if-unmarked
#[unstable] //~ ERROR: stability attributes may not be used
#[stable] //~ ERROR: stability attributes may not be used
#[rustc_deprecated] //~ ERROR: stability attributes may not be used
#[unstable()] //~ ERROR: stability attributes may not be used
#[stable()] //~ ERROR: stability attributes may not be used
#[rustc_deprecated()] //~ ERROR: stability attributes may not be used
fn main() { }

View File

@ -1,20 +1,20 @@
error: stability attributes may not be used outside of the standard library
--> $DIR/stability-attribute-non-staged-force-unstable.rs:3:1
|
LL | #[unstable] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^
LL | #[unstable()] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/stability-attribute-non-staged-force-unstable.rs:4:1
|
LL | #[stable] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^
LL | #[stable()] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/stability-attribute-non-staged-force-unstable.rs:5:1
|
LL | #[rustc_deprecated] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^^^^^^^^^
LL | #[rustc_deprecated()] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors

View File

@ -1,4 +1,4 @@
#[unstable] //~ ERROR: stability attributes may not be used
#[stable] //~ ERROR: stability attributes may not be used
#[rustc_deprecated] //~ ERROR: stability attributes may not be used
#[unstable()] //~ ERROR: stability attributes may not be used
#[stable()] //~ ERROR: stability attributes may not be used
#[rustc_deprecated()] //~ ERROR: stability attributes may not be used
fn main() { }

View File

@ -1,20 +1,20 @@
error: stability attributes may not be used outside of the standard library
--> $DIR/stability-attribute-non-staged.rs:1:1
|
LL | #[unstable] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^
LL | #[unstable()] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/stability-attribute-non-staged.rs:2:1
|
LL | #[stable] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^
LL | #[stable()] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^
error: stability attributes may not be used outside of the standard library
--> $DIR/stability-attribute-non-staged.rs:3:1
|
LL | #[rustc_deprecated] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^^^^^^^^^
LL | #[rustc_deprecated()] //~ ERROR: stability attributes may not be used
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors

View File

@ -0,0 +1,29 @@
// Various checks that stability attributes are used correctly, per RFC 507
#![feature(staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]
mod bogus_attribute_types_2 {
#[unstable] //~ ERROR attribute must be of the form
fn f1() { }
#[unstable = "b"] //~ ERROR attribute must be of the form
fn f2() { }
#[stable] //~ ERROR attribute must be of the form
fn f3() { }
#[stable = "a"] //~ ERROR attribute must be of the form
fn f4() { }
#[stable(feature = "a", since = "b")]
#[rustc_deprecated] //~ ERROR attribute must be of the form
fn f5() { }
#[stable(feature = "a", since = "b")]
#[rustc_deprecated = "a"] //~ ERROR attribute must be of the form
fn f6() { }
}
fn main() { }

View File

@ -0,0 +1,38 @@
error: attribute must be of the form `#[unstable(feature = "name", reason = "...", issue = "N")]`
--> $DIR/stability-attribute-sanity-4.rs:8:5
|
LL | #[unstable] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^
error: attribute must be of the form `#[unstable(feature = "name", reason = "...", issue = "N")]`
--> $DIR/stability-attribute-sanity-4.rs:11:5
|
LL | #[unstable = "b"] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^
error: attribute must be of the form `#[stable(feature = "name", since = "version")]`
--> $DIR/stability-attribute-sanity-4.rs:14:5
|
LL | #[stable] //~ ERROR attribute must be of the form
| ^^^^^^^^^
error: attribute must be of the form `#[stable(feature = "name", since = "version")]`
--> $DIR/stability-attribute-sanity-4.rs:17:5
|
LL | #[stable = "a"] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^
error: attribute must be of the form `#[rustc_deprecated(since = "version", reason = "...")]`
--> $DIR/stability-attribute-sanity-4.rs:21:5
|
LL | #[rustc_deprecated] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^
error: attribute must be of the form `#[rustc_deprecated(since = "version", reason = "...")]`
--> $DIR/stability-attribute-sanity-4.rs:25:5
|
LL | #[rustc_deprecated = "a"] //~ ERROR attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors

View File

@ -21,28 +21,6 @@ mod bogus_attribute_types_1 {
fn f6() { }
}
mod bogus_attribute_types_2 {
#[unstable] //~ ERROR incorrect stability attribute type [E0548]
fn f1() { }
#[unstable = "b"] //~ ERROR incorrect stability attribute type [E0548]
fn f2() { }
#[stable] //~ ERROR incorrect stability attribute type [E0548]
fn f3() { }
#[stable = "a"] //~ ERROR incorrect stability attribute type [E0548]
fn f4() { }
#[stable(feature = "a", since = "b")]
#[rustc_deprecated] //~ ERROR incorrect stability attribute type [E0548]
fn f5() { }
#[stable(feature = "a", since = "b")]
#[rustc_deprecated = "a"] //~ ERROR incorrect stability attribute type [E0548]
fn f6() { }
}
mod missing_feature_names {
#[unstable(issue = "0")] //~ ERROR missing 'feature' [E0546]
fn f1() { }

Some files were not shown because too many files have changed in this diff Show More