@@ -2564,9 +2564,7 @@ fn num_decimal_digits(num: usize) -> usize {
25642564
25652565// We replace some characters so the CLI output is always consistent and underlines aligned.
25662566// Keep the following list in sync with `rustc_span::char_width`.
2567- // ATTENTION: keep lexicografically sorted so that the binary search will work
25682567const OUTPUT_REPLACEMENTS : & [ ( char , & str ) ] = & [
2569- // tidy-alphabetical-start
25702568 // In terminals without Unicode support the following will be garbled, but in *all* terminals
25712569 // the underlying codepoint will be as well. We could gate this replacement behind a "unicode
25722570 // support" gate.
@@ -2579,7 +2577,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
25792577 ( '\u{0006}' , "␆" ) ,
25802578 ( '\u{0007}' , "␇" ) ,
25812579 ( '\u{0008}' , "␈" ) ,
2582- ( '\u{0009} ' , " " ) , // We do our own tab replacement
2580+ ( '\t ' , " " ) , // We do our own tab replacement
25832581 ( '\u{000b}' , "␋" ) ,
25842582 ( '\u{000c}' , "␌" ) ,
25852583 ( '\u{000d}' , "␍" ) ,
@@ -2612,10 +2610,20 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
26122610 ( '\u{2067}' , "�" ) ,
26132611 ( '\u{2068}' , "�" ) ,
26142612 ( '\u{2069}' , "�" ) ,
2615- // tidy-alphabetical-end
26162613] ;
26172614
26182615fn 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+ }
26192627 // Scan the input string for a character in the ordered table above. If it's present, replace
26202628 // it with it's alternative string (it can be more than 1 char!). Otherwise, retain the input
26212629 // char. At the end, allocate all chars into a string in one operation.
0 commit comments