@@ -2564,9 +2564,7 @@ fn num_decimal_digits(num: usize) -> usize {
2564
2564
2565
2565
// We replace some characters so the CLI output is always consistent and underlines aligned.
2566
2566
// Keep the following list in sync with `rustc_span::char_width`.
2567
- // ATTENTION: keep lexicografically sorted so that the binary search will work
2568
2567
const OUTPUT_REPLACEMENTS : & [ ( char , & str ) ] = & [
2569
- // tidy-alphabetical-start
2570
2568
// In terminals without Unicode support the following will be garbled, but in *all* terminals
2571
2569
// the underlying codepoint will be as well. We could gate this replacement behind a "unicode
2572
2570
// support" gate.
@@ -2579,7 +2577,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
2579
2577
( '\u{0006}' , "␆" ) ,
2580
2578
( '\u{0007}' , "␇" ) ,
2581
2579
( '\u{0008}' , "␈" ) ,
2582
- ( '\u{0009} ' , " " ) , // We do our own tab replacement
2580
+ ( '\t ' , " " ) , // We do our own tab replacement
2583
2581
( '\u{000b}' , "␋" ) ,
2584
2582
( '\u{000c}' , "␌" ) ,
2585
2583
( '\u{000d}' , "␍" ) ,
@@ -2612,10 +2610,20 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
2612
2610
( '\u{2067}' , "�" ) ,
2613
2611
( '\u{2068}' , "�" ) ,
2614
2612
( '\u{2069}' , "�" ) ,
2615
- // tidy-alphabetical-end
2616
2613
] ;
2617
2614
2618
2615
fn normalize_whitespace ( s : & str ) -> String {
2616
+ const {
2617
+ let mut i = 1 ;
2618
+ while i < OUTPUT_REPLACEMENTS . len ( ) {
2619
+ assert ! (
2620
+ OUTPUT_REPLACEMENTS [ i - 1 ] . 0 < OUTPUT_REPLACEMENTS [ i] . 0 ,
2621
+ "The OUTPUT_REPLACEMENTS array must be sorted (for binary search to work) \
2622
+ and must contain no duplicate entries"
2623
+ ) ;
2624
+ i += 1 ;
2625
+ }
2626
+ }
2619
2627
// Scan the input string for a character in the ordered table above. If it's present, replace
2620
2628
// it with it's alternative string (it can be more than 1 char!). Otherwise, retain the input
2621
2629
// char. At the end, allocate all chars into a string in one operation.
0 commit comments