]> git.lizzy.rs Git - rust.git/blob - tests/ui/wildcard_imports.fixed
Auto merge of #5522 - CrazyRoka:match_vec_item, r=phansch
[rust.git] / tests / ui / wildcard_imports.fixed
1 // run-rustfix
2 // aux-build:wildcard_imports_helper.rs
3
4 #![warn(clippy::wildcard_imports)]
5 //#![allow(clippy::redundant_pub_crate)]
6 #![allow(unused)]
7 #![warn(unused_imports)]
8
9 extern crate wildcard_imports_helper;
10
11 use crate::fn_mod::foo;
12 use crate::mod_mod::inner_mod;
13 use crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod};
14 #[macro_use]
15 use crate::struct_mod::{A, inner_struct_mod};
16
17 #[allow(unused_imports)]
18 use wildcard_imports_helper::inner::inner_for_self_import;
19 use wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar;
20 use wildcard_imports_helper::{ExternA, extern_foo};
21
22 use std::io::prelude::*;
23
24 struct ReadFoo;
25
26 impl Read for ReadFoo {
27     fn read(&mut self, _buf: &mut [u8]) -> std::io::Result<usize> {
28         Ok(0)
29     }
30 }
31
32 mod fn_mod {
33     pub fn foo() {}
34 }
35
36 mod mod_mod {
37     pub mod inner_mod {
38         pub fn foo() {}
39     }
40 }
41
42 mod multi_fn_mod {
43     pub fn multi_foo() {}
44     pub fn multi_bar() {}
45     pub fn multi_baz() {}
46     pub mod multi_inner_mod {
47         pub fn foo() {}
48     }
49 }
50
51 mod struct_mod {
52     pub struct A;
53     pub struct B;
54     pub mod inner_struct_mod {
55         pub struct C;
56     }
57
58     #[macro_export]
59     macro_rules! double_struct_import_test {
60         () => {
61             let _ = A;
62         };
63     }
64 }
65
66 fn main() {
67     foo();
68     multi_foo();
69     multi_bar();
70     multi_inner_mod::foo();
71     inner_mod::foo();
72     extern_foo();
73     inner_extern_bar();
74
75     let _ = A;
76     let _ = inner_struct_mod::C;
77     let _ = ExternA;
78
79     double_struct_import_test!();
80     double_struct_import_test!();
81 }
82
83 mod in_fn_test {
84     pub use self::inner_exported::*;
85     #[allow(unused_imports)]
86     pub(crate) use self::inner_exported2::*;
87
88     fn test_intern() {
89         use crate::fn_mod::foo;
90
91         foo();
92     }
93
94     fn test_extern() {
95         use wildcard_imports_helper::inner::inner_for_self_import::{self, inner_extern_foo};
96         use wildcard_imports_helper::{ExternA, extern_foo};
97
98         inner_for_self_import::inner_extern_foo();
99         inner_extern_foo();
100
101         extern_foo();
102
103         let _ = ExternA;
104     }
105
106     fn test_inner_nested() {
107         use self::{inner::inner_foo, inner2::inner_bar};
108
109         inner_foo();
110         inner_bar();
111     }
112
113     fn test_extern_reexported() {
114         use wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported};
115
116         extern_exported();
117         let _ = ExternExportedStruct;
118         let _ = ExternExportedEnum::A;
119     }
120
121     mod inner_exported {
122         pub fn exported() {}
123         pub struct ExportedStruct;
124         pub enum ExportedEnum {
125             A,
126         }
127     }
128
129     mod inner_exported2 {
130         pub(crate) fn exported2() {}
131     }
132
133     mod inner {
134         pub fn inner_foo() {}
135     }
136
137     mod inner2 {
138         pub fn inner_bar() {}
139     }
140 }
141
142 fn test_reexported() {
143     use crate::in_fn_test::{ExportedEnum, ExportedStruct, exported};
144
145     exported();
146     let _ = ExportedStruct;
147     let _ = ExportedEnum::A;
148 }
149
150 #[rustfmt::skip]
151 fn test_weird_formatting() {
152     use crate:: in_fn_test::exported;
153     use crate:: fn_mod::foo;
154
155     exported();
156     foo();
157 }