Skip to content

Commit

Permalink
Fix processing of escape sequences so we don't forget about \r. This …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
kfitch committed Apr 6, 2020
1 parent 4015890 commit 972560b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustc_builtin_macros/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand All @@ -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, '\\')))
Expand Down

0 comments on commit 972560b

Please sign in to comment.