1733: diagnostics: Add underline for tokens in diagnostics. r=CohenArthur a=TuringKi
Currently, the diagnostics only point to the corresponding token's start position by carets, and lack of underlines for full token. This commit add support for such underlines in diagnostics by encoding range information in location_t.
the results like this:
```
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:5:14: error: invalid cast 'bool' to 'f32' [E0054]
5 | let fone = t as f32; // { dg-error "invalid cast" }
| ^ ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:6:15: error: invalid cast 'bool' to 'f64' [E0054]
6 | let fzero = f as f64; // { dg-error "invalid cast" }
| ^ ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:8:12: error: invalid cast 'u8' to 'bool' [E0054]
8 | let nb = 0u8 as bool; // { dg-error "invalid cast .u8. to .bool. \\\[E0054\\\]" }
| ^~~ ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:9:12: error: invalid cast 'bool' to 'char' [E0054]
9 | let nc = true as char; // { dg-error "invalid cast" }
| ^~~~ ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:13:12: error: invalid cast 'char' to 'f32' [E0054]
13 | let fa = a as f32; // { dg-error "invalid cast" }
| ^ ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:14:12: error: invalid cast 'char' to 'bool' [E0054]
14 | let bb = b as bool; // { dg-error "invalid cast .char. to .bool. \\\[E0054\\\]" }
| ^ ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:17:12: error: invalid cast 'u32' to 'char' [E0054]
17 | let ab = t32 as char; // { dg-error "invalid cast" }
| ^~~ ~~~~
```
This commit is split from pr #1718.
Signed-off-by: Xiao Ma <mxlol233@outlook.com> Co-authored-by: mxlol233 <mxlol233@outlook.com>
This page took 0.065832 seconds and 6 git commands to generate.