Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambiguous name when glob importing an enum into a block when variant has same name as enum #131110

Open
lolbinarycat opened this issue Oct 1, 2024 · 0 comments
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

related: #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
@lolbinarycat lolbinarycat added the C-bug Category: This is a bug. label Oct 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 1, 2024
@fmease fmease added A-resolve Area: Name/path resolution done by `rustc_resolve` specifically T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 1, 2024
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants