Skip to content

Commit 972560b

Browse files
committed
Fix processing of escape sequences so we don't forget about \r. This avoids OBOEs when generating diagnostics. Also, this OBOE could cause a panic/ICE if we end up offcut in the middle of a UTF-8 sequence.
1 parent 4015890 commit 972560b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc_builtin_macros/format.rs

+7
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,9 @@ pub fn expand_preparsed_format_args(
918918
skips.push(*next_pos);
919919
let _ = s.next();
920920
}
921+
922+
// TODO: Should this include:
923+
// | ('\\', Some((next_pos, 'r')))
921924
('\\', Some((next_pos, '\n')))
922925
| ('\\', Some((next_pos, 'n')))
923926
| ('\\', Some((next_pos, 't')))
@@ -927,10 +930,14 @@ pub fn expand_preparsed_format_args(
927930
skips.push(*next_pos);
928931
let _ = s.next();
929932
}
933+
934+
// TODO: Should this include ('\r'), what about other weird
935+
// whitespace like vertical tab?
930936
(' ', _) | ('\n', _) | ('\t', _) if eat_ws => {
931937
skips.push(pos);
932938
}
933939
('\\', Some((next_pos, 'n')))
940+
| ('\\', Some((next_pos, 'r')))
934941
| ('\\', Some((next_pos, 't')))
935942
| ('\\', Some((next_pos, '0')))
936943
| ('\\', Some((next_pos, '\\')))

0 commit comments

Comments
 (0)