diff options
| author | bors <bors@rust-lang.org> | 2014-12-01 21:56:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-01 21:56:53 +0000 |
| commit | 21ba1d5e58144c83093a8cbb467a6c9cb12fc4a1 (patch) | |
| tree | c2855394846b767303ca815487cbbf81be608f4c /src/libsyntax/parse | |
| parent | de95ad4c46788518822326941bdc5084b1023abf (diff) | |
| parent | a779e3b5c432c341b0e32d588d966199d3be9c27 (diff) | |
| download | rust-21ba1d5e58144c83093a8cbb467a6c9cb12fc4a1.tar.gz rust-21ba1d5e58144c83093a8cbb467a6c9cb12fc4a1.zip | |
auto merge of #19405 : jfager/rust/de-match-pyramid, r=bstrie
No semantic changes, no enabling `if let` where it wasn't already enabled.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 63 |
1 files changed, 19 insertions, 44 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c76d9edf635..fe9c5494517 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -178,11 +178,8 @@ macro_rules! maybe_whole ( } _ => None }; - match found { - Some(token::Interpolated(token::$constructor(x))) => { - return x.clone() - } - _ => {} + if let Some(token::Interpolated(token::$constructor(x))) = found { + return x.clone(); } } ); @@ -194,11 +191,8 @@ macro_rules! maybe_whole ( } _ => None }; - match found { - Some(token::Interpolated(token::$constructor(x))) => { - return x - } - _ => {} + if let Some(token::Interpolated(token::$constructor(x))) = found { + return x; } } ); @@ -210,11 +204,8 @@ macro_rules! maybe_whole ( } _ => None }; - match found { - Some(token::Interpolated(token::$constructor(x))) => { - return (*x).clone() - } - _ => {} + if let Some(token::Interpolated(token::$constructor(x))) = found { + return (*x).clone(); } } ); @@ -226,11 +217,8 @@ macro_rules! maybe_whole ( } _ => None }; - match found { - Some(token::Interpolated(token::$constructor(x))) => { - return Some(x.clone()), - } - _ => {} + if let Some(token::Interpolated(token::$constructor(x))) = found { + return Some(x.clone()); } } ); @@ -242,11 +230,8 @@ macro_rules! maybe_whole ( } _ => None }; - match found { - Some(token::Interpolated(token::$constructor(x))) => { - return IoviItem(x.clone()) - } - _ => {} + if let Some(token::Interpolated(token::$constructor(x))) = found { + return IoviItem(x.clone()); } } ); @@ -258,11 +243,8 @@ macro_rules! maybe_whole ( } _ => None }; - match found { - Some(token::Interpolated(token::$constructor(x))) => { - return (Vec::new(), x) - } - _ => {} + if let Some(token::Interpolated(token::$constructor(x))) = found { + return (Vec::new(), x); } } ) @@ -469,15 +451,11 @@ impl<'a> Parser<'a> { /// from anticipated input errors, discarding erroneous characters. pub fn commit_expr(&mut self, e: &Expr, edible: &[token::Token], inedible: &[token::Token]) { debug!("commit_expr {}", e); - match e.node { - ExprPath(..) => { - // might be unit-struct construction; check for recoverableinput error. - let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>(); - expected.push_all(inedible); - self.check_for_erroneous_unit_struct_expecting( - expected.as_slice()); - } - _ => {} + if let ExprPath(..) = e.node { + // might be unit-struct construction; check for recoverableinput error. + let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>(); + expected.push_all(inedible); + self.check_for_erroneous_unit_struct_expecting(expected.as_slice()); } self.expect_one_of(edible, inedible) } @@ -1765,11 +1743,8 @@ impl<'a> Parser<'a> { token::Interpolated(token::NtPath(_)) => Some(self.bump_and_get()), _ => None, }; - match found { - Some(token::Interpolated(token::NtPath(box path))) => { - return path; - } - _ => {} + if let Some(token::Interpolated(token::NtPath(box path))) = found { + return path; } let lo = self.span.lo; |
