From d493a4476c2059924d032fbf01dda091601f9667 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 16 Oct 2018 11:51:58 -0400 Subject: clippy: Use if lets and remove redundant returns --- crates/ra_syntax/src/grammar/expressions/atom.rs | 5 ++--- crates/ra_syntax/src/grammar/items/mod.rs | 6 ++---- crates/ra_syntax/src/grammar/patterns.rs | 5 ++--- 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'crates/ra_syntax/src/grammar') diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index 11f766d33..04087fd60 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs @@ -62,9 +62,8 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![ const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option { - match literal(p) { - Some(m) => return Some(m), - None => (), + if let Some(m) = literal(p) { + return Some(m); } if paths::is_path_start(p) || p.at(L_ANGLE) { return Some(path_expr(p, r)); diff --git a/crates/ra_syntax/src/grammar/items/mod.rs b/crates/ra_syntax/src/grammar/items/mod.rs index dc4742bce..06c6b5e6e 100644 --- a/crates/ra_syntax/src/grammar/items/mod.rs +++ b/crates/ra_syntax/src/grammar/items/mod.rs @@ -352,7 +352,7 @@ fn macro_call(p: &mut Parser) -> BlockLike { pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike { p.expect(EXCL); p.eat(IDENT); - let flavor = match p.current() { + match p.current() { L_CURLY => { token_tree(p); BlockLike::Block @@ -365,9 +365,7 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike { p.error("expected `{`, `[`, `(`"); BlockLike::NotBlock } - }; - - flavor + } } pub(crate) fn token_tree(p: &mut Parser) { diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs index 9d35dbb3d..10fa0e0be 100644 --- a/crates/ra_syntax/src/grammar/patterns.rs +++ b/crates/ra_syntax/src/grammar/patterns.rs @@ -49,9 +49,8 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option { // "hello" => (), // } // } - match expressions::literal(p) { - Some(m) => return Some(m), - None => (), + if let Some(m) = expressions::literal(p) { + return Some(m); } let m = match la0 { -- cgit v1.2.3