Skip to content
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

rustc: error when both both defining and using a module should be more specific #15769

Closed
aturon opened this issue Jul 18, 2014 · 1 comment
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution

Comments

@aturon
Copy link
Member

aturon commented Jul 18, 2014

Given the following setup,

use test;
mod test {}

rustc says

mod-usage.rs:1:5: 1:9 error: unresolved import (maybe you meant `test::*`?)
mod-usage.rs:1 use test;
                   ^~~~

I ran into this while refactoring, but I imagine newcomers getting used to the use/mod distinction (and the fact that mod automatically uses) would benefit from a message more like:

mod-usage.rs:1:5: 1:9 error: cannot import `test` because it was already defined:
mod-usage.rs:1 use test;
                   ^~~~ import
mod-usage.rs:2 mod test {}
                   ^~~~ definition

It's also a bit strange that double-imports are allowed, but the situation above isn't. RFC PR 116 could help regularize things.

@flaper87
Copy link
Contributor

This has been fixed. The current error reported is:

test.rs:1:5: 1:9 error: import `test` conflicts with existing submodule [E0258]
test.rs:1 use test;
              ^~~~
test.rs:2:1: 2:12 note: note conflicting module here
test.rs:2 mod test {}
          ^~~~~~~~~~~
error: aborting due to previous error

bors added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2023
internal: Create `~/.ssh` before writing deploy key
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 A-resolve Area: Name resolution
Projects
None yet
Development

No branches or pull requests

3 participants