Diagnostics ICE when replaying proof trees with next-solver - #154329
Conversation
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8c7b38e to
30c3bd2
Compare
|
r? lcnr |
|
this is a surprising failure, while revisiting goals can get different results with proof trees, instantiating the response generally shouldn't fail 🤔 can you provide some more detail how this test ends up returning some canonical state we cannot instantiate. What is the constraint we get when replying the proof tree but not while actually proving the goal please generally move fix #issuenum into the PR description instead of the title |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
The failure is not in the original proof of the goal, but in the diagnostics-only replay of a stored We save a canonical state while proving the goal, and later try to replay that state after more trait solving has happened in the same For this testcase, the ICE only happens with I have not yet isolated the exact replay mismatch for this testcase, i.e. the specific constraint that is present during replay but not during the original proof, but I can instrument that next if that would be useful. I have also moved the #issuenum from the title to the PR description. |
|
@rustbot ready |
This is a bit incorrect. We usually unify the What happens in the problematic code is the following: We have a failed root goal But as there aren't any orig value for rust/compiler/rustc_next_trait_solver/src/canonical/mod.rs Lines 323 to 336 in c753cef But this inserts a new ty var in the infcx's current universe rather than the universe of var kind bound to that canonical var value, which is a HR as being in rust/compiler/rustc_trait_selection/src/solve/delegate.rs Lines 158 to 167 in c753cef So, the error is created while trying to unify the ty var from root universe to the binder's universe and I guess we should fix |
|
so this is caused by a universe error 🤔 yeah, that's an annoying problem, so we should instantiate the canonical state and between that and unifying the var_values should we create the infer vars 🤔 unsure how to impl this as we don't support instantiating a response without guessing having a var_value guess first. I guess we could create infer vars which are just in the MAX_UNIVERSE. I think this shouldn't blow up anything |
|
Ahh, that makes sense — thanks for the clarification. You're right that my previous explanation was off. So the core issue seems to be that For possible fixes, I see two options:
I can try prototyping either approach. Do you have a preference for which direction better fits the solver design? |
hard to do as with the current setup we need to crate the variables before we enter create these new universes. so the second alternative should be easier |
|
in case you are using an LLM to generate/cleanup your messages, please don't. try to state your current understanding in your own words, otherwise it's hard to figure out your current understanding and what I actually need to respond to. It also makes it hard to know whether it's worth it to correct cases where the perspective/framing is slightly off. Even if writing it yourself is less structured or clear, that's still preferable to me. idk if there's a more complete writeup i can point u to here |
|
Okay, I'll keep my comments more direct. I'll try to implement the second approach. |
This comment has been minimized.
This comment has been minimized.
92d2729 to
0d5cae8
Compare
2c5cf18 to
01a0735
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
When diagnostics replay proof tree state, rebuilding a canonical state can fail to match the current inference state. With -Znext-solver=globally, this could panic because inference variables created to replay a canonical state were placed in the wrong universe relative to placeholders bound by the same state. Fix this by threading a `prev_universe` through proof tree replay: `InspectGoal` now stores the caller-side universe at the time the goal was created, and `instantiate_canonical_state` reuses that same base universe (instead of recomputing it) when creating any replay-only fresh variables and when reconstructing placeholders from the canonical state, ensuring all canonical states for a single goal share a consistent universe mapping. Add a regression test for the higher-ranked PartialEq and PartialOrd case. Signed-off-by: Vicente Gusmão <vicente.gusmao@tecnico.ulisboa.pt>
01a0735 to
4828030
Compare
|
No worries! I have just rebased, but in order to do so I squashed the commits. It was causing merge conflicts in all the previews commits so I thought this was the best approach. |
|
@bors r=lcnr |
|
@VicenteGusmao: 🔑 Insufficient privileges: not in review users |
|
Sorry, this is my first time contributing, wasn't I supposed to do that? |
|
@rustbot ready |
| @@ -0,0 +1,14 @@ | |||
| //@ compile-flags: -Znext-solver=globally | |||
|
|
|||
| #![allow(incomplete_features)] | |||
There was a problem hiding this comment.
please add a few short sentences about this test.
the relevant rust issue, why it failed, and any other potentially useful information
There was a problem hiding this comment.
Okay, I'm going to do that.
|
now u can approve it urself after adding this short comment @bors delegate+ |
|
✌️ @VicenteGusmao, you can now approve this pull request! If @lcnr told you to " |
This comment has been minimized.
This comment has been minimized.
4ab58df to
1cf12a5
Compare
|
@bors r=lcnr |
|
@lcnr thank you for all the help! |
…uwer Rollup of 7 pull requests Successful merges: - #160629 ([Priroda] Add bootstrap test and check steps) - #160811 (Fix `visible_parent_map` fallback map merging perf regression) - #154329 (Diagnostics ICE when replaying proof trees with next-solver) - #157841 (Ensure inferred let pattern types are well-formed) - #159300 (Implement `to_string()` on `ByteStr` and `ByteString`) - #160858 (Add regression test for assoc const panic ICE in match) - #160864 (Rename `HostEffectPredicate` to `HostEffectClause`)
Rollup merge of #154329 - VicenteGusmao:fix-bug-151304, r=lcnr Diagnostics ICE when replaying proof trees with next-solver When diagnostics replay proof tree state, rebuilding a canonical state can fail to match the current inference state. With -Znext-solver=globally, this could panic while reporting an error, avoiding the panic. Make proof tree replay fallible in diagnostics and fall back to the current obligation when replay fails. Add a regression test for the higher-ranked PartialEq and PartialOrd case. Fixes #151304.
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#160629 ([Priroda] Add bootstrap test and check steps) - rust-lang/rust#160811 (Fix `visible_parent_map` fallback map merging perf regression) - rust-lang/rust#154329 (Diagnostics ICE when replaying proof trees with next-solver) - rust-lang/rust#157841 (Ensure inferred let pattern types are well-formed) - rust-lang/rust#159300 (Implement `to_string()` on `ByteStr` and `ByteString`) - rust-lang/rust#160858 (Add regression test for assoc const panic ICE in match) - rust-lang/rust#160864 (Rename `HostEffectPredicate` to `HostEffectClause`)
View all comments
When diagnostics replay proof tree state, rebuilding a canonical state can fail to match the current inference state. With -Znext-solver=globally, this could panic while reporting an error, avoiding the panic.
Make proof tree replay fallible in diagnostics and fall back to the current obligation when replay fails. Add a regression test for the higher-ranked PartialEq and PartialOrd case. Fixes #151304.