Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement basic input validation for built-in attributes #57321

Merged
merged 2 commits into from
Jan 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 2 additions & 35 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 0 additions & 15 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
@@ -137,15 +137,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.
@@ -160,12 +151,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.
13 changes: 7 additions & 6 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
@@ -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,
)
}
2 changes: 0 additions & 2 deletions src/librustc/lint/levels.rs
Original file line number Diff line number Diff line change
@@ -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;
};

3 changes: 2 additions & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
}
}

13 changes: 3 additions & 10 deletions src/librustc/middle/recursion_limit.rs
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 1 addition & 4 deletions src/librustc/traits/on_unimplemented.rs
Original file line number Diff line number Diff line change
@@ -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
26 changes: 10 additions & 16 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
@@ -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 {
@@ -1526,13 +1526,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
81 changes: 4 additions & 77 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
@@ -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};
@@ -682,86 +683,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 {
@@ -780,7 +707,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,
11 changes: 9 additions & 2 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
@@ -113,7 +114,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
UnusedImportBraces,
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");
}
4 changes: 2 additions & 2 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
@@ -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
5 changes: 1 addition & 4 deletions src/librustc_plugin/load.rs
Original file line number Diff line number Diff line change
@@ -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 {
15 changes: 1 addition & 14 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
@@ -2136,12 +2136,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 {
@@ -2339,14 +2334,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 {
24 changes: 1 addition & 23 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -3785,29 +3785,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.
@@ -4896,6 +4873,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`,
3 changes: 0 additions & 3 deletions src/libsyntax/attr/builtin.rs
Original file line number Diff line number Diff line change
@@ -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
}
}

43 changes: 24 additions & 19 deletions src/libsyntax/attr/mod.rs
Original file line number Diff line number Diff line change
@@ -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),
9 changes: 3 additions & 6 deletions src/libsyntax/config.rs
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/libsyntax/diagnostic_list.rs
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions src/libsyntax/early_buffered_lints.rs
Original file line number Diff line number Diff line change
@@ -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`.
5 changes: 5 additions & 0 deletions src/libsyntax/ext/derive.rs
Original file line number Diff line number Diff line change
@@ -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)) {
385 changes: 242 additions & 143 deletions src/libsyntax/feature_gate.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
9 changes: 3 additions & 6 deletions src/libsyntax/test.rs
Original file line number Diff line number Diff line change
@@ -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()
})
}
27 changes: 5 additions & 22 deletions src/libsyntax_ext/proc_macro_decls.rs
Original file line number Diff line number Diff line change
@@ -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);
16 changes: 3 additions & 13 deletions src/libsyntax_ext/test.rs
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion src/libterm/terminfo/searcher.rs
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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
7 changes: 1 addition & 6 deletions src/test/ui/derives/deriving-meta-empty-trait-list.rs
Original file line number Diff line number Diff line change
@@ -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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw... I tried to look for the reason why this happens instead of unused_attributes but got lost... (cc #54651).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hardcoded warning in libsyntax/ext/derive.rs.
derive is removed during expansion currently (

let item = self.fully_configure(item)
.map_attrs(|mut attrs| { attrs.retain(|a| a.path != "derive"); attrs });
) so it doesn't survive until unused attribute checking, IIRC.

Expansion should degrade #[derive(Macro1, Macro2, ...)] into #[derive()] instead with derive attribute itself marked as used when it applies a macro.

struct Bar;
8 changes: 1 addition & 7 deletions src/test/ui/derives/deriving-meta-empty-trait-list.stderr
Original file line number Diff line number Diff line change
@@ -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`
| ^^^^^^^^^^^
8 changes: 0 additions & 8 deletions src/test/ui/error-codes/E0232.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/error-codes/E0232.stderr

This file was deleted.

3 changes: 0 additions & 3 deletions src/test/ui/error-codes/E0296.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/error-codes/E0296.stderr

This file was deleted.

6 changes: 0 additions & 6 deletions src/test/ui/error-codes/E0558.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/error-codes/E0558.stderr

This file was deleted.

331 changes: 145 additions & 186 deletions src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs

Large diffs are not rendered by default.

879 changes: 376 additions & 503 deletions src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions src/test/ui/feature-gate/issue-43106-gating-of-deprecated.rs
Original file line number Diff line number Diff line change
@@ -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() {}
14 changes: 8 additions & 6 deletions src/test/ui/feature-gate/issue-43106-gating-of-inline.rs
Original file line number Diff line number Diff line change
@@ -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
}

38 changes: 24 additions & 14 deletions src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr
Original file line number Diff line number Diff line change
@@ -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

16 changes: 9 additions & 7 deletions src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs
Original file line number Diff line number Diff line change
@@ -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] fn f() { }

#[macro_use = "2700"] type T = S;
#[macro_use] type T = S;

#[macro_use = "2700"] impl S { }
#[macro_use] impl S { }
}

fn main() { }
24 changes: 15 additions & 9 deletions src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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
}

Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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
}

Original file line number Diff line number Diff line change
@@ -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

14 changes: 7 additions & 7 deletions src/test/ui/feature-gate/issue-43106-gating-of-stable.rs
Original file line number Diff line number Diff line change
@@ -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
}

28 changes: 14 additions & 14 deletions src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr
Original file line number Diff line number Diff line change
@@ -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

14 changes: 7 additions & 7 deletions src/test/ui/feature-gate/issue-43106-gating-of-unstable.rs
Original file line number Diff line number Diff line change
@@ -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
}

28 changes: 14 additions & 14 deletions src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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();
}

Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions src/test/ui/gated-bad-feature.rs
Original file line number Diff line number Diff line change
@@ -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

24 changes: 12 additions & 12 deletions src/test/ui/gated-bad-feature.stderr
Original file line number Diff line number Diff line change
@@ -10,25 +10,25 @@ error[E0556]: malformed feature, expected just one word
LL | foo = "baz"
| ^^^^^^^^^^^

error[E0555]: malformed feature attribute, expected #![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: malformed feature
LL | #![feature] //~ ERROR: attribute must be of the form
| ^^^^^^^^^^^

error[E0555]: malformed feature attribute, expected #![feature(...)]
error: attribute must be of the form `#[feature(name1, name1, ...)]`
--> $DIR/gated-bad-feature.rs:10:1
|
LL | #![feature = "foo"] //~ ERROR: malformed feature
LL | #![feature = "foo"] //~ ERROR: attribute must be of the form
| ^^^^^^^^^^^^^^^^^^^

error[E0557]: feature has been removed
--> $DIR/gated-bad-feature.rs:12:12
|
LL | #![feature(test_removed_feature)] //~ ERROR: feature has been removed
| ^^^^^^^^^^^^^^^^^^^^

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`.
2 changes: 1 addition & 1 deletion src/test/ui/invalid_crate_type_syntax.rs
Original file line number Diff line number Diff line change
@@ -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() {}

6 changes: 2 additions & 4 deletions src/test/ui/invalid_crate_type_syntax.stderr
Original file line number Diff line number Diff line change
@@ -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

5 changes: 2 additions & 3 deletions src/test/ui/issues/issue-43988.rs
Original file line number Diff line number Diff line change
@@ -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
}
23 changes: 8 additions & 15 deletions src/test/ui/issues/issue-43988.stderr
Original file line number Diff line number Diff line change
@@ -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,20 +53,20 @@ 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)]
| ^^^^^^^^^^^^^^
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`.
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-malformed.rs
Original file line number Diff line number Diff line change
@@ -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() { }
12 changes: 6 additions & 6 deletions src/test/ui/lint/lint-malformed.stderr
Original file line number Diff line number Diff line change
@@ -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`.
4 changes: 4 additions & 0 deletions src/test/ui/macros/meta-item-absolute-path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[derive(::Absolute)] //~ ERROR failed to resolve
struct S;

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/macros/meta-item-absolute-path.stderr
Original file line number Diff line number Diff line change
@@ -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`.
2 changes: 1 addition & 1 deletion src/test/ui/malformed/malformed-derive-entry.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ struct Test2;
struct Test3;

#[derive]
//~^ WARNING empty trait list
//~^ ERROR attribute must be of the form
struct Test4;

fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/malformed/malformed-derive-entry.stderr
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion src/test/ui/malformed/malformed-plugin-1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(plugin)]
#![plugin] //~ ERROR malformed plugin attribute
#![plugin] //~ ERROR attribute must be of the form

