]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/useless_attribute.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / useless_attribute.rs
CommitLineData
f20569fa
XL
1// run-rustfix
2// aux-build:proc_macro_derive.rs
3
487cf647 4#![allow(unused)]
f20569fa
XL
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]
15extern crate rustc_middle;
16
17#[macro_use]
18extern crate proc_macro_derive;
19
487cf647
FG
20fn test_indented_attr() {
21 #[allow(clippy::almost_swapped)]
22 use std::collections::HashSet;
23
24 let _ = HashSet::<u32>::default();
25}
26
f20569fa
XL
27// don't lint on unused_import for `use` items
28#[allow(unused_imports)]
29use std::collections;
30
31// don't lint on unused for `use` items
32#[allow(unused)]
33use std::option;
34
35// don't lint on deprecated for `use` items
36mod foo {
37 #[deprecated]
38 pub struct Bar;
39}
40#[allow(deprecated)]
41pub 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)]
46struct Baz;
47
48// don't lint on unreachable_pub for `use` items
49mod a {
50 mod b {
51 #[allow(dead_code)]
52 #[allow(unreachable_pub)]
04454e1e 53 pub struct C;
f20569fa
XL
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)]
62pub use std::io::prelude::*;
63
64// don't lint on clippy::enum_glob_use for `use` items
65#[allow(clippy::enum_glob_use)]
66pub use std::cmp::Ordering::*;
67
04454e1e
FG
68// don't lint on clippy::redundant_pub_crate
69mod c {
70 #[allow(clippy::redundant_pub_crate)]
71 pub(crate) struct S;
72}
73
487cf647
FG
74// https://github.com/rust-lang/rust-clippy/issues/7511
75pub mod split {
76 #[allow(clippy::module_name_repetitions)]
77 pub use regex::SplitN;
f20569fa
XL
78}
79
487cf647
FG
80// https://github.com/rust-lang/rust-clippy/issues/8768
81#[allow(clippy::single_component_path_imports)]
82use regex;
83
f20569fa
XL
84fn main() {
85 test_indented_attr();
86}