1 //@revisions: edition2018 edition2021
2 //@[edition2018] edition:2018
3 //@[edition2021] edition:2021
5 //@aux-build:wildcard_imports_helper.rs
7 #![warn(clippy::wildcard_imports)]
8 #![allow(unused, clippy::unnecessary_wraps, clippy::let_unit_value)]
9 #![warn(unused_imports)]
11 extern crate wildcard_imports_helper;
13 use crate::fn_mod::foo;
14 use crate::mod_mod::inner_mod;
15 use crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod};
16 use crate::struct_mod::{A, inner_struct_mod};
18 #[allow(unused_imports)]
19 use wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar;
20 use wildcard_imports_helper::prelude::v1::*;
21 use wildcard_imports_helper::{ExternA, extern_foo};
23 use std::io::prelude::*;
27 impl Read for ReadFoo {
28 fn read(&mut self, _buf: &mut [u8]) -> std::io::Result<usize> {
47 pub mod multi_inner_mod {
55 pub mod inner_struct_mod {
60 macro_rules! double_struct_import_test {
69 // allow use of `deref` so that `clippy --fix` includes `Deref`.
70 #![allow(noop_method_call)]
72 mod exports_underscore {
73 pub use std::ops::Deref as _;
77 mod exports_underscore_ish {
78 pub use std::ops::Deref as _Deref;
83 use exports_underscore::*;
89 use exports_underscore_ish::{_Deref, dummy};
99 multi_inner_mod::foo();
105 let _ = inner_struct_mod::C;
107 let _ = PreludeModAnywhere;
109 double_struct_import_test!();
110 double_struct_import_test!();
114 pub use self::inner_exported::*;
115 #[allow(unused_imports)]
116 pub(crate) use self::inner_exported2::*;
119 use crate::fn_mod::foo;
125 use wildcard_imports_helper::inner::inner_for_self_import::{self, inner_extern_foo};
126 use wildcard_imports_helper::{ExternA, extern_foo};
128 inner_for_self_import::inner_extern_foo();
136 fn test_inner_nested() {
138 use self::{inner::inner_foo, inner2::inner_bar};
144 fn test_extern_reexported() {
145 use wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported};
148 let _ = ExternExportedStruct;
149 let _ = ExternExportedEnum::A;
154 pub struct ExportedStruct;
155 pub enum ExportedEnum {
160 mod inner_exported2 {
161 pub(crate) fn exported2() {}
165 pub fn inner_foo() {}
169 pub fn inner_bar() {}
173 fn test_reexported() {
174 use crate::in_fn_test::{ExportedEnum, ExportedStruct, exported};
177 let _ = ExportedStruct;
178 let _ = ExportedEnum::A;
182 fn test_weird_formatting() {
183 use crate:: in_fn_test::exported;
184 use crate:: fn_mod::foo;
193 mod should_be_replaced {
201 mod test_should_pass {
209 mod test_should_pass_inside_function {
210 fn with_super_inside_function() {
216 mod test_should_pass_further_inside {
226 mod should_be_replaced_further_inside {
229 use super::insidefoo;
236 mod use_explicit_should_be_replaced {
237 use crate::super_imports::foofoo;
244 mod use_double_super_should_be_replaced {
246 use super::super::foofoo;
248 fn with_double_super() {
254 mod use_super_explicit_should_be_replaced {
255 use super::super::super_imports::foofoo;
257 fn with_super_explicit() {
262 mod attestation_should_be_replaced {