fn main() {}
5 changes: 2 additions & 3 deletions src/test/ui/malformed/malformed-plugin-1.stderr
Original file line number Diff line number Diff line change
@@ -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`.
2 changes: 1 addition & 1 deletion src/test/ui/malformed/malformed-plugin-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(plugin)]
#![plugin="bleh"] //~ ERROR malformed plugin attribute
#![plugin="bleh"] //~ ERROR attribute must be of the form

fn main() {}
5 changes: 2 additions & 3 deletions src/test/ui/malformed/malformed-plugin-2.stderr
Original file line number Diff line number Diff line change
@@ -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`.
8 changes: 8 additions & 0 deletions src/test/ui/malformed/malformed-regressions.rs
Original file line number Diff line number Diff line change
@@ -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() {}
48 changes: 48 additions & 0 deletions src/test/ui/malformed/malformed-regressions.stderr
Original file line number Diff line number Diff line change
@@ -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>

13 changes: 13 additions & 0 deletions src/test/ui/malformed/malformed-special-attrs.rs
Original file line number Diff line number Diff line change
@@ -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() {}
25 changes: 25 additions & 0 deletions src/test/ui/malformed/malformed-special-attrs.stderr
Original file line number Diff line number Diff line change
@@ -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

6 changes: 3 additions & 3 deletions src/test/ui/marker_trait_attr/marker-attribute-with-values.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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

