about summary refs log tree commit diff
path: root/tests/ui/attributes/positions/used.rs
blob: 7e106d278f279dceedfd20c7d1838d97706a2c59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Checks that `#[used]` cannot be used on invalid positions.
#![crate_type = "lib"]

#[used]
static FOO: u32 = 0; // OK

#[used] //~ ERROR attribute cannot be used on
fn foo() {}

#[used] //~ ERROR attribute cannot be used on
struct Foo {}

#[used] //~ ERROR attribute cannot be used on
trait Bar {}

#[used] //~ ERROR attribute cannot be used on
impl Bar for Foo {}

// Regression test for <https://github.com/rust-lang/rust/issues/126789>.
extern "C" {
    #[used] //~ ERROR attribute cannot be used on
    static BAR: i32;
}