Skip to content

Commit 0799524

Browse files
committed
Auto merge of #145108 - LorrensP-2158466:batched-import-resolution, r=<try>
Resolver: Batched Import Resolution
2 parents b2fabe3 + 5cd22e1 commit 0799524

File tree

17 files changed

+318
-251
lines changed

17 files changed

+318
-251
lines changed

‎compiler/rustc_resolve/src/imports.rs‎

Lines changed: 236 additions & 131 deletions
Large diffs are not rendered by default.

‎compiler/rustc_resolve/src/lib.rs‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,16 +2652,10 @@ mod ref_mut {
26522652
#[track_caller]
26532653
pub(crate) fn get_mut(&mut self) -> &mut T {
26542654
match self.mutable {
2655-
false => panic!("Can't mutably borrow speculative resolver"),
2655+
false => panic!("can't mutably borrow speculative resolver"),
26562656
true => self.p,
26572657
}
26582658
}
2659-
2660-
/// Returns a mutable reference to the inner value without checking if
2661-
/// it's in a mutable state.
2662-
pub(crate) fn get_mut_unchecked(&mut self) -> &mut T {
2663-
self.p
2664-
}
26652659
}
26662660

26672661
/// A wrapper around a [`Cell`] that only allows mutation based on a condition in the resolver.
@@ -2685,12 +2679,12 @@ mod ref_mut {
26852679
self.0.get()
26862680
}
26872681

2688-
pub(crate) fn update_unchecked(&self, f: impl FnOnce(T) -> T)
2682+
pub(crate) fn update<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>, f: impl FnOnce(T) -> T)
26892683
where
26902684
T: Copy,
26912685
{
26922686
let old = self.get();
2693-
self.set_unchecked(f(old));
2687+
self.set(f(old), r);
26942688
}
26952689
}
26962690

@@ -2699,7 +2693,10 @@ mod ref_mut {
26992693
CmCell(Cell::new(value))
27002694
}
27012695

2702-
pub(crate) fn set_unchecked(&self, val: T) {
2696+
pub(crate) fn set<'ra, 'tcx>(&self, val: T, r: &Resolver<'ra, 'tcx>) {
2697+
if r.assert_speculative {
2698+
panic!("not allowed to mutate a `CmCell` during speculative resolution")
2699+
}
27032700
self.0.set(val);
27042701
}
27052702

@@ -2725,16 +2722,26 @@ mod ref_mut {
27252722
#[track_caller]
27262723
pub(crate) fn borrow_mut<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>) -> RefMut<'_, T> {
27272724
if r.assert_speculative {
2728-
panic!("Not allowed to mutably borrow a CmRefCell during speculative resolution");
2725+
panic!("not allowed to mutably borrow a `CmRefCell` during speculative resolution");
27292726
}
2730-
self.borrow_mut_unchecked()
2727+
self.0.borrow_mut()
27312728
}
27322729

2733-
#[track_caller]
27342730
pub(crate) fn try_borrow_mut_unchecked(&self) -> Result<RefMut<'_, T>, BorrowMutError> {
27352731
self.0.try_borrow_mut()
27362732
}
27372733

