aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r--crates/ide_assists/src/assist_context.rs3
-rw-r--r--crates/ide_assists/src/handlers/apply_demorgan.rs4
-rw-r--r--crates/ide_assists/src/handlers/convert_comment_block.rs4
-rw-r--r--crates/ide_assists/src/handlers/early_return.rs4
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs8
-rw-r--r--crates/ide_assists/src/handlers/fill_match_arms.rs6
-rw-r--r--crates/ide_assists/src/handlers/fix_visibility.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.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_function.rs8
-rw-r--r--crates/ide_assists/src/handlers/generate_getter.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_new.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_setter.rs2
-rw-r--r--crates/ide_assists/src/handlers/remove_dbg.rs2
-rw-r--r--crates/ide_assists/src/handlers/reorder_fields.rs2
-rw-r--r--crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs2
-rw-r--r--crates/ide_assists/src/handlers/replace_if_let_with_match.rs2
-rw-r--r--crates/ide_assists/src/handlers/wrap_return_type_in_result.rs2
-rw-r--r--crates/ide_assists/src/lib.rs8
-rw-r--r--crates/ide_assists/src/tests.rs2
-rw-r--r--crates/ide_assists/src/utils.rs2
-rw-r--r--crates/ide_assists/src/utils/suggest_name.rs2
22 files changed, 36 insertions, 37 deletions
diff --git a/crates/ide_assists/src/assist_context.rs b/crates/ide_assists/src/assist_context.rs
index 8fc40f9bd..36a2bf89a 100644
--- a/crates/ide_assists/src/assist_context.rs
+++ b/crates/ide_assists/src/assist_context.rs
@@ -291,8 +291,7 @@ impl AssistBuilder {
291 algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit) 291 algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit)
292 } 292 }
293 pub(crate) fn create_file(&mut self, dst: AnchoredPathBuf, content: impl Into<String>) { 293 pub(crate) fn create_file(&mut self, dst: AnchoredPathBuf, content: impl Into<String>) {
294 let file_system_edit = 294 let file_system_edit = FileSystemEdit::CreateFile { dst, initial_contents: content.into() };
295 FileSystemEdit::CreateFile { dst: dst, initial_contents: content.into() };
296 self.source_change.push_file_system_edit(file_system_edit); 295 self.source_change.push_file_system_edit(file_system_edit);
297 } 296 }
298 297
diff --git a/crates/ide_assists/src/handlers/apply_demorgan.rs b/crates/ide_assists/src/handlers/apply_demorgan.rs
index 5c936a510..c93959e66 100644
--- a/crates/ide_assists/src/handlers/apply_demorgan.rs
+++ b/crates/ide_assists/src/handlers/apply_demorgan.rs
@@ -78,12 +78,12 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<(
78 terms.sort_by_key(|t| t.syntax().text_range().start()); 78 terms.sort_by_key(|t| t.syntax().text_range().start());
79 let mut terms = VecDeque::from(terms); 79 let mut terms = VecDeque::from(terms);
80 80
81 let paren_expr = expr.syntax().parent().and_then(|parent| ast::ParenExpr::cast(parent)); 81 let paren_expr = expr.syntax().parent().and_then(ast::ParenExpr::cast);
82 82
83 let neg_expr = paren_expr 83 let neg_expr = paren_expr
84 .clone() 84 .clone()
85 .and_then(|paren_expr| paren_expr.syntax().parent()) 85 .and_then(|paren_expr| paren_expr.syntax().parent())
86 .and_then(|parent| ast::PrefixExpr::cast(parent)) 86 .and_then(ast::PrefixExpr::cast)
87 .and_then(|prefix_expr| { 87 .and_then(|prefix_expr| {
88 if prefix_expr.op_kind().unwrap() == ast::PrefixOp::Not { 88 if prefix_expr.op_kind().unwrap() == ast::PrefixOp::Not {
89 Some(prefix_expr) 89 Some(prefix_expr)
diff --git a/crates/ide_assists/src/handlers/convert_comment_block.rs b/crates/ide_assists/src/handlers/convert_comment_block.rs
index d202a85f9..749e8685b 100644
--- a/crates/ide_assists/src/handlers/convert_comment_block.rs
+++ b/crates/ide_assists/src/handlers/convert_comment_block.rs
@@ -88,7 +88,7 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
88 // We pick a single indentation level for the whole block comment based on the 88 // We pick a single indentation level for the whole block comment based on the
89 // comment where the assist was invoked. This will be prepended to the 89 // comment where the assist was invoked. This will be prepended to the
90 // contents of each line comment when they're put into the block comment. 90 // contents of each line comment when they're put into the block comment.
91 let indentation = IndentLevel::from_token(&comment.syntax()); 91 let indentation = IndentLevel::from_token(comment.syntax());
92 92
93 let block_comment_body = 93 let block_comment_body =
94 comments.into_iter().map(|c| line_comment_text(indentation, c)).join("\n"); 94 comments.into_iter().map(|c| line_comment_text(indentation, c)).join("\n");
@@ -167,7 +167,7 @@ fn line_comment_text(indentation: IndentLevel, comm: ast::Comment) -> String {
167 if contents.is_empty() { 167 if contents.is_empty() {
168 contents.to_owned() 168 contents.to_owned()
169 } else { 169 } else {
170 indentation.to_string() + &contents 170 indentation.to_string() + contents
171 } 171 }
172} 172}
173 173
diff --git a/crates/ide_assists/src/handlers/early_return.rs b/crates/ide_assists/src/handlers/early_return.rs
index 5eb6a57f0..ef4a7cb50 100644
--- a/crates/ide_assists/src/handlers/early_return.rs
+++ b/crates/ide_assists/src/handlers/early_return.rs
@@ -108,7 +108,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
108 "Convert to guarded return", 108 "Convert to guarded return",
109 target, 109 target,
110 |edit| { 110 |edit| {
111 let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); 111 let if_indent_level = IndentLevel::from_node(if_expr.syntax());
112 let new_block = match if_let_pat { 112 let new_block = match if_let_pat {
113 None => { 113 None => {
114 // If. 114 // If.
@@ -174,7 +174,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
174 .take_while(|i| *i != end_of_then), 174 .take_while(|i| *i != end_of_then),
175 ); 175 );
176 replace_children( 176 replace_children(
177 &parent_block.syntax(), 177 parent_block.syntax(),
178 RangeInclusive::new( 178 RangeInclusive::new(
179 if_expr.clone().syntax().clone().into(), 179 if_expr.clone().syntax().clone().into(),
180 if_expr.syntax().clone().into(), 180 if_expr.syntax().clone().into(),
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index 624e13db3..f2be091f4 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -76,7 +76,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option
76 let module = ctx.sema.scope(&insert_after).module()?; 76 let module = ctx.sema.scope(&insert_after).module()?;
77 77
78 let vars_defined_in_body_and_outlive = 78 let vars_defined_in_body_and_outlive =
79 vars_defined_in_body_and_outlive(ctx, &body, &node.parent().as_ref().unwrap_or(&node)); 79 vars_defined_in_body_and_outlive(ctx, &body, node.parent().as_ref().unwrap_or(&node));
80 let ret_ty = body_return_ty(ctx, &body)?; 80 let ret_ty = body_return_ty(ctx, &body)?;
81 81
82 // FIXME: we compute variables that outlive here just to check `never!` condition 82 // FIXME: we compute variables that outlive here just to check `never!` condition
@@ -808,7 +808,7 @@ trait HasTokenAtOffset {
808 808
809impl HasTokenAtOffset for SyntaxNode { 809impl HasTokenAtOffset for SyntaxNode {
810 fn token_at_offset(&self, offset: TextSize) -> TokenAtOffset<SyntaxToken> { 810 fn token_at_offset(&self, offset: TextSize) -> TokenAtOffset<SyntaxToken> {
811 SyntaxNode::token_at_offset(&self, offset) 811 SyntaxNode::token_at_offset(self, offset)
812 } 812 }
813} 813}
814 814
@@ -854,7 +854,7 @@ fn vars_defined_in_body_and_outlive(
854 body: &FunctionBody, 854 body: &FunctionBody,
855 parent: &SyntaxNode, 855 parent: &SyntaxNode,
856) -> Vec<OutlivedLocal> { 856) -> Vec<OutlivedLocal> {
857 let vars_defined_in_body = vars_defined_in_body(&body, ctx); 857 let vars_defined_in_body = vars_defined_in_body(body, ctx);
858 vars_defined_in_body 858 vars_defined_in_body
859 .into_iter() 859 .into_iter()
860 .filter_map(|var| var_outlives_body(ctx, body, var, parent)) 860 .filter_map(|var| var_outlives_body(ctx, body, var, parent))
@@ -868,7 +868,7 @@ fn is_defined_before(
868 src: &hir::InFile<Either<ast::IdentPat, ast::SelfParam>>, 868 src: &hir::InFile<Either<ast::IdentPat, ast::SelfParam>>,
869) -> bool { 869) -> bool {
870 src.file_id.original_file(ctx.db()) == ctx.frange.file_id 870 src.file_id.original_file(ctx.db()) == ctx.frange.file_id
871 && !body.contains_node(&either_syntax(&src.value)) 871 && !body.contains_node(either_syntax(&src.value))
872} 872}
873 873
874fn either_syntax(value: &Either<ast::IdentPat, ast::SelfParam>) -> &SyntaxNode { 874fn either_syntax(value: &Either<ast::IdentPat, ast::SelfParam>) -> &SyntaxNode {
diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs
index 3d2cd739a..5a43bdd6f 100644
--- a/crates/ide_assists/src/handlers/fill_match_arms.rs
+++ b/crates/ide_assists/src/handlers/fill_match_arms.rs
@@ -202,7 +202,7 @@ impl ExtendedEnum {
202 fn variants(self, db: &RootDatabase) -> Vec<ExtendedVariant> { 202 fn variants(self, db: &RootDatabase) -> Vec<ExtendedVariant> {
203 match self { 203 match self {
204 ExtendedEnum::Enum(e) => { 204 ExtendedEnum::Enum(e) => {
205 e.variants(db).into_iter().map(|x| ExtendedVariant::Variant(x)).collect::<Vec<_>>() 205 e.variants(db).into_iter().map(ExtendedVariant::Variant).collect::<Vec<_>>()
206 } 206 }
207 ExtendedEnum::Bool => { 207 ExtendedEnum::Bool => {
208 Vec::<ExtendedVariant>::from([ExtendedVariant::True, ExtendedVariant::False]) 208 Vec::<ExtendedVariant>::from([ExtendedVariant::True, ExtendedVariant::False])
@@ -212,7 +212,7 @@ impl ExtendedEnum {
212} 212}
213 213
214fn resolve_enum_def(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<ExtendedEnum> { 214fn resolve_enum_def(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<ExtendedEnum> {
215 sema.type_of_expr(&expr)?.autoderef(sema.db).find_map(|ty| match ty.as_adt() { 215 sema.type_of_expr(expr)?.autoderef(sema.db).find_map(|ty| match ty.as_adt() {
216 Some(Adt::Enum(e)) => Some(ExtendedEnum::Enum(e)), 216 Some(Adt::Enum(e)) => Some(ExtendedEnum::Enum(e)),
217 _ => { 217 _ => {
218 if ty.is_bool() { 218 if ty.is_bool() {
@@ -228,7 +228,7 @@ fn resolve_tuple_of_enum_def(
228 sema: &Semantics<RootDatabase>, 228 sema: &Semantics<RootDatabase>,
229 expr: &ast::Expr, 229 expr: &ast::Expr,
230) -> Option<Vec<ExtendedEnum>> { 230) -> Option<Vec<ExtendedEnum>> {
231 sema.type_of_expr(&expr)? 231 sema.type_of_expr(expr)?
232 .tuple_fields(sema.db) 232 .tuple_fields(sema.db)
233 .iter() 233 .iter()
234 .map(|ty| { 234 .map(|ty| {
diff --git a/crates/ide_assists/src/handlers/fix_visibility.rs b/crates/ide_assists/src/handlers/fix_visibility.rs
index 89f7b2c2c..9b432e92f 100644
--- a/crates/ide_assists/src/handlers/fix_visibility.rs
+++ b/crates/ide_assists/src/handlers/fix_visibility.rs
@@ -43,7 +43,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O
43 _ => return None, 43 _ => return None,
44 }; 44 };
45 45
46 let current_module = ctx.sema.scope(&path.syntax()).module()?; 46 let current_module = ctx.sema.scope(path.syntax()).module()?;
47 let target_module = def.module(ctx.db())?; 47 let target_module = def.module(ctx.db())?;
48 48
49 let vis = target_module.visibility_of(ctx.db(), &def)?; 49 let vis = target_module.visibility_of(ctx.db(), &def)?;
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 a9f71a703..24939f262 100644
--- a/crates/ide_assists/src/handlers/generate_enum_is_method.rs
+++ b/crates/ide_assists/src/handlers/generate_enum_is_method.rs
@@ -47,7 +47,7 @@ pub(crate) fn generate_enum_is_method(acc: &mut Assists, ctx: &AssistContext) ->
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)?;
51 51
52 let target = variant.syntax().text_range(); 52 let target = variant.syntax().text_range();
53 acc.add( 53 acc.add(
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 e2f572ba3..986fb2315 100644
--- a/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
+++ b/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
@@ -136,7 +136,7 @@ fn generate_enum_projection_method(
136 format!("{}_{}", props.fn_name_prefix, &to_lower_snake_case(&variant_name.text())); 136 format!("{}_{}", props.fn_name_prefix, &to_lower_snake_case(&variant_name.text()));
137 137
138 // Return early if we've found an existing new fn 138 // Return early if we've found an existing new fn
139 let impl_def = find_struct_impl(&ctx, &parent_enum, &fn_name)?; 139 let impl_def = find_struct_impl(ctx, &parent_enum, &fn_name)?;
140 140
141 let target = variant.syntax().text_range(); 141 let target = variant.syntax().text_range();
142 acc.add(AssistId(assist_id, AssistKind::Generate), assist_description, target, |builder| { 142 acc.add(AssistId(assist_id, AssistKind::Generate), assist_description, target, |builder| {
diff --git a/crates/ide_assists/src/handlers/generate_function.rs b/crates/ide_assists/src/handlers/generate_function.rs
index bc9fc524b..706c995ac 100644
--- a/crates/ide_assists/src/handlers/generate_function.rs
+++ b/crates/ide_assists/src/handlers/generate_function.rs
@@ -59,7 +59,7 @@ pub(crate) fn generate_function(acc: &mut Assists, ctx: &AssistContext) -> Optio
59 None => None, 59 None => None,
60 }; 60 };
61 61
62 let function_builder = FunctionBuilder::from_call(&ctx, &call, &path, target_module)?; 62 let function_builder = FunctionBuilder::from_call(ctx, &call, &path, target_module)?;
63 63
64 let target = call.syntax().text_range(); 64 let target = call.syntax().text_range();
65 acc.add( 65 acc.add(
@@ -128,12 +128,12 @@ impl FunctionBuilder {
128 file = in_file; 128 file = in_file;
129 target 129 target
130 } 130 }
131 None => next_space_for_fn_after_call_site(&call)?, 131 None => next_space_for_fn_after_call_site(call)?,
132 }; 132 };
133 let needs_pub = target_module.is_some(); 133 let needs_pub = target_module.is_some();
134 let target_module = target_module.or_else(|| ctx.sema.scope(target.syntax()).module())?; 134 let target_module = target_module.or_else(|| ctx.sema.scope(target.syntax()).module())?;
135 let fn_name = fn_name(&path)?; 135 let fn_name = fn_name(path)?;
136 let (type_params, params) = fn_args(ctx, target_module, &call)?; 136 let (type_params, params) = fn_args(ctx, target_module, call)?;
137 137
138 // should_render_snippet intends to express a rough level of confidence about 138 // should_render_snippet intends to express a rough level of confidence about
139 // the correctness of the return type. 139 // the correctness of the return type.
diff --git a/crates/ide_assists/src/handlers/generate_getter.rs b/crates/ide_assists/src/handlers/generate_getter.rs
index 09971226e..cc020c92c 100644
--- a/crates/ide_assists/src/handlers/generate_getter.rs
+++ b/crates/ide_assists/src/handlers/generate_getter.rs
@@ -75,7 +75,7 @@ pub(crate) fn generate_getter_impl(
75 if mutable { 75 if mutable {
76 format_to!(fn_name, "_mut"); 76 format_to!(fn_name, "_mut");
77 } 77 }
78 let impl_def = find_struct_impl(&ctx, &ast::Adt::Struct(strukt.clone()), fn_name.as_str())?; 78 let impl_def = find_struct_impl(ctx, &ast::Adt::Struct(strukt.clone()), fn_name.as_str())?;
79 79
80 let (id, label) = if mutable { 80 let (id, label) = if mutable {
81 ("generate_getter_mut", "Generate a mut getter method") 81 ("generate_getter_mut", "Generate a mut getter method")
diff --git a/crates/ide_assists/src/handlers/generate_new.rs b/crates/ide_assists/src/handlers/generate_new.rs
index 959a1f86c..b65e8387b 100644
--- a/crates/ide_assists/src/handlers/generate_new.rs
+++ b/crates/ide_assists/src/handlers/generate_new.rs
@@ -36,7 +36,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
36 }; 36 };
37 37
38 // Return early if we've found an existing new fn 38 // Return early if we've found an existing new fn
39 let impl_def = find_struct_impl(&ctx, &ast::Adt::Struct(strukt.clone()), "new")?; 39 let impl_def = find_struct_impl(ctx, &ast::Adt::Struct(strukt.clone()), "new")?;
40 40
41 let target = strukt.syntax().text_range(); 41 let target = strukt.syntax().text_range();
42 acc.add(AssistId("generate_new", AssistKind::Generate), "Generate `new`", target, |builder| { 42 acc.add(AssistId("generate_new", AssistKind::Generate), "Generate `new`", target, |builder| {
diff --git a/crates/ide_assists/src/handlers/generate_setter.rs b/crates/ide_assists/src/handlers/generate_setter.rs
index 288cf745d..5bdf6b3f4 100644
--- a/crates/ide_assists/src/handlers/generate_setter.rs
+++ b/crates/ide_assists/src/handlers/generate_setter.rs
@@ -39,7 +39,7 @@ pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext) -> Option<
39 // Return early if we've found an existing fn 39 // Return early if we've found an existing fn
40 let fn_name = to_lower_snake_case(&field_name.to_string()); 40 let fn_name = to_lower_snake_case(&field_name.to_string());
41 let impl_def = find_struct_impl( 41 let impl_def = find_struct_impl(
42 &ctx, 42 ctx,
43 &ast::Adt::Struct(strukt.clone()), 43 &ast::Adt::Struct(strukt.clone()),
44 format!("set_{}", fn_name).as_str(), 44 format!("set_{}", fn_name).as_str(),
45 )?; 45 )?;
diff --git a/crates/ide_assists/src/handlers/remove_dbg.rs b/crates/ide_assists/src/handlers/remove_dbg.rs
index c8226550f..b20fe992d 100644
--- a/crates/ide_assists/src/handlers/remove_dbg.rs
+++ b/crates/ide_assists/src/handlers/remove_dbg.rs
@@ -85,7 +85,7 @@ fn whitespace_start(it: SyntaxElement) -> Option<TextSize> {
85} 85}
86 86
87fn adjusted_macro_contents(macro_call: &ast::MacroCall) -> Option<String> { 87fn adjusted_macro_contents(macro_call: &ast::MacroCall) -> Option<String> {
88 let contents = get_valid_macrocall_contents(&macro_call, "dbg")?; 88 let contents = get_valid_macrocall_contents(macro_call, "dbg")?;
89 let macro_text_with_brackets = macro_call.token_tree()?.syntax().text(); 89 let macro_text_with_brackets = macro_call.token_tree()?.syntax().text();
90 let macro_text_in_brackets = macro_text_with_brackets.slice(TextRange::new( 90 let macro_text_in_brackets = macro_text_with_brackets.slice(TextRange::new(
91 TextSize::of('('), 91 TextSize::of('('),
diff --git a/crates/ide_assists/src/handlers/reorder_fields.rs b/crates/ide_assists/src/handlers/reorder_fields.rs
index 933acead1..f6a926042 100644
--- a/crates/ide_assists/src/handlers/reorder_fields.rs
+++ b/crates/ide_assists/src/handlers/reorder_fields.rs
@@ -28,7 +28,7 @@ pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<(
28 .or_else(|| ctx.find_node_at_offset::<ast::RecordPat>().map(Either::Right))?; 28 .or_else(|| ctx.find_node_at_offset::<ast::RecordPat>().map(Either::Right))?;
29 29
30 let path = record.as_ref().either(|it| it.path(), |it| it.path())?; 30 let path = record.as_ref().either(|it| it.path(), |it| it.path())?;
31 let ranks = compute_fields_ranks(&path, &ctx)?; 31 let ranks = compute_fields_ranks(&path, ctx)?;
32 let get_rank_of_field = 32 let get_rank_of_field =
33 |of: Option<_>| *ranks.get(&of.unwrap_or_default()).unwrap_or(&usize::MAX); 33 |of: Option<_>| *ranks.get(&of.unwrap_or_default()).unwrap_or(&usize::MAX);
34 34
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 10d9cec31..f9474c9f5 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
@@ -112,7 +112,7 @@ fn add_assist(
112 let insert_pos = adt.syntax().text_range().end(); 112 let insert_pos = adt.syntax().text_range().end();
113 let impl_def_with_items = 113 let impl_def_with_items =
114 impl_def_from_trait(&ctx.sema, &annotated_name, trait_, trait_path); 114 impl_def_from_trait(&ctx.sema, &annotated_name, trait_, trait_path);
115 update_attribute(builder, &input, &trait_name, &attr); 115 update_attribute(builder, input, &trait_name, attr);
116 let trait_path = format!("{}", trait_path); 116 let trait_path = format!("{}", trait_path);
117 match (ctx.config.snippet_cap, impl_def_with_items) { 117 match (ctx.config.snippet_cap, impl_def_with_items) {
118 (None, _) => { 118 (None, _) => {
diff --git a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
index aee880625..9404aa26d 100644
--- a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
+++ b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
@@ -169,7 +169,7 @@ pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext)
169} 169}
170 170
171fn is_pat_wildcard_or_sad(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool { 171fn is_pat_wildcard_or_sad(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool {
172 sema.type_of_pat(&pat) 172 sema.type_of_pat(pat)
173 .and_then(|ty| TryEnum::from_ty(sema, &ty)) 173 .and_then(|ty| TryEnum::from_ty(sema, &ty))
174 .map(|it| it.sad_pattern().syntax().text() == pat.syntax().text()) 174 .map(|it| it.sad_pattern().syntax().text() == pat.syntax().text())
175 .unwrap_or_else(|| matches!(pat, ast::Pat::WildcardPat(_))) 175 .unwrap_or_else(|| matches!(pat, ast::Pat::WildcardPat(_)))
diff --git a/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs b/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs
index 2f1da82c7..140e27356 100644
--- a/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs
+++ b/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs
@@ -123,7 +123,7 @@ impl TailReturnCollector {
123 fn handle_exprs(&mut self, expr: &Expr, collect_break: bool) { 123 fn handle_exprs(&mut self, expr: &Expr, collect_break: bool) {
124 match expr { 124 match expr {
125 Expr::BlockExpr(block_expr) => { 125 Expr::BlockExpr(block_expr) => {
126 self.collect_jump_exprs(&block_expr, collect_break); 126 self.collect_jump_exprs(block_expr, collect_break);
127 } 127 }
128 Expr::ReturnExpr(ret_expr) => { 128 Expr::ReturnExpr(ret_expr) => {
129 if let Some(ret_expr_arg) = &ret_expr.expr() { 129 if let Some(ret_expr_arg) = &ret_expr.expr() {
diff --git a/crates/ide_assists/src/lib.rs b/crates/ide_assists/src/lib.rs
index 16af72927..331a6df2b 100644
--- a/crates/ide_assists/src/lib.rs
+++ b/crates/ide_assists/src/lib.rs
@@ -47,14 +47,14 @@ impl AssistKind {
47 } 47 }
48 48
49 match self { 49 match self {
50 AssistKind::None | AssistKind::Generate => return true, 50 AssistKind::None | AssistKind::Generate => true,
51 AssistKind::Refactor => match other { 51 AssistKind::Refactor => match other {
52 AssistKind::RefactorExtract 52 AssistKind::RefactorExtract
53 | AssistKind::RefactorInline 53 | AssistKind::RefactorInline
54 | AssistKind::RefactorRewrite => return true, 54 | AssistKind::RefactorRewrite => true,
55 _ => return false, 55 _ => false,
56 }, 56 },
57 _ => return false, 57 _ => false,
58 } 58 }
59 } 59 }
60 60
diff --git a/crates/ide_assists/src/tests.rs b/crates/ide_assists/src/tests.rs
index 2b7c2d581..bdf9cb71c 100644
--- a/crates/ide_assists/src/tests.rs
+++ b/crates/ide_assists/src/tests.rs
@@ -74,7 +74,7 @@ pub(crate) fn check_assist_unresolved(assist: Handler, ra_fixture: &str) {
74#[track_caller] 74#[track_caller]
75fn check_doc_test(assist_id: &str, before: &str, after: &str) { 75fn check_doc_test(assist_id: &str, before: &str, after: &str) {
76 let after = trim_indent(after); 76 let after = trim_indent(after);
77 let (db, file_id, selection) = RootDatabase::with_range_or_offset(&before); 77 let (db, file_id, selection) = RootDatabase::with_range_or_offset(before);
78 let before = db.file_text(file_id).to_string(); 78 let before = db.file_text(file_id).to_string();
79 let frange = FileRange { file_id, range: selection.into() }; 79 let frange = FileRange { file_id, range: selection.into() };
80 80
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs
index 30128a24a..068df005b 100644
--- a/crates/ide_assists/src/utils.rs
+++ b/crates/ide_assists/src/utils.rs
@@ -492,7 +492,7 @@ pub(crate) fn add_method_to_adt(
492 let start_offset = impl_def 492 let start_offset = impl_def
493 .and_then(|impl_def| find_impl_block_end(impl_def, &mut buf)) 493 .and_then(|impl_def| find_impl_block_end(impl_def, &mut buf))
494 .unwrap_or_else(|| { 494 .unwrap_or_else(|| {
495 buf = generate_impl_text(&adt, &buf); 495 buf = generate_impl_text(adt, &buf);
496 adt.syntax().text_range().end() 496 adt.syntax().text_range().end()
497 }); 497 });
498 498
diff --git a/crates/ide_assists/src/utils/suggest_name.rs b/crates/ide_assists/src/utils/suggest_name.rs
index b3aabeab3..cb8bc8b2f 100644
--- a/crates/ide_assists/src/utils/suggest_name.rs
+++ b/crates/ide_assists/src/utils/suggest_name.rs
@@ -187,7 +187,7 @@ fn from_method_call(expr: &ast::Expr) -> Option<String> {
187 } 187 }
188 } 188 }
189 189
190 normalize(&name) 190 normalize(name)
191} 191}
192 192
193fn from_param(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> Option<String> { 193fn from_param(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> Option<String> {