Rust: Be clearer on type mismatch within a range

Created on 6 Jan 2019  路  6Comments  路  Source: rust-lang/rust

When matching on a range between two values of different type we currently emit the following output:

error[E0308]: mismatched types
  --> $DIR/E0308-4.rs:4:9
   |
LL |         0u8..=3i8 => (), //~ ERROR E0308
   |         ^^^^^^^^^ expected u8, found i8

We should have a more targeted error:

error[E0308]: mismatched types
  --> $DIR/E0308-4.rs:4:9
   |
LL |         0u8..=3i8 => (), //~ ERROR E0308
   |         ---   ^^^ expected u8, found i8
   |         |
   |         expected because of this
A-diagnostics D-confusing D-newcomer-roadblock E-medium P-low T-compiler

Most helpful comment

@kevgrasso I got occupied with other things, Please take it. Thanks

All 6 comments

@estebank Can I take this one if nobody is working on it?

@PramodBisht go ahead!

@PramodBisht Are you still working on this? Or could I take this over?

@kevgrasso I got occupied with other things, Please take it. Thanks

@estebank I'm getting some weird behavior from my attempted fix. Most of the bugs I'm getting are understandable, but the one I don't understand is that the text annotating for the primary span in the error diagnostic doesn't show up if I let it display to terminal, but it does if I pipe stderr to a file, and I have no idea what I changed that caused this. Any chance you'd have any clue what might have happened? My changes are here if it helps: https://github.com/kevgrasso/rust/commit/3d37d388e40896f10d6105d80dedd2711d183067

image

@kevgrasso

1) Love the new output!
2) I'm not sure what could be causing this, it seems like it should work based on the code I'm seeing.

Was this page helpful?
0 / 5 - 0 ratings