@@ -6,6 +6,7 @@ use self::Normalization::*;
66use crate :: directory:: Directory ;
77use crate :: run:: PathDependency ;
88use std:: cmp;
9+ use std:: mem;
910use std:: path:: Path ;
1011
1112#[ derive( Copy , Clone ) ]
@@ -59,6 +60,7 @@ normalizations! {
5960 StripLongTypeNameFiles ,
6061 UnindentAfterHelp ,
6162 AndOthersVerbose ,
63+ UnindentMultilineNote ,
6264 // New normalization steps are to be inserted here at the end so that any
6365 // snapshots saved before your normalization change remain passing.
6466}
@@ -542,7 +544,7 @@ fn unindent(diag: String, normalization: Normalization) -> String {
542544 normalized. push_str ( line) ;
543545 normalized. push ( '\n' ) ;
544546
545- if indented_line_kind ( line, normalization) != IndentedLineKind :: Heading {
547+ if indented_line_kind ( line, & mut false , normalization) != IndentedLineKind :: Heading {
546548 continue ;
547549 }
548550
@@ -551,12 +553,15 @@ fn unindent(diag: String, normalization: Normalization) -> String {
551553 continue ;
552554 } ;
553555
554- if let IndentedLineKind :: Code ( indent) = indented_line_kind ( next_line, normalization) {
556+ if let IndentedLineKind :: Code ( indent) =
557+ indented_line_kind ( next_line, & mut false , normalization)
558+ {
555559 if next_line[ indent + 1 ..] . starts_with ( "--> " ) {
556560 let mut lines_in_block = 1 ;
557561 let mut least_indent = indent;
562+ let mut previous_line_is_note = false ;
558563 while let Some ( line) = ahead. next ( ) {
559- match indented_line_kind ( line, normalization) {
564+ match indented_line_kind ( line, & mut previous_line_is_note , normalization) {
560565 IndentedLineKind :: Heading => break ,
561566 IndentedLineKind :: Code ( indent) => {
562567 lines_in_block += 1 ;
@@ -572,10 +577,11 @@ fn unindent(diag: String, normalization: Normalization) -> String {
572577 }
573578 }
574579 }
580+ previous_line_is_note = false ;
575581 for _ in 0 ..lines_in_block {
576582 let line = lines. next ( ) . unwrap ( ) ;
577583 if let IndentedLineKind :: Code ( _) | IndentedLineKind :: Other ( _) =
578- indented_line_kind ( line, normalization)
584+ indented_line_kind ( line, & mut previous_line_is_note , normalization)
579585 {
580586 let space = line. find ( ' ' ) . unwrap ( ) ;
581587 normalized. push_str ( & line[ ..space] ) ;
@@ -592,7 +598,13 @@ fn unindent(diag: String, normalization: Normalization) -> String {
592598 normalized
593599}
594600
595- fn indented_line_kind ( line : & str , normalization : Normalization ) -> IndentedLineKind {
601+ fn indented_line_kind (
602+ line : & str ,
603+ previous_line_is_note : & mut bool ,
604+ normalization : Normalization ,
605+ ) -> IndentedLineKind {
606+ let previous_line_was_note = mem:: replace ( previous_line_is_note, false ) ;
607+
596608 if let Some ( heading_len) = if line. starts_with ( "error" ) {
597609 Some ( "error" . len ( ) )
598610 } else if line. starts_with ( "warning" ) {
@@ -608,7 +620,11 @@ fn indented_line_kind(line: &str, normalization: Normalization) -> IndentedLineK
608620 if line. starts_with ( "note:" )
609621 || line == "..."
610622 || normalization >= UnindentAfterHelp && line. starts_with ( "help:" )
623+ || normalization >= UnindentMultilineNote
624+ && previous_line_was_note
625+ && line. starts_with ( " " )
611626 {
627+ * previous_line_is_note = true ;
612628 return IndentedLineKind :: Note ;
613629 }
614630
0 commit comments