-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add test for inductive cycle hangs #118774
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions
4
tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.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
33 changes: 33 additions & 0 deletions
33
tests/ui/traits/new-solver/cycles/inductive-fixpoint-hang.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,33 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
|
||
// This currently hangs if we do not erase constraints from | ||
// overflow. | ||
// | ||
// We set the provisional result of `W<?0>` to `?0 := W<_>`. | ||
// The next iteration does not simply result in a `?0 := W<W<_>` constraint as | ||
// one might expect, but instead each time we evaluate the nested `W<T>` goal we | ||
// apply the previously returned constraints: the first fixpoint iteration goes | ||
// as follows: `W<?1>: Trait` constrains `?1` to `W<?2>`, we then evaluate | ||
// `W<W<?2>>: Trait` the next time we try to prove the nested goal. This results | ||
// inn `W<W<W<?3>>>` and so on. This goes on until we reach overflow in | ||
// `try_evaluate_added_goals`. This means the provisional result after the | ||
// second fixpoint iteration is already `W<W<W<...>>>` with a size proportional | ||
// to the number of steps in `try_evaluate_added_goals`. The size then continues | ||
// to grow. The exponential blowup from having 2 nested goals per impl causes | ||
// the solver to hang without hitting the recursion limit. | ||
trait Trait {} | ||
|
||
struct W<T: ?Sized>(*const T); | ||
|
||
impl<T: ?Sized> Trait for W<W<T>> | ||
where | ||
W<T>: Trait, | ||
W<T>: Trait, | ||
{} | ||
|
||
fn impls_trait<T: Trait>() {} | ||
|
||
fn main() { | ||
impls_trait::<W<_>>(); | ||
//~^ ERROR overflow evaluating the requirement | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/ui/traits/new-solver/cycles/inductive-fixpoint-hang.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,16 @@ | ||
error[E0275]: overflow evaluating the requirement `W<_>: Trait` | ||
--> $DIR/inductive-fixpoint-hang.rs:31:19 | ||
| | ||
LL | impls_trait::<W<_>>(); | ||
| ^^^^ | ||
| | ||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_fixpoint_hang`) | ||
note: required by a bound in `impls_trait` | ||
--> $DIR/inductive-fixpoint-hang.rs:28:19 | ||
| | ||
LL | fn impls_trait<T: Trait>() {} | ||
| ^^^^^ required by this bound in `impls_trait` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in