Skip to content

Possibly incorrect/confusing error message for E0251/E0252 when importing modules. #25396

Closed
@nham

Description

@nham

I found an error message that seems a bit off to me. The code:

use foo::baz;
use bar::baz;

fn main() {}

mod foo {
    pub mod baz {}
}

mod bar {
    pub mod baz {}
}

Clearly it should fail to compile, and it does. But the error message is:

E0252_module.rs:2:5: 2:13 error: a type named `baz` has already been imported in this module [E0252]
E0252_module.rs:2 use bar::baz;
                      ^~~~~~~~

I would expect something like "a module name baz has already been imported", instead. Is it accurate to call it a type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions