]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/unused/unused-attr-duplicate.rs
Rollup merge of #103236 - tspiteri:redoc-int-adc-sbb, r=m-ou-se
[rust.git] / tests / ui / lint / unused / unused-attr-duplicate.rs
1 // Tests for repeating attribute warnings.
2 // aux-build:lint_unused_extern_crate.rs
3 // compile-flags:--test
4 // Not tested due to extra requirements:
5 // - panic_handler: needs extra setup
6 // - target_feature: platform-specific
7 // - link_section: platform-specific
8 // - proc_macro, proc_macro_derive, proc_macro_attribute: needs to be a
9 //   proc-macro, and have special handling for mixing.
10 // - unstable attributes (not going to bother)
11 // - no_main: extra setup
12 #![deny(unused_attributes)]
13 #![crate_name = "unused_attr_duplicate"]
14 #![crate_name = "unused_attr_duplicate2"] //~ ERROR unused attribute
15 //~^ WARN this was previously accepted
16 #![recursion_limit = "128"]
17 #![recursion_limit = "256"] //~ ERROR unused attribute
18 //~^ WARN this was previously accepted
19 #![type_length_limit = "1048576"]
20 #![type_length_limit = "1"] //~ ERROR unused attribute
21 //~^ WARN this was previously accepted
22 #![no_std]
23 #![no_std] //~ ERROR unused attribute
24 #![no_implicit_prelude]
25 #![no_implicit_prelude] //~ ERROR unused attribute
26 #![windows_subsystem = "console"]
27 #![windows_subsystem = "windows"] //~ ERROR unused attribute
28 //~^ WARN this was previously accepted
29 #![no_builtins]
30 #![no_builtins] //~ ERROR unused attribute
31
32 #[no_link]
33 #[no_link] //~ ERROR unused attribute
34 extern crate lint_unused_extern_crate;
35
36 #[macro_use]
37 #[macro_use] //~ ERROR unused attribute
38 pub mod m {
39     #[macro_export]
40     #[macro_export] //~ ERROR unused attribute
41     macro_rules! foo {
42         () => {};
43     }
44 }
45
46 #[path = "auxiliary/lint_unused_extern_crate.rs"]
47 #[path = "bar.rs"] //~ ERROR unused attribute
48 //~^ WARN this was previously accepted
49 pub mod from_path;
50
51 #[test]
52 #[ignore]
53 #[ignore = "some text"] //~ ERROR unused attribute
54 #[should_panic]
55 #[should_panic(expected = "values don't match")] //~ ERROR unused attribute
56 //~^ WARN this was previously accepted
57 fn t1() {}
58
59 #[must_use]
60 #[must_use = "some message"] //~ ERROR unused attribute
61 //~^ WARN this was previously accepted
62 // No warnings for #[repr], would require more logic.
63 #[repr(C)]
64 #[repr(C)]
65 #[non_exhaustive]
66 #[non_exhaustive] //~ ERROR unused attribute
67 pub struct X;
68
69 #[automatically_derived]
70 #[automatically_derived] //~ ERROR unused attribute
71 impl X {}
72
73 #[inline(always)]
74 #[inline(never)] //~ ERROR unused attribute
75 //~^ WARN this was previously accepted
76 #[cold]
77 #[cold] //~ ERROR unused attribute
78 #[track_caller]
79 #[track_caller] //~ ERROR unused attribute
80 pub fn xyz() {}
81
82 // No warnings for #[link], would require more logic.
83 #[link(name = "rust_test_helpers", kind = "static")]
84 #[link(name = "rust_test_helpers", kind = "static")]
85 extern "C" {
86     #[link_name = "this_does_not_exist"] //~ ERROR unused attribute
87     //~^ WARN this was previously accepted
88     #[link_name = "rust_dbg_extern_identity_u32"]
89     pub fn name_in_rust(v: u32) -> u32;
90 }
91
92 #[export_name = "exported_symbol_name"] //~ ERROR unused attribute
93 //~^ WARN this was previously accepted
94 #[export_name = "exported_symbol_name2"]
95 pub fn export_test() {}
96
97 #[no_mangle]
98 #[no_mangle] //~ ERROR unused attribute
99 pub fn no_mangle_test() {}
100
101 #[used]
102 #[used] //~ ERROR unused attribute
103 static FOO: u32 = 0;
104
105 fn main() {}