1 change: 0 additions & 1 deletion src/test/ui/nll/user-annotations/normalization.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
// after normalization.

#![feature(nll)]
#![ignore(unused)]

trait Foo { type Out; }
impl Foo for () { type Out = &'static u32; }
2 changes: 1 addition & 1 deletion src/test/ui/nll/user-annotations/normalization.stderr
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/test/ui/no_crate_type.rs
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions src/test/ui/no_crate_type.stderr
Original file line number Diff line number Diff line change
@@ -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

3 changes: 2 additions & 1 deletion src/test/ui/on-unimplemented/bad-annotation.rs
Original file line number Diff line number Diff line change
@@ -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
{}

26 changes: 12 additions & 14 deletions src/test/ui/on-unimplemented/bad-annotation.stderr
Original file line number Diff line number Diff line change
@@ -1,71 +1,69 @@
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
|
= 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
|
= 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
|
= 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
|
= 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
|
= 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
2 changes: 1 addition & 1 deletion src/test/ui/on-unimplemented/expected-comma-found-token.rs
Original file line number Diff line number Diff line change
@@ -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`
)]
14 changes: 1 addition & 13 deletions src/test/ui/on-unimplemented/expected-comma-found-token.stderr
Original file line number Diff line number Diff line change
@@ -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 2 previous errors
error: aborting due to previous error

For more information about this error, try `rustc --explain E0232`.
3 changes: 2 additions & 1 deletion src/test/ui/parser/attr.rs
Original file line number Diff line number Diff line change
@@ -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() {}
11 changes: 9 additions & 2 deletions src/test/ui/parser/attr.stderr
Original file line number Diff line number Diff line change
@@ -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`.
4 changes: 2 additions & 2 deletions src/test/ui/proc-macro/attribute.rs
Original file line number Diff line number Diff line change
@@ -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
}
24 changes: 12 additions & 12 deletions src/test/ui/proc-macro/attribute.stderr
Original file line number Diff line number Diff line change
@@ -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

12 changes: 6 additions & 6 deletions src/test/ui/proc-macro/invalid-attributes.rs
Original file line number Diff line number Diff line change
@@ -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 }
24 changes: 12 additions & 12 deletions src/test/ui/proc-macro/invalid-attributes.stderr
Original file line number Diff line number Diff line change
@@ -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
8 changes: 3 additions & 5 deletions src/test/ui/repr.rs
Original file line number Diff line number Diff line change
@@ -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)]
27 changes: 11 additions & 16 deletions src/test/ui/repr.stderr
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion src/test/ui/rfc-2008-non-exhaustive/invalid-attribute.rs
Original file line number Diff line number Diff line change
@@ -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]
8 changes: 2 additions & 6 deletions src/test/ui/rfc-2008-non-exhaustive/invalid-attribute.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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() { }
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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() { }
Original file line number Diff line number Diff line change
@@ -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

29 changes: 29 additions & 0 deletions src/test/ui/stability-attribute/stability-attribute-sanity-4.rs
Original file line number Diff line number Diff line change
@@ -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() { }
Original file line number Diff line number Diff line change
@@ -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

