Closed
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
A similar mechanism should probably also be used for consts.