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

nightly regression: ambiguous import #57539

Closed
rukai opened this issue Jan 12, 2019 · 5 comments · Fixed by #57551
Closed

nightly regression: ambiguous import #57539

rukai opened this issue Jan 12, 2019 · 5 comments · Fixed by #57551
Labels
A-resolve Area: Name resolution E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@rukai
Copy link
Contributor

rukai commented Jan 12, 2019

main.rs

mod foo {
    mod simple_command {
        use simple_command;
        use crate::foo::*;
    }
}

mod bar {
}

fn main() {
}

cargo.toml

[package]
name = "foo"
version = "0.1.0"
authors = ["Rukai <rubickent@gmail.com>"]
edition = "2018"

[dependencies]
simple_command = "0.1"

On stable and nightly-2018-12-29 the code compiles successfully.
On nightly-2019-01-01 the code fails to compile with:

rubic@memes src$ cargo run
   Compiling foo v0.1.0 (/home/rubic/Foo/foo)
error[E0659]: `simple_command` is ambiguous (name vs any other name during import resolution)
 --> src/main.rs:3:13
  |
3 |         use simple_command;
  |             ^^^^^^^^^^^^^^ ambiguous name
  |
  = note: `simple_command` could refer to an extern crate passed with `--extern`
  = help: use `::simple_command` to refer to this extern crate unambiguously
note: `simple_command` could also refer to the module imported here
 --> src/main.rs:4:13
  |
4 |         use crate::foo::*;
  |             ^^^^^^^^^^^^^
  = help: use `self::simple_command` to refer to this module unambiguously

warning: unused import: `simple_command`
 --> src/main.rs:3:13
  |
3 |         use simple_command;
  |             ^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error: aborting due to previous error

For more information about this error, try `rustc --explain E0659`.
error: Could not compile `foo`.

At first I thought this was part of #56316
but now I think it is different because it started happening on nightly-2019-01-01 whereas that issue is from November.

This is currently causing ggez to fail to compile on nightly: ggez/ggez#542

@Centril Centril added the A-resolve Area: Name resolution label Jan 12, 2019
@Centril
Copy link
Contributor

Centril commented Jan 12, 2019

#![feature(uniform_paths)]

mod foo {
    mod simple_command {
        use simple_command;
        use crate::foo::*;
    }
}

mod bar {}

fn main() {}

With uniform paths, which will be in 1.32, this compiles, so this should resolve itself I think.

cc @petrochenkov

@petrochenkov petrochenkov self-assigned this Jan 12, 2019
@petrochenkov
Copy link
Contributor

petrochenkov commented Jan 12, 2019

So, this is indeed a regression from #57160.

@Centril
Looks like you missed the [dependencies] simple_command = "0.1" part, I'm still able to reproduce the error with #![feature(uniform_paths)] added.

@petrochenkov
Copy link
Contributor

It's not obvious to me right away what behavior is right here, pre-#57160 or post-#57160.
I'll look in more detail.

@petrochenkov
Copy link
Contributor

The ambiguity is reported correctly.
I.e. it's obvious that there's an ambiguity (the error message says what exactly), but before #57160 the ambiguity wasn't detected due to "self-confirming" import use simple_command "standing in the way".
It's great that the fix got into 1.32 stable, so the time for which the issue existed on stable was minimized.

Minimized reproduction:

mod core {
    use core;
    use crate::*;
}

fn main() {}

@petrochenkov petrochenkov added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 12, 2019
petrochenkov added a commit to petrochenkov/rust that referenced this issue Jan 12, 2019
@petrochenkov
Copy link
Contributor

Test added in #57551

@petrochenkov petrochenkov removed their assignment Jan 12, 2019
Centril added a commit to Centril/rust that referenced this issue Jan 15, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
bors added a commit that referenced this issue Jan 16, 2019
Rollup of 6 pull requests

Successful merges:

 - #56884 (rustdoc: overhaul code block lexing errors)
 - #57065 (Optimize try_mark_green and eliminate the lock on dep node colors)
 - #57107 (Add a regression test for mutating a non-mut #[thread_local])
 - #57268 (Add a target option "merge-functions", and a corresponding -Z flag (works around #57356))
 - #57551 (resolve: Add a test for issue #57539)
 - #57598 (Add missing unpretty option help message)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this issue Jan 17, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
Centril added a commit to Centril/rust that referenced this issue Jan 17, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
Centril added a commit to Centril/rust that referenced this issue Jan 17, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 18, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
bors added a commit that referenced this issue Jan 18, 2019
Rollup of 10 pull requests

Successful merges:

 - #56594 (Remove confusing comment about ideally using `!` for `c_void`)
 - #57340 (Use correct tracking issue for c_variadic)
 - #57357 (Cleanup PartialEq docs.)
 - #57551 (resolve: Add a test for issue #57539)
 - #57636 (Fix sources sidebar not showing up)
 - #57646 (Fixes text becoming invisible when element targetted)
 - #57654 (Add some links in std::fs.)
 - #57683 (Document Unpin in std::prelude documentation)
 - #57685 (Enhance `Pin` impl applicability for `PartialEq` and `PartialOrd`.)
 - #57710 (Fix non-clickable urls)

Failed merges:

r? @ghost
VardhanThigle pushed a commit to jethrogb/rust that referenced this issue Jan 31, 2019