Introduce `#[rustc_dummy]` attribute and use it in tests

Unlike other built-in attributes, this attribute accepts any input
This commit is contained in:
Vadim Petrochenkov 2019-06-08 11:36:43 +03:00
parent 74a6d1c821
commit ea4ad555d7
25 changed files with 458 additions and 482 deletions

View File

@ -1336,6 +1336,11 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
"internal implementation detail",
cfg_fn!(rustc_attrs))),
(sym::rustc_dummy, Normal, template!(Word /* doesn't matter*/), Gated(Stability::Unstable,
sym::rustc_attrs,
"used by the test suite",
cfg_fn!(rustc_attrs))),
// FIXME: #14408 whitelist docs since rustdoc looks at them
(
sym::doc,
@ -1962,12 +1967,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
match attr_info {
Some(&(name, _, template, _)) => self.check_builtin_attribute(
attr,
name,
template
),
None => if let Some(TokenTree::Token(token)) = attr.tokens.trees().next() {
// `rustc_dummy` doesn't have any restrictions specific to built-in attributes.
Some(&(name, _, template, _)) if name != sym::rustc_dummy =>
self.check_builtin_attribute(attr, name, template),
_ => if let Some(TokenTree::Token(token)) = attr.tokens.trees().next() {
if token == token::Eq {
// All key-value attributes are restricted to meta-item syntax.
attr.parse_meta(self.context.parse_sess).map_err(|mut err| err.emit()).ok();

View File

@ -527,6 +527,7 @@ symbols! {
rustc_diagnostic_macros,
rustc_dirty,
rustc_doc_only_macro,
rustc_dummy,
rustc_dump_env_program_clauses,
rustc_dump_program_clauses,
rustc_dump_user_substs,

View File

@ -1,15 +1,16 @@
// pp-exact
// Testing that both the inner item and next outer item are
// preserved, and that the first outer item parsed in main is not
// accidentally carried over to each inner function
#![feature(custom_attribute)]
// pp-exact
#![feature(rustc_attrs)]
fn main() {
#![inner_attr]
#[outer_attr]
#![rustc_dummy]
#[rustc_dummy]
fn f() { }
#[outer_attr]
#[rustc_dummy]
fn g() { }
}

View File

@ -1,13 +1,14 @@
// pp-exact
// Tests literals in attributes.
#![feature(custom_attribute)]
// pp-exact
#![feature(rustc_attrs)]
fn main() {
#![hello("hi", 1, 2, 1.012, pi = 3.14, bye, name("John"))]
#[align = 8]
#![rustc_dummy("hi", 1, 2, 1.012, pi = 3.14, bye, name("John"))]
#[rustc_dummy = 8]
fn f() { }
#[vector(1, 2, 3)]
#[rustc_dummy(1, 2, 3)]
fn g() { }
}

View File

@ -1,20 +1,20 @@
// pp-exact
#![feature(custom_attribute)]
#![feature(box_syntax)]
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
fn main() { }
fn _0() {
#[attr]
#[rustc_dummy]
foo();
}
fn _1() {
#[attr]
#[rustc_dummy]
unsafe {
// code
}
@ -22,11 +22,11 @@ fn _1() {
fn _2() {
#[attr]
#[rustc_dummy]
{ foo(); }
{
#![attr]
#![rustc_dummy]
foo()
}
@ -34,51 +34,51 @@ fn _2() {
fn _3() {
#[attr]
#[rustc_dummy]
match () { _ => { } }
}
fn _4() {
#[attr]
#[rustc_dummy]
match () {
#![attr]
#![rustc_dummy]
_ => (),
}
let _ =
#[attr] match () {
#![attr]
() => (),
};
#[rustc_dummy] match () {
#![rustc_dummy]
() => (),
};
}
fn _5() {
#[attr]
#[rustc_dummy]
let x = 1;
let x = #[attr] 1;
let x = #[rustc_dummy] 1;
let y = ();
let z = ();
foo3(x, #[attr] y, z);
foo3(x, #[rustc_dummy] y, z);
qux(3 + #[attr] 2);
qux(3 + #[rustc_dummy] 2);
}
fn _6() {
#[attr]
[#![attr] 1, 2, 3];
#[rustc_dummy]
[#![rustc_dummy] 1, 2, 3];
let _ = #[attr] [#![attr] 1, 2, 3];
let _ = #[rustc_dummy] [#![rustc_dummy] 1, 2, 3];
#[attr]
[#![attr] 1; 4];
#[rustc_dummy]
[#![rustc_dummy] 1; 4];
let _ = #[attr] [#![attr] 1; 4];
let _ = #[rustc_dummy] [#![rustc_dummy] 1; 4];
}
struct Foo {
@ -89,45 +89,41 @@ struct Bar(());
fn _7() {
#[attr]
Foo{#![attr] data: (),};
#[rustc_dummy]
Foo{#![rustc_dummy] data: (),};
let _ = #[attr] Foo{#![attr] data: (),};
let _ = #[rustc_dummy] Foo{#![rustc_dummy] data: (),};
}
fn _8() {
#[attr]
(#![attr] );
#[rustc_dummy]
(#![rustc_dummy] );
#[attr]
(#![attr] 0);
#[rustc_dummy]
(#![rustc_dummy] 0);
#[attr]
(#![attr] 0,);
#[rustc_dummy]
(#![rustc_dummy] 0,);
#[attr]
(#![attr] 0, 1);
#[rustc_dummy]
(#![rustc_dummy] 0, 1);
}
fn _9() {
macro_rules! stmt_mac(( ) => { let _ = ( ) ; });
#[attr]
#[rustc_dummy]
stmt_mac!();
/*
// pre existing pp bug: delimiter styles gets lost:
#[attr]
#[rustc_dummy]
stmt_mac!{ };
#[attr]
#[rustc_dummy]
stmt_mac![];
#[attr]
stmt_mac!{ } // pre-existing pp bug: compiler ICEs with a None unwrap
*/
#[rustc_dummy]
stmt_mac!{ }
let _ = ();
}
@ -135,138 +131,131 @@ fn _9() {
macro_rules! expr_mac(( ) => { ( ) });
fn _10() {
let _ = #[attr] expr_mac!();
/*
// pre existing pp bug: delimiter styles gets lost:
let _ = #[attr] expr_mac![];
let _ = #[attr] expr_mac!{};
*/
let _ = #[rustc_dummy] expr_mac!();
let _ = #[rustc_dummy] expr_mac![];
let _ = #[rustc_dummy] expr_mac!{ };
}
fn _11() {
let _ = #[attr] box 0;
let _: [(); 0] = #[attr] [#![attr] ];
let _ = #[attr] [#![attr] 0, 0];
let _ = #[attr] [#![attr] 0; 0];
let _ = #[attr] foo();
let _ = #[attr] 1i32.clone();
let _ = #[attr] (#![attr] );
let _ = #[attr] (#![attr] 0);
let _ = #[attr] (#![attr] 0,);
let _ = #[attr] (#![attr] 0, 0);
let _ = #[attr] 0 + #[attr] 0;
let _ = #[attr] !0;
let _ = #[attr] -0i32;
let _ = #[attr] false;
let _ = #[attr] 'c';
let _ = #[attr] 0;
let _ = #[attr] 0 as usize;
let _ = #[rustc_dummy] box 0;
let _: [(); 0] = #[rustc_dummy] [#![rustc_dummy] ];
let _ = #[rustc_dummy] [#![rustc_dummy] 0, 0];
let _ = #[rustc_dummy] [#![rustc_dummy] 0; 0];
let _ = #[rustc_dummy] foo();
let _ = #[rustc_dummy] 1i32.clone();
let _ = #[rustc_dummy] (#![rustc_dummy] );
let _ = #[rustc_dummy] (#![rustc_dummy] 0);
let _ = #[rustc_dummy] (#![rustc_dummy] 0,);
let _ = #[rustc_dummy] (#![rustc_dummy] 0, 0);
let _ = #[rustc_dummy] 0 + #[rustc_dummy] 0;
let _ = #[rustc_dummy] !0;
let _ = #[rustc_dummy] -0i32;
let _ = #[rustc_dummy] false;
let _ = #[rustc_dummy] 'c';
let _ = #[rustc_dummy] 0;
let _ = #[rustc_dummy] 0 as usize;
let _ =
#[attr] while false {
#![attr]
};
#[rustc_dummy] while false {
#![rustc_dummy]
};
let _ =
#[attr] while let None = Some(()) {
#![attr]
};
#[rustc_dummy] while let None = Some(()) {
#![rustc_dummy]
};
let _ =
#[attr] for _ in 0..0 {
#![attr]
};
#[rustc_dummy] for _ in 0..0 {
#![rustc_dummy]
};
// FIXME: pp bug, two spaces after the loop
let _ =
#[attr] loop {
#![attr]
};
#[rustc_dummy] loop {
#![rustc_dummy]
};
let _ =
#[attr] match false {
#![attr]
_ => (),
};
let _ = #[attr] || #[attr] ();
let _ = #[attr] move || #[attr] ();
#[rustc_dummy] match false {
#![rustc_dummy]
_ => (),
};
let _ = #[rustc_dummy] || #[rustc_dummy] ();
let _ = #[rustc_dummy] move || #[rustc_dummy] ();
let _ =
#[attr] ||
{
#![attr]
#[attr]
()
};
#[rustc_dummy] ||
{
#![rustc_dummy]
#[rustc_dummy]
()
};
let _ =
#[attr] move ||
{
#![attr]
#[attr]
()
};
#[rustc_dummy] move ||
{
#![rustc_dummy]
#[rustc_dummy]
()
};
let _ =
#[attr] {
#![attr]
};
#[rustc_dummy] {
#![rustc_dummy]
};
let _ =
#[attr] {
#![attr]
let _ = ();
};
#[rustc_dummy] {
#![rustc_dummy]
let _ = ();
};
let _ =
#[attr] {
#![attr]
let _ = ();
()
};
#[rustc_dummy] {
#![rustc_dummy]
let _ = ();
()
};
let mut x = 0;
let _ = #[attr] x = 15;
let _ = #[attr] x += 15;
let _ = #[rustc_dummy] x = 15;
let _ = #[rustc_dummy] x += 15;
let s = Foo{data: (),};
let _ = #[attr] s.data;
let _ = (#[attr] s).data;
let _ = #[rustc_dummy] s.data;
let _ = (#[rustc_dummy] s).data;
let t = Bar(());
let _ = #[attr] t.0;
let _ = (#[attr] t).0;
let _ = #[rustc_dummy] t.0;
let _ = (#[rustc_dummy] t).0;
let v = vec!(0);
let _ = #[attr] v[0];
let _ = (#[attr] v)[0];
let _ = #[attr] 0..#[attr] 0;
let _ = #[attr] 0..;
let _ = #[attr] (0..0);
let _ = #[attr] (0..);
let _ = #[attr] (..0);
let _ = #[attr] (..);
let _: fn(&u32) -> u32 = #[attr] std::clone::Clone::clone;
let _ = #[attr] &0;
let _ = #[attr] &mut 0;
let _ = #[attr] &#[attr] 0;
let _ = #[attr] &mut #[attr] 0;
let _ = #[rustc_dummy] v[0];
let _ = (#[rustc_dummy] v)[0];
let _ = #[rustc_dummy] 0..#[rustc_dummy] 0;
let _ = #[rustc_dummy] 0..;
let _ = #[rustc_dummy] (0..0);
let _ = #[rustc_dummy] (0..);
let _ = #[rustc_dummy] (..0);
let _ = #[rustc_dummy] (..);
let _: fn(&u32) -> u32 = #[rustc_dummy] std::clone::Clone::clone;
let _ = #[rustc_dummy] &0;
let _ = #[rustc_dummy] &mut 0;
let _ = #[rustc_dummy] &#[rustc_dummy] 0;
let _ = #[rustc_dummy] &mut #[rustc_dummy] 0;
// FIXME: pp bug, extra space after keyword?
while false { let _ = #[attr] continue ; }
while true { let _ = #[attr] break ; }
|| #[attr] return;
let _ = #[attr] expr_mac!();
/* FIXME: pp bug, losing delimiter styles
let _ = #[attr] expr_mac![];
let _ = #[attr] expr_mac!{};
*/
let _ = #[attr] Foo{#![attr] data: (),};
let _ = #[attr] Foo{#![attr] ..s};
let _ = #[attr] Foo{#![attr] data: (), ..s};
let _ = #[attr] (#![attr] 0);
while false { let _ = #[rustc_dummy] continue ; }
while true { let _ = #[rustc_dummy] break ; }
|| #[rustc_dummy] return;
let _ = #[rustc_dummy] expr_mac!();
let _ = #[rustc_dummy] expr_mac![];
let _ = #[rustc_dummy] expr_mac!{ };
let _ = #[rustc_dummy] Foo{#![rustc_dummy] data: (),};
let _ = #[rustc_dummy] Foo{#![rustc_dummy] ..s};
let _ = #[rustc_dummy] Foo{#![rustc_dummy] data: (), ..s};
let _ = #[rustc_dummy] (#![rustc_dummy] 0);
}
fn _12() {
#[attr]
#[rustc_dummy]
let _ = 0;
#[attr]
#[rustc_dummy]
0;
#[attr]
#[rustc_dummy]
expr_mac!();
#[attr]
#[rustc_dummy]
{
#![attr]
#![rustc_dummy]
}
}

View File

@ -1,11 +1,10 @@
#![allow(unused_attributes)]
// pretty-expanded FIXME #23616
#![feature(custom_attribute, test)]
#![allow(unused)]
#![feature(rustc_attrs)]
#![feature(test)]
#[foo = "bar"]
#[rustc_dummy = "bar"]
extern crate test;
pub fn main() {
}
fn main() {}

View File

@ -1,13 +1,12 @@
#![allow(unused_attributes)]
// pretty-expanded FIXME #23616
#![feature(custom_attribute, test)]
#![allow(unused)]
#![feature(rustc_attrs)]
#![feature(test)]
mod m {
#[foo = "bar"]
#[rustc_dummy = "bar"]
extern crate test;
}
pub fn main() {
}
fn main() {}

View File

@ -1,14 +1,11 @@
#![allow(unused_attributes)]
#![allow(unknown_lints)]
// pretty-expanded FIXME #23616
#![allow(unused_attribute)]
#![feature(custom_attribute)]
#![allow(unused)]
#![feature(rustc_attrs)]
#[foo(bar)]
#[rustc_dummy(bar)]
mod foo {
#![feature(globs)]
}
pub fn main() {}
fn main() {}

View File

@ -1,80 +1,76 @@
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(unused_attributes)]
#![allow(dead_code)]
#![allow(unknown_lints)]
// These are attributes of the implicit crate. Really this just needs to parse
// for completeness since .rs files linked from .rc files support this
// notation to specify their module's attributes
#![feature(custom_attribute)]
#![allow(unused_attribute)]
#![attr1 = "val"]
#![attr2 = "val"]
#![attr3]
#![attr4(attr5)]
#![allow(unused)]
#![feature(rustc_attrs)]
#![rustc_dummy = "val"]
#![rustc_dummy = "val"]
#![rustc_dummy]
#![rustc_dummy(attr5)]
#![crate_id="foobar#0.1"]
// These are attributes of the following mod
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
mod test_first_item_in_file_mod {}
mod test_single_attr_outer {
#[attr = "val"]
pub static x: isize = 10;
#[rustc_dummy = "val"]
pub static X: isize = 10;
#[attr = "val"]
#[rustc_dummy = "val"]
pub fn f() { }
#[attr = "val"]
#[rustc_dummy = "val"]
pub mod mod1 {}
pub mod rustrt {
#[attr = "val"]
#[rustc_dummy = "val"]
extern {}
}
}
mod test_multi_attr_outer {
#[attr1 = "val"]
#[attr2 = "val"]
pub static x: isize = 10;
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
pub static X: isize = 10;
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
pub fn f() { }
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
pub mod mod1 {}
pub mod rustrt {
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
extern {}
}
#[attr1 = "val"]
#[attr2 = "val"]
struct t {x: isize}
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
struct T {x: isize}
}
mod test_stmt_single_attr_outer {
pub fn f() {
#[attr = "val"]
static x: isize = 10;
#[rustc_dummy = "val"]
static X: isize = 10;
#[attr = "val"]
#[rustc_dummy = "val"]
fn f() { }
#[attr = "val"]
#[rustc_dummy = "val"]
mod mod1 {
}
mod rustrt {
#[attr = "val"]
#[rustc_dummy = "val"]
extern {
}
}
@ -84,22 +80,22 @@ mod test_stmt_single_attr_outer {
mod test_stmt_multi_attr_outer {
pub fn f() {
#[attr1 = "val"]
#[attr2 = "val"]
static x: isize = 10;
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
static X: isize = 10;
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
fn f() { }
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
mod mod1 {
}
mod rustrt {
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
extern {
}
}
@ -109,16 +105,16 @@ mod test_stmt_multi_attr_outer {
mod test_attr_inner {
pub mod m {
// This is an attribute of mod m
#![attr = "val"]
#![rustc_dummy = "val"]
}
}
mod test_attr_inner_then_outer {
pub mod m {
// This is an attribute of mod m
#![attr = "val"]
#![rustc_dummy = "val"]
// This is an attribute of fn f
#[attr = "val"]
#[rustc_dummy = "val"]
fn f() { }
}
}
@ -126,11 +122,11 @@ mod test_attr_inner_then_outer {
mod test_attr_inner_then_outer_multi {
pub mod m {
// This is an attribute of mod m
#![attr1 = "val"]
#![attr2 = "val"]
#![rustc_dummy = "val"]
#![rustc_dummy = "val"]
// This is an attribute of fn f
#[attr1 = "val"]
#[attr2 = "val"]
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
fn f() { }
}
}
@ -138,25 +134,25 @@ mod test_attr_inner_then_outer_multi {
mod test_distinguish_syntax_ext {
pub fn f() {
format!("test{}", "s");
#[attr = "val"]
#[rustc_dummy = "val"]
fn g() { }
}
}
mod test_other_forms {
#[attr]
#[attr(word)]
#[attr(attr(word))]
#[attr(key1 = "val", key2 = "val", attr)]
#[rustc_dummy]
#[rustc_dummy(word)]
#[rustc_dummy(attr(word))]
#[rustc_dummy(key1 = "val", key2 = "val", attr)]
pub fn f() { }
}
mod test_foreign_items {
pub mod rustrt {
extern {
#![attr]
#![rustc_dummy]
#[attr]
#[rustc_dummy]
fn rust_get_test_int() -> u32;
}
}
@ -178,7 +174,7 @@ mod test_foreign_items {
}*/
fn test_fn_inner() {
#![inner_fn_attr]
#![rustc_dummy]
}
pub fn main() { }
fn main() {}

View File

@ -1,31 +1,28 @@
// run-pass
#![allow(unused_attributes)]
#![allow(non_camel_case_types)]
// pp-exact - Make sure we print all the attributes
// pretty-expanded FIXME #23616
#![feature(custom_attribute)]
#![allow(unused)]
#![feature(rustc_attrs)]
#[frobable]
trait frobable {
#[frob_attr]
#[rustc_dummy]
trait Frobable {
#[rustc_dummy]
fn frob(&self);
#[defrob_attr]
#[rustc_dummy]
fn defrob(&self);
}
#[int_frobable]
impl frobable for isize {
#[frob_attr1]
#[rustc_dummy]
impl Frobable for isize {
#[rustc_dummy]
fn frob(&self) {
#![frob_attr2]
#![rustc_dummy]
}
#[defrob_attr1]
#[rustc_dummy]
fn defrob(&self) {
#![defrob_attr2]
#![rustc_dummy]
}
}
pub fn main() { }
fn main() {}

View File

@ -1,21 +1,19 @@
// run-pass
#![allow(unused_attributes)]
#![allow(non_camel_case_types)]
// pp-exact - Make sure we actually print the attributes
#![feature(custom_attribute)]
struct cat {
#![allow(unused)]
#![feature(rustc_attrs)]
struct Cat {
name: String,
}
impl Drop for cat {
#[cat_dropper]
impl Drop for Cat {
#[rustc_dummy]
fn drop(&mut self) { println!("{} landed on hir feet" , self . name); }
}
#[cat_maker]
fn cat(name: String) -> cat { cat{name: name,} }
#[rustc_dummy]
fn cat(name: String) -> Cat { Cat{name: name,} }
pub fn main() { let _kitty = cat("Spotty".to_string()); }
fn main() { let _kitty = cat("Spotty".to_string()); }

View File

@ -1,15 +1,12 @@
// run-pass
#![allow(unused_attributes)]
#![allow(non_camel_case_types)]
#![allow(unused)]
#![feature(rustc_attrs)]
#![feature(custom_attribute)]
struct cat {
name: String,
struct Cat {
name: String,
}
impl Drop for cat {
#[cat_dropper]
impl Drop for Cat {
#[rustc_dummy]
/**
Actually, cats don't always land on their feet when you drop them.
*/
@ -18,16 +15,16 @@ impl Drop for cat {
}
}
#[cat_maker]
#[rustc_dummy]
/**
Maybe it should technically be a kitten_maker.
*/
fn cat(name: String) -> cat {
cat {
fn cat(name: String) -> Cat {
Cat {
name: name
}
}
pub fn main() {
let _kitty = cat("Spotty".to_string());
fn main() {
let _kitty = cat("Spotty".to_string());
}

View File

@ -1,38 +1,37 @@
#![allow(unused_attributes)]
#![allow(non_camel_case_types)]
#![allow(dead_code)]
// pp-exact - Make sure we actually print the attributes
// pretty-expanded FIXME #23616
#![feature(custom_attribute)]
#![allow(unused)]
#![allow(non_camel_case_types)]
#![feature(rustc_attrs)]
enum crew_of_enterprise_d {
#[captain]
#[rustc_dummy]
jean_luc_picard,
#[oldcommander]
#[rustc_dummy]
william_t_riker,
#[chief_medical_officer]
#[rustc_dummy]
beverly_crusher,
#[ships_councellor]
#[rustc_dummy]
deanna_troi,
#[lieutenant_oldcommander]
#[rustc_dummy]
data,
#[chief_of_security]
#[rustc_dummy]
worf,
#[chief_engineer]
#[rustc_dummy]
geordi_la_forge,
}
fn boldly_go(_crew_member: crew_of_enterprise_d, _where: String) { }
pub fn main() {
fn main() {
boldly_go(crew_of_enterprise_d::worf,
"where no one has gone before".to_string());
}

View File

@ -1,8 +1,7 @@
// compile-pass
#![allow(unused_attributes)]
// compile-flags:--cfg set1
#![cfg_attr(set1, feature(custom_attribute))]
#![cfg_attr(set1, feature(rustc_attrs))]
#![rustc_dummy]
#![foobar]
fn main() {}

View File

@ -1,4 +1,4 @@
#![feature(custom_attribute)]
#![feature(rustc_attrs)]
macro_rules! test { ($nm:ident,
#[$a:meta],
@ -12,7 +12,7 @@ test!(b,
#[cfg(not(qux))],
pub fn bar() { });
#[qux]
#[rustc_dummy]
fn main() {
a::bar();
//~^ ERROR failed to resolve: use of undeclared type or module `a`

View File

@ -1,4 +1,4 @@
#![feature(custom_attribute)]
#![feature(rustc_attrs)]
macro_rules! test { ($nm:ident,
#[$a:meta],
@ -13,7 +13,7 @@ test!(b,
pub fn bar() { });
// test1!(#[bar])
#[qux]
#[rustc_dummy]
fn main() {
a::bar(); //~ ERROR cannot find function `bar` in module `a`
b::bar();

View File

@ -1,9 +1,9 @@
#![feature(custom_attribute)]
#![feature(rustc_attrs)]
macro_rules! check {
($expr: expr) => (
#[my_attr = $expr] //~ ERROR unexpected token: `-0`
//~| ERROR unexpected token: `0 + 0`
#[rustc_dummy = $expr] //~ ERROR unexpected token: `-0`
//~| ERROR unexpected token: `0 + 0`
use main as _;
);
}

View File

@ -7,19 +7,19 @@ LL | check!(0u8);
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
error: unexpected token: `-0`
--> $DIR/malformed-interpolated.rs:5:21
--> $DIR/malformed-interpolated.rs:5:25
|
LL | #[my_attr = $expr]
| ^^^^^
LL | #[rustc_dummy = $expr]
| ^^^^^
...
LL | check!(-0); // ERROR, see above
| ----------- in this macro invocation
error: unexpected token: `0 + 0`
--> $DIR/malformed-interpolated.rs:5:21
--> $DIR/malformed-interpolated.rs:5:25
|
LL | #[my_attr = $expr]
| ^^^^^
LL | #[rustc_dummy = $expr]
| ^^^^^
...
LL | check!(0 + 0); // ERROR, see above
| -------------- in this macro invocation

View File

@ -1,4 +1,4 @@
#![feature(custom_attribute)]
#![feature(rustc_attrs)]
macro_rules! stmt_mac {
() => {
@ -7,18 +7,19 @@ macro_rules! stmt_mac {
}
fn main() {
#[attr]
#[rustc_dummy]
fn a() {}
#[attr] //~ ERROR attributes on expressions are experimental
// Bug: built-in attrs like `rustc_dummy` are not gated on blocks, but other attrs are.
#[rustfmt::skip] //~ ERROR attributes on expressions are experimental
{
}
#[attr]
#[rustc_dummy]
5;
#[attr]
#[rustc_dummy]
stmt_mac!();
}
@ -26,25 +27,25 @@ fn main() {
#[cfg(unset)]
fn c() {
#[attr]
#[rustc_dummy]
5;
}
#[cfg(not(unset))]
fn j() {
#[attr]
#[rustc_dummy]
5;
}
#[cfg_attr(not(unset), cfg(unset))]
fn d() {
#[attr]
#[rustc_dummy]
8;
}
#[cfg_attr(not(unset), cfg(not(unset)))]
fn i() {
#[attr]
#[rustc_dummy]
8;
}
@ -53,30 +54,30 @@ fn i() {
macro_rules! item_mac {
($e:ident) => {
fn $e() {
#[attr]
#[rustc_dummy]
42;
#[cfg(unset)]
fn f() {
#[attr]
#[rustc_dummy]
5;
}
#[cfg(not(unset))]
fn k() {
#[attr]
#[rustc_dummy]
5;
}
#[cfg_attr(not(unset), cfg(unset))]
fn g() {
#[attr]
#[rustc_dummy]
8;
}
#[cfg_attr(not(unset), cfg(not(unset)))]
fn h() {
#[attr]
#[rustc_dummy]
8;
}
@ -90,51 +91,51 @@ item_mac!(e);
extern {
#[cfg(unset)]
fn x(a: [u8; #[attr] 5]);
fn y(a: [u8; #[attr] 5]); //~ ERROR attributes on expressions are experimental
fn x(a: [u8; #[rustc_dummy] 5]);
fn y(a: [u8; #[rustc_dummy] 5]); //~ ERROR attributes on expressions are experimental
}
struct Foo;
impl Foo {
#[cfg(unset)]
const X: u8 = #[attr] 5;
const Y: u8 = #[attr] 5; //~ ERROR attributes on expressions are experimental
const X: u8 = #[rustc_dummy] 5;
const Y: u8 = #[rustc_dummy] 5; //~ ERROR attributes on expressions are experimental
}
trait Bar {
#[cfg(unset)]
const X: [u8; #[attr] 5];
const Y: [u8; #[attr] 5]; //~ ERROR attributes on expressions are experimental
const X: [u8; #[rustc_dummy] 5];
const Y: [u8; #[rustc_dummy] 5]; //~ ERROR attributes on expressions are experimental
}
struct Joyce {
#[cfg(unset)]
field: [u8; #[attr] 5],
field2: [u8; #[attr] 5] //~ ERROR attributes on expressions are experimental
field: [u8; #[rustc_dummy] 5],
field2: [u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
}
struct Walky(
#[cfg(unset)] [u8; #[attr] 5],
[u8; #[attr] 5] //~ ERROR attributes on expressions are experimental
#[cfg(unset)] [u8; #[rustc_dummy] 5],
[u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
);
enum Mike {
Happy(
#[cfg(unset)] [u8; #[attr] 5],
[u8; #[attr] 5] //~ ERROR attributes on expressions are experimental
#[cfg(unset)] [u8; #[rustc_dummy] 5],
[u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
),
Angry {
#[cfg(unset)]
field: [u8; #[attr] 5],
field2: [u8; #[attr] 5] //~ ERROR attributes on expressions are experimental
field: [u8; #[rustc_dummy] 5],
field2: [u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
}
}
fn pat() {
match 5 {
#[cfg(unset)]
5 => #[attr] (),
6 => #[attr] (), //~ ERROR attributes on expressions are experimental
5 => #[rustc_dummy] (),
6 => #[rustc_dummy] (), //~ ERROR attributes on expressions are experimental
_ => (),
}
}

View File

@ -1,80 +1,80 @@
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:13:5
--> $DIR/stmt_expr_attrs_no_feature.rs:14:5
|
LL | #[attr]
| ^^^^^^^
LL | #[rustfmt::skip]
| ^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:94:18
--> $DIR/stmt_expr_attrs_no_feature.rs:95:18
|
LL | fn y(a: [u8; #[attr] 5]);
| ^^^^^^^
LL | fn y(a: [u8; #[rustc_dummy] 5]);
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:101:19
--> $DIR/stmt_expr_attrs_no_feature.rs:102:19
|
LL | const Y: u8 = #[attr] 5;
| ^^^^^^^
LL | const Y: u8 = #[rustc_dummy] 5;
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:107:19
--> $DIR/stmt_expr_attrs_no_feature.rs:108:19
|
LL | const Y: [u8; #[attr] 5];
| ^^^^^^^
LL | const Y: [u8; #[rustc_dummy] 5];
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:113:18
--> $DIR/stmt_expr_attrs_no_feature.rs:114:18
|
LL | field2: [u8; #[attr] 5]
| ^^^^^^^
LL | field2: [u8; #[rustc_dummy] 5]
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:118:10
--> $DIR/stmt_expr_attrs_no_feature.rs:119:10
|
LL | [u8; #[attr] 5]
| ^^^^^^^
LL | [u8; #[rustc_dummy] 5]
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:124:14
--> $DIR/stmt_expr_attrs_no_feature.rs:125:14
|
LL | [u8; #[attr] 5]
| ^^^^^^^
LL | [u8; #[rustc_dummy] 5]
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:129:22
--> $DIR/stmt_expr_attrs_no_feature.rs:130:22
|
LL | field2: [u8; #[attr] 5]
| ^^^^^^^
LL | field2: [u8; #[rustc_dummy] 5]
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
--> $DIR/stmt_expr_attrs_no_feature.rs:137:14
--> $DIR/stmt_expr_attrs_no_feature.rs:138:14
|
LL | 6 => #[attr] (),
| ^^^^^^^
LL | 6 => #[rustc_dummy] (),
| ^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/15701
= help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable

View File

@ -1,15 +1,15 @@
#![feature(custom_attribute)]
#![feature(rustc_attrs)]
#[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() { }
#[rustc_dummy = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
#[rustc_dummy = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
fn main() {}

View File

@ -1,96 +1,96 @@
error: suffixed literals are not allowed in attributes
--> $DIR/suffixed-literal-meta.rs:3:13
--> $DIR/suffixed-literal-meta.rs:3:17
|
LL | #[my_attr = 1usize]
| ^^^^^^
LL | #[rustc_dummy = 1usize]
| ^^^^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:4:17
|
LL | #[my_attr = 1u8]
| ^^^
LL | #[rustc_dummy = 1u8]
| ^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:5:17
|
LL | #[my_attr = 1u16]
| ^^^^
LL | #[rustc_dummy = 1u16]
| ^^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:6:17
|
LL | #[my_attr = 1u32]
| ^^^^
LL | #[rustc_dummy = 1u32]
| ^^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:7:17
|
LL | #[my_attr = 1u64]
| ^^^^
LL | #[rustc_dummy = 1u64]
| ^^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:8:17
|
LL | #[my_attr = 1isize]
| ^^^^^^
LL | #[rustc_dummy = 1isize]
| ^^^^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:9:17
|
LL | #[my_attr = 1i8]
| ^^^
LL | #[rustc_dummy = 1i8]
| ^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:10:17
|
LL | #[my_attr = 1i16]
| ^^^^
LL | #[rustc_dummy = 1i16]
| ^^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:11:17
|
LL | #[my_attr = 1i32]
| ^^^^
LL | #[rustc_dummy = 1i32]
| ^^^^
|
= 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:13
--> $DIR/suffixed-literal-meta.rs:12:17
|
LL | #[my_attr = 1i64]
| ^^^^
LL | #[rustc_dummy = 1i64]
| ^^^^
|
= 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:13:13
--> $DIR/suffixed-literal-meta.rs:13:17
|
LL | #[my_attr = 1.0f32]
| ^^^^^^
LL | #[rustc_dummy = 1.0f32]
| ^^^^^^
|
= 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:14:13
--> $DIR/suffixed-literal-meta.rs:14:17
|
LL | #[my_attr = 1.0f64]
| ^^^^^^
LL | #[rustc_dummy = 1.0f64]
| ^^^^^^
|
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).

View File

@ -1,8 +1,8 @@
// compile-pass
#![feature(custom_attribute)]
#![feature(rustc_attrs)]
#[my_attr(a b c d)]
#[my_attr[a b c d]]
#[my_attr{a b c d}]
#[rustc_dummy(a b c d)]
#[rustc_dummy[a b c d]]
#[rustc_dummy{a b c d}]
fn main() {}

View File

@ -1,49 +1,48 @@
#![deny(unused_attributes)]
#![allow(dead_code, unused_imports, unused_extern_crates)]
#![feature(custom_attribute)]
#![feature(rustc_attrs)]
#![foo] //~ ERROR unused attribute
#![rustc_dummy] //~ ERROR unused attribute
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
extern crate core;
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
use std::collections;
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
extern "C" {
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
fn foo();
}
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
mod foo {
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
pub enum Foo {
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
Bar,
}
}
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
fn bar(f: foo::Foo) {
match f {
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
foo::Foo::Bar => {}
}
}
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
struct Foo {
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
a: isize
}
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
trait Baz {
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
fn blah(&self);
#[foo] //~ ERROR unused attribute
#[rustc_dummy] //~ ERROR unused attribute
fn blah2(&self) {}
}

View File

@ -1,8 +1,8 @@
error: unused attribute
--> $DIR/unused-attr.rs:7:1
--> $DIR/unused-attr.rs:6:1
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/unused-attr.rs:1:9
@ -11,88 +11,88 @@ LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:10:1
--> $DIR/unused-attr.rs:9:1
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:15:5
--> $DIR/unused-attr.rs:14:5
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:13:1
--> $DIR/unused-attr.rs:12:1
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:23:9
--> $DIR/unused-attr.rs:22:9
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:21:5
--> $DIR/unused-attr.rs:20:5
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:19:1
--> $DIR/unused-attr.rs:18:1
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:31:9
--> $DIR/unused-attr.rs:30:9
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:28:1
--> $DIR/unused-attr.rs:27:1
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:38:5
--> $DIR/unused-attr.rs:37:5
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:36:1
--> $DIR/unused-attr.rs:35:1
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:44:5
--> $DIR/unused-attr.rs:43:5
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:46:5
--> $DIR/unused-attr.rs:45:5
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:42:1
--> $DIR/unused-attr.rs:41:1
|
LL | #[foo]
| ^^^^^^
LL | #[rustc_dummy]
| ^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr.rs:5:1
--> $DIR/unused-attr.rs:4:1
|
LL | #![foo]
| ^^^^^^^
LL | #![rustc_dummy]
| ^^^^^^^^^^^^^^^
error: aborting due to 15 previous errors