1 #![warn(unused_attributes)]
2 
3 // Tests that placing the #[no_mangle] attribute on a foreign fn or static emits
4 // a specialized warning.
5 // The previous warning only talks about a "function or static" but foreign fns/statics
6 // are also not allowed to have #[no_mangle]
7 
8 // build-pass
9 
10 extern "C" {
11     #[no_mangle]
12     //~^ WARNING `#[no_mangle]` has no effect on a foreign static
13     //~^^ WARNING this was previously accepted by the compiler
14     pub static FOO: u8;
15 
16     #[no_mangle]
17     //~^ WARNING `#[no_mangle]` has no effect on a foreign function
18     //~^^ WARNING this was previously accepted by the compiler
bar()19     pub fn bar();
20 }
21 
no_new_warn()22 fn no_new_warn() {
23     // Should emit the generic "not a function or static" warning
24     #[no_mangle]
25     //~^ WARNING attribute should be applied to a free function, impl method or static
26     //~^^ WARNING this was previously accepted by the compiler
27     let x = 0_u8;
28 }
29 
main()30 fn main() {}
31