Skip to content

'ambiguous name' error message has weird wording #79717

Closed
@camelid

Description

@camelid
Member
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.

Activity

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-diagnosticsArea: Messages for errors, warnings, and lints
A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
D-confusingDiagnostics: Confusing error or lint that should be reworked.
on Dec 5, 2020
changed the title [-]Ambiguous name error message has weird wording[/-] [+]'ambiguous name' error message has weird wording[/+] on Dec 5, 2020
petrochenkov

petrochenkov commented on Dec 5, 2020

@petrochenkov
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

goodwjak commented on Aug 3, 2021

@goodwjak

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

pierwill commented on Oct 19, 2021

@pierwill
Member

@rustbot claim

added a commit that references this issue on Oct 26, 2021

Auto merge of rust-lang#90075 - pierwill:fix-79717, r=petrochenkov

c7a30c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @petrochenkov@pierwill@camelid@goodwjak

    Issue actions

      'ambiguous name' error message has weird wording · Issue #79717 · rust-lang/rust