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/parser.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_mbe/src/parser.rs') 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; } -- cgit v1.2.3 From eceaf94f1936436e33ae235ca65bf2a6d4f77da5 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 15:32:19 +0200 Subject: More manual clippy fixes --- crates/ra_mbe/src/parser.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'crates/ra_mbe/src/parser.rs') diff --git a/crates/ra_mbe/src/parser.rs b/crates/ra_mbe/src/parser.rs index 1cdebc216..10a6f300a 100644 --- a/crates/ra_mbe/src/parser.rs +++ b/crates/ra_mbe/src/parser.rs @@ -45,15 +45,15 @@ impl PartialEq for Separator { } } -pub(crate) fn parse_template<'a>( - template: &'a tt::Subtree, -) -> impl Iterator, ExpandError>> { +pub(crate) fn parse_template( + template: &tt::Subtree, +) -> impl Iterator, ExpandError>> { parse_inner(template, Mode::Template) } -pub(crate) fn parse_pattern<'a>( - pattern: &'a tt::Subtree, -) -> impl Iterator, ExpandError>> { +pub(crate) fn parse_pattern( + pattern: &tt::Subtree, +) -> impl Iterator, ExpandError>> { parse_inner(pattern, Mode::Pattern) } @@ -63,10 +63,7 @@ enum Mode { Template, } -fn parse_inner<'a>( - src: &'a tt::Subtree, - mode: Mode, -) -> impl Iterator, ExpandError>> { +fn parse_inner(src: &tt::Subtree, mode: Mode) -> impl Iterator, ExpandError>> { let mut src = TtIter::new(src); std::iter::from_fn(move || { let first = src.next()?; -- cgit v1.2.3