Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
305 changes: 196 additions & 109 deletions compiler/rustc_resolve/src/imports.rs

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2541,12 +2541,6 @@ mod ref_mut {
true => self.p,
}
}

/// Returns a mutable reference to the inner value without checking if
/// it's in a mutable state.
pub(crate) fn get_mut_unchecked(&mut self) -> &mut T {
self.p
}
}
}

Expand Down
8 changes: 3 additions & 5 deletions tests/ui/imports/ambiguous-9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ pub mod dsl {
mod range {
pub fn date_range() {}
}
pub use self::range::*; //~ WARNING ambiguous glob re-exports
pub use self::range::*;
use super::prelude::*;
}

pub mod prelude {
mod t {
pub fn date_range() {}
}
pub use self::t::*; //~ WARNING ambiguous glob re-exports
pub use super::dsl::*;
pub use self::t::*;
pub use super::dsl::*; //~ WARNING ambiguous glob re-exports
}

use dsl::*;
Expand All @@ -23,6 +23,4 @@ fn main() {
date_range();
//~^ ERROR `date_range` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
//~| ERROR `date_range` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}
88 changes: 17 additions & 71 deletions tests/ui/imports/ambiguous-9.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
warning: ambiguous glob re-exports
--> $DIR/ambiguous-9.rs:7:13
--> $DIR/ambiguous-9.rs:16:13
|
LL | pub use self::range::*;
| ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
LL | use super::prelude::*;
| ----------------- but the name `date_range` in the value namespace is also re-exported here
LL | pub use self::t::*;
| ---------- but the name `date_range` in the value namespace is also re-exported here
LL | pub use super::dsl::*;
| ^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
|
= note: `#[warn(ambiguous_glob_reexports)]` on by default

Expand All @@ -18,50 +18,20 @@ LL | date_range();
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `date_range` could refer to the function imported here
--> $DIR/ambiguous-9.rs:7:13
--> $DIR/ambiguous-9.rs:16:13
|
LL | pub use self::range::*;
| ^^^^^^^^^^^^^^
LL | pub use super::dsl::*;
| ^^^^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
note: `date_range` could also refer to the function imported here
--> $DIR/ambiguous-9.rs:8:9
|
LL | use super::prelude::*;
| ^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default

warning: ambiguous glob re-exports
--> $DIR/ambiguous-9.rs:15:13
|
LL | pub use self::t::*;
| ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
LL | pub use super::dsl::*;
| ------------- but the name `date_range` in the value namespace is also re-exported here

error: `date_range` is ambiguous
--> $DIR/ambiguous-9.rs:23:5
|
LL | date_range();
| ^^^^^^^^^^ ambiguous name
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `date_range` could refer to the function imported here
--> $DIR/ambiguous-9.rs:19:5
|
LL | use dsl::*;
| ^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
note: `date_range` could also refer to the function imported here
--> $DIR/ambiguous-9.rs:20:5
|
LL | use prelude::*;
| ^^^^^^^^^^
| ^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default

error: aborting due to 2 previous errors; 2 warnings emitted
error: aborting due to 1 previous error; 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
error: `date_range` is ambiguous
Expand All @@ -74,40 +44,16 @@ LL | date_range();
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `date_range` could refer to the function imported here
--> $DIR/ambiguous-9.rs:7:13
|
LL | pub use self::range::*;
| ^^^^^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
note: `date_range` could also refer to the function imported here
--> $DIR/ambiguous-9.rs:8:9
|
LL | use super::prelude::*;
| ^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default

Future breakage diagnostic:
error: `date_range` is ambiguous
--> $DIR/ambiguous-9.rs:23:5
|
LL | date_range();
| ^^^^^^^^^^ ambiguous name
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
= note: ambiguous because of multiple glob imports of a name in the same module
note: `date_range` could refer to the function imported here
--> $DIR/ambiguous-9.rs:19:5
--> $DIR/ambiguous-9.rs:16:13
|
LL | use dsl::*;
| ^^^^^^
LL | pub use super::dsl::*;
| ^^^^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
note: `date_range` could also refer to the function imported here
--> $DIR/ambiguous-9.rs:20:5
--> $DIR/ambiguous-9.rs:15:13
|
LL | use prelude::*;
| ^^^^^^^^^^
LL | pub use self::t::*;
| ^^^^^^^^^^
= help: consider adding an explicit import of `date_range` to disambiguate
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default

2 changes: 1 addition & 1 deletion tests/ui/imports/glob-conflict-cross-crate-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
glob_conflict::f(); //~ ERROR cannot find function `f` in crate `glob_conflict`
//^ FIXME: `glob_conflict::f` should raise an
// ambiguity error instead of a not found error.
glob_conflict::glob::f(); //~ ERROR cannot find function `f` in module `glob_conflict::glob`
glob_conflict::glob::f();
//^ FIXME: `glob_conflict::glob::f` should raise an
// ambiguity error instead of a not found error.
}
16 changes: 10 additions & 6 deletions tests/ui/imports/glob-conflict-cross-crate-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ error[E0425]: cannot find function `f` in crate `glob_conflict`
|
LL | glob_conflict::f();
| ^ not found in `glob_conflict`

