public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Merge #1733
@ 2023-01-13  8:26 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-01-13  8:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2f9f77f9dd6330fe60554400133d7217f78afa43

commit 2f9f77f9dd6330fe60554400133d7217f78afa43
Merge: 0030bead12e 68839a57ea5
Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Date:   Thu Jan 12 13:54:04 2023 +0000

    Merge #1733
    
    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>

Diff:

 gcc/rust/lex/rust-lex.cc                           | 57 ++++++++++++++++++++++
 gcc/testsuite/rust/compile/diagnostic_underline.rs | 15 ++++++
 2 files changed, 72 insertions(+)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-13  8:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13  8:26 [gcc/devel/rust/master] Merge #1733 Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).