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)]
12 #![allow(clippy::unnecessary_wraps)]
13 #![warn(unused_imports)]
15 extern crate wildcard_imports_helper;
18 use crate::mod_mod::*;
19 use crate::multi_fn_mod::*;
21 use crate::struct_mod::*;
23 #[allow(unused_imports)]
24 use wildcard_imports_helper::inner::inner_for_self_import;
25 use wildcard_imports_helper::inner::inner_for_self_import::*;
26 use wildcard_imports_helper::*;
28 use std::io::prelude::*;
29 use wildcard_imports_helper::prelude::v1::*;
33 impl Read for ReadFoo {
34 fn read(&mut self, _buf: &mut [u8]) -> std::io::Result<usize> {
53 pub mod multi_inner_mod {
61 pub mod inner_struct_mod {
66 macro_rules! double_struct_import_test {
77 multi_inner_mod::foo();
83 let _ = inner_struct_mod::C;
85 let _ = PreludeModAnywhere;
87 double_struct_import_test!();
88 double_struct_import_test!();
92 pub use self::inner_exported::*;
93 #[allow(unused_imports)]
94 pub(crate) use self::inner_exported2::*;
103 use wildcard_imports_helper::inner::inner_for_self_import::{self, *};
104 use wildcard_imports_helper::*;
106 inner_for_self_import::inner_extern_foo();
114 fn test_inner_nested() {
115 use self::{inner::*, inner2::*};
121 fn test_extern_reexported() {
122 use wildcard_imports_helper::*;
125 let _ = ExternExportedStruct;
126 let _ = ExternExportedEnum::A;
131 pub struct ExportedStruct;
132 pub enum ExportedEnum {
137 mod inner_exported2 {
138 pub(crate) fn exported2() {}
142 pub fn inner_foo() {}
146 pub fn inner_bar() {}
150 fn test_reexported() {
151 use crate::in_fn_test::*;
154 let _ = ExportedStruct;
155 let _ = ExportedEnum::A;
159 fn test_weird_formatting() {
160 use crate:: in_fn_test:: * ;
171 mod should_be_replaced {
179 mod test_should_pass {
187 mod test_should_pass_inside_function {
188 fn with_super_inside_function() {
194 mod test_should_pass_further_inside {
204 mod should_be_replaced_futher_inside {
214 mod use_explicit_should_be_replaced {
215 use super_imports::*;
222 mod use_double_super_should_be_replaced {
226 fn with_double_super() {
232 mod use_super_explicit_should_be_replaced {
233 use super::super::super_imports::*;
235 fn with_super_explicit() {
240 mod attestation_should_be_replaced {