rust/tests/ui/inference
Matthias Krüger e63586f386
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]: f98a271814/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs (L471)
2023-04-07 00:00:24 +02:00
..
auxiliary
need_type_info account for self type when looking for source of unsolved ty var 2023-04-05 20:28:18 +02:00
ambiguous_type_parameter.rs
ambiguous_type_parameter.stderr
array-len-mismatch.rs Suggest the correct array length on mismatch 2023-02-12 02:15:41 +00:00
array-len-mismatch.stderr Suggest the correct array length on mismatch 2023-02-12 02:15:41 +00:00
cannot-infer-async.rs
cannot-infer-async.stderr
cannot-infer-closure-circular.rs
cannot-infer-closure-circular.stderr
cannot-infer-closure.rs
cannot-infer-closure.stderr
cannot-infer-partial-try-return.rs
cannot-infer-partial-try-return.stderr Deprioritize fulfillment errors that come from expansions. 2023-01-14 14:05:26 +01:00
char-as-str-multi.rs
char-as-str-multi.stderr
char-as-str-single.fixed fix type suggestions in match arms 2023-03-25 22:27:24 +01:00
char-as-str-single.rs fix type suggestions in match arms 2023-03-25 22:27:24 +01:00
char-as-str-single.stderr fix type suggestions in match arms 2023-03-25 22:27:24 +01:00
deref-suggestion.rs
deref-suggestion.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
erase-type-params-in-label.rs
erase-type-params-in-label.stderr
infer-binary-operand-behind-reference.rs
inference_unstable_featured.rs
inference_unstable_featured.stderr diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
inference_unstable_forced.rs
inference_unstable_forced.stderr
inference_unstable.rs diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
inference_unstable.stderr diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
inference-variable-behind-raw-pointer.rs
inference-variable-behind-raw-pointer.stderr
issue-28935.rs
issue-36053.rs
issue-70703.rs
issue-71309.rs
issue-71309.stderr
issue-71732.rs
issue-71732.stderr diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
issue-72616.rs
issue-72616.stderr
issue-72690.rs
issue-72690.stderr
issue-80409.rs Add regression test for #80409 2023-04-05 21:20:07 +09:00
issue-80816.rs
issue-80816.stderr
issue-81522.rs
issue-83606.rs defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
issue-83606.stderr defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
issue-86162-1.rs
issue-86162-1.stderr
issue-86162-2.rs
issue-86162-2.stderr
issue-103587.rs
issue-103587.stderr
issue-104649.rs
issue-104649.stderr
issue-107090.rs Introduce ReError 2023-02-09 10:26:49 +00:00
issue-107090.stderr Introduce ReError 2023-02-09 10:26:49 +00:00
lub-glb-with-unbound-infer-var.rs
newlambdas-ret-infer2.rs
newlambdas-ret-infer.rs
question-mark-type-infer.rs
question-mark-type-infer.stderr diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
range-type-infer.rs
simple-infer.rs
str-as-char.fixed
str-as-char.rs
str-as-char.stderr
tutorial-suffix-inference-test.rs
tutorial-suffix-inference-test.stderr
type-infer-generalize-ty-var.rs