Skip to content

Bad error message in case of namespace overlapping imports #10100

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
Kimundi opened this issue Oct 27, 2013 · 3 comments
Closed

Bad error message in case of namespace overlapping imports #10100

Kimundi opened this issue Oct 27, 2013 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@Kimundi
Copy link
Member

Kimundi commented Oct 27, 2013

use foo::Speed;

mod foo {
    pub use self::Speed::Speed;
    pub mod Speed {
        pub enum Speed {
            Fast,
            Slow
        }
    }
}

fn main() {
    let a: Speed = Speed::Fast;
    let b: Speed = Speed::Slow;
}
scope_use.rs:14:11: 14:16 error: found value name used as a type: DefMod(syntax::ast::DefId{crate: 0, node: 9})
scope_use.rs:14     let a: Speed = Speed::Fast;
                           ^~~~~
@Kimundi
Copy link
Member Author

Kimundi commented Oct 27, 2013

Possibly related: #7607, #8767, #8763

@JustAPerson
Copy link
Contributor

Perhaps this issue should be closed, as it now gives a much more useful error:

10100.rs:14:12: 14:17 error: found module name used as a type: mod foo::Speed::Speed (id=8)
10100.rs:14     let a: Speed = Speed::Fast;
                       ^~~~~
$ rustc -v
rustc 0.10-pre (7bda3df 2014-04-02 17:51:48 -0700)
host: x86_64-unknown-linux-gnu

@alexcrichton
Copy link
Member

Looks like this has been greatly improved in the meantime!

foo.rs:4:13: 4:31 error: import `Speed` conflicts with existing submodule [E0256]
foo.rs:4     pub use self::Speed::Speed;
                     ^~~~~~~~~~~~~~~~~~
foo.rs:5:5: 10:6 note: note conflicting module here
foo.rs:5     pub mod Speed {
foo.rs:6         pub enum Speed {
foo.rs:7             Fast,
foo.rs:8             Slow
foo.rs:9         }
foo.rs:10     }
error: aborting due to previous error

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