Skip to content

Need better error messages for conflicts due to glob imports #19609

Closed
@mukilan

Description

@mukilan

PR #19522 fixed issue #19498 for the single import case. i.e previously having use self::A; mod A {} in the same file gave error "unresolved import A" while now it gives a more meaningful message - "import A conflicts with exisiting submodule", which is consistent with the error messages for the non-self import cases like

mod A {

   use self::B::C::B;  //  error: import `B` conflicts with existing submodule

   mod B {   //  note: note conflicting module here
       mod C {
            mod B {}
       }
   }
}


fn main() {
}

However PR #19522 does not handle the conflicts due to glob import such as this:

#![feature(globs)]
mod mod1 {
    use mod1::submodule::*; // error: import `A` conflicts with type in this module
    mod submodule { pub struct A {j: char} }
    struct A {i: int}
}

mod mod2 {
    use mod2::*;  // error: unresolved import
    mod submodule {}
}

fn main() {
}

As it can be seen, the error message is clear when the imported names conflicts a type (error: import A conflicts with type in this module) whereas conflicts in module names are not reported as such, but as error: unresolved import.

Also it is unclear whether for the use mod2::* and use self::* cases we need to list all existing names as conflicts, since that would be too verbose.

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