2020-10-03 13:45:39 -05:00
|
|
|
//~ NOTE: not an `extern crate` item
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ NOTE: not a free function, impl method or static
|
2020-10-03 13:45:39 -05:00
|
|
|
//~^^ NOTE: not a function or closure
|
2020-06-13 23:47:42 -05:00
|
|
|
// This is testing whether various builtin attributes signals an
|
|
|
|
// error or warning when put in "weird" places.
|
|
|
|
//
|
|
|
|
// (This file sits on its own because it actually signals an error,
|
|
|
|
// which would mess up the treatment of other cases in
|
|
|
|
// issue-43106-gating-of-builtin-attrs.rs)
|
|
|
|
|
|
|
|
|
2020-09-29 14:29:42 -05:00
|
|
|
#![macro_export]
|
2020-10-03 13:45:39 -05:00
|
|
|
//~^ ERROR: `macro_export` attribute cannot be used at crate level
|
2021-04-08 08:37:38 -05:00
|
|
|
#![rustc_main] //~ ERROR: the `#[rustc_main]` attribute is used internally to specify
|
|
|
|
//~^ ERROR: `rustc_main` attribute cannot be used at crate level
|
2024-01-10 00:39:02 -06:00
|
|
|
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
2020-09-29 14:29:42 -05:00
|
|
|
#![start]
|
2020-10-03 13:45:39 -05:00
|
|
|
//~^ ERROR: `start` attribute cannot be used at crate level
|
2020-09-29 14:29:42 -05:00
|
|
|
#![repr()]
|
2020-10-03 13:45:39 -05:00
|
|
|
//~^ ERROR: `repr` attribute cannot be used at crate level
|
2020-09-29 14:29:42 -05:00
|
|
|
#![path = "3800"]
|
2020-10-03 13:45:39 -05:00
|
|
|
//~^ ERROR: `path` attribute cannot be used at crate level
|
2020-09-29 14:29:42 -05:00
|
|
|
#![automatically_derived]
|
2020-10-03 13:45:39 -05:00
|
|
|
//~^ ERROR: `automatically_derived` attribute cannot be used at crate level
|
2020-09-29 14:29:42 -05:00
|
|
|
#![no_mangle]
|
|
|
|
#![no_link]
|
|
|
|
//~^ ERROR: attribute should be applied to an `extern crate` item
|
|
|
|
#![export_name = "2200"]
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ ERROR: attribute should be applied to a free function, impl method or static
|
2020-09-29 14:29:42 -05:00
|
|
|
#![inline]
|
|
|
|
//~^ ERROR: attribute should be applied to function or closure
|
2020-06-13 23:47:42 -05:00
|
|
|
#[inline]
|
|
|
|
//~^ ERROR attribute should be applied to function or closure
|
|
|
|
mod inline {
|
|
|
|
//~^ NOTE not a function or closure
|
2023-10-17 19:24:21 -05:00
|
|
|
//~| NOTE the inner attribute doesn't annotate this module
|
|
|
|
//~| NOTE the inner attribute doesn't annotate this module
|
|
|
|
//~| NOTE the inner attribute doesn't annotate this module
|
|
|
|
//~| NOTE the inner attribute doesn't annotate this module
|
|
|
|
//~| NOTE the inner attribute doesn't annotate this module
|
|
|
|
//~| NOTE the inner attribute doesn't annotate this module
|
2020-06-13 23:47:42 -05:00
|
|
|
|
|
|
|
mod inner { #![inline] }
|
|
|
|
//~^ ERROR attribute should be applied to function or closure
|
|
|
|
//~| NOTE not a function or closure
|
|
|
|
|
|
|
|
#[inline = "2100"] fn f() { }
|
2024-04-15 13:07:22 -05:00
|
|
|
//~^ ERROR valid forms for the attribute are
|
2020-06-13 23:47:42 -05:00
|
|
|
//~| WARN this was previously accepted
|
|
|
|
//~| NOTE #[deny(ill_formed_attribute_input)]` on by default
|
|
|
|
//~| NOTE for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
|
|
|
|
|
|
|
#[inline] struct S;
|
|
|
|
//~^ ERROR attribute should be applied to function or closure
|
|
|
|
//~| NOTE not a function or closure
|
|
|
|
|
|
|
|
#[inline] type T = S;
|
|
|
|
//~^ ERROR attribute should be applied to function or closure
|
|
|
|
//~| NOTE not a function or closure
|
|
|
|
|
|
|
|
#[inline] impl S { }
|
|
|
|
//~^ ERROR attribute should be applied to function or closure
|
|
|
|
//~| NOTE not a function or closure
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_link]
|
|
|
|
//~^ ERROR attribute should be applied to an `extern crate` item
|
|
|
|
mod no_link {
|
|
|
|
//~^ NOTE not an `extern crate` item
|
|
|
|
|
|
|
|
mod inner { #![no_link] }
|
|
|
|
//~^ ERROR attribute should be applied to an `extern crate` item
|
|
|
|
//~| NOTE not an `extern crate` item
|
|
|
|
|
|
|
|
#[no_link] fn f() { }
|
|
|
|
//~^ ERROR attribute should be applied to an `extern crate` item
|
|
|
|
//~| NOTE not an `extern crate` item
|
|
|
|
|
|
|
|
#[no_link] struct S;
|
|
|
|
//~^ ERROR attribute should be applied to an `extern crate` item
|
|
|
|
//~| NOTE not an `extern crate` item
|
|
|
|
|
|
|
|
#[no_link]type T = S;
|
|
|
|
//~^ ERROR attribute should be applied to an `extern crate` item
|
|
|
|
//~| NOTE not an `extern crate` item
|
|
|
|
|
|
|
|
#[no_link] impl S { }
|
|
|
|
//~^ ERROR attribute should be applied to an `extern crate` item
|
|
|
|
//~| NOTE not an `extern crate` item
|
|
|
|
}
|
|
|
|
|
|
|
|
#[export_name = "2200"]
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ ERROR attribute should be applied to a free function, impl method or static
|
2020-06-13 23:47:42 -05:00
|
|
|
mod export_name {
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ NOTE not a free function, impl method or static
|
2020-06-13 23:47:42 -05:00
|
|
|
|
|
|
|
mod inner { #![export_name="2200"] }
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ ERROR attribute should be applied to a free function, impl method or static
|
|
|
|
//~| NOTE not a free function, impl method or static
|
2020-06-13 23:47:42 -05:00
|
|
|
|
|
|
|
#[export_name = "2200"] fn f() { }
|
|
|
|
|
|
|
|
#[export_name = "2200"] struct S;
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ ERROR attribute should be applied to a free function, impl method or static
|
|
|
|
//~| NOTE not a free function, impl method or static
|
2020-06-13 23:47:42 -05:00
|
|
|
|
|
|
|
#[export_name = "2200"] type T = S;
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ ERROR attribute should be applied to a free function, impl method or static
|
|
|
|
//~| NOTE not a free function, impl method or static
|
2020-06-13 23:47:42 -05:00
|
|
|
|
|
|
|
#[export_name = "2200"] impl S { }
|
2021-08-10 13:41:57 -05:00
|
|
|
//~^ ERROR attribute should be applied to a free function, impl method or static
|
|
|
|
//~| NOTE not a free function, impl method or static
|
|
|
|
|
|
|
|
trait Tr {
|
|
|
|
#[export_name = "2200"] fn foo();
|
|
|
|
//~^ ERROR attribute should be applied to a free function, impl method or static
|
|
|
|
//~| NOTE not a free function, impl method or static
|
|
|
|
|
|
|
|
#[export_name = "2200"] fn bar() {}
|
|
|
|
//~^ ERROR attribute should be applied to a free function, impl method or static
|
|
|
|
//~| NOTE not a free function, impl method or static
|
|
|
|
}
|
2020-06-13 23:47:42 -05:00
|
|
|
}
|
|
|
|
|
2020-10-03 13:45:39 -05:00
|
|
|
#[start]
|
|
|
|
//~^ ERROR: `start` attribute can only be used on functions
|
|
|
|
mod start {
|
|
|
|
mod inner { #![start] }
|
|
|
|
//~^ ERROR: `start` attribute can only be used on functions
|
|
|
|
|
|
|
|
// for `fn f()` case, see feature-gate-start.rs
|
|
|
|
|
|
|
|
#[start] struct S;
|
|
|
|
//~^ ERROR: `start` attribute can only be used on functions
|
|
|
|
|
|
|
|
#[start] type T = S;
|
|
|
|
//~^ ERROR: `start` attribute can only be used on functions
|
|
|
|
|
|
|
|
#[start] impl S { }
|
|
|
|
//~^ ERROR: `start` attribute can only be used on functions
|
|
|
|
}
|
|
|
|
|
2021-09-05 19:16:28 -05:00
|
|
|
#[repr(C)]
|
|
|
|
//~^ ERROR: attribute should be applied to a struct, enum, or union
|
|
|
|
mod repr {
|
|
|
|
//~^ NOTE not a struct, enum, or union
|
|
|
|
mod inner { #![repr(C)] }
|
|
|
|
//~^ ERROR: attribute should be applied to a struct, enum, or union
|
|
|
|
//~| NOTE not a struct, enum, or union
|
|
|
|
|
|
|
|
#[repr(C)] fn f() { }
|
|
|
|
//~^ ERROR: attribute should be applied to a struct, enum, or union
|
|
|
|
//~| NOTE not a struct, enum, or union
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
#[repr(C)] type T = S;
|
|
|
|
//~^ ERROR: attribute should be applied to a struct, enum, or union
|
|
|
|
//~| NOTE not a struct, enum, or union
|
|
|
|
|
|
|
|
#[repr(C)] impl S { }
|
|
|
|
//~^ ERROR: attribute should be applied to a struct, enum, or union
|
|
|
|
//~| NOTE not a struct, enum, or union
|
|
|
|
}
|
|
|
|
|
2020-06-13 23:47:42 -05:00
|
|
|
fn main() {}
|