Skip to content

Commit ae40d86

Browse files
Auto merge of #145108 - LorrensP-2158466:batched-import-resolution, r=<try>
Resolver: Batched Import Resolution
2 parents 35d55b3 + 0eba015 commit ae40d86

File tree

13 files changed

+297
-246
lines changed

13 files changed

+297
-246
lines changed

compiler/rustc_resolve/src/imports.rs

Lines changed: 213 additions & 127 deletions
Large diffs are not rendered by default.

compiler/rustc_resolve/src/lib.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,15 +1823,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18231823
f(self, MacroNS);
18241824
}
18251825

1826-
fn per_ns_cm<'r, F: FnMut(&mut CmResolver<'r, 'ra, 'tcx>, Namespace)>(
1827-
mut self: CmResolver<'r, 'ra, 'tcx>,
1828-
mut f: F,
1829-
) {
1830-
f(&mut self, TypeNS);
1831-
f(&mut self, ValueNS);
1832-
f(&mut self, MacroNS);
1833-
}
1834-
18351826
fn is_builtin_macro(&self, res: Res) -> bool {
18361827
self.get_macro(res).is_some_and(|macro_data| macro_data.ext.builtin_name.is_some())
18371828
}
@@ -2541,12 +2532,6 @@ mod ref_mut {
25412532
true => self.p,
25422533
}
25432534
}
2544-
2545-
/// Returns a mutable reference to the inner value without checking if
2546-
/// it's in a mutable state.
2547-
pub(crate) fn get_mut_unchecked(&mut self) -> &mut T {
2548-
self.p
2549-
}
25502535
}
25512536
}
25522537

tests/ui/imports/ambiguous-2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
//@ check-pass
21
//@ aux-build: ../ambiguous-1.rs
32
// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396
43

54
extern crate ambiguous_1;
65

76
fn main() {
8-
ambiguous_1::id();
7+
ambiguous_1::id(); //~ ERROR cannot find function `id` in crate `ambiguous_1`
98
//^ FIXME: `id` should be identified as an ambiguous item.
109
}

tests/ui/imports/ambiguous-2.stderr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0425]: cannot find function `id` in crate `ambiguous_1`
2+
--> $DIR/ambiguous-2.rs:7:18
3+
|
4+
LL | ambiguous_1::id();
5+
| ^^ not found in `ambiguous_1`
6+
|
7+
help: consider importing this function
8+
|
9+
LL + use std::process::id;
10+
|
11+
help: if you import `id`, refer to it directly
12+
|
13+
LL - ambiguous_1::id();
14+
LL + id();
15+
|
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0425`.

tests/ui/imports/ambiguous-4.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
//@ check-pass
21
//@ aux-build: ../ambiguous-4-extern.rs
32

43
extern crate ambiguous_4_extern;
54

65
fn main() {
7-
ambiguous_4_extern::id();
6+
ambiguous_4_extern::id(); //~ ERROR cannot find function `id` in crate `ambiguous_4_extern`
87
//^ FIXME: `id` should be identified as an ambiguous item.
98
}

tests/ui/imports/ambiguous-4.stderr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0425]: cannot find function `id` in crate `ambiguous_4_extern`
2+
--> $DIR/ambiguous-4.rs:6:25
3+
|
4+
LL | ambiguous_4_extern::id();
5+
| ^^ not found in `ambiguous_4_extern`
6+
|
7+
help: consider importing this function
8+
|
9+
LL + use std::process::id;
10+
|
11+
help: if you import `id`, refer to it directly
12+
|
13+
LL - ambiguous_4_extern::id();
14+
LL + id();
15+
|
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0425`.

tests/ui/imports/ambiguous-9.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ pub mod dsl {
44
mod range {
55
pub fn date_range() {}
66
}
7-
pub use self::range::*; //~ WARNING ambiguous glob re-exports
7+
pub use self::range::*;
88
use super::prelude::*;
99
}
1010

1111
pub mod prelude {
1212
mod t {
1313
pub fn date_range() {}
1414
}
15-
pub use self::t::*; //~ WARNING ambiguous glob re-exports
16-
pub use super::dsl::*;
15+
pub use self::t::*;
16+
pub use super::dsl::*; //~ WARNING ambiguous glob re-exports
1717
}
1818

1919
use dsl::*;
@@ -23,6 +23,4 @@ fn main() {
2323
date_range();
2424
//~^ ERROR `date_range` is ambiguous
2525
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
26-
//~| ERROR `date_range` is ambiguous
27-
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2826
}

tests/ui/imports/ambiguous-9.stderr

Lines changed: 17 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
warning: ambiguous glob re-exports
2-
--> $DIR/ambiguous-9.rs:7:13
2+
--> $DIR/ambiguous-9.rs:16:13
33
|
4-
LL | pub use self::range::*;
5-
| ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
6-
LL | use super::prelude::*;
7-
| ----------------- but the name `date_range` in the value namespace is also re-exported here
4+
LL | pub use self::t::*;
5+
| ---------- but the name `date_range` in the value namespace is also re-exported here
6+
LL | pub use super::dsl::*;
7+
| ^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
88
|
99
= note: `#[warn(ambiguous_glob_reexports)]` on by default
1010

