aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-02-18 12:53:02 +0000
committerKirill Bulatov <[email protected]>2020-02-18 14:03:08 +0000
commitb8ddcb0652f3ec8683023afc1e1f5166d6a712f4 (patch)
treeea95a1e2083280d84e99f274e5b2b8b269545297 /crates/ra_assists
parenteab80cd961919b9321e1d34343ae3f3adb0502e5 (diff)
Run cargo +nightly fix --clippy -Z unstable-options
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/handlers/add_custom_impl.rs4
-rw-r--r--crates/ra_assists/src/handlers/add_new.rs2
-rw-r--r--crates/ra_assists/src/handlers/replace_if_let_with_match.rs2
-rw-r--r--crates/ra_assists/src/lib.rs4
4 files changed, 6 insertions, 6 deletions
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<Assist> {
45 let trait_token = 45 let trait_token =
46 ctx.token_at_offset().filter(|t| t.kind() == IDENT && *t.text() != attr_name).next()?; 46 ctx.token_at_offset().filter(|t| t.kind() == IDENT && *t.text() != attr_name).next()?;
47 47
48 let annotated = attr.syntax().siblings(Direction::Next).find_map(|s| ast::Name::cast(s))?; 48 let annotated = attr.syntax().siblings(Direction::Next).find_map(ast::Name::cast)?;
49 let annotated_name = annotated.syntax().text().to_string(); 49 let annotated_name = annotated.syntax().text().to_string();
50 let start_offset = annotated.syntax().parent()?.text_range().end(); 50 let start_offset = annotated.syntax().parent()?.text_range().end();
51 51
@@ -62,7 +62,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> {
62 .filter_map(|t| t.into_token().map(|t| t.text().clone())) 62 .filter_map(|t| t.into_token().map(|t| t.text().clone()))
63 .filter(|t| t != trait_token.text()) 63 .filter(|t| t != trait_token.text())
64 .collect::<Vec<SmolStr>>(); 64 .collect::<Vec<SmolStr>>();
65 let has_more_derives = new_attr_input.len() > 0; 65 let has_more_derives = !new_attr_input.is_empty();
66 let new_attr_input = 66 let new_attr_input =
67 join(new_attr_input.iter()).separator(", ").surround_with("(", ")").to_string(); 67 join(new_attr_input.iter()).separator(", ").surround_with("(", ")").to_string();
68 let new_attr_input_len = new_attr_input.len(); 68 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<Assist> {
53 } 53 }
54 54
55 let vis = strukt.visibility().map(|v| format!("{} ", v.syntax())); 55 let vis = strukt.visibility().map(|v| format!("{} ", v.syntax()));
56 let vis = vis.as_ref().map(String::as_str).unwrap_or(""); 56 let vis = vis.as_deref().unwrap_or("");
57 write!(&mut buf, " {}fn new(", vis).unwrap(); 57 write!(&mut buf, " {}fn new(", vis).unwrap();
58 58
59 join(field_list.fields().filter_map(|f| { 59 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<Assist> {
61 61
62 edit.target(if_expr.syntax().text_range()); 62 edit.target(if_expr.syntax().text_range());
63 edit.set_cursor(if_expr.syntax().text_range().start()); 63 edit.set_cursor(if_expr.syntax().text_range().start());
64 edit.replace_ast::<ast::Expr>(if_expr.into(), match_expr.into()); 64 edit.replace_ast::<ast::Expr>(if_expr.into(), match_expr);
65 }) 65 })
66} 66}
67 67
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index cb124eaf0..a0e7fe17e 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -38,8 +38,8 @@ pub struct GroupLabel(pub String);
38impl AssistLabel { 38impl AssistLabel {
39 pub(crate) fn new(label: String, id: AssistId) -> AssistLabel { 39 pub(crate) fn new(label: String, id: AssistId) -> AssistLabel {
40 // FIXME: make fields private, so that this invariant can't be broken 40 // FIXME: make fields private, so that this invariant can't be broken
41 assert!(label.chars().nth(0).unwrap().is_uppercase()); 41 assert!(label.chars().next().unwrap().is_uppercase());
42 AssistLabel { label: label.into(), id } 42 AssistLabel { label, id }
43 } 43 }
44} 44}
45 45