-
Couldn't load subscription status.
- Fork 13.9k
Description
We currently don't store the origin of const inference variables. This is needed to emit more helpful error messages.
For type inference variables, this is done using https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxtInner.html#method.type_variables and then
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/type_variable/struct.TypeVariableTable.html#method.var_origin.
We use this to provide better diagnostics in case type inference fails:
rust/src/librustc_infer/infer/error_reporting/need_type_info.rs
Lines 198 to 201 in 9912925
| let ty_vars = &inner.type_variables(); | |
| let var_origin = ty_vars.var_origin(ty_vid); | |
| if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) = var_origin.kind { | |
| let parent_def_id = def_id.and_then(|def_id| self.tcx.parent(def_id)); |
A similar mechanism should probably also be used for consts.