Skip to content

Commit d446c73

Browse files
committed
parser: refactor away at_end
1 parent abc46a5 commit d446c73

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/librustc_parse/parser/item.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'a> Parser<'a> {
161161
(Ident::invalid(), ItemKind::Use(P(tree)))
162162
} else if self.check_fn_front_matter() {
163163
// FUNCTION ITEM
164-
let (ident, sig, generics, body) = self.parse_fn(&mut false, attrs, req_name)?;
164+
let (ident, sig, generics, body) = self.parse_fn(attrs, req_name)?;
165165
(ident, ItemKind::Fn(sig, generics, body))
166166
} else if self.eat_keyword(kw::Extern) {
167167
if self.eat_keyword(kw::Crate) {
@@ -1406,7 +1406,6 @@ impl<'a> Parser<'a> {
14061406
/// Parse a function starting from the front matter (`const ...`) to the body `{ ... }` or `;`.
14071407
fn parse_fn(
14081408
&mut self,
1409-
at_end: &mut bool,
14101409
attrs: &mut Vec<Attribute>,
14111410
req_name: ReqName,
14121411
) -> PResult<'a, (Ident, FnSig, Generics, Option<P<Block>>)> {
@@ -1415,18 +1414,14 @@ impl<'a> Parser<'a> {
14151414
let mut generics = self.parse_generics()?; // `<'a, T, ...>`
14161415
let decl = self.parse_fn_decl(req_name, AllowPlus::Yes)?; // `(p: u8, ...)`
14171416
generics.where_clause = self.parse_where_clause()?; // `where T: Ord`
1418-
let body = self.parse_fn_body(at_end, attrs)?; // `;` or `{ ... }`.
1417+
let body = self.parse_fn_body(attrs)?; // `;` or `{ ... }`.
14191418
Ok((ident, FnSig { header, decl }, generics, body))
14201419
}
14211420

14221421
/// Parse the "body" of a function.
14231422
/// This can either be `;` when there's no body,
14241423
/// or e.g. a block when the function is a provided one.
1425-
fn parse_fn_body(
1426-
&mut self,
1427-
at_end: &mut bool,
1428-
attrs: &mut Vec<Attribute>,
1429-
) -> PResult<'a, Option<P<Block>>> {
1424+
fn parse_fn_body(&mut self, attrs: &mut Vec<Attribute>) -> PResult<'a, Option<P<Block>>> {
14301425
let (inner_attrs, body) = match self.token.kind {
14311426
token::Semi => {
14321427
self.bump();
@@ -1446,7 +1441,6 @@ impl<'a> Parser<'a> {
14461441
_ => return self.expected_semi_or_open_brace(),
14471442
};
14481443
attrs.extend(inner_attrs);
1449-
*at_end = true;
14501444
Ok(body)
14511445
}
14521446

0 commit comments

Comments
 (0)