Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #156885 - Dnreikronos:fix/index-expr-ambiguous-type-span, r=BoxyUwU
Fix misattributed type inference error span for index expressions If `arr[idx.into()]` appears inside a cast or binary op, the type inference error gets blamed on the wrong expression. **Before:** - `[1, 2, 3][bad_idx.into()] as i32` → error points at `[1, 2, 3][bad_idx.into()]` (the whole indexing expr) - `0 + [1, 2, 3][bad_idx.into()]` → error points at `+` **After:** - Both cases point at `.into()`, which is where the ambiguity actually is. In `cast.rs`, before resolving the cast expression type, we check if it's an index with an unresolved index type. If so, resolve the index sub-expression first at its own span so the error lands there. If that already errored, skip the broader resolution to avoid duplicates. In `op.rs`, after writing the method call for an overloaded binary op, if the return type still has inference variables and the RHS is an index expression, force resolution of the index type at its span. Fixes rust-lang/rust#156738 r? compiler
Jacob Pratt 5 weeks ago
parent d012aa9 · parent e32769d · commit 99d34f0
0 files changed, 0 insertions, 0 deletions