Skip to content

Commit 5ec4d3c

Browse files
committed
applied suggestions
1 parent a56bd54 commit 5ec4d3c

File tree

1 file changed

+3
-7
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+3
-7
lines changed

compiler/rustc_parse/src/parser/item.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,17 @@ impl<'a> Parser<'a> {
5858
let attrs = self.parse_inner_attributes()?;
5959

6060
let post_attr_lo = self.token.span;
61-
let mut items = ThinVec::new();
61+
let mut items: ThinVec<P<_>> = ThinVec::new();
6262

63-
// There shouldn't be any semicolons before or afer items.
63+
// There shouldn't be any stray semicolons before or after items.
6464
// `parse_item` consumes the appropriate semicolons so any leftover is an error.
65-
let mut last = None;
6665
loop {
67-
while self.maybe_consume_incorrect_semicolon(last) {} // Eat all bad semicolons
66+
while self.maybe_consume_incorrect_semicolon(items.last().map(|x| &**x)) {} // Eat all bad semicolons
6867
let Some(item) = self.parse_item(ForceCollect::No)? else {
6968
break;
7069
};
7170
items.push(item);
72-
last = items.last().map(|x| &**x);
7371
}
74-
// Handle trailing semicolon at the end of the module
75-
self.maybe_consume_incorrect_semicolon(last);
7672

7773
if !self.eat(term) {
7874
let token_str = super::token_descr(&self.token);

0 commit comments

Comments
 (0)