22 changes: 0 additions & 22 deletions src/test/ui/stability-attribute/stability-attribute-sanity.rs
Original file line number Diff line number Diff line change
@@ -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() { }
64 changes: 14 additions & 50 deletions src/test/ui/stability-attribute/stability-attribute-sanity.stderr
Original file line number Diff line number Diff line change
@@ -28,115 +28,79 @@ error[E0539]: incorrect meta item
LL | #[stable(feature(b), since = "a")] //~ ERROR incorrect meta item [E0539]
| ^^^^^^^^^^

error[E0548]: incorrect stability attribute type
--> $DIR/stability-attribute-sanity.rs:25:5
|
LL | #[unstable] //~ ERROR incorrect stability attribute type [E0548]
| ^^^^^^^^^^^

error[E0548]: incorrect stability attribute type
--> $DIR/stability-attribute-sanity.rs:28:5
|
LL | #[unstable = "b"] //~ ERROR incorrect stability attribute type [E0548]
| ^^^^^^^^^^^^^^^^^

error[E0548]: incorrect stability attribute type
--> $DIR/stability-attribute-sanity.rs:31:5
|
LL | #[stable] //~ ERROR incorrect stability attribute type [E0548]
| ^^^^^^^^^

error[E0548]: incorrect stability attribute type
--> $DIR/stability-attribute-sanity.rs:34:5
|
LL | #[stable = "a"] //~ ERROR incorrect stability attribute type [E0548]
| ^^^^^^^^^^^^^^^

error[E0548]: incorrect stability attribute type
--> $DIR/stability-attribute-sanity.rs:38:5
|
LL | #[rustc_deprecated] //~ ERROR incorrect stability attribute type [E0548]
| ^^^^^^^^^^^^^^^^^^^

error[E0548]: incorrect stability attribute type
--> $DIR/stability-attribute-sanity.rs:42:5
|
LL | #[rustc_deprecated = "a"] //~ ERROR incorrect stability attribute type [E0548]
| ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0546]: missing 'feature'
--> $DIR/stability-attribute-sanity.rs:47:5
--> $DIR/stability-attribute-sanity.rs:25:5
|
LL | #[unstable(issue = "0")] //~ ERROR missing 'feature' [E0546]
| ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0547]: missing 'issue'
--> $DIR/stability-attribute-sanity.rs:50:5
--> $DIR/stability-attribute-sanity.rs:28:5
|
LL | #[unstable(feature = "b")] //~ ERROR missing 'issue' [E0547]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0546]: missing 'feature'
--> $DIR/stability-attribute-sanity.rs:53:5
--> $DIR/stability-attribute-sanity.rs:31:5
|
LL | #[stable(since = "a")] //~ ERROR missing 'feature' [E0546]
| ^^^^^^^^^^^^^^^^^^^^^^

error[E0542]: missing 'since'
--> $DIR/stability-attribute-sanity.rs:58:5
--> $DIR/stability-attribute-sanity.rs:36:5
|
LL | #[stable(feature = "a")] //~ ERROR missing 'since' [E0542]
| ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0542]: missing 'since'
--> $DIR/stability-attribute-sanity.rs:62:5
--> $DIR/stability-attribute-sanity.rs:40:5
|
LL | #[rustc_deprecated(reason = "a")] //~ ERROR missing 'since' [E0542]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0544]: multiple stability levels
--> $DIR/stability-attribute-sanity.rs:67:1
--> $DIR/stability-attribute-sanity.rs:45:1
|
LL | #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0544]: multiple stability levels
--> $DIR/stability-attribute-sanity.rs:71:1
--> $DIR/stability-attribute-sanity.rs:49:1
|
LL | #[unstable(feature = "b", issue = "0")] //~ ERROR multiple stability levels [E0544]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0544]: multiple stability levels
--> $DIR/stability-attribute-sanity.rs:75:1
--> $DIR/stability-attribute-sanity.rs:53:1
|
LL | #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0540]: multiple rustc_deprecated attributes
--> $DIR/stability-attribute-sanity.rs:83:1
--> $DIR/stability-attribute-sanity.rs:61:1
|
LL | pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0553]: multiple rustc_const_unstable attributes
--> $DIR/stability-attribute-sanity.rs:83:1
--> $DIR/stability-attribute-sanity.rs:61:1
|
LL | pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Invalid stability or deprecation version found
--> $DIR/stability-attribute-sanity.rs:83:1
--> $DIR/stability-attribute-sanity.rs:61:1
|
LL | pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0549]: rustc_deprecated attribute must be paired with either stable or unstable attribute
--> $DIR/stability-attribute-sanity.rs:88:1
--> $DIR/stability-attribute-sanity.rs:66:1
|
LL | fn deprecated_without_unstable_or_stable() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 23 previous errors
error: aborting due to 17 previous errors

