aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists')
-rw-r--r--crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_enum_is_method.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_enum_projection_method.rs3
-rw-r--r--crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs5
-rw-r--r--crates/ide_assists/src/utils.rs4
5 files changed, 9 insertions, 7 deletions
diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
index 596c536a7..a8d6355bd 100644
--- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -195,7 +195,7 @@ fn extract_struct_def(
195 195
196fn update_variant(rewriter: &mut SyntaxRewriter, variant: &ast::Variant) -> Option<()> { 196fn update_variant(rewriter: &mut SyntaxRewriter, variant: &ast::Variant) -> Option<()> {
197 let name = variant.name()?; 197 let name = variant.name()?;
198 let tuple_field = make::tuple_field(None, make::ty(name.text())); 198 let tuple_field = make::tuple_field(None, make::ty(&name.text()));
199 let replacement = make::variant( 199 let replacement = make::variant(
200 name, 200 name,
201 Some(ast::FieldList::TupleFieldList(make::tuple_field_list(iter::once(tuple_field)))), 201 Some(ast::FieldList::TupleFieldList(make::tuple_field_list(iter::once(tuple_field)))),
diff --git a/crates/ide_assists/src/handlers/generate_enum_is_method.rs b/crates/ide_assists/src/handlers/generate_enum_is_method.rs
index 7e181a480..a9f71a703 100644
--- a/crates/ide_assists/src/handlers/generate_enum_is_method.rs
+++ b/crates/ide_assists/src/handlers/generate_enum_is_method.rs
@@ -44,7 +44,7 @@ pub(crate) fn generate_enum_is_method(acc: &mut Assists, ctx: &AssistContext) ->
44 }; 44 };
45 45
46 let enum_lowercase_name = to_lower_snake_case(&parent_enum.name()?.to_string()); 46 let enum_lowercase_name = to_lower_snake_case(&parent_enum.name()?.to_string());
47 let fn_name = format!("is_{}", &to_lower_snake_case(variant_name.text())); 47 let fn_name = format!("is_{}", &to_lower_snake_case(&variant_name.text()));
48 48
49 // Return early if we've found an existing new fn 49 // Return early if we've found an existing new fn
50 let impl_def = find_struct_impl(&ctx, &parent_enum, &fn_name)?; 50 let impl_def = find_struct_impl(&ctx, &parent_enum, &fn_name)?;
diff --git a/crates/ide_assists/src/handlers/generate_enum_projection_method.rs b/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
index 871bcab50..e2f572ba3 100644
--- a/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
+++ b/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
@@ -132,7 +132,8 @@ fn generate_enum_projection_method(
132 ast::StructKind::Unit => return None, 132 ast::StructKind::Unit => return None,
133 }; 133 };
134 134
135 let fn_name = format!("{}_{}", props.fn_name_prefix, &to_lower_snake_case(variant_name.text())); 135 let fn_name =
136 format!("{}_{}", props.fn_name_prefix, &to_lower_snake_case(&variant_name.text()));
136 137
137 // Return early if we've found an existing new fn 138 // Return early if we've found an existing new fn
138 let impl_def = find_struct_impl(&ctx, &parent_enum, &fn_name)?; 139 let impl_def = find_struct_impl(&ctx, &parent_enum, &fn_name)?;
diff --git a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
index 4f0ef52ca..f872d20c8 100644
--- a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
+++ b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
@@ -165,7 +165,7 @@ fn impl_def_from_trait(
165 } 165 }
166 let impl_def = make::impl_trait( 166 let impl_def = make::impl_trait(
167 trait_path.clone(), 167 trait_path.clone(),
168 make::path_unqualified(make::path_segment(make::name_ref(annotated_name.text()))), 168 make::path_unqualified(make::path_segment(make::name_ref(&annotated_name.text()))),
169 ); 169 );
170 let (impl_def, first_assoc_item) = 170 let (impl_def, first_assoc_item) =
171 add_trait_assoc_items_to_impl(sema, trait_items, trait_, impl_def, target_scope); 171 add_trait_assoc_items_to_impl(sema, trait_items, trait_, impl_def, target_scope);
@@ -178,12 +178,13 @@ fn update_attribute(
178 trait_name: &ast::NameRef, 178 trait_name: &ast::NameRef,
179 attr: &ast::Attr, 179 attr: &ast::Attr,
180) { 180) {
181 let trait_name = trait_name.text();
181 let new_attr_input = input 182 let new_attr_input = input
182 .syntax() 183 .syntax()
183 .descendants_with_tokens() 184 .descendants_with_tokens()
184 .filter(|t| t.kind() == IDENT) 185 .filter(|t| t.kind() == IDENT)
185 .filter_map(|t| t.into_token().map(|t| t.text().to_string())) 186 .filter_map(|t| t.into_token().map(|t| t.text().to_string()))
186 .filter(|t| t != trait_name.text()) 187 .filter(|t| t != &trait_name)
187 .collect::<Vec<_>>(); 188 .collect::<Vec<_>>();
188 let has_more_derives = !new_attr_input.is_empty(); 189 let has_more_derives = !new_attr_input.is_empty();
189 190
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs
index 728d174db..5f630ec75 100644
--- a/crates/ide_assists/src/utils.rs
+++ b/crates/ide_assists/src/utils.rs
@@ -246,7 +246,7 @@ fn invert_special_case(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Opti
246 let method = mce.name_ref()?; 246 let method = mce.name_ref()?;
247 let arg_list = mce.arg_list()?; 247 let arg_list = mce.arg_list()?;
248 248
249 let method = match method.text() { 249 let method = match method.text().as_str() {
250 "is_some" => "is_none", 250 "is_some" => "is_none",
251 "is_none" => "is_some", 251 "is_none" => "is_some",
252 "is_ok" => "is_err", 252 "is_ok" => "is_err",
@@ -443,7 +443,7 @@ fn generate_impl_text_inner(adt: &ast::Adt, trait_text: Option<&str>, code: &str
443 buf.push_str(trait_text); 443 buf.push_str(trait_text);
444 buf.push_str(" for "); 444 buf.push_str(" for ");
445 } 445 }
446 buf.push_str(adt.name().unwrap().text()); 446 buf.push_str(&adt.name().unwrap().text());
447 if let Some(generic_params) = generic_params { 447 if let Some(generic_params) = generic_params {
448 let lifetime_params = generic_params 448 let lifetime_params = generic_params
449 .lifetime_params() 449 .lifetime_params()