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

'ambiguous name' error message has weird wording #79717

Closed
camelid opened this issue Dec 5, 2020 · 3 comments · Fixed by #90075
Closed

'ambiguous name' error message has weird wording #79717

camelid opened this issue Dec 5, 2020 · 3 comments · Fixed by #90075
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@camelid
Copy link
Member

camelid commented Dec 5, 2020

mod serde {}

use serde::foo;

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0432]: unresolved import `serde::foo`
 --> src/lib.rs:3:5
  |
3 | use serde::foo;
  |     ^^^^^^^^^^ no `foo` in `serde`

error[E0659]: `serde` is ambiguous (name vs any other name during import resolution)
 --> src/lib.rs:3:5
  |
3 | use serde::foo;
  |     ^^^^^ ambiguous name
  |
  = note: `serde` could refer to a crate passed with `--extern`
  = help: use `::serde` to refer to this crate unambiguously
note: `serde` could also refer to the module defined here
 --> src/lib.rs:1:1
  |
1 | mod serde {}
  | ^^^^^^^^^^^^
  = help: use `crate::serde` to refer to this module unambiguously

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0432, E0659.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `playground`

To learn more, run the command again with --verbose.

The error message says:

serde is ambiguous (name vs any other name during import resolution)

But what does it mean by "name vs any other name during import resolution"? I think this should be reworded or even deleted – it doesn't seem to add anything.

@camelid camelid added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-confusing Diagnostics: Confusing error or lint that should be reworked. labels Dec 5, 2020
@camelid camelid changed the title Ambiguous name error message has weird wording 'ambiguous name' error message has weird wording Dec 5, 2020
@petrochenkov
Copy link
Contributor

But what does it mean by "name vs any other name during import resolution"?

The key part here is "during import resolution", any shadowing during resolution of use items is prohibited.
I'd personally just remove this restriction - #56414.

@goodwjak
Copy link

goodwjak commented Aug 3, 2021

Just wanted to note this is still a issue in Rust version 1.56.0-nightly for now I'm using
#[macro_use] extern crate serde;

@pierwill
Copy link
Member

@rustbot claim

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants