From 619a61529878f82daf7aed571bc4f6a10bd6dd9f Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 4 Jun 2019 02:28:22 -0400 Subject: Fix clippy::len_zero --- crates/ra_mbe/src/syntax_bridge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_mbe') diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 0edb6f9a2..e3f93b23c 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -292,7 +292,7 @@ fn delim_to_str(d: tt::Delimiter, closing: bool) -> SmolStr { }; let idx = closing as usize; - 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 { "" }; text.into() } -- cgit v1.2.3 From 40424d4222d4630bc53294d10f1718f2d3d300de Mon Sep 17 00:00:00 2001 From: Alan Du Date: Mon, 3 Jun 2019 10:21:08 -0400 Subject: Fix clippy::identity_conversion --- crates/ra_mbe/src/mbe_expander.rs | 24 ++++++++++++------------ crates/ra_mbe/src/syntax_bridge.rs | 7 ++++--- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'crates/ra_mbe') diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index a0bd0c5f8..7cfb47f7a 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs @@ -206,48 +206,48 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result { let path = input.eat_path().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(path.into())); + res.inner.insert(text.clone(), Binding::Simple(path)); } "expr" => { let expr = input.eat_expr().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(expr.into())); + res.inner.insert(text.clone(), Binding::Simple(expr)); } "ty" => { let ty = input.eat_ty().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(ty.into())); + res.inner.insert(text.clone(), Binding::Simple(ty)); } "pat" => { let pat = input.eat_pat().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(pat.into())); + res.inner.insert(text.clone(), Binding::Simple(pat)); } "stmt" => { let pat = input.eat_stmt().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(pat.into())); + res.inner.insert(text.clone(), Binding::Simple(pat)); } "block" => { let block = input.eat_block().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(block.into())); + res.inner.insert(text.clone(), Binding::Simple(block)); } "meta" => { let meta = input.eat_meta().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(meta.into())); + res.inner.insert(text.clone(), Binding::Simple(meta)); } "tt" => { let token = input.eat().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(token.into())); + res.inner.insert(text.clone(), Binding::Simple(token)); } "item" => { let item = input.eat_item().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(item.into())); + res.inner.insert(text.clone(), Binding::Simple(item)); } "lifetime" => { let lifetime = input.eat_lifetime().ok_or(ExpandError::UnexpectedToken)?.clone(); - res.inner.insert(text.clone(), Binding::Simple(lifetime.into())); + res.inner.insert(text.clone(), Binding::Simple(lifetime)); } "literal" => { let literal = @@ -262,7 +262,7 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result(token: &ra_syntax::SyntaxToken<'a>) -> Option Date: Mon, 3 Jun 2019 10:27:51 -0400 Subject: Fix clippy::or_fun_call --- crates/ra_mbe/src/mbe_expander.rs | 14 ++++++-------- crates/ra_mbe/src/mbe_parser.rs | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'crates/ra_mbe') diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 7cfb47f7a..55a6ecf58 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs @@ -105,17 +105,15 @@ impl Bindings { } fn get(&self, name: &SmolStr, nesting: &[usize]) -> Result<&tt::TokenTree, ExpandError> { - let mut b = self - .inner - .get(name) - .ok_or(ExpandError::BindingError(format!("could not find binding `{}`", name)))?; + let mut b = self.inner.get(name).ok_or_else(|| { + ExpandError::BindingError(format!("could not find binding `{}`", name)) + })?; for &idx in nesting.iter() { b = match b { Binding::Simple(_) => break, - Binding::Nested(bs) => bs.get(idx).ok_or(ExpandError::BindingError(format!( - "could not find nested binding `{}`", - name - )))?, + Binding::Nested(bs) => bs.get(idx).ok_or_else(|| { + ExpandError::BindingError(format!("could not find nested binding `{}`", name)) + })?, Binding::Empty => { return Err(ExpandError::BindingError(format!( "could not find empty binding `{}`", diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs index d8fe293c7..dca16b537 100644 --- a/crates/ra_mbe/src/mbe_parser.rs +++ b/crates/ra_mbe/src/mbe_parser.rs @@ -125,8 +125,8 @@ fn parse_repeat(p: &mut TtCursor, transcriber: bool) -> Result