gccrs: diagnostics: Add underline for tokens in diagnostics.
authormxlol233 <mxlol233@outlook.com>
Wed, 11 Jan 2023 12:36:13 +0000 (20:36 +0800)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 6 Apr 2023 08:47:17 +0000 (10:47 +0200)
commit86f8e47f9df3cb0adf9b6cd6e48d7c89e2556721
tree56541e7c3b397a1f4fbebc4cc676f56785791f8c
parent8e2abbef4cc04adf048730b1a608cf95b6d5cc4f
gccrs: diagnostics: Add underline for tokens in diagnostics.

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.

gcc/rust/ChangeLog:

* lex/rust-lex.cc (Lexer::build_token): Make location enclose entire token.
(Lexer::parse_byte_char): Likewise.
(Lexer::parse_byte_string): Likewise.
(Lexer::parse_raw_byte_string): Likewise.
(Lexer::parse_raw_identifier): Likewise.
(Lexer::parse_string): Likewise.
(Lexer::parse_identifier_or_keyword): Likewise.
(Lexer::parse_raw_string): Likewise.
(Lexer::parse_non_decimal_int_literal): Likewise.
(Lexer::parse_decimal_int_or_float): Likewise.
(Lexer::parse_char_or_lifetime): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/diagnostic_underline.rs: New test.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
gcc/rust/lex/rust-lex.cc
gcc/testsuite/rust/compile/diagnostic_underline.rs [new file with mode: 0644]