Skip to content

Commit dade9fe

Browse files
authored
Rollup merge of #147251 - jackh726:global-cache-non-concurrent-change, r=lcnr
Do not assert that a change in global cache only happens when concurrent Fixes rust-lang/trait-system-refactor-initiative#234 I think it should just be safe to remove this assert (rather than delaying a bug). If the previous and current result are the same, I wouldn't expect issues. r? lcnr
2 parents c389e2e + 55aeb17 commit dade9fe

File tree

7 files changed

+84
-22
lines changed

7 files changed

+84
-22
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
207207
from_entry(entry)
208208
}
209209

210-
fn evaluation_is_concurrent(&self) -> bool {
211-
self.sess.threads() > 1
210+
fn assert_evaluation_is_concurrent(&self) {
211+
// Turns out, the assumption for this function isn't perfect.
212+
// See trait-system-refactor-initiative#234.
212213
}
213214

214215
fn expand_abstract_consts<T: TypeFoldable<TyCtxt<'tcx>>>(self, t: T) -> T {

compiler/rustc_type_ir/src/interner.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ pub trait Interner:
183183
from_entry: impl FnOnce(&CanonicalParamEnvCacheEntry<Self>) -> R,
184184
) -> R;
185185

186-
fn evaluation_is_concurrent(&self) -> bool;
186+
/// Useful for testing. If a cache entry is replaced, this should
187+
/// (in theory) only happen when concurrent.
188+
fn assert_evaluation_is_concurrent(&self);
187189

188190
fn expand_abstract_consts<T: TypeFoldable<Self>>(self, t: T) -> T;
189191

