Skip to content

Commit 37f37a5

Browse files
committed
parser/pat: minor misc cleanup
1 parent 49740b7 commit 37f37a5

File tree

1 file changed

+15
-13
lines changed
  • src/libsyntax/parse/parser

1 file changed

+15
-13
lines changed

src/libsyntax/parse/parser/pat.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,13 @@ impl<'a> Parser<'a> {
202202
} else {
203203
// Try to parse everything else as literal with optional minus
204204
match self.parse_literal_maybe_minus() {
205-
Ok(begin) if self.check(&token::DotDot) || self.check(&token::DotDotEq)
206-
|| self.check(&token::DotDotDot)
207-
=> self.parse_pat_range_starting_with_lit(begin)?,
205+
Ok(begin)
206+
if self.check(&token::DotDot)
207+
|| self.check(&token::DotDotEq)
208+
|| self.check(&token::DotDotDot) =>
209+
{
210+
self.parse_pat_range_starting_with_lit(begin)?
211+
}
208212
Ok(begin) => PatKind::Lit(begin),
209213
Err(mut err) => {
210214
self.cancel(&mut err);
@@ -446,28 +450,26 @@ impl<'a> Parser<'a> {
446450
}
447451

448452
/// Parses `ident` or `ident @ pat`.
449-
/// used by the copy foo and ref foo patterns to give a good
453+
/// Used by the copy foo and ref foo patterns to give a good
450454
/// error message when parsing mistakes like `ref foo(a, b)`.
451-
fn parse_pat_ident(&mut self,
452-
binding_mode: ast::BindingMode)
453-
-> PResult<'a, PatKind> {
455+
fn parse_pat_ident(&mut self, binding_mode: BindingMode) -> PResult<'a, PatKind> {
454456
let ident = self.parse_ident()?;
455457
let sub = if self.eat(&token::At) {
456458
Some(self.parse_pat(Some("binding pattern"))?)
457459
} else {
458460
None
459461
};
460462

461-
// just to be friendly, if they write something like
462-
// ref Some(i)
463-
// we end up here with ( as the current token. This shortly
464-
// leads to a parse error. Note that if there is no explicit
463+
// Just to be friendly, if they write something like `ref Some(i)`,
464+
// we end up here with `(` as the current token.
465+
// This shortly leads to a parse error. Note that if there is no explicit
465466
// binding mode then we do not end up here, because the lookahead
466-
// will direct us over to parse_enum_variant()
467+
// will direct us over to `parse_enum_variant()`.
467468
if self.token == token::OpenDelim(token::Paren) {
468469
return Err(self.span_fatal(
469470
self.prev_span,
470-
"expected identifier, found enum pattern"))
471+
"expected identifier, found enum pattern",
472+
))
471473
}
472474

473475
Ok(PatKind::Ident(binding_mode, ident, sub))

0 commit comments

Comments
 (0)