error[E0425]: cannot find function `f` in module `glob_conflict::glob`
--> $DIR/glob-conflict-cross-crate-1.rs:9:26
|
LL | glob_conflict::glob::f();
| ^ not found in `glob_conflict::glob`
help: consider importing this function
|
LL + use glob_conflict::glob::f;
|
help: if you import `f`, refer to it directly
|
LL - glob_conflict::f();
LL + f();
|

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0425`.
4 changes: 2 additions & 2 deletions tests/ui/imports/import-loop-2.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
mod a {
pub use crate::b::x;
pub use crate::b::x; //~ ERROR unresolved import `crate::b::x` [E0432]
}

mod b {
pub use crate::a::x; //~ ERROR unresolved import `crate::a::x`
pub use crate::a::x;

fn main() { let y = x; }
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/imports/import-loop-2.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0432]: unresolved import `crate::a::x`
--> $DIR/import-loop-2.rs:6:13
error[E0432]: unresolved import `crate::b::x`
--> $DIR/import-loop-2.rs:2:13
|
LL | pub use crate::a::x;
| ^^^^^^^^^^^ no `x` in `a`
LL | pub use crate::b::x;
| ^^^^^^^^^^^ no `x` in `b`

error: aborting due to 1 previous error

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/imports/import4.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod a { pub use crate::b::foo; }
mod b { pub use crate::a::foo; } //~ ERROR unresolved import `crate::a::foo`
mod a { pub use crate::b::foo; } //~ ERROR unresolved import `crate::b::foo`
mod b { pub use crate::a::foo; }

fn main() { println!("loop"); }
8 changes: 4 additions & 4 deletions tests/ui/imports/import4.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0432]: unresolved import `crate::a::foo`
--> $DIR/import4.rs:2:17
error[E0432]: unresolved import `crate::b::foo`
--> $DIR/import4.rs:1:17
|
LL | mod b { pub use crate::a::foo; }
| ^^^^^^^^^^^^^ no `foo` in `a`
LL | mod a { pub use crate::b::foo; }
| ^^^^^^^^^^^^^ no `foo` in `b`

error: aborting due to 1 previous error

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/imports/issue-109148.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ macro_rules! m {

m!();

use std::mem; //~ ERROR `std` is ambiguous
use ::std::mem as _; //~ ERROR `std` is ambiguous
use std::mem; //~ ERROR `std` is ambiguous [E0659]
use ::std::mem as _; //~ ERROR `std` is ambiguous [E0659]

fn main() {}
41 changes: 40 additions & 1 deletion tests/ui/imports/issue-109148.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,45 @@ LL | m!();
| ---- in this macro invocation
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors
error[E0659]: `std` is ambiguous
--> $DIR/issue-109148.rs:13:5
|
LL | use std::mem;
| ^^^ ambiguous name
|
= note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
= note: `std` could refer to a built-in crate
note: `std` could also refer to the crate imported here
--> $DIR/issue-109148.rs:6:9
|
LL | extern crate core as std;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | m!();
| ---- in this macro invocation
= help: use `crate::std` to refer to this crate unambiguously
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0659]: `std` is ambiguous
--> $DIR/issue-109148.rs:14:7
|
LL | use ::std::mem as _;
| ^^^ ambiguous name
|
= note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
= note: `std` could refer to a built-in crate
note: `std` could also refer to the crate imported here
--> $DIR/issue-109148.rs:6:9
|
LL | extern crate core as std;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | m!();
| ---- in this macro invocation
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0659`.
6 changes: 3 additions & 3 deletions tests/ui/imports/issue-56125.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

