-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #130094 - workingjubilee:concurrency-is-real, r=lcnr
Inform the solver if evaluation is concurrent Parallel compilation of a program can cause unexpected event sequencing. Inform the solver when this is true so it can skip invalid asserts.
- Loading branch information
Showing
6 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/ui/traits/next-solver/global-cache-and-parallel-frontend.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//@ compile-flags: -Zthreads=16 | ||
|
||
// original issue: https://github.com/rust-lang/rust/issues/129112 | ||
// Previously, the "next" solver asserted that each successful solution is only obtained once. | ||
// This test exhibits a repro that, with next-solver + -Zthreads, triggered that old assert. | ||
// In the presence of multithreaded solving, it's possible to concurrently evaluate things twice, | ||
// which leads to replacing already-solved solutions in the global solution cache! | ||
// We assume this is fine if we check to make sure they are solved the same way each time. | ||
|
||
// This test only nondeterministically fails but that's okay, as it will be rerun by CI many times, | ||
// so it should almost always fail before anything is merged. As other thread tests already exist, | ||
// we already face this difficulty, probably. If we need to fix this by reducing the error margin, | ||
// we should improve compiletest. | ||
|
||
#[derive(Clone, Eq)] //~ ERROR [E0277] | ||
pub struct Struct<T>(T); | ||
|
||
impl<T: Clone, U> PartialEq<U> for Struct<T> | ||
where | ||
U: Into<Struct<T>> + Clone | ||
{ | ||
fn eq(&self, _other: &U) -> bool { | ||
todo!() | ||
} | ||
} | ||
|
||
fn main() {} |
24 changes: 24 additions & 0 deletions
24
tests/ui/traits/next-solver/global-cache-and-parallel-frontend.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0277]: the trait bound `T: Clone` is not satisfied | ||
--> $DIR/global-cache-and-parallel-frontend.rs:15:17 | ||
| | ||
LL | #[derive(Clone, Eq)] | ||
| ^^ the trait `Clone` is not implemented for `T`, which is required by `Struct<T>: PartialEq` | ||
| | ||
note: required for `Struct<T>` to implement `PartialEq` | ||
--> $DIR/global-cache-and-parallel-frontend.rs:18:19 | ||
| | ||
LL | impl<T: Clone, U> PartialEq<U> for Struct<T> | ||
| ----- ^^^^^^^^^^^^ ^^^^^^^^^ | ||
| | | ||
| unsatisfied trait bound introduced here | ||
note: required by a bound in `Eq` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
= note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider restricting type parameter `T` | ||
| | ||
LL | pub struct Struct<T: std::clone::Clone>(T); | ||
| +++++++++++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |