diff options
| author | bors <bors@rust-lang.org> | 2024-05-21 19:29:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-21 19:29:59 +0000 |
| commit | 39e02f1bd1e53d009da382654139f7c0639172a8 (patch) | |
| tree | 5d30e39fef6aaf31366f0db20eb2af9c8bee77ff /compiler/rustc_parse/src/parser | |
| parent | 506512391b1a75ae450d36c9420978402a91abcc (diff) | |
| parent | d04e2e2858a3805f170a2934c9da45205965253c (diff) | |
| download | rust-39e02f1bd1e53d009da382654139f7c0639172a8.tar.gz rust-39e02f1bd1e53d009da382654139f7c0639172a8.zip | |
Auto merge of #125379 - matthiaskrgr:rollup-6149w01, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #123122 (Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.) - #123492 (add pull request template asking for relevant tracking issues) - #125276 (Fix parsing of erroneously placed semicolons) - #125310 (Move ~100 tests from tests/ui to subdirs) - #125357 (Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs`) - #125369 (Don't do cc detection for synthetic targets) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index a46c104b6d9..f43ddadc2ea 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -58,9 +58,15 @@ impl<'a> Parser<'a> { let attrs = self.parse_inner_attributes()?; let post_attr_lo = self.token.span; - let mut items = ThinVec::new(); - while let Some(item) = self.parse_item(ForceCollect::No)? { - self.maybe_consume_incorrect_semicolon(Some(&item)); + let mut items: ThinVec<P<_>> = ThinVec::new(); + + // There shouldn't be any stray semicolons before or after items. + // `parse_item` consumes the appropriate semicolons so any leftover is an error. + loop { + while self.maybe_consume_incorrect_semicolon(items.last().map(|x| &**x)) {} // Eat all bad semicolons + let Some(item) = self.parse_item(ForceCollect::No)? else { + break; + }; items.push(item); } |
