Special case when a code line only has multiline span starts · rust-lang/rust@284437d (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -902,7 +902,7 @@ impl HumanEmitter { | ||
902 | 902 | // |
903 | 903 | // |
904 | 904 | let mut annotations_position = vec![]; |
905 | -let mut line_len = 0; | |
905 | +let mut line_len: usize = 0; | |
906 | 906 | let mut p = 0; |
907 | 907 | for (i, annotation) in annotations.iter().enumerate() { |
908 | 908 | for (j, next) in annotations.iter().enumerate() { |
@@ -973,6 +973,31 @@ impl HumanEmitter { | ||
973 | 973 | return vec![]; |
974 | 974 | } |
975 | 975 | |
976 | +if annotations_position | |
977 | +.iter() | |
978 | +.all(|(_, ann) | |
979 | + && let Some(max_pos) = annotations_position.iter().map(|(pos, _) | |
980 | +{ | |
981 | +// Special case the following, so that we minimize overlapping multiline spans. | |
982 | +// | |
983 | +// 3 │ X0 Y0 Z0 | |
984 | +// │ ┏━━━━━┛ │ │ < We are writing these lines | |
985 | +// │ ┃┌───────┘ │ < by reverting the "depth" of | |
986 | +// │ ┃│┌─────────┘ < their multilne spans. | |
987 | +// 4 │ ┃││ X1 Y1 Z1 | |
988 | +// 5 │ ┃││ X2 Y2 Z2 | |
989 | +// │ ┃│└────╿──│──┘ `Z` label | |
990 | +// │ ┃└─────│──┤ | |
991 | +// │ ┗━━━━━━┥ `Y` is a good letter too | |
992 | +// ╰╴ `X` is a good letter | |
993 | +for (pos, _) in &mut annotations_position { | |
994 | +*pos = max_pos - *pos; | |
995 | +} | |
996 | +// We know then that we don't need an additional line for the span label, saving us | |
997 | +// one line of vertical space. | |
998 | + line_len = line_len.saturating_sub(1); | |
999 | +} | |
1000 | + | |
976 | 1001 | // Write the column separator. |
977 | 1002 | // |
978 | 1003 | // After this we will have: |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
@@ -322,9 +322,8 @@ error: foo | |||
322 | 322 | --> test.rs:3:3 | |
323 | 323 | | | |
324 | 324 | 3 | X0 Y0 | |
325 | - | ___^__- | ||
326 | - | | ___ | |
327 | - | | ||
325 | + | ____^ - | ||
326 | + | | ______ | |
328 | 327 | 4 | | |
329 | 328 | 5 | | |
330 | 329 | | | |
@@ -361,9 +360,8 @@ error: foo | |||
361 | 360 | --> test.rs:3:3 | |
362 | 361 | | | |
363 | 362 | 3 | X0 Y0 | |
364 | - | ___^__- | ||
365 | - | | ___ | |
366 | - | | ||
363 | + | ____^ - | ||
364 | + | | ______ | |
367 | 365 | 4 | | |
368 | 366 | | | |
369 | 367 | | | ____ |
@@ -445,10 +443,9 @@ error: foo | |||
445 | 443 | --> test.rs:3:3 | |
446 | 444 | | | |
447 | 445 | 3 | X0 Y0 Z0 | |
448 | - | ___^__-__- | ||
449 | - | | ___ | |
450 | - | | ||
451 | - | | ||
446 | + | _____^ - - | ||
447 | + | | _______ | |
448 | + | | ||
452 | 449 | 4 | | |
453 | 450 | 5 | | |
454 | 451 | | |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
@@ -2,9 +2,8 @@ error[E0277]: the type `&mut Context<'_>` may not be safely transferred across a | |||
2 | 2 | --> $DIR/async-is-unwindsafe.rs:12:5 | |
3 | 3 | | | |
4 | 4 | LL | is_unwindsafe(async { | |
5 | - | _____^_____________- | ||
6 | - | | _____ | |
7 | - | | ||
5 | + | ______^ - | ||
6 | + | | ___________________ | |
8 | 7 | LL | | |
9 | 8 | LL | | |
10 | 9 | LL | |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
@@ -41,9 +41,8 @@ warning: variable does not need to be mutable | |||
41 | 41 | --> $DIR/suggestions.rs:54:13 | |
42 | 42 | | | |
43 | 43 | LL | let mut | |
44 | - | ______________^ | ||
45 | - | | _____________ | |
46 | - | | ||
44 | + | _____________^ | ||
45 | + | | _____________ | |
47 | 46 | LL | | |
48 | 47 | | | |
49 | 48 | | | _____________ |