Skip to content

use dep1::foo as dep1 is considered ambiguous #77586

Closed

Description

src/lib.rs:

pub mod foo {
    pub use dep1::foo as dep1;
}

dep1/src/lib.rs:

pub mod foo {}

I expected to see this happen: build succeeds.

Instead, this happened:

error[E0432]: unresolved import `dep1::foo`
 --> src/lib.rs:2:13
  |
2 |     pub use dep1::foo as dep1;
  |             ^^^^^^^^^^^^^^^^^ no `foo` in `foo`

error[E0659]: `dep1` is ambiguous (name vs any other name during import resolution)
 --> src/lib.rs:2:13
  |
2 |     pub use dep1::foo as dep1;
  |             ^^^^ ambiguous name
  |
  = note: `dep1` could refer to a crate passed with `--extern`
  = help: use `::dep1` to refer to this crate unambiguously
note: `dep1` could also refer to the module imported here
 --> src/lib.rs:2:13
  |
2 |     pub use dep1::foo as dep1;
  |             ^^^^^^^^^^^^^^^^^
  = help: use `self::dep1` 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`.

Meta

working beta: rustc --version --verbose:

rustc 1.47.0-beta.9 (d6646f647 2020-10-03)
binary: rustc
commit-hash: d6646f64790018719caebeafd352a92adfa1d75a
commit-date: 2020-10-03
host: x86_64-unknown-linux-gnu
release: 1.47.0-beta.9
LLVM version: 11.0

non-working nightly: rustc +nightly --version --verbose

rustc 1.49.0-nightly (beb5ae474 2020-10-04)
binary: rustc
commit-hash: beb5ae474d2835962ebdf7416bd1c9ad864fe101
commit-date: 2020-10-04
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

This broke rust-systemd's build (https://travis-ci.com/github/jmesmon/rust-systemd/jobs/395293939) (broken versions are v0.6.0 and v0.5.0 which use edition = "2018").

I'm not sure if there is a simpler single-crate break (there could be).

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

Metadata

Labels

A-inferenceArea: Type inferenceA-resolveArea: Name resolutionC-bugCategory: This is a bug.T-langRelevant to the language team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions