]> git.lizzy.rs Git - rust.git/commitdiff
simplify parse_fn_block_decl
authorMazdak Farrokhzad <twingoow@gmail.com>
Fri, 6 Dec 2019 22:35:48 +0000 (23:35 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Mon, 23 Dec 2019 12:43:21 +0000 (13:43 +0100)
src/librustc_parse/parser/expr.rs

index ce0a3e18877681a79d730d3cd0950d04405904bf..acc7bfd3f8a1b67ce47ae9306518042a6f119578 100644 (file)
@@ -1360,26 +1360,24 @@ fn parse_capture_clause(&mut self) -> CaptureBy {
 
     /// Parses the `|arg, arg|` header of a closure.
     fn parse_fn_block_decl(&mut self) -> PResult<'a, P<FnDecl>> {
-        let inputs_captures = {
-            if self.eat(&token::OrOr) {
-                Vec::new()
-            } else {
-                self.expect(&token::BinOp(token::Or))?;
-                let args = self
-                    .parse_seq_to_before_tokens(
-                        &[&token::BinOp(token::Or), &token::OrOr],
-                        SeqSep::trailing_allowed(token::Comma),
-                        TokenExpectType::NoExpect,
-                        |p| p.parse_fn_block_param(),
-                    )?
-                    .0;
-                self.expect_or()?;
-                args
-            }
+        let inputs = if self.eat(&token::OrOr) {
+            Vec::new()
+        } else {
+            self.expect(&token::BinOp(token::Or))?;
+            let args = self
+                .parse_seq_to_before_tokens(
+                    &[&token::BinOp(token::Or), &token::OrOr],
+                    SeqSep::trailing_allowed(token::Comma),
+                    TokenExpectType::NoExpect,
+                    |p| p.parse_fn_block_param(),
+                )?
+                .0;
+            self.expect_or()?;
+            args
         };
         let output = self.parse_ret_ty(true, true)?;
 
-        Ok(P(FnDecl { inputs: inputs_captures, output }))
+        Ok(P(FnDecl { inputs, output }))
     }
 
     /// Parses a parameter in a closure header (e.g., `|arg, arg|`).