Some errors occurred: E0539, E0540, E0541, E0542, E0544, E0546, E0547, E0548, E0549...
Some errors occurred: E0539, E0540, E0541, E0542, E0544, E0546, E0547, E0549, E0553.
For more information about an error, try `rustc --explain E0539`.
26 changes: 14 additions & 12 deletions src/test/ui/suffixed-literal-meta.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#[path = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
#[path = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
#![feature(custom_attribute)]

#[my_attr = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
#[my_attr = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
fn main() { }
72 changes: 36 additions & 36 deletions src/test/ui/suffixed-literal-meta.stderr
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:1:10
--> $DIR/suffixed-literal-meta.rs:3:13
|
LL | #[path = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
LL | #[my_attr = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:2:10
--> $DIR/suffixed-literal-meta.rs:4:13
|
LL | #[path = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^
LL | #[my_attr = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:3:10
--> $DIR/suffixed-literal-meta.rs:5:13
|
LL | #[path = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
LL | #[my_attr = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:4:10
--> $DIR/suffixed-literal-meta.rs:6:13
|
LL | #[path = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
LL | #[my_attr = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:5:10
--> $DIR/suffixed-literal-meta.rs:7:13
|
LL | #[path = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
LL | #[my_attr = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:6:10
--> $DIR/suffixed-literal-meta.rs:8:13
|
LL | #[path = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
LL | #[my_attr = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:7:10
--> $DIR/suffixed-literal-meta.rs:9:13
|
LL | #[path = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^
LL | #[my_attr = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:8:10
--> $DIR/suffixed-literal-meta.rs:10:13
|
LL | #[path = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
LL | #[my_attr = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:9:10
--> $DIR/suffixed-literal-meta.rs:11:13
|
LL | #[path = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
LL | #[my_attr = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:10:10
--> $DIR/suffixed-literal-meta.rs:12:13
|
LL | #[path = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
LL | #[my_attr = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:11:10
--> $DIR/suffixed-literal-meta.rs:13:13
|
LL | #[path = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
LL | #[my_attr = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:12:10
--> $DIR/suffixed-literal-meta.rs:14:13
|
LL | #[path = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
LL | #[my_attr = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
| ^^^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

2 changes: 1 addition & 1 deletion src/test/ui/target-feature-wrong.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: #[target_feature] attribute must be of the form #[target_feature(..)]
error: attribute must be of the form `#[target_feature(enable = "name")]`
--> $DIR/target-feature-wrong.rs:16:1
|
LL | #[target_feature = "+sse2"]
3 changes: 1 addition & 2 deletions src/test/ui/test-should-panic-attr.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// run-pass
// compile-pass
// compile-flags: --test

#[test]
#[should_panic = "foo"]
//~^ WARN: attribute must be of the form:
fn test1() {
panic!();
}
16 changes: 4 additions & 12 deletions src/test/ui/test-should-panic-attr.stderr
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
warning: attribute must be of the form: `#[should_panic]` or `#[should_panic(expected = "error message")]`
--> $DIR/test-should-panic-attr.rs:5:1
|
LL | #[should_panic = "foo"]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.

warning: argument must be of the form: `expected = "error message"`
--> $DIR/test-should-panic-attr.rs:12:1
--> $DIR/test-should-panic-attr.rs:11:1
|
LL | #[should_panic(expected)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.

warning: argument must be of the form: `expected = "error message"`
--> $DIR/test-should-panic-attr.rs:19:1
--> $DIR/test-should-panic-attr.rs:18:1
|
LL | #[should_panic(expect)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.

warning: argument must be of the form: `expected = "error message"`
--> $DIR/test-should-panic-attr.rs:26:1
--> $DIR/test-should-panic-attr.rs:25:1
|
LL | #[should_panic(expected(foo, bar))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.

warning: argument must be of the form: `expected = "error message"`
--> $DIR/test-should-panic-attr.rs:33:1
--> $DIR/test-should-panic-attr.rs:32:1
|
LL | #[should_panic(expected = "foo", bar)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^