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 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') 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 From f6816c253b96e8436f1156d6bd6b0942ee9fb4d3 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 15:57:41 +0200 Subject: Update versions --- crates/ra_mbe/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_mbe') diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml index a3fc01f63..4dec24914 100644 --- a/crates/ra_mbe/Cargo.toml +++ b/crates/ra_mbe/Cargo.toml @@ -11,9 +11,9 @@ doctest = false ra_syntax = { path = "../ra_syntax" } ra_parser = { path = "../ra_parser" } tt = { path = "../ra_tt", package = "ra_tt" } -rustc-hash = "1.0.0" -smallvec = "1.0.0" -log = "0.4.5" +rustc-hash = "1.1.0" +smallvec = "1.2.0" +log = "0.4.8" [dev-dependencies] test_utils = { path = "../test_utils" } -- cgit v1.2.3