From 972560b83f80e1219b5735ff3d751c034115b08e Mon Sep 17 00:00:00 2001 From: Kevin Fitch Date: Mon, 6 Apr 2020 14:44:10 -0400 Subject: [PATCH] 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. --- src/librustc_builtin_macros/format.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs index 2883159a9f34c..d96398da616dc 100644 --- a/src/librustc_builtin_macros/format.rs +++ b/src/librustc_builtin_macros/format.rs @@ -918,6 +918,9 @@ pub fn expand_preparsed_format_args( skips.push(*next_pos); let _ = s.next(); } + + // TODO: Should this include: + // | ('\\', Some((next_pos, 'r'))) ('\\', Some((next_pos, '\n'))) | ('\\', Some((next_pos, 'n'))) | ('\\', Some((next_pos, 't'))) @@ -927,10 +930,14 @@ pub fn expand_preparsed_format_args( skips.push(*next_pos); let _ = s.next(); } + + // TODO: Should this include ('\r'), what about other weird + // whitespace like vertical tab? (' ', _) | ('\n', _) | ('\t', _) if eat_ws => { skips.push(pos); } ('\\', Some((next_pos, 'n'))) + | ('\\', Some((next_pos, 'r'))) | ('\\', Some((next_pos, 't'))) | ('\\', Some((next_pos, '0'))) | ('\\', Some((next_pos, '\\')))