Repository navigation
Detect errors in opaque type bounds when deriving errors in next solver - #163801
darkraider01 wants to merge 2 commits into
Conversation
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| self.detect_error_in_self_ty_normalization(goal, pred.projection_term.self_ty())?; | ||
| self.detect_non_well_formed_assoc_item(goal, pred.projection_term)?; | ||
| } | ||
| Some(ty::PredicateKind::Clause(ty::ClauseKind::Projection(pred))) |
There was a problem hiding this comment.
I’m handling this here because normalization can fail before a candidate gets recorded. The usual diagnostic walk then misses the actual trait failure and reports the opaque mismatch. This fallback lets me reach the missing trait bound instead.
| )); | ||
| } | ||
| } | ||
| let () = instantiate_canonical_state( |
There was a problem hiding this comment.
Rebuilt the nested goals first, apply the recorded constraints, then revisit them. That order matters here, the goals need the constraints from the failed attempt. I’m using the existing diagnostic probe so the inference changes get rolled back afterward.
| @@ -0,0 +1,32 @@ | |||
| //@ edition:2021 | |||
| //@ check-pass | |||
There was a problem hiding this comment.
I kept these in a separate check-pass test to cover both solvers. It checks that adding .await works, and that leaving it out is still fine when the function intentionally returns a future.
|
r? JonathanBrouwer |
|
|
|
r? types |
|
r? types |
Forgetting
.awaithere makes the next solver complain about an opaque-type mismatch, which doesn’t really tell you what went wrong.The tricky part was tracking down why the diagnostic walker missed the actual trait failure. Opaque-type normalization could fail before its nested goals became visible through the normal candidate traversal.
This change follows those failing goals and reports that the future doesn’t implement
Iterator(or whatever trait the function returns). The fix stays in diagnostic derivation and uses existing messages. It still points at the return type, so there’s room to improve the location later.Added coverage for missing
.await, awaited returns, and intentionally returning a future. Forced next-solver mode still has the same 296 baseline failures.The diagnostic still highlights the declared return type rather than
other(), where.awaitis missing. Improving that location can be done in a follow up maybe?Fixes #163536