@@ -567,7 +569,7 @@ impl<I: Interner> search_graph::Cx for I {
567569
fn with_global_cache<R>(self, f: impl FnOnce(&mut search_graph::GlobalCache<Self>) -> R) -> R {
568570
I::with_global_cache(self, f)
569571
}
570-
fn evaluation_is_concurrent(&self) -> bool {
571-
self.evaluation_is_concurrent()
572+
fn assert_evaluation_is_concurrent(&self) {
573+
self.assert_evaluation_is_concurrent()
572574
}
573575
}

compiler/rustc_type_ir/src/search_graph/global_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ impl<X: Cx> GlobalCache<X> {
5656
let with_overflow = WithOverflow { nested_goals, result };
5757
let prev = entry.with_overflow.insert(required_depth, with_overflow);
5858
if let Some(prev) = &prev {
59-
assert!(cx.evaluation_is_concurrent());
59+
cx.assert_evaluation_is_concurrent();
6060
assert_eq!(cx.get_tracked(&prev.result), evaluation_result.result);
6161
}
6262
} else {
6363
let prev = entry.success.replace(Success { required_depth, nested_goals, result });
6464
if let Some(prev) = &prev {
65-
assert!(cx.evaluation_is_concurrent());
65+
cx.assert_evaluation_is_concurrent();
6666
assert_eq!(cx.get_tracked(&prev.result), evaluation_result.result);
6767
}
6868
}

compiler/rustc_type_ir/src/search_graph/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub trait Cx: Copy {
5353

5454
fn with_global_cache<R>(self, f: impl FnOnce(&mut GlobalCache<Self>) -> R) -> R;
5555

56-
fn evaluation_is_concurrent(&self) -> bool;
56+
fn assert_evaluation_is_concurrent(&self);
5757
}
5858

5959
pub trait Delegate: Sized {

tests/ui/delegation/unsupported.stderr renamed to tests/ui/delegation/unsupported.current.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret::{anon_assoc#0}`
2-
--> $DIR/unsupported.rs:22:25
1+
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`
2+
--> $DIR/unsupported.rs:30:25
33
|
44
LL | reuse to_reuse::opaque_ret;
55
| ^^^^^^^^^^
66
|
77
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
8-
--> $DIR/unsupported.rs:22:25
8+
--> $DIR/unsupported.rs:30:25
99
|
1010
LL | reuse to_reuse::opaque_ret;
1111
| ^^^^^^^^^^
12-
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret::{anon_assoc#0}`, completing the cycle
13-
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret` is compatible with trait definition
14-
--> $DIR/unsupported.rs:22:25
12+
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`, completing the cycle
13+
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret` is compatible with trait definition
14+
--> $DIR/unsupported.rs:30:25
1515
|
1616
LL | reuse to_reuse::opaque_ret;
1717
| ^^^^^^^^^^
1818
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
1919

20-
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret::{anon_assoc#0}`
21-
--> $DIR/unsupported.rs:25:24
20+
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`
21+
--> $DIR/unsupported.rs:33:24
2222
|
2323
LL | reuse ToReuse::opaque_ret;
2424
| ^^^^^^^^^^
2525
|
2626
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
27-
--> $DIR/unsupported.rs:25:24
27+
--> $DIR/unsupported.rs:33:24
2828
|
2929
LL | reuse ToReuse::opaque_ret;
3030
| ^^^^^^^^^^
31-
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
32-
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret` is compatible with trait definition
33-
--> $DIR/unsupported.rs:25:24
31+
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
32+
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret` is compatible with trait definition
33+
--> $DIR/unsupported.rs:33:24
3434
|
3535
LL | reuse ToReuse::opaque_ret;
3636
| ^^^^^^^^^^
3737
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
3838

3939
error: recursive delegation is not supported yet
40-
--> $DIR/unsupported.rs:38:22
40+
--> $DIR/unsupported.rs:46:22
4141
|
4242
LL | pub reuse to_reuse2::foo;
4343
| --- callee defined here
@@ -46,7 +46,7 @@ LL | reuse to_reuse1::foo;
4646
| ^^^
4747

4848
error[E0283]: type annotations needed
49-
--> $DIR/unsupported.rs:48:18
49+
--> $DIR/unsupported.rs:56:18
5050
|
5151
LL | reuse Trait::foo;
5252
| ^^^ cannot infer type
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`
2+
--> $DIR/unsupported.rs:30:25
3+
|
4+
LL | reuse to_reuse::opaque_ret;
5+
| ^^^^^^^^^^
6+
|
7+
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
8+
--> $DIR/unsupported.rs:30:25
9+
|
10+
LL | reuse to_reuse::opaque_ret;
11+
| ^^^^^^^^^^
12+
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`, completing the cycle
13+
= note: cycle used when computing implied outlives bounds for `<u8 as opaque::ToReuse>::opaque_ret::{anon_assoc#0}` (hack disabled = false)
14+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
15+
16+
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`
17+
--> $DIR/unsupported.rs:33:24
18+
|
19+
LL | reuse ToReuse::opaque_ret;
20+
| ^^^^^^^^^^
21+
|
22+
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
23+
--> $DIR/unsupported.rs:33:24
24+
|
25+
LL | reuse ToReuse::opaque_ret;
26+
| ^^^^^^^^^^
27+
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
28+
= note: cycle used when computing implied outlives bounds for `<u16 as opaque::ToReuse>::opaque_ret::{anon_assoc#0}` (hack disabled = false)
29+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
30+
31+
error: recursive delegation is not supported yet
32+
--> $DIR/unsupported.rs:46:22
33+
|
34+
LL | pub reuse to_reuse2::foo;
35+
| --- callee defined here
36+
...
37+
LL | reuse to_reuse1::foo;
38+
| ^^^
39+
40+
error[E0283]: type annotations needed
41+
--> $DIR/unsupported.rs:56:18
42+
|
43+
LL | reuse Trait::foo;
44+
| ^^^ cannot infer type
45+
|
46+
= note: cannot satisfy `_: effects::Trait`
47+
48+
error: aborting due to 4 previous errors
49+
50+
Some errors have detailed explanations: E0283, E0391.
51+
For more information about an error, try `rustc --explain E0283`.

tests/ui/delegation/unsupported.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
//@ check-fail
5+
6+
// Next solver revision included because of trait-system-refactor-initiative#234.
7+
// If we end up in a query cycle, it should be okay as long as results are the same.
8+
19
#![feature(const_trait_impl)]
210
#![feature(c_variadic)]
311
#![feature(fn_delegation)]

0 commit comments

Comments
 (0)