Repository navigation
trait solver: Track canonical response universe assumptions #159987
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
Merged
rust-bors
merged 5 commits into
rust-lang:main
from
Dnreikronos:trait_solver/canonical_response_assumptions
Aug 12, 2026
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
698320c
Track assumptions for canonical response universes
Dnreikronos d9f9edc
Add FIXME for opaque placeholder workaround
Dnreikronos 1f7c5a4
Improve canonical response assumptions regression coverage
Dnreikronos 1e9b3aa
Drop check-pass that misses the ICE regression path
Dnreikronos 4dd5235
Add Trait impl to ICE regression test
Dnreikronos 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 hidden or 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
24 changes: 24 additions & 0 deletions
24
tests/ui/assumptions_on_binders/canonical-response-placeholder-assumptions-issue-159889.rs
This file contains hidden or 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 @@ | ||
| //@ compile-flags: -Znext-solver=globally -Zassumptions-on-binders | ||
|
|
||
| #![feature(type_alias_impl_trait)] | ||
|
|
||
| // Regression test for #159889. Normalizing `FooAssoc<'a>` returns an opaque type constraint | ||
| // containing a query-created placeholder. Applying that response recreates its universe in the | ||
| // caller, where it must have an assumptions entry before eager placeholder handling visits it. | ||
| // | ||
| // Adding `impl Trait for ()` to this same shape still ICEs on nightly (same | ||
| // `assumptions` unwrap). A separately rewritten check-pass does not hit this path, so it is not | ||
| // a useful regression guard. | ||
|
|
||
| trait Trait { | ||
| type Assoc<'a>; | ||
| } | ||
|
|
||
| type Foo = impl for<'a> Trait<Assoc<'a> = FooAssoc<'a>>; | ||
| type FooAssoc<'a> = impl ?Sized; | ||
|
|
||
| #[define_opaque(Foo)] | ||
| fn foo() -> Foo {} | ||
| //~^ ERROR the trait bound `(): Trait` is not satisfied | ||
|
|
||
| fn main() {} | ||
15 changes: 15 additions & 0 deletions
15
.../ui/assumptions_on_binders/canonical-response-placeholder-assumptions-issue-159889.stderr
This file contains hidden or 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,15 @@ | ||
| error[E0277]: the trait bound `(): Trait` is not satisfied | ||
| --> $DIR/canonical-response-placeholder-assumptions-issue-159889.rs:17:13 | ||
| | | ||
| LL | fn foo() -> Foo {} | ||
| | ^^^ the trait `Trait` is not implemented for `()` | ||
| | | ||
| help: this trait has no implementations, consider adding one | ||
| --> $DIR/canonical-response-placeholder-assumptions-issue-159889.rs:9:1 | ||
| | | ||
| LL | trait Trait { | ||
| | ^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0277`. |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
does this test also work if you actually implement
(): Traitseems preferable to me to have a check-pass test here 🤔View changes since the review
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.
I restored the original test as the ICE regression guard and added a separate check-pass case with
impl Trait for (), btw. fyi, removing the workaround locally makes the original test ICE again. I think keeping both tests separate is safer; idk if combining them is worth running into the opaque defining-use issue again. ltm if you see a cleaner way.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.
Oh, so the test with
(): Traitdoes not ICE on nightly? In this case, please mention that in the comment of the actual regression test and I don't think we need to add the test where(): Traitdoes hold then.I think that it's nicer to have tests to only encounter as few errors as possible, as the behavior of rustc gets a lot less predictable once a first error happens, which makes it easier to accidentally stop testing the underlying issue in the future.
But if the test actually needs
(): Traitto not hold for the ICE to trigger, then keeping that as the only test makes sense to meThere 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.
ah, so that was me being unclear earlier, sorry. checked on nightly: same shape with
impl Trait for ()still ICEs (same unwrap). the check-pass was a different program that never hit that path, so it looked fine. dropped it and left a note on the regression test. ltm if that worksThere 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.
okay, so if it also ICEs with this impl, please add the impl so that the test doesn't have an error that's unrelated to the thing this is testing.
What do you mean with "A separately rewritten check-pass does not hit this path, so it is not a useful regression guard". Saying that does not feel like useful information to any future readers
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.
make sense, that comment was useless for future readers, my bad. removed it.
also added
impl Trait for ()(+?Sized) so we don't hit the unrelated Trait error. still ICEs on nightly with that shape, fyi. after the fix it just fails with the opaque "does not constrain" error instead, which imo is fine for a regression guard.idk if we can make this check-pass without losing the ICE path, btw. every time I tried to make the defining use "real" enough it stopped ICEing. so I kept the minimal shape.
ltm if that looks good