mod m1 {
use issue_56125::last_segment::*;
//~^ ERROR `issue_56125` is ambiguous
//~^ ERROR `issue_56125` is ambiguous [E0659]
}

mod m2 {
use issue_56125::non_last_segment::non_last_segment::*;
//~^ ERROR `issue_56125` is ambiguous
//~^ ERROR `issue_56125` is ambiguous [E0659]
}

mod m3 {
mod empty {}
use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125`
use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
use issue_56125::*; //~ ERROR `issue_56125` is ambiguous [E0659]
}

fn main() {}
56 changes: 55 additions & 1 deletion tests/ui/imports/issue-56125.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,59 @@ LL | use issue_56125::non_last_segment::non_last_segment::*;
= help: consider adding an explicit import of `issue_56125` to disambiguate
= help: or use `self::issue_56125` to refer to this module unambiguously

error[E0659]: `issue_56125` is ambiguous
--> $DIR/issue-56125.rs:6:9
|
LL | use issue_56125::last_segment::*;
| ^^^^^^^^^^^ ambiguous name
|
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
= note: `issue_56125` could refer to a crate passed with `--extern`
= help: use `::issue_56125` to refer to this crate unambiguously
note: `issue_56125` could also refer to the module imported here
--> $DIR/issue-56125.rs:6:9
|
LL | use issue_56125::last_segment::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `issue_56125` to disambiguate
= help: or use `self::issue_56125` to refer to this module unambiguously
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0659]: `issue_56125` is ambiguous
--> $DIR/issue-56125.rs:11:9
|
LL | use issue_56125::non_last_segment::non_last_segment::*;
| ^^^^^^^^^^^ ambiguous name
|
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
= note: `issue_56125` could refer to a crate passed with `--extern`
= help: use `::issue_56125` to refer to this crate unambiguously
note: `issue_56125` could also refer to the module imported here
--> $DIR/issue-56125.rs:11:9
|
LL | use issue_56125::non_last_segment::non_last_segment::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: consider adding an explicit import of `issue_56125` to disambiguate
= help: or use `self::issue_56125` to refer to this module unambiguously
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0659]: `issue_56125` is ambiguous
--> $DIR/issue-56125.rs:18:9
|
LL | use issue_56125::*;
| ^^^^^^^^^^^ ambiguous name
|
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
= note: `issue_56125` could refer to a crate passed with `--extern`
= help: use `::issue_56125` to refer to this crate unambiguously
note: `issue_56125` could also refer to the module imported here
--> $DIR/issue-56125.rs:18:9
|
LL | use issue_56125::*;
| ^^^^^^^^^^^^^^
= help: consider adding an explicit import of `issue_56125` to disambiguate
= help: or use `self::issue_56125` to refer to this module unambiguously

error[E0659]: `issue_56125` is ambiguous
--> $DIR/issue-56125.rs:18:9
|
Expand All @@ -70,8 +123,9 @@ LL | use issue_56125::*;
| ^^^^^^^^^^^^^^
= help: consider adding an explicit import of `issue_56125` to disambiguate
= help: or use `self::issue_56125` to refer to this module unambiguously
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 4 previous errors
error: aborting due to 7 previous errors

Some errors have detailed explanations: E0432, E0659.
For more information about an error, try `rustc --explain E0432`.
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-57539.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ edition:2018

mod core {
use core; //~ ERROR `core` is ambiguous
use core; //~ ERROR `core` is ambiguous [E0659]
use crate::*;
}

Expand Down
Loading
Loading