3 // aux-build:wildcard_imports_helper.rs
5 // the 2015 edition here is needed because edition 2018 changed the module system
6 // (see https://doc.rust-lang.org/edition-guide/rust-2018/path-changes.html) which means the lint
7 // no longer detects some of the cases starting with Rust 2018.
8 // FIXME: We should likely add another edition 2021 test case for this lint
10 #![warn(clippy::wildcard_imports)]
11 #![allow(unused, clippy::unnecessary_wraps, clippy::let_unit_value)]
12 #![warn(unused_imports)]
14 extern crate wildcard_imports_helper;
16 use crate::fn_mod::foo;
17 use crate::mod_mod::inner_mod;
18 use crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod};
20 use crate::struct_mod::{A, inner_struct_mod};
22 #[allow(unused_imports)]
23 use wildcard_imports_helper::inner::inner_for_self_import;
24 use wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar;
25 use wildcard_imports_helper::{ExternA, extern_foo};
27 use std::io::prelude::*;
28 use wildcard_imports_helper::prelude::v1::*;
32 impl Read for ReadFoo {
33 fn read(&mut self, _buf: &mut [u8]) -> std::io::Result<usize> {
52 pub mod multi_inner_mod {
60 pub mod inner_struct_mod {
65 macro_rules! double_struct_import_test {
76 multi_inner_mod::foo();
82 let _ = inner_struct_mod::C;
84 let _ = PreludeModAnywhere;
86 double_struct_import_test!();
87 double_struct_import_test!();
91 pub use self::inner_exported::*;
92 #[allow(unused_imports)]
93 pub(crate) use self::inner_exported2::*;
96 use crate::fn_mod::foo;
102 use wildcard_imports_helper::inner::inner_for_self_import::{self, inner_extern_foo};
103 use wildcard_imports_helper::{ExternA, extern_foo};
105 inner_for_self_import::inner_extern_foo();
113 fn test_inner_nested() {
114 use self::{inner::inner_foo, inner2::inner_bar};
120 fn test_extern_reexported() {
121 use wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported};
124 let _ = ExternExportedStruct;
125 let _ = ExternExportedEnum::A;
130 pub struct ExportedStruct;
131 pub enum ExportedEnum {
136 mod inner_exported2 {
137 pub(crate) fn exported2() {}
141 pub fn inner_foo() {}
145 pub fn inner_bar() {}
149 fn test_reexported() {
150 use crate::in_fn_test::{ExportedEnum, ExportedStruct, exported};
153 let _ = ExportedStruct;
154 let _ = ExportedEnum::A;
158 fn test_weird_formatting() {
159 use crate:: in_fn_test::exported;
160 use crate:: fn_mod::foo;
169 mod should_be_replaced {
177 mod test_should_pass {
185 mod test_should_pass_inside_function {
186 fn with_super_inside_function() {
192 mod test_should_pass_further_inside {
202 mod should_be_replaced_further_inside {
205 use super::insidefoo;
212 mod use_explicit_should_be_replaced {
213 use super_imports::foofoo;
220 mod use_double_super_should_be_replaced {
222 use super::super::foofoo;
224 fn with_double_super() {
230 mod use_super_explicit_should_be_replaced {
231 use super::super::super_imports::foofoo;
233 fn with_super_explicit() {
238 mod attestation_should_be_replaced {