2734+
#[track_caller]
2735+
pub(crate) fn try_borrow_mut<'ra, 'tcx>(
2736+
&self,
2737+
r: &Resolver<'ra, 'tcx>,
2738+
) -> Result<RefMut<'_, T>, BorrowMutError> {
2739+
if r.assert_speculative {
2740+
panic!("not allowed to mutably borrow a `CmRefCell` during speculative resolution");
2741+
}
2742+
self.0.try_borrow_mut()
2743+
}
2744+
27382745
#[track_caller]
27392746
pub(crate) fn borrow(&self) -> Ref<'_, T> {
27402747
self.0.borrow()
@@ -2744,7 +2751,7 @@ mod ref_mut {
27442751
impl<T: Default> CmRefCell<T> {
27452752
pub(crate) fn take<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>) -> T {
27462753
if r.assert_speculative {
2747-
panic!("Not allowed to mutate a CmRefCell during speculative resolution");
2754+
panic!("not allowed to mutate a CmRefCell during speculative resolution");
27482755
}
27492756
self.0.take()
27502757
}

‎compiler/rustc_span/src/symbol.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ symbols! {
293293
ResumeTy,
294294
Reverse,
295295
Rust,
296+
// Temporary name for the rust_embed hack introduced in #145108
297+
RustEmbed,
296298
RustaceansAreAwesome,
297299
RwLock,
298300
RwLockReadGuard,

‎src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use hir_def::FunctionId;
44
use intern::sym;
5-
use rustc_type_ir::inherent::{Region as _, Ty as _};
5+
use rustc_type_ir::inherent::Region as _;
66

77
use super::*;
88
use crate::{

‎tests/ui/imports/ambiguous-14.stderr‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ LL | g::foo();
66
|
77
= note: ambiguous because of multiple glob imports of a name in the same module
88
note: `foo` could refer to the function imported here
9-
--> $DIR/ambiguous-14.rs:18:13
9+
--> $DIR/ambiguous-14.rs:13:13
1010
|
1111
LL | pub use a::*;
1212
| ^^^^
1313
= help: consider adding an explicit import of `foo` to disambiguate
1414
note: `foo` could also refer to the function imported here
15-
--> $DIR/ambiguous-14.rs:19:13
15+
--> $DIR/ambiguous-14.rs:14:13
1616
|
17-
LL | pub use f::*;
17+
LL | pub use b::*;
1818
| ^^^^
1919
= help: consider adding an explicit import of `foo` to disambiguate
2020
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@@ -32,15 +32,15 @@ LL | g::foo();
3232
|
3333
= note: ambiguous because of multiple glob imports of a name in the same module
3434
note: `foo` could refer to the function imported here
35-
--> $DIR/ambiguous-14.rs:18:13
35+
--> $DIR/ambiguous-14.rs:13:13
3636
|
3737
LL | pub use a::*;
3838
| ^^^^
3939
= help: consider adding an explicit import of `foo` to disambiguate
4040
note: `foo` could also refer to the function imported here
41-
--> $DIR/ambiguous-14.rs:19:13
41+
--> $DIR/ambiguous-14.rs:14:13
4242
|
43-
LL | pub use f::*;
43+
LL | pub use b::*;
4444
| ^^^^
4545
= help: consider adding an explicit import of `foo` to disambiguate
4646
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

‎tests/ui/imports/ambiguous-9.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ 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::*;

‎tests/ui/imports/ambiguous-9.stderr‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ LL | use super::prelude::*;
3232
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
3333

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

4242
error: `date_range` is ambiguous
4343
--> $DIR/ambiguous-9.rs:23:5
@@ -47,16 +47,16 @@ LL | date_range();
4747
|
4848
= note: ambiguous because of multiple glob imports of a name in the same module
4949
note: `date_range` could refer to the function imported here
50-
--> $DIR/ambiguous-9.rs:19:5
50+
--> $DIR/ambiguous-9.rs:16:13
5151
|
52-
LL | use dsl::*;
53-
| ^^^^^^
52+
LL | pub use super::dsl::*;
53+
| ^^^^^^^^^^^^^
5454
= help: consider adding an explicit import of `date_range` to disambiguate
5555
note: `date_range` could also refer to the function imported here
56-
--> $DIR/ambiguous-9.rs:20:5
56+
--> $DIR/ambiguous-9.rs:15:13
5757
|
58-
LL | use prelude::*;
59-
| ^^^^^^^^^^
58+
LL | pub use self::t::*;
59+
| ^^^^^^^^^^
6060
= help: consider adding an explicit import of `date_range` to disambiguate
6161
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
6262
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
@@ -96,16 +96,16 @@ LL | date_range();
9696
|
9797
= note: ambiguous because of multiple glob imports of a name in the same module
9898
note: `date_range` could refer to the function imported here
99-
--> $DIR/ambiguous-9.rs:19:5
99+
--> $DIR/ambiguous-9.rs:16:13
100100
|
101-
LL | use dsl::*;
102-
| ^^^^^^
101+
LL | pub use super::dsl::*;
102+
| ^^^^^^^^^^^^^
103103
= help: consider adding an explicit import of `date_range` to disambiguate
104104
note: `date_range` could also refer to the function imported here
105-
--> $DIR/ambiguous-9.rs:20:5
105+
--> $DIR/ambiguous-9.rs:15:13
106106
|
107-
LL | use prelude::*;
108-
| ^^^^^^^^^^
107+
LL | pub use self::t::*;
108+
| ^^^^^^^^^^
109109
= help: consider adding an explicit import of `date_range` to disambiguate
110110
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
111111
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>

‎tests/ui/imports/ambiguous-panic-globvsglob.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ fn foo() {
1818
panic!();
1919
//~^ WARN: `panic` is ambiguous [ambiguous_panic_imports]
2020
//~| WARN: this was previously accepted by the compiler
21-
//~| ERROR: `panic` is ambiguous [ambiguous_glob_imports]
22-
//~| WARN: this was previously accepted by the compiler
21+
//~| ERROR: `panic` is ambiguous
2322
}
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `panic` is ambiguous
1+
error[E0659]: `panic` is ambiguous
22
--> $DIR/ambiguous-panic-globvsglob.rs:18:5
33
|
44
LL | panic!();
@@ -17,9 +17,6 @@ note: `panic` could also refer to the macro imported here
1717
LL | use m2::*;
1818
| ^^^^^
1919
= help: consider adding an explicit import of `panic` to disambiguate
20-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21-
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22-
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320

2421
warning: `panic` is ambiguous
2522
--> $DIR/ambiguous-panic-globvsglob.rs:18:5
@@ -42,27 +39,4 @@ note: `panic` could also refer to a macro from prelude
4239

4340
error: aborting due to 1 previous error; 1 warning emitted
4441

45-
Future incompatibility report: Future breakage diagnostic:
46-
error: `panic` is ambiguous
47-
--> $DIR/ambiguous-panic-globvsglob.rs:18:5
48-
|
49-
LL | panic!();
50-
| ^^^^^ ambiguous name
51-
|
52-
= note: ambiguous because of multiple glob imports of a name in the same module
53-
note: `panic` could refer to the macro imported here
54-
--> $DIR/ambiguous-panic-globvsglob.rs:12:9
55-
|
56-
LL | use m1::*;
57-
| ^^^^^
58-
= help: consider adding an explicit import of `panic` to disambiguate
59-
note: `panic` could also refer to the macro imported here
60-
--> $DIR/ambiguous-panic-globvsglob.rs:13:9
61-
|
62-
LL | use m2::*;
63-
| ^^^^^
64-
= help: consider adding an explicit import of `panic` to disambiguate
65-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
66-
= note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
67-
= note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
68-
42+
For more information about this error, try `rustc --explain E0659`.

‎tests/ui/imports/duplicate.stderr‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ LL | g::foo();
7676
|
7777
= note: ambiguous because of multiple glob imports of a name in the same module
7878
note: `foo` could refer to the function imported here
79-
--> $DIR/duplicate.rs:29:13
79+
--> $DIR/duplicate.rs:24:13
8080
|
8181
LL | pub use crate::a::*;
8282
| ^^^^^^^^^^^
8383
= help: consider adding an explicit import of `foo` to disambiguate
8484
note: `foo` could also refer to the function imported here
85-
--> $DIR/duplicate.rs:30:13
85+
--> $DIR/duplicate.rs:25:13
8686
|
87-
LL | pub use crate::f::*;
87+
LL | pub use crate::b::*;
8888
| ^^^^^^^^^^^
8989
= help: consider adding an explicit import of `foo` to disambiguate
9090
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@@ -104,15 +104,15 @@ LL | g::foo();
104104
|
105105
= note: ambiguous because of multiple glob imports of a name in the same module
106106
note: `foo` could refer to the function imported here
107-
--> $DIR/duplicate.rs:29:13
107+
--> $DIR/duplicate.rs:24:13
108108
|
109109
LL | pub use crate::a::*;
110110
| ^^^^^^^^^^^
111111
= help: consider adding an explicit import of `foo` to disambiguate
112112
note: `foo` could also refer to the function imported here
113-
--> $DIR/duplicate.rs:30:13
113+
--> $DIR/duplicate.rs:25:13
114114
|
115-
LL | pub use crate::f::*;
115+
LL | pub use crate::b::*;
116116
| ^^^^^^^^^^^
117117
= help: consider adding an explicit import of `foo` to disambiguate
118118
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

0 commit comments

Comments
 (0)