diagnostics: account for self type when looking for source of unsolved type variable#109957
diagnostics: account for self type when looking for source of unsolved type variable#109957bors merged 1 commit intorust-lang:masterfrom
Conversation
|
(rustbot has picked a reviewer for you, use r? to override) |
|
Some changes occurred in need_type_info.rs cc @lcnr |
compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
The CI test failures answer it lol. Going back to checking the |
|
@rustbot review |
I've looked at the implementation of Looking at relevant definitions
|
|
@bors r+ |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#109806 (Workaround rust-lang#109797 on windows-gnu) - rust-lang#109957 (diagnostics: account for self type when looking for source of unsolved type variable) - rust-lang#109960 (Fix buffer overrun in bootstrap and (test-only) symlink_junction) - rust-lang#110013 (Label `non_exhaustive` attribute on privacy errors from non-local items) - rust-lang#110016 (Run collapsed GUI test in mobile mode as well) - rust-lang#110022 (fix: fix regression in rust-lang#109203) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #109905.
When searching for the source of an unsolved infer var inside of a list of generic args, we look through the
tcx.generics_of(…).own_substs(…)which skips the self type if present. However, the computedargument_indexis later1 used to index intotcx.generics_of(…).paramswhich may still contain the self type. In such case, we are off by one when indexing into the parameters.From now on, we account for this immediately after calling
own_substswhich keeps things local.This also fixes the wrong output in the preexisting UI test
inference/need_type_info/concrete-impl.rswhich was overlooked. It used to claim that the type of type parameterSelfcouldn't be inferred in<Struct as Ambiguous<_>>::method()which of course isn't true:SelfequalsStructhere,Acouldn't be inferred.@rustbot label A-diagnostics
Footnotes
https://github.com/rust-lang/rust/blob/f98a2718141593fbb8dbad10acc537786d748156/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs#L471 ↩