diff options
| author | bors <bors@rust-lang.org> | 2021-03-27 07:59:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-27 07:59:24 +0000 |
| commit | feaac19f1710ebcfecc783d51f52a9b0d8e998f5 (patch) | |
| tree | 44502d0676b2b73cc6c5c4377338d5309134d7ca /compiler/rustc_parse_format/src | |
| parent | f811f14006fa46030f1af714f7d640580d3ad822 (diff) | |
| parent | 1b01e0d36a1498ffe69dad46168efbf762bf0bb8 (diff) | |
| download | rust-feaac19f1710ebcfecc783d51f52a9b0d8e998f5.tar.gz rust-feaac19f1710ebcfecc783d51f52a9b0d8e998f5.zip | |
Auto merge of #83547 - JohnTitor:rollup-qh7j6hg, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #83239 (Remove/replace some outdated crates from the dependency tree) - #83328 (Fixes to inline assmebly tests) - #83343 (Simplify and fix byte skipping in format! string parser) - #83388 (Make # pretty print format easier to discover) - #83431 (Tell GitHub to highlight `config.toml.example` as TOML) - #83508 (Use the direct link to the platform support page) - #83511 (compiletest: handle llvm_version with suffix like "12.0.0libcxx") - #83524 (Document that the SocketAddr memory representation is not stable) - #83525 (fix doc comment for `ty::Dynamic`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse_format/src')
| -rw-r--r-- | compiler/rustc_parse_format/src/lib.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index c2fc2bfcd33..a5fdf064e94 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -735,25 +735,24 @@ fn find_skips_from_snippet( }; fn find_skips(snippet: &str, is_raw: bool) -> Vec<usize> { - let mut eat_ws = false; let mut s = snippet.char_indices().peekable(); let mut skips = vec![]; while let Some((pos, c)) = s.next() { match (c, s.peek()) { // skip whitespace and empty lines ending in '\\' ('\\', Some((next_pos, '\n'))) if !is_raw => { - eat_ws = true; skips.push(pos); skips.push(*next_pos); let _ = s.next(); - } - ('\\', Some((next_pos, '\n' | 'n' | 't'))) if eat_ws => { - skips.push(pos); - skips.push(*next_pos); - let _ = s.next(); - } - (' ' | '\n' | '\t', _) if eat_ws => { - skips.push(pos); + + while let Some((pos, c)) = s.peek() { + if matches!(c, ' ' | '\n' | '\t') { + skips.push(*pos); + let _ = s.next(); + } else { + break; + } + } } ('\\', Some((next_pos, 'n' | 't' | 'r' | '0' | '\\' | '\'' | '\"'))) => { skips.push(*next_pos); @@ -804,10 +803,6 @@ fn find_skips_from_snippet( } } } - _ if eat_ws => { - // `take_while(|c| c.is_whitespace())` - eat_ws = false; - } _ => {} } } |
