Skip to content

Commit adc634c

Browse files
committed
Embed escape form in suggestion message; move test to parser/
- Suggestion message now reads e.g. "consider writing it as \`\u{2033}\` for clarity" so the diagnostic itself names the form the user should type, rather than abstractly referring to "its escaped form". - Move tests/ui/unicode-quote.{rs,stderr} into tests/ui/parser/ to satisfy the ui_tests tidy rule (compiler-team#902): ui tests must live under a meaningful subdirectory. Signed-off-by: Giles Cope <gilescope@gmail.com>
1 parent 5b8d834 commit adc634c

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

compiler/rustc_parse/src/lexer/unescape_error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub(crate) fn emit_unescape_error(
164164
));
165165
diag.span_suggestion_verbose(
166166
err_span,
167-
"consider writing it in its escaped form for clarity",
167+
format!("consider writing it as `{ec}` for clarity"),
168168
&ec,
169169
Applicability::MaybeIncorrect,
170170
);
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | dbg!("\″"); //U+2033
55
| ^ unknown character escape
66
|
77
= help: \u{2033} is not an ASCII quote, but may look like one in some fonts
8-
help: consider writing it in its escaped form for clarity
8+
help: consider writing it as `\u{2033}` for clarity
99
|
1010
LL - dbg!("\″"); //U+2033
1111
LL + dbg!("\u{2033}"); //U+2033
@@ -18,7 +18,7 @@ LL | dbg!("\ʺ"); //U+02BA
1818
| ^ unknown character escape
1919
|
2020
= help: \u{2ba} is not an ASCII quote, but may look like one in some fonts
21-
help: consider writing it in its escaped form for clarity
21+
help: consider writing it as `\u{2ba}` for clarity
2222
|
2323
LL - dbg!("\ʺ"); //U+02BA
2424
LL + dbg!("\u{2ba}"); //U+02BA
@@ -31,7 +31,7 @@ LL | dbg!("\˝"); //U+02DD
3131
| ^ unknown character escape
3232
|
3333
= help: \u{2dd} is not an ASCII quote, but may look like one in some fonts
34-
help: consider writing it in its escaped form for clarity
34+
help: consider writing it as `\u{2dd}` for clarity
3535
|
3636
LL - dbg!("\˝"); //U+02DD
3737
LL + dbg!("\u{2dd}"); //U+02DD
@@ -44,7 +44,7 @@ LL | dbg!("\̋"); //U+030B
4444
| ^unknown character escape
4545
|
4646
= help: \u{30b} is not an ASCII quote, but may look like one in some fonts
47-
help: consider writing it in its escaped form for clarity
47+
help: consider writing it as `\u{30b}` for clarity
4848
|
4949
LL - dbg!("\̋"); //U+030B
5050
LL + dbg!("\u{30b}"); //U+030B
@@ -57,7 +57,7 @@ LL | dbg!("\̎"); //U+030E
5757
| ^unknown character escape
5858
|
5959
= help: \u{30e} is not an ASCII quote, but may look like one in some fonts
60-
help: consider writing it in its escaped form for clarity
60+
help: consider writing it as `\u{30e}` for clarity
6161
|
6262
LL - dbg!("\̎"); //U+030E
6363
LL + dbg!("\u{30e}"); //U+030E
@@ -70,7 +70,7 @@ LL | dbg!("\״"); //U+05F4
7070
| ^ unknown character escape
7171
|
7272
= help: \u{5f4} is not an ASCII quote, but may look like one in some fonts
73-
help: consider writing it in its escaped form for clarity
73+
help: consider writing it as `\u{5f4}` for clarity
7474
|
7575
LL - dbg!("\״"); //U+05F4
7676
LL + dbg!("\u{5f4}"); //U+05F4
@@ -83,7 +83,7 @@ LL | dbg!("\“"); //U+201C
8383
| ^ unknown character escape
8484
|
8585
= help: \u{201c} is not an ASCII quote, but may look like one in some fonts
86-
help: consider writing it in its escaped form for clarity
86+
help: consider writing it as `\u{201c}` for clarity
8787
|
8888
LL - dbg!("\“"); //U+201C
8989
LL + dbg!("\u{201c}"); //U+201C
@@ -96,7 +96,7 @@ LL | dbg!("\”"); //U+201D
9696
| ^ unknown character escape
9797
|
9898
= help: \u{201d} is not an ASCII quote, but may look like one in some fonts
99-
help: consider writing it in its escaped form for clarity
99+
help: consider writing it as `\u{201d}` for clarity
100100
|
101101
LL - dbg!("\”"); //U+201D
102102
LL + dbg!("\u{201d}"); //U+201D

0 commit comments

Comments
 (0)