@@ -60,13 +60,17 @@ pub enum EscapeError {
6060 /// After a line ending with '\', the next line contains whitespace
6161 /// characters that are not skipped.
6262 UnskippedWhitespaceWarning ,
63+
64+ /// After a line ending with '\', multiple lines are skipped.
65+ MultipleSkippedLinesWarning ,
6366}
6467
6568impl EscapeError {
6669 /// Returns true for actual errors, as opposed to warnings.
6770 pub fn is_fatal ( & self ) -> bool {
6871 match self {
6972 EscapeError :: UnskippedWhitespaceWarning => false ,
73+ EscapeError :: MultipleSkippedLinesWarning => false ,
7074 _ => true ,
7175 }
7276 }
@@ -315,12 +319,17 @@ where
315319 where
316320 F : FnMut ( Range < usize > , Result < char , EscapeError > ) ,
317321 {
318- let str = chars. as_str ( ) ;
319- let first_non_space = str
322+ let tail = chars. as_str ( ) ;
323+ let first_non_space = tail
320324 . bytes ( )
321325 . position ( |b| b != b' ' && b != b'\t' && b != b'\n' && b != b'\r' )
322- . unwrap_or ( str. len ( ) ) ;
323- let tail = & str[ first_non_space..] ;
326+ . unwrap_or ( tail. len ( ) ) ;
327+ if tail[ 1 ..first_non_space] . contains ( '\n' ) {
328+ // The +1 accounts for the escaping slash.
329+ let end = start + first_non_space + 1 ;
330+ callback ( start..end, Err ( EscapeError :: MultipleSkippedLinesWarning ) ) ;
331+ }
332+ let tail = & tail[ first_non_space..] ;
324333 if let Some ( c) = tail. chars ( ) . nth ( 0 ) {
325334 // For error reporting, we would like the span to contain the character that was not
326335 // skipped. The +1 is necessary to account for the leading \ that started the escape.
0 commit comments