Skip to content
Merged
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
5 changes: 3 additions & 2 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
from_entry(entry)
}

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

fn expand_abstract_consts<T: TypeFoldable<TyCtxt<'tcx>>>(self, t: T) -> T {
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_type_ir/src/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ pub trait Interner:
from_entry: impl FnOnce(&CanonicalParamEnvCacheEntry<Self>) -> R,
) -> R;

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

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

Expand Down Expand Up @@ -569,7 +571,7 @@ impl<I: Interner> search_graph::Cx for I {
fn with_global_cache<R>(self, f: impl FnOnce(&mut search_graph::GlobalCache<Self>) -> R) -> R {
I::with_global_cache(self, f)
}
fn evaluation_is_concurrent(&self) -> bool {
self.evaluation_is_concurrent()
fn assert_evaluation_is_concurrent(&self) {
self.assert_evaluation_is_concurrent()
}
}
4 changes: 2 additions & 2 deletions compiler/rustc_type_ir/src/search_graph/global_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ impl<X: Cx> GlobalCache<X> {
let with_overflow = WithOverflow { nested_goals, result };
let prev = entry.with_overflow.insert(required_depth, with_overflow);
if let Some(prev) = &prev {
assert!(cx.evaluation_is_concurrent());
cx.assert_evaluation_is_concurrent();
assert_eq!(cx.get_tracked(&prev.result), evaluation_result.result);
}
} else {
let prev = entry.success.replace(Success { required_depth, nested_goals, result });
if let Some(prev) = &prev {
assert!(cx.evaluation_is_concurrent());
cx.assert_evaluation_is_concurrent();
assert_eq!(cx.get_tracked(&prev.result), evaluation_result.result);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/search_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub trait Cx: Copy {

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

fn evaluation_is_concurrent(&self) -> bool;
fn assert_evaluation_is_concurrent(&self);
}

pub trait Delegate: Sized {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret::{anon_assoc#0}`
--> $DIR/unsupported.rs:22:25
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`
--> $DIR/unsupported.rs:30:25
|
LL | reuse to_reuse::opaque_ret;
| ^^^^^^^^^^
|
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
--> $DIR/unsupported.rs:22:25
--> $DIR/unsupported.rs:30:25
|
LL | reuse to_reuse::opaque_ret;
| ^^^^^^^^^^
= 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
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret` is compatible with trait definition
--> $DIR/unsupported.rs:22:25
= 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
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret` is compatible with trait definition
--> $DIR/unsupported.rs:30:25
|
LL | reuse to_reuse::opaque_ret;
| ^^^^^^^^^^
= 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

error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret::{anon_assoc#0}`
--> $DIR/unsupported.rs:25:24
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`
--> $DIR/unsupported.rs:33:24
|
LL | reuse ToReuse::opaque_ret;
| ^^^^^^^^^^
|
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
--> $DIR/unsupported.rs:25:24
--> $DIR/unsupported.rs:33:24
|
LL | reuse ToReuse::opaque_ret;
| ^^^^^^^^^^
= 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
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret` is compatible with trait definition
--> $DIR/unsupported.rs:25:24
= 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
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret` is compatible with trait definition
--> $DIR/unsupported.rs:33:24
|
LL | reuse ToReuse::opaque_ret;
| ^^^^^^^^^^
= 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

error: recursive delegation is not supported yet
--> $DIR/unsupported.rs:38:22
--> $DIR/unsupported.rs:46:22
|
LL | pub reuse to_reuse2::foo;
| --- callee defined here
Expand All @@ -46,7 +46,7 @@ LL | reuse to_reuse1::foo;
| ^^^

error[E0283]: type annotations needed
--> $DIR/unsupported.rs:48:18
--> $DIR/unsupported.rs:56:18
|
LL | reuse Trait::foo;
| ^^^ cannot infer type
Expand Down
51 changes: 51 additions & 0 deletions tests/ui/delegation/unsupported.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`
--> $DIR/unsupported.rs:30:25
|
LL | reuse to_reuse::opaque_ret;
| ^^^^^^^^^^
|
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
--> $DIR/unsupported.rs:30:25
|
LL | reuse to_reuse::opaque_ret;
| ^^^^^^^^^^
= 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
= note: cycle used when computing implied outlives bounds for `<u8 as opaque::ToReuse>::opaque_ret::{anon_assoc#0}` (hack disabled = false)
= 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

error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`
--> $DIR/unsupported.rs:33:24
|
LL | reuse ToReuse::opaque_ret;
| ^^^^^^^^^^
|
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
--> $DIR/unsupported.rs:33:24
|
LL | reuse ToReuse::opaque_ret;
| ^^^^^^^^^^
= 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
= note: cycle used when computing implied outlives bounds for `<u16 as opaque::ToReuse>::opaque_ret::{anon_assoc#0}` (hack disabled = false)
= 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

error: recursive delegation is not supported yet
--> $DIR/unsupported.rs:46:22
|
LL | pub reuse to_reuse2::foo;
| --- callee defined here
...
LL | reuse to_reuse1::foo;
| ^^^

error[E0283]: type annotations needed
--> $DIR/unsupported.rs:56:18
|
LL | reuse Trait::foo;
| ^^^ cannot infer type
|
= note: cannot satisfy `_: effects::Trait`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0283, E0391.
For more information about an error, try `rustc --explain E0283`.
8 changes: 8 additions & 0 deletions tests/ui/delegation/unsupported.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@ check-fail

// Next solver revision included because of trait-system-refactor-initiative#234.
// If we end up in a query cycle, it should be okay as long as results are the same.

#![feature(const_trait_impl)]
#![feature(c_variadic)]
#![feature(fn_delegation)]
Expand Down
Loading