Skip to content

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

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

Closed
mukilan opened this issue Dec 7, 2014 · 1 comment
Closed

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

mukilan opened this issue Dec 7, 2014 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@mukilan
Copy link
Contributor

mukilan commented Dec 7, 2014

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.

@jdm jdm added the I-papercut label Dec 8, 2014
@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 7, 2015
@steveklabnik
Copy link
Member

The second error now says

error: unresolved import `mod2::*`. Cannot glob-import a module into itself. [E0432]

which seems very clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants