Repository navigation
fix: well-formed goals for tuples, arrays, and slices in next-solver - #23490
GauravPawar101 wants to merge 0 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
|
I suspected that you used AI tools contrary to our policy. Please read our AI policy and follow it. |
This comment was marked as low quality.
This comment was marked as low quality.
|
https://github.com/rust-lang/rust-analyzer/blob/master/AI_POLICY.md
|
This comment has been minimized.
This comment has been minimized.
This comment was marked as low quality.
This comment was marked as low quality.
There was a problem hiding this comment.
Besides the AI policy, I think this doesn't match with what rustc does. It creates wf goals by TypeVisitor and I think it's not that complex to be ported here. (I'm not sure on the perf effect though)
The actual behaviors don't match even for tuples and arrays. As in, if you are making wf goals for ((usize, i32), u8), rustc emits no goals, as it visits each nested scalar types inside the tuples and they are trivially wf. But your code adds Wf((usize, i32)) and Wf(u8). Of course they hold trivially but it's waste to create and evaluate them and sometimes the difference between rustc could be even observable, e.g. by hitting recursion limits for very complex types.
| } | ||
| Some(goals) | ||
| } | ||
| TyKind::Array(t, _) | TyKind::Slice(t) => Some(vec![ |
There was a problem hiding this comment.
I think we should check whether const N is usize
This comment was marked as low quality.
This comment was marked as low quality.
|
Well, this code is just wrong and can cause other bugs or problems by itself, as I've stated above. |
|
Indeed, don't drift from rustc. We need full WF checking anyway. |
|
☔ The latest upstream changes (possibly #23181) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment was marked as low quality.
This comment was marked as low quality.
|
This PR was rebased onto a different master 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. |
Summary
Fixes #23475
changes
crates/hir-ty/src/next_solver/wf.rs (N): WfPredicates visitor over Terms like ruswtc.solver.rs: Implimented visitor.infer/expr.rs,infer/unify.rs: register WF obligation.infer/errors.rs: error-type fallback so the server no longer crashes.dyn_compatibility.rs: region bound helper using caller’s interner.NEW
solver_errors.r,hir/src/diagnostics.rs: solver diagnosticseE0308.ide-diagnostics/src/handlers: extendedE0308handler.VALIDATION
[x]
cargo test[x]
cargo clippy,cargo fmtDisclosure
Claude was used for rustc citations and understanding.
Rustc ref
The implementation is modeled directly on:
(rustc_middle/rustc_trait_selection dyn-object bounds machinery)
Divergences
following remains unimplemented as FIXME or narrower: