-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
diagnostics: account for self type when looking for source of unsolved type variable #109957
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in need_type_info.rs cc @lcnr |
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_index
is later1 used to index intotcx.generics_of(…).params
which 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_substs
which keeps things local.This also fixes the wrong output in the preexisting UI test
inference/need_type_info/concrete-impl.rs
which was overlooked. It used to claim that the type of type parameterSelf
couldn't be inferred in<Struct as Ambiguous<_>>::method()
which of course isn't true:Self
equalsStruct
here,A
couldn'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 ↩