Skip to content

"Foo is ambiguous" even though it's not #62768

Closed
@oberien

Description

@oberien

playpen

Given the following code:

mod foo {
    pub enum Foo {
        Foo(i32),
    }
}
use foo::*;
use Foo::*;

The compiler claims, that the Foo in use Foo::* could either mean the type foo::Foo imported by use foo::*, or the variant (value) Foo::Foo imported by use Foo::*:

error[E0659]: `Foo` is ambiguous (glob import vs glob import in the same module)
 --> src/lib.rs:7:5
  |
7 | use Foo::*;
  |     ^^^ ambiguous name
  |
note: `Foo` could refer to the enum imported here
 --> src/lib.rs:6:5
  |
6 | use foo::*;
  |     ^^^^^^
  = help: consider adding an explicit import of `Foo` to disambiguate
note: `Foo` could also refer to the variant imported here
 --> src/lib.rs:7:5
  |
7 | use Foo::*;
  |     ^^^^^^
  = help: consider adding an explicit import of `Foo` to disambiguate

How can a name refer to something that's not imported yet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions