2019-06-08 08:36:43 +00:00
|
|
|
#![feature(rustc_attrs)]
|
2015-11-24 13:56:20 +00:00
|
|
|
|
|
|
|
macro_rules! stmt_mac {
|
|
|
|
() => {
|
|
|
|
fn b() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
fn a() {}
|
|
|
|
|
2019-06-08 08:36:43 +00:00
|
|
|
// Bug: built-in attrs like `rustc_dummy` are not gated on blocks, but other attrs are.
|
|
|
|
#[rustfmt::skip] //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
5;
|
|
|
|
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
stmt_mac!();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that cfg works right
|
|
|
|
|
|
|
|
#[cfg(unset)]
|
|
|
|
fn c() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
5;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(unset))]
|
|
|
|
fn j() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
5;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg_attr(not(unset), cfg(unset))]
|
|
|
|
fn d() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
8;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg_attr(not(unset), cfg(not(unset)))]
|
|
|
|
fn i() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
8;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check that macro expansion and cfg works right
|
|
|
|
|
|
|
|
macro_rules! item_mac {
|
|
|
|
($e:ident) => {
|
|
|
|
fn $e() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
42;
|
|
|
|
|
|
|
|
#[cfg(unset)]
|
|
|
|
fn f() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
5;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(unset))]
|
|
|
|
fn k() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
5;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg_attr(not(unset), cfg(unset))]
|
|
|
|
fn g() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
8;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg_attr(not(unset), cfg(not(unset)))]
|
|
|
|
fn h() {
|
2019-06-08 08:36:43 +00:00
|
|
|
#[rustc_dummy]
|
2015-11-24 13:56:20 +00:00
|
|
|
8;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item_mac!(e);
|
|
|
|
|
|
|
|
// check that the gate visitor works right:
|
|
|
|
|
2020-09-01 21:12:52 +00:00
|
|
|
extern "C" {
|
2015-11-24 13:56:20 +00:00
|
|
|
#[cfg(unset)]
|
2019-06-08 08:36:43 +00:00
|
|
|
fn x(a: [u8; #[rustc_dummy] 5]);
|
|
|
|
fn y(a: [u8; #[rustc_dummy] 5]); //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
impl Foo {
|
|
|
|
#[cfg(unset)]
|
2019-06-08 08:36:43 +00:00
|
|
|
const X: u8 = #[rustc_dummy] 5;
|
|
|
|
const Y: u8 = #[rustc_dummy] 5; //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trait Bar {
|
|
|
|
#[cfg(unset)]
|
2019-06-08 08:36:43 +00:00
|
|
|
const X: [u8; #[rustc_dummy] 5];
|
|
|
|
const Y: [u8; #[rustc_dummy] 5]; //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Joyce {
|
|
|
|
#[cfg(unset)]
|
2019-06-08 08:36:43 +00:00
|
|
|
field: [u8; #[rustc_dummy] 5],
|
|
|
|
field2: [u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Walky(
|
2019-06-08 08:36:43 +00:00
|
|
|
#[cfg(unset)] [u8; #[rustc_dummy] 5],
|
|
|
|
[u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
enum Mike {
|
|
|
|
Happy(
|
2019-06-08 08:36:43 +00:00
|
|
|
#[cfg(unset)] [u8; #[rustc_dummy] 5],
|
|
|
|
[u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
),
|
|
|
|
Angry {
|
|
|
|
#[cfg(unset)]
|
2019-06-08 08:36:43 +00:00
|
|
|
field: [u8; #[rustc_dummy] 5],
|
|
|
|
field2: [u8; #[rustc_dummy] 5] //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn pat() {
|
|
|
|
match 5 {
|
|
|
|
#[cfg(unset)]
|
2019-06-08 08:36:43 +00:00
|
|
|
5 => #[rustc_dummy] (),
|
|
|
|
6 => #[rustc_dummy] (), //~ ERROR attributes on expressions are experimental
|
2015-11-24 13:56:20 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|