From b8ddcb0652f3ec8683023afc1e1f5166d6a712f4 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 14:53:02 +0200 Subject: Run cargo +nightly fix --clippy -Z unstable-options --- crates/ra_mbe/src/mbe_expander/matcher.rs | 2 +- crates/ra_mbe/src/parser.rs | 12 ++++++------ crates/ra_mbe/src/subtree_source.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'crates/ra_mbe') diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs index e36b5a412..2bdea11e1 100644 --- a/crates/ra_mbe/src/mbe_expander/matcher.rs +++ b/crates/ra_mbe/src/mbe_expander/matcher.rs @@ -101,7 +101,7 @@ fn match_subtree( tt::Leaf::Literal(tt::Literal { text: lhs, .. }), tt::Leaf::Literal(tt::Literal { text: rhs, .. }), ) if lhs == rhs => (), - _ => Err(ExpandError::UnexpectedToken)?, + _ => return Err(ExpandError::UnexpectedToken), } } Op::TokenTree(tt::TokenTree::Subtree(lhs)) => { diff --git a/crates/ra_mbe/src/parser.rs b/crates/ra_mbe/src/parser.rs index 50b8011a9..1cdebc216 100644 --- a/crates/ra_mbe/src/parser.rs +++ b/crates/ra_mbe/src/parser.rs @@ -100,7 +100,7 @@ fn next_op<'a>( Op::Repeat { subtree, separator, kind } } tt::TokenTree::Leaf(leaf) => match leaf { - tt::Leaf::Punct(..) => Err(ExpandError::UnexpectedToken)?, + tt::Leaf::Punct(..) => return Err(ExpandError::UnexpectedToken), tt::Leaf::Ident(ident) => { let name = &ident.text; let kind = eat_fragment_kind(src, mode)?; @@ -147,15 +147,15 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option, RepeatKind), Exp for tt in src { let tt = match tt { tt::TokenTree::Leaf(leaf) => leaf, - tt::TokenTree::Subtree(_) => Err(ExpandError::InvalidRepeat)?, + tt::TokenTree::Subtree(_) => return Err(ExpandError::InvalidRepeat), }; let has_sep = match &separator { - Separator::Puncts(puncts) => puncts.len() != 0, + Separator::Puncts(puncts) => !puncts.is_empty(), _ => true, }; match tt { tt::Leaf::Ident(_) | tt::Leaf::Literal(_) if has_sep => { - Err(ExpandError::InvalidRepeat)? + return Err(ExpandError::InvalidRepeat) } tt::Leaf::Ident(ident) => separator = Separator::Ident(ident.clone()), tt::Leaf::Literal(lit) => separator = Separator::Literal(lit.clone()), @@ -168,11 +168,11 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option, RepeatKind), Exp match &mut separator { Separator::Puncts(puncts) => { if puncts.len() == 3 { - Err(ExpandError::InvalidRepeat)? + return Err(ExpandError::InvalidRepeat); } puncts.push(punct.clone()) } - _ => Err(ExpandError::InvalidRepeat)?, + _ => return Err(ExpandError::InvalidRepeat), } continue; } diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index c9f42b3dd..eb8b79e9a 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs @@ -124,7 +124,7 @@ fn convert_delim(d: Option, closing: bool) -> TtToken { let idx = closing as usize; let kind = kinds[idx]; - let text = if texts.len() > 0 { &texts[idx..texts.len() - (1 - idx)] } else { "" }; + let text = if !texts.is_empty() { &texts[idx..texts.len() - (1 - idx)] } else { "" }; TtToken { kind, is_joint_to_next: false, text: SmolStr::new(text) } } -- cgit v1.2.3