forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#110614 - compiler-errors:new-solver-overflo…
…w-response, r=lcnr Clear response values for overflow in new solver When we have an overflow, return a trivial query response. This fixes an ICE with the code described in rust-lang#110544: ```rust trait Trait {} struct W<T>(T); impl<T, U> Trait for W<(W<T>, W<U>)> where W<T>: Trait, W<U>: Trait, {} fn impls<T: Trait>() {} fn main() { impls::<W<_>>() } ``` Where, while proving `W<?0>: Trait`, we overflow but still apply the query response of `?0 = (W<?1>, W<?2>)`. Then while re-processing the query to validate that our evaluation result was stable, we get a different query response that looks like `?1 = (W<?3>, W<?4>), ?2 = (W<?5>, W<?6>)`, and so we trigger the ICE. Also, by returning a trivial query response we also avoid the infinite-loop/OOM behavior of the old solver. r? ``@lcnr``
- Loading branch information
Showing
5 changed files
with
122 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
|
||
trait Trait {} | ||
|
||
struct W<T>(T); | ||
|
||
impl<T, U> Trait for W<(W<T>, W<U>)> | ||
where | ||
W<T>: Trait, | ||
W<U>: Trait, | ||
{ | ||
} | ||
|
||
fn impls<T: Trait>() {} | ||
|
||
fn main() { | ||
impls::<W<_>>(); | ||
//~^ ERROR type annotations needed | ||
//~| ERROR overflow evaluating the requirement `W<_>: Trait` | ||
} |
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,23 @@ | ||
error[E0282]: type annotations needed | ||
--> $DIR/exponential-trait-goals.rs:17:5 | ||
| | ||
LL | impls::<W<_>>(); | ||
| ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls` | ||
|
||
error[E0275]: overflow evaluating the requirement `W<_>: Trait` | ||
--> $DIR/exponential-trait-goals.rs:17:5 | ||
| | ||
LL | impls::<W<_>>(); | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`exponential_trait_goals`) | ||
note: required by a bound in `impls` | ||
--> $DIR/exponential-trait-goals.rs:14:13 | ||
| | ||
LL | fn impls<T: Trait>() {} | ||
| ^^^^^ required by this bound in `impls` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0275, E0282. | ||
For more information about an error, try `rustc --explain E0275`. |