rust-lang / rust-lang/rust-clippy
`wildcard-import` breaks `super::*` import
Open
Nobody has claimed this yet.
I-suggestion-causes-error
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Using the following flags
--force-warn clippy::wildcard-imports
this code:
//@ build-pass (FIXME(62277): could be check-pass?)
macro_rules! define_exported { () => {
#[macro_export]
macro_rules! exported {
() => ()
}
}}
mod inner1 {
use super::*;
exported!();
}
mod inner2 {
define_exported!();
}
fn main() {}
caused the following diagnostics:
Checking _local-modularized-tricky-pass-1 v0.1.0 (/tmp/icemaker_global_tempdir.o4hDRjvshrmO/icemaker_clippyfix_tempdir.NiwCbcBCaaTt/_local-modularized-tricky-pass-1)
warning: usage of wildcard import
--> src/main.rs:11:9
|
11 | use super::*;
| ^^^^^^^^ help: try: `super::exported`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports
= note: requested on the command line with `--force-warn clippy::wildcard-imports`
warning: `_local-modularized-tricky-pass-1` (bin "_local-modularized-tricky-pass-1") generated 1 warning (run `cargo clippy --fix --bin "_local-modularized-tricky-pass-1"` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
However after applying these diagnostics, the resulting code:
//@ build-pass (FIXME(62277): could be check-pass?)
macro_rules! define_exported { () => {
#[macro_export]
macro_rules! exported {
() => ()
}
}}
mod inner1 {
use super::exported;
exported!();
}
mod inner2 {
define_exported!();
}
fn main() {}
no longer compiled:
Checking _local-modularized-tricky-pass-1 v0.1.0 (/tmp/icemaker_global_tempdir.o4hDRjvshrmO/icemaker_clippyfix_tempdir.NiwCbcBCaaTt/_local-modularized-tricky-pass-1)
error: cannot determine resolution for the import
--> src/main.rs:11:9
|
11 | use super::exported;
| ^^^^^^^^^^^^^^^
error: could not compile `_local-modularized-tricky-pass-1` (bin "_local-modularized-tricky-pass-1") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_local-modularized-tricky-pass-1` (bin "_local-modularized-tricky-pass-1" test) due to 1 previous error
Version:
rustc 1.89.0-nightly (cf423712b 2025-06-05)
binary: rustc
commit-hash: cf423712b9e95e9f6ec84b1ecb3d125e55ac8d56
commit-date: 2025-06-05
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the supplied Rust snippet and the clippy::wildcard-imports flag. Start by locating the wildcard-imports lint and its suggestion generation; done means the suggested replacement for use super::* still compiles, with a regression test covering the exported macro case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100