@@ -60,13 +60,17 @@ pub enum EscapeError {
60
60
/// After a line ending with '\', the next line contains whitespace
61
61
/// characters that are not skipped.
62
62
UnskippedWhitespaceWarning ,
63
+
64
+ /// After a line ending with '\', multiple lines are skipped.
65
+ MultipleSkippedLinesWarning ,
63
66
}
64
67
65
68
impl EscapeError {
66
69
/// Returns true for actual errors, as opposed to warnings.
67
70
pub fn is_fatal ( & self ) -> bool {
68
71
match self {
69
72
EscapeError :: UnskippedWhitespaceWarning => false ,
73
+ EscapeError :: MultipleSkippedLinesWarning => false ,
70
74
_ => true ,
71
75
}
72
76
}
@@ -315,12 +319,17 @@ where
315
319
where
316
320
F : FnMut ( Range < usize > , Result < char , EscapeError > ) ,
317
321
{
318
- let str = chars. as_str ( ) ;
319
- let first_non_space = str
322
+ let tail = chars. as_str ( ) ;
323
+ let first_non_space = tail
320
324
. bytes ( )
321
325
. 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..] ;
324
333
if let Some ( c) = tail. chars ( ) . nth ( 0 ) {
325
334
// For error reporting, we would like the span to contain the character that was not
326
335
// skipped. The +1 is necessary to account for the leading \ that started the escape.
0 commit comments