Rust: Hide `found a, expected b` label when suggestion is provided

Created on 1 May 2019  路  1Comment  路  Source: rust-lang/rust

I'm ambivalent about this, but @oli-obk pointed this case out in https://github.com/rust-lang/rust/pull/60159#discussion_r277263162

When providing a suggestion for a type error that would fix the problem, we have the following output:

error[E0308]: mismatched types
  --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:19
   |
LL |     let _ = RGB { r, g, c };
   |                   ^
   |                   |
   |                   expected f64, found f32
   |                   help: you can convert an `f32` to `f64`: `r: r.into()`

we could change it to

error[E0308]: mismatched types
  --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:19
   |
LL |     let _ = RGB { r, g, c };
   |                   ^ help: you can convert an `f32` to `f64`: `r: r.into()`

but I'm not sure wether that is a good move.

A-diagnostics C-enhancement S-waiting-on-bikeshed T-compiler

Most helpful comment

I think a good diagnostic consists at minimum of:

  1. what went wrong,
  2. how you can fix it

but this move would get rid of 1. so I'm not a fan.

>All comments

I think a good diagnostic consists at minimum of:

  1. what went wrong,
  2. how you can fix it

but this move would get rid of 1. so I'm not a fan.

Was this page helpful?
0 / 5 - 0 ratings