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_assists/src/handlers/add_custom_impl.rs | 4 ++-- crates/ra_assists/src/handlers/add_new.rs | 2 +- crates/ra_assists/src/handlers/replace_if_let_with_match.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index 7fdd816bf..4d3a72c18 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs @@ -45,7 +45,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option { let trait_token = ctx.token_at_offset().filter(|t| t.kind() == IDENT && *t.text() != attr_name).next()?; - let annotated = attr.syntax().siblings(Direction::Next).find_map(|s| ast::Name::cast(s))?; + let annotated = attr.syntax().siblings(Direction::Next).find_map(ast::Name::cast)?; let annotated_name = annotated.syntax().text().to_string(); let start_offset = annotated.syntax().parent()?.text_range().end(); @@ -62,7 +62,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option { .filter_map(|t| t.into_token().map(|t| t.text().clone())) .filter(|t| t != trait_token.text()) .collect::>(); - let has_more_derives = new_attr_input.len() > 0; + let has_more_derives = !new_attr_input.is_empty(); let new_attr_input = join(new_attr_input.iter()).separator(", ").surround_with("(", ")").to_string(); let new_attr_input_len = new_attr_input.len(); diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 2701eddb8..dd070e8ec 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -53,7 +53,7 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { } let vis = strukt.visibility().map(|v| format!("{} ", v.syntax())); - let vis = vis.as_ref().map(String::as_str).unwrap_or(""); + let vis = vis.as_deref().unwrap_or(""); write!(&mut buf, " {}fn new(", vis).unwrap(); join(field_list.fields().filter_map(|f| { diff --git a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs index e6cd50bc1..0a0a88f3d 100644 --- a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs @@ -61,7 +61,7 @@ pub(crate) fn replace_if_let_with_match(ctx: AssistCtx) -> Option { edit.target(if_expr.syntax().text_range()); edit.set_cursor(if_expr.syntax().text_range().start()); - edit.replace_ast::(if_expr.into(), match_expr.into()); + edit.replace_ast::(if_expr.into(), match_expr); }) } -- cgit v1.2.3