]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/useless_attribute.rs
Rollup merge of #105144 - compiler-errors:normalization-doc, r=lcnr
[rust.git] / src / tools / clippy / tests / ui / useless_attribute.rs
1 // run-rustfix
2 // aux-build:proc_macro_derive.rs
3
4 #![allow(unused)]
5 #![warn(clippy::useless_attribute)]
6 #![warn(unreachable_pub)]
7 #![feature(rustc_private)]
8
9 #[allow(dead_code)]
10 #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
11 #[rustfmt::skip]
12 #[allow(unused_imports)]
13 #[allow(unused_extern_crates)]
14 #[macro_use]
15 extern crate rustc_middle;
16
17 #[macro_use]
18 extern crate proc_macro_derive;
19
20 fn test_indented_attr() {
21     #[allow(clippy::almost_swapped)]
22     use std::collections::HashSet;
23
24     let _ = HashSet::<u32>::default();
25 }
26
27 // don't lint on unused_import for `use` items
28 #[allow(unused_imports)]
29 use std::collections;
30
31 // don't lint on unused for `use` items
32 #[allow(unused)]
33 use std::option;
34
35 // don't lint on deprecated for `use` items
36 mod foo {
37     #[deprecated]
38     pub struct Bar;
39 }
40 #[allow(deprecated)]
41 pub use foo::Bar;
42
43 // This should not trigger the lint. There's lint level definitions inside the external derive
44 // that would trigger the useless_attribute lint.
45 #[derive(DeriveSomething)]
46 struct Baz;
47
48 // don't lint on unreachable_pub for `use` items
49 mod a {
50     mod b {
51         #[allow(dead_code)]
52         #[allow(unreachable_pub)]
53         pub struct C;
54     }
55
56     #[allow(unreachable_pub)]
57     pub use self::b::C;
58 }
59
60 // don't lint on clippy::wildcard_imports for `use` items
61 #[allow(clippy::wildcard_imports)]
62 pub use std::io::prelude::*;
63
64 // don't lint on clippy::enum_glob_use for `use` items
65 #[allow(clippy::enum_glob_use)]
66 pub use std::cmp::Ordering::*;
67
68 // don't lint on clippy::redundant_pub_crate
69 mod c {
70     #[allow(clippy::redundant_pub_crate)]
71     pub(crate) struct S;
72 }
73
74 // https://github.com/rust-lang/rust-clippy/issues/7511
75 pub mod split {
76     #[allow(clippy::module_name_repetitions)]
77     pub use regex::SplitN;
78 }
79
80 // https://github.com/rust-lang/rust-clippy/issues/8768
81 #[allow(clippy::single_component_path_imports)]
82 use regex;
83
84 fn main() {
85     test_indented_attr();
86 }