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