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