]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/useless_attribute.rs
turn `append_place_to_string` from recursion into iteration
[rust.git] / src / tools / clippy / 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_middle;
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 unused for `use` items
24 #[allow(unused)]
25 use std::option;
26
27 // don't lint on deprecated for `use` items
28 mod foo {
29     #[deprecated]
30     pub struct Bar;
31 }
32 #[allow(deprecated)]
33 pub use foo::Bar;
34
35 // This should not trigger the lint. There's lint level definitions inside the external derive
36 // that would trigger the useless_attribute lint.
37 #[derive(DeriveSomething)]
38 struct Baz;
39
40 // don't lint on unreachable_pub for `use` items
41 mod a {
42     mod b {
43         #[allow(dead_code)]
44         #[allow(unreachable_pub)]
45         pub struct C;
46     }
47
48     #[allow(unreachable_pub)]
49     pub use self::b::C;
50 }
51
52 // don't lint on clippy::wildcard_imports for `use` items
53 #[allow(clippy::wildcard_imports)]
54 pub use std::io::prelude::*;
55
56 // don't lint on clippy::enum_glob_use for `use` items
57 #[allow(clippy::enum_glob_use)]
58 pub use std::cmp::Ordering::*;
59
60 fn test_indented_attr() {
61     #[allow(clippy::almost_swapped)]
62     use std::collections::HashSet;
63
64     let _ = HashSet::<u32>::default();
65 }
66
67 fn main() {
68     test_indented_attr();
69 }