diff options
author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-04-07 00:00:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-07 00:00:24 +0200 |
commit | e63586f386ea32c658974a0174da4cf9ac4cf385 (patch) | |
tree | 8f68c6e96ecee5677d6ba8f40eb184b41c62cbb7 /tests/rustdoc-js-std/parser-errors.js | |
parent | b7e69732878c5e2118d237b0a9b338cd192f1142 (diff) | |
parent | b904ce94a23744032f930841b6fecb6ac2620cd9 (diff) | |
download | rust-e63586f386ea32c658974a0174da4cf9ac4cf385.tar.gz |
Rollup merge of #109957 - fmease:fix-109905, r=petrochenkov
diagnostics: account for self type when looking for source of unsolved type variable
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 computed `argument_index` is later[^1] used to index into `tcx.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 parameter `Self`* couldn't be inferred in `<Struct as Ambiguous<_>>::method()` which of course isn't true: `Self` equals `Struct` here, `A` couldn't be inferred.
`@rustbot` label A-diagnostics
[^1]: https://github.com/rust-lang/rust/blob/f98a2718141593fbb8dbad10acc537786d748156/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs#L471
Diffstat (limited to 'tests/rustdoc-js-std/parser-errors.js')
0 files changed, 0 insertions, 0 deletions