@@ -18,50 +18,20 @@ LL | date_range();
1818
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
1919
= note: ambiguous because of multiple glob imports of a name in the same module
2020
note: `date_range` could refer to the function imported here
21-
--> $DIR/ambiguous-9.rs:7:13
21+
--> $DIR/ambiguous-9.rs:16:13
2222
|
23-
LL | pub use self::range::*;
24-
| ^^^^^^^^^^^^^^
23+
LL | pub use super::dsl::*;
24+
| ^^^^^^^^^^^^^
2525
= help: consider adding an explicit import of `date_range` to disambiguate
2626
note: `date_range` could also refer to the function imported here
27-
--> $DIR/ambiguous-9.rs:8:9
28-
|
29-
LL | use super::prelude::*;
30-
| ^^^^^^^^^^^^^^^^^
31-
= help: consider adding an explicit import of `date_range` to disambiguate
32-
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
33-
34-
warning: ambiguous glob re-exports
3527
--> $DIR/ambiguous-9.rs:15:13
3628
|
3729
LL | pub use self::t::*;
38-
| ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
39-
LL | pub use super::dsl::*;
40-
| ------------- but the name `date_range` in the value namespace is also re-exported here
41-
42-
error: `date_range` is ambiguous
43-
--> $DIR/ambiguous-9.rs:23:5
44-
|
45-
LL | date_range();
46-
| ^^^^^^^^^^ ambiguous name
47-
|
48-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
49-
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
50-
= note: ambiguous because of multiple glob imports of a name in the same module
51-
note: `date_range` could refer to the function imported here
52-
--> $DIR/ambiguous-9.rs:19:5
53-
|
54-
LL | use dsl::*;
55-
| ^^^^^^
56-
= help: consider adding an explicit import of `date_range` to disambiguate
57-
note: `date_range` could also refer to the function imported here
58-
--> $DIR/ambiguous-9.rs:20:5
59-
|
60-
LL | use prelude::*;
61-
| ^^^^^^^^^^
30+
| ^^^^^^^^^^
6231
= help: consider adding an explicit import of `date_range` to disambiguate
32+
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
6333

64-
error: aborting due to 2 previous errors; 2 warnings emitted
34+
error: aborting due to 1 previous error; 1 warning emitted
6535

6636
Future incompatibility report: Future breakage diagnostic:
6737
error: `date_range` is ambiguous
@@ -74,40 +44,16 @@ LL | date_range();
7444
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
7545
= note: ambiguous because of multiple glob imports of a name in the same module
7646
note: `date_range` could refer to the function imported here
77-
--> $DIR/ambiguous-9.rs:7:13
78-
|
79-
LL | pub use self::range::*;
80-
| ^^^^^^^^^^^^^^
81-
= help: consider adding an explicit import of `date_range` to disambiguate
82-
note: `date_range` could also refer to the function imported here
83-
--> $DIR/ambiguous-9.rs:8:9
84-
|
85-
LL | use super::prelude::*;
86-
| ^^^^^^^^^^^^^^^^^
87-
= help: consider adding an explicit import of `date_range` to disambiguate
88-
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
89-
90-
Future breakage diagnostic:
91-
error: `date_range` is ambiguous
92-
--> $DIR/ambiguous-9.rs:23:5
93-
|
94-
LL | date_range();
95-
| ^^^^^^^^^^ ambiguous name
96-
|
97-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
98-
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
99-
= note: ambiguous because of multiple glob imports of a name in the same module
100-
note: `date_range` could refer to the function imported here
101-
--> $DIR/ambiguous-9.rs:19:5
47+
--> $DIR/ambiguous-9.rs:16:13
10248
|
103-
LL | use dsl::*;
104-
| ^^^^^^
49+
LL | pub use super::dsl::*;
50+
| ^^^^^^^^^^^^^
10551
= help: consider adding an explicit import of `date_range` to disambiguate
10652
note: `date_range` could also refer to the function imported here
107-
--> $DIR/ambiguous-9.rs:20:5
53+
--> $DIR/ambiguous-9.rs:15:13
10854
|
109-
LL | use prelude::*;
110-
| ^^^^^^^^^^
55+
LL | pub use self::t::*;
56+
| ^^^^^^^^^^
11157
= help: consider adding an explicit import of `date_range` to disambiguate
11258
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
11359

tests/ui/imports/import-loop-2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
mod a {
2-
pub use crate::b::x;
2+
pub use crate::b::x; //~ ERROR unresolved import `crate::b::x`
33
}
44

55
mod b {
6-
pub use crate::a::x; //~ ERROR unresolved import `crate::a::x`
6+
pub use crate::a::x;
77

88
fn main() { let y = x; }
99
}

tests/ui/imports/import-loop-2.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0432]: unresolved import `crate::a::x`
2-
--> $DIR/import-loop-2.rs:6:13
1+
error[E0432]: unresolved import `crate::b::x`
2+
--> $DIR/import-loop-2.rs:2:13
33
|
4-
LL | pub use crate::a::x;
5-
| ^^^^^^^^^^^ no `x` in `a`
4+
LL | pub use crate::b::x;
5+
| ^^^^^^^^^^^ no `x` in `b`
66

77
error: aborting due to 1 previous error
88

0 commit comments

Comments
 (0)