right now, the decision of whether to fully elide the type as _ is inconsistent - it never happens for functions, fn pointers, tuples, refs where the pointee types are equal, or adts, but it does happen for primitives and ADTs behind a raw pointer. that is probably not intended? might be worth moving the t1 == t2 comparison up above the big match for consistency.
|
if t1 == t2 && !self.tcx.sess.verbose() { |
|
// The two types are the same, elide and don't highlight. |
|
(DiagnosticStyledString::normal("_"), DiagnosticStyledString::normal("_")) |
here is an example of it being inconsistent:
|
LL | fn say(self: &Pair<&str, isize>) { |
|
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch |
|
| |
|
= note: expected struct `Pair<&str, _>` |
isize is elided but
str is not.
i originally changed this to almost always elide the type, but @estebank is worried that will be confusing:

he suggested instead eliding if the type has either type params or projection types ("looks complicated", basically).
Originally posted by @jyn514 in #118730 (comment)
@rustbot label +A-diagnostics +E-medium
right now, the decision of whether to fully elide the type as
_is inconsistent - it never happens for functions, fn pointers, tuples, refs where the pointee types are equal, or adts, but it does happen for primitives and ADTs behind a raw pointer. that is probably not intended? might be worth moving thet1 == t2comparison up above the big match for consistency.rust/compiler/rustc_infer/src/infer/error_reporting/mod.rs
Lines 1510 to 1512 in eb53721
here is an example of it being inconsistent:
rust/tests/ui/issues/issue-17905-2.stderr
Lines 23 to 26 in cf2dff2
isizeis elided butstris not.i originally changed this to almost always elide the type, but @estebank is worried that will be confusing:

he suggested instead eliding if the type has either type params or projection types ("looks complicated", basically).
Originally posted by @jyn514 in #118730 (comment)
@rustbot label +A-diagnostics +E-medium