Description
Over in #65951, @estebank and I were discussing that we could improve the error message in cases like:
rust/src/test/ui/async-await/unresolved_type_param.rs
Lines 8 to 14 in 3964a55
Presently, we say:
but this T
we reference comes from the definition of bar
:
it'd be nice if we said "cannot infer value for type parameter T
declared on the fn bar
".
I believe that name comes from the TypeParameterDefinition
information that we track as part of a type variable's origin:
rust/src/librustc/infer/error_reporting/need_type_info.rs
Lines 159 to 161 in 3964a55
So we could do this by modifying that variant to track the DefId
of the type parameter and then looking at the parent to derive the context.
This issue has been assigned to @ohadravid via this comment.