Skip to content

Resolver: Batched Import Resolution #145108

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
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
308 changes: 198 additions & 110 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 @@ -2530,12 +2530,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
30 changes: 30 additions & 0 deletions fail.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![no_core]
#![feature(no_core)]
#![allow(internal_features)]
#![feature(lang_items)]

#[lang = "sized"]
pub trait Sized: MetaSized {}

#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}

#[lang = "pointee_sized"]
pub trait PointeeSized {}

mod core_simd {
mod vector {
pub struct Simd {}
}
pub mod simd {
pub use crate::core_simd::vector::*;
}
}

pub mod simd {
pub use crate::core_simd::simd::*;
}

mod fail {
use crate::simd::Simd;
}
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!
}
52 changes: 15 additions & 37 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,10 +18,10 @@ 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
Expand All @@ -35,33 +35,11 @@ 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)]` 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,13 +52,13 @@ 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
--> $DIR/ambiguous-9.rs:15:13
|
LL | use super::prelude::*;
| ^^^^^^^^^^^^^^^^^
Expand Down
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`.
20 changes: 10 additions & 10 deletions tests/ui/imports/reexports.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@ LL | pub use super::foo;
| ^^^^^^^^^^

error[E0603]: module import `foo` is private
--> $DIR/reexports.rs:36:22
--> $DIR/reexports.rs:37:22
|
LL | use crate::b::a::foo::S;
LL | use crate::b::b::foo::S as T;
| ^^^ private module import
|
note: the module import `foo` is defined here...
--> $DIR/reexports.rs:24:17
--> $DIR/reexports.rs:29:17
|
LL | pub use super::foo; // This is OK since the value `foo` is visible enough.
| ^^^^^^^^^^
LL | pub use super::*; // This is also OK since the value `foo` is visible enough.
| ^^^^^^^^
note: ...and refers to the module `foo` which is defined here
--> $DIR/reexports.rs:19:5
|
LL | mod foo {
| ^^^^^^^

error[E0603]: module import `foo` is private
--> $DIR/reexports.rs:37:22
--> $DIR/reexports.rs:36:22
|
LL | use crate::b::b::foo::S as T;
LL | use crate::b::a::foo::S;
| ^^^ private module import
|
note: the module import `foo` is defined here...
--> $DIR/reexports.rs:29:17
--> $DIR/reexports.rs:24:17
|
LL | pub use super::*; // This is also OK since the value `foo` is visible enough.
| ^^^^^^^^
LL | pub use super::foo; // This is OK since the value `foo` is visible enough.
| ^^^^^^^^^^
note: ...and refers to the module `foo` which is defined here
--> $DIR/reexports.rs:19:5
|
Expand Down
32 changes: 16 additions & 16 deletions tests/ui/shadowed/shadowed-use-visibility.stderr
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error[E0603]: module import `bar` is private
--> $DIR/shadowed-use-visibility.rs:9:21
error[E0603]: module import `f` is private
--> $DIR/shadowed-use-visibility.rs:15:10
|
LL | use crate::foo::bar::f as g;
| ^^^ private module import
LL | use bar::f::f;
| ^ private module import
|
note: the module import `bar` is defined here...
--> $DIR/shadowed-use-visibility.rs:4:9
note: the module import `f` is defined here...
--> $DIR/shadowed-use-visibility.rs:11:9
|
LL | use crate::foo as bar;
| ^^^^^^^^^^^^^^^^^
LL | use crate::foo as f;
| ^^^^^^^^^^^^^^^
note: ...and refers to the module `foo` which is defined here
--> $DIR/shadowed-use-visibility.rs:1:1
|
LL | mod foo {
| ^^^^^^^

error[E0603]: module import `f` is private
--> $DIR/shadowed-use-visibility.rs:15:10
error[E0603]: module import `bar` is private
--> $DIR/shadowed-use-visibility.rs:9:21
|
LL | use bar::f::f;
| ^ private module import
LL | use crate::foo::bar::f as g;
| ^^^ private module import
|
note: the module import `f` is defined here...
--> $DIR/shadowed-use-visibility.rs:11:9
note: the module import `bar` is defined here...
--> $DIR/shadowed-use-visibility.rs:4:9
|
LL | use crate::foo as f;
| ^^^^^^^^^^^^^^^
LL | use crate::foo as bar;
| ^^^^^^^^^^^^^^^^^
note: ...and refers to the module `foo` which is defined here
--> $DIR/shadowed-use-visibility.rs:1:1
|
Expand Down
Loading