Skip to content

Commit 01e2d29

Browse files
committed
Replace ZWJ with nothing in terminal output
1 parent 9d64a8d commit 01e2d29

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2054,8 +2054,17 @@ fn num_decimal_digits(num: usize) -> usize {
20542054
MAX_DIGITS
20552055
}
20562056

2057+
const REPLACEMENTS: &[(char, &str)] = &[
2058+
('\t', " "),
2059+
('\u{200D}', ""), // Replace ZWJ with nothing for consistent terminal output of grapheme clusters.
2060+
];
2061+
20572062
fn replace_tabs(str: &str) -> String {
2058-
str.replace('\t', " ")
2063+
let mut output = str.to_string();
2064+
for (c, replacement) in REPLACEMENTS {
2065+
output = output.replace(*c, replacement);
2066+
}
2067+
output
20592068
}
20602069

20612070
fn draw_col_separator(buffer: &mut StyledBuffer, line: usize, col: usize) {

src/test/ui/parser/emoji-identifiers.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ error: identifiers cannot contain emojis: `i_like_to_😅_a_lot`
4848
LL | fn i_like_to_😅_a_lot() -> 👀 {
4949
| ^^^^^^^^^^^^^^^^^^
5050

51-
error: identifiers cannot contain emojis: `ABig👩‍👩‍👧‍👧Family`
51+
error: identifiers cannot contain emojis: `ABig👩👩👧👧Family`
5252
--> $DIR/emoji-identifiers.rs:1:8
5353
|
54-
LL | struct ABig👩‍👩‍👧‍👧Family;
54+
LL | struct ABig👩👩👧👧Family;
5555
| ^^^^^^^^^^^^^^^^^^
5656

5757
error[E0599]: no function or associated item named `full_of✨` found for struct `👀` in the current scope

0 commit comments

Comments
 (0)