Closed
Description
When working on PR #37442, I ended up with the following output:
error: casting `&f64` as `i16` is invalid
--> file3.rs:2:30
|
2 | vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>();
| ^^^^^^^^ // <<< this in red
| | // <<< this in red
| casting `&f64` as `i16` is invalid // <<< this in red
| try dereferencing for the cast to work // <<< this in blue
The second span label points at the first character of the span, but because there's already a larger span there, the actual extent of that span is lost.
I believe that either the shortest span should be shown within the existing span:
2 | vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>();
| -^^^^^^^
| |
| casting `&f64` as `i16` is invalid
| try dereferencing for the cast to work
there should be a new character introduced for when multiple labels overlap:
2 | vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>();
| ~^^^^^^^
| |
| casting `&f64` as `i16` is invalid
| try dereferencing for the cast to work
or at the very least, colorize the smaller span with the secondary label's color:
2 | vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>();
| ^^^^^^^^ // <<< first character should be blue
| |
| casting `&f64` as `i16` is invalid
| try dereferencing for the cast to work