ambiguous name when glob importing an enum into a block when variant has same name as enum
Open
Nobody has claimed this yet.
A-resolve
C-bug
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
related: https://github.com/rust-lang/rust/issues/102855
I tried this code:
enum En {
En
}
mod m {
use super::En;
const _ = {
use En::*;
1
};
}
I expected to see this happen: exact path shadows glob import
Instead, this happened: compile error:
Compiling playground v0.0.1 (/playground)
error[[E0659]](https://doc.rust-lang.org/nightly/error_codes/E0659.html): `En` is ambiguous
--> src/lib.rs:8:13
|
8 | use En::*;
| ^^ ambiguous name
|
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
note: `En` could refer to the variant imported here
--> src/lib.rs:8:13
|
8 | use En::*;
| ^^^^^
= help: consider adding an explicit import of `En` to disambiguate
note: `En` could also refer to the enum imported here
--> src/lib.rs:6:9
|
6 | use super::En;
| ^^^^^^^^^
= help: use `self::En` to refer to this enum unambiguously
error: missing type for `const` item
--> src/lib.rs:7:12
|
7 | const _ = {
| ^ help: provide a type for the constant: `: i32`
For more information about this error, try `rustc --explain E0659`.
error: could not compile `playground` (lib) due to 2 previous errors
Meta
rustc --version --verbose:
rustc 1.83.0-nightly (2bd1e894e 2024-09-26)
binary: rustc
commit-hash: 2bd1e894efde3b6be857ad345914a3b1cea51def
commit-date: 2024-09-26
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
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
Start by compiling the minimal example in src/lib.rs with the reported nightly rustc version and compare the ambiguity diagnostic with the expected exact-path shadowing behavior. No compiler source file or test is named; done means the example no longer reports the enum path as ambiguous while preserving the variant import behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100