about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorZack M. Davis <code@zackmdavis.net>2016-07-03 14:38:37 -0700
committerZack M. Davis <code@zackmdavis.net>2016-07-03 16:27:02 -0700
commitd37edef9dd088d953c5e272db37686a338c31778 (patch)
tree294c125abc99a5d3e7d788c2cc0b056ecd35a26e /src/libsyntax/parse/parser.rs
parent5e858f34df6ac9ae9d2fbc40c84db9d4bcd29eff (diff)
downloadrust-d37edef9dd088d953c5e272db37686a338c31778.tar.gz
rust-d37edef9dd088d953c5e272db37686a338c31778.zip
prefer `if let` to match with `None => {}` arm in some places
This is a spiritual succesor to #34268/8531d581, in which we replaced a
number of matches of None to the unit value with `if let` conditionals
where it was judged that this made for clearer/simpler code (as would be
recommended by Manishearth/rust-clippy's `single_match` lint). The same
rationale applies to matches of None to the empty block.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 20a54228d01..6fa95afd9fb 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2752,9 +2752,8 @@ impl<'a> Parser<'a> {
             }
         };
 
-        match parse_kleene_op(self)? {
-            Some(kleene_op) => return Ok((None, kleene_op)),
-            None => {}
+        if let Some(kleene_op) = parse_kleene_op(self)? {
+            return Ok((None, kleene_op));
         }
 
         let separator = self.bump_and_get();
@@ -5691,15 +5690,12 @@ impl<'a> Parser<'a> {
             }
             _ => None
         };
-        match nt_item {
-            Some(mut item) => {
-                self.bump();
-                let mut attrs = attrs;
-                mem::swap(&mut item.attrs, &mut attrs);
-                item.attrs.extend(attrs);
-                return Ok(Some(P(item)));
-            }
-            None => {}
+        if let Some(mut item) = nt_item {
+            self.bump();
+            let mut attrs = attrs;
+            mem::swap(&mut item.attrs, &mut attrs);
+            item.attrs.extend(attrs);
+            return Ok(Some(P(item)));
         }
 
         let lo = self.span.lo;