@@ -2559,9 +2559,7 @@ fn num_decimal_digits(num: usize) -> usize {
25592559
25602560// We replace some characters so the CLI output is always consistent and underlines aligned.
25612561// Keep the following list in sync with `rustc_span::char_width`.
2562- // ATTENTION: keep lexicografically sorted so that the binary search will work
25632562const OUTPUT_REPLACEMENTS : & [ ( char , & str ) ] = & [
2564- // tidy-alphabetical-start
25652563 // In terminals without Unicode support the following will be garbled, but in *all* terminals
25662564 // the underlying codepoint will be as well. We could gate this replacement behind a "unicode
25672565 // support" gate.
@@ -2574,7 +2572,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
25742572 ( '\u{0006}' , "␆" ) ,
25752573 ( '\u{0007}' , "␇" ) ,
25762574 ( '\u{0008}' , "␈" ) ,
2577- ( '\u{0009} ' , " " ) , // We do our own tab replacement
2575+ ( '\t ' , " " ) , // We do our own tab replacement
25782576 ( '\u{000b}' , "␋" ) ,
25792577 ( '\u{000c}' , "␌" ) ,
25802578 ( '\u{000d}' , "␍" ) ,
@@ -2607,10 +2605,20 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
26072605 ( '\u{2067}' , "�" ) ,
26082606 ( '\u{2068}' , "�" ) ,
26092607 ( '\u{2069}' , "�" ) ,
2610- // tidy-alphabetical-end
26112608] ;
26122609
26132610fn 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+ }
26142622 // Scan the input string for a character in the ordered table above. If it's present, replace
26152623 // it with it's alternative string (it can be more than 1 char!). Otherwise, retain the input
26162624 // char. At the end, allocate all chars into a string in one operation.
0 commit comments