]> git.lizzy.rs Git - rust.git/blob - tests/ui/useless_attribute.rs
Auto merge of #4809 - iankronquist:patch-1, r=flip1995
[rust.git] / tests / ui / useless_attribute.rs
1 // run-rustfix
2 // aux-build:proc_macro_derive.rs
3
4 #![warn(clippy::useless_attribute)]
5 #![warn(unreachable_pub)]
6 #![feature(rustc_private)]
7
8 #[allow(dead_code)]
9 #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
10 #[rustfmt::skip]
11 #[allow(unused_imports)]
12 #[allow(unused_extern_crates)]
13 #[macro_use]
14 extern crate rustc;
15
16 #[macro_use]
17 extern crate proc_macro_derive;
18
19 // don't lint on unused_import for `use` items
20 #[allow(unused_imports)]
21 use std::collections;
22
23 // don't lint on deprecated for `use` items
24 mod foo {
25     #[deprecated]
26     pub struct Bar;
27 }
28 #[allow(deprecated)]
29 pub use foo::Bar;
30
31 // This should not trigger the lint. There's lint level definitions inside the external derive
32 // that would trigger the useless_attribute lint.
33 #[derive(DeriveSomething)]
34 struct Baz;
35
36 // don't lint on unreachable_pub for `use` items
37 mod a {
38     mod b {
39         #[allow(dead_code)]
40         #[allow(unreachable_pub)]
41         pub struct C {}
42     }
43
44     #[allow(unreachable_pub)]
45     pub use self::b::C;
46 }
47
48 fn test_indented_attr() {
49     #[allow(clippy::almost_swapped)]
50     use std::collections::HashSet;
51
52     let _ = HashSet::<u32>::default();
53 }
54
55 fn main() {
56     test_indented_attr();
57 }