Skip to content

"Foo is ambiguous" only when deriving Debug #62769

Open
@oberien

Description

@oberien

playpen

This may be related to #62768.

Given this code:

pub use Foo::*;
#[derive(Debug)]
pub enum Foo {
    Foo(i32),
}

The compiler errors, saying that the Foo in use Foo::* may refer both to the enum (type-namespace) Foo and the yet-to-be-imported variant (value-namespace) Foo::Foo:

error[E0659]: `Foo` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution)
 --> src/lib.rs:1:9
  |
1 | pub use Foo::*;
  |         ^^^ ambiguous name
  |
note: `Foo` could refer to the enum defined here
 --> src/lib.rs:3:1
  |
3 | / pub enum Foo {
4 | |     Foo(i32),
5 | | }
  | |_^
note: `Foo` could also refer to the variant imported here
 --> src/lib.rs:1:9
  |
1 | pub use Foo::*;
  |         ^^^^^^
  = help: consider adding an explicit import of `Foo` to disambiguate

However, if I remove the #[derive(Debug)], then the code compiles just fine as expected (playpen).

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