Open oli-obk opened 5 years ago
I think it would be ideal if we could print the unevaluated expression itself. (Though we might have to point out specifically that it's unevaluated in diagnostics if this proves confusing.)
that's what we are doing right now, but you end up with errors like expected 3 got 3usize
. If we eagerly evaluated we'd even get expected 3usize got 3usize
These errors may just disappear if we manage to normalize before doing whatever causes the error.
Ah, I was specifically referring to the case when _
is printed at the moment, which has been encountered quite frequently with const generics.
I agree the cases when it does print the expression, and they look the same as what's expected is confusing, but these seem more indicative of existing issues, like normalisation, than printing. Maybe the diagnostics, rather than the pretty printing, could be adjusted for now to address this.
cc https://github.com/rust-lang/rust/pull/60742#discussion_r288742080
Right now when we encounter a
ConstValue::Unevaluated
during pretty printing, we fall back to printing the constant's source code or_
if that also fails. Alternative options are:_
{{unevaluated: {}}}
where{}
is the source code{unevaluated}
(seems useless for users, so maybe not a good idea)