Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22131 from ChayimFriedman2/remove-arcs
internal: Remove some `Arc`s
Chayim Refael Friedman 2 weeks ago
parent 0856450 · parent e105679 · commit 8dcb776
-rw-r--r--crates/hir-def/src/attrs/docs.rs4
-rw-r--r--crates/hir-def/src/expr_store/expander.rs24
-rw-r--r--crates/hir-def/src/expr_store/lower.rs4
-rw-r--r--crates/hir-def/src/find_path.rs2
-rw-r--r--crates/hir-def/src/item_tree/lower.rs13
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mod.rs16
-rw-r--r--crates/hir-def/src/nameres/assoc.rs29
-rw-r--r--crates/hir-def/src/nameres/tests/incremental.rs72
-rw-r--r--crates/hir-expand/src/attrs.rs4
-rw-r--r--crates/hir-expand/src/cfg_process.rs6
-rw-r--r--crates/hir-expand/src/db.rs32
-rw-r--r--crates/hir-expand/src/declarative.rs6
-rw-r--r--crates/hir-expand/src/eager.rs18
-rw-r--r--crates/hir-expand/src/files.rs20
-rw-r--r--crates/hir-expand/src/fixup.rs15
-rw-r--r--crates/hir-expand/src/lib.rs18
-rw-r--r--crates/hir-expand/src/span_map.rs58
-rw-r--r--crates/hir-ty/src/tests/incremental.rs28
-rw-r--r--crates/hir/src/lib.rs2
-rw-r--r--crates/hir/src/semantics.rs6
-rw-r--r--crates/hir/src/semantics/source_to_def.rs12
-rw-r--r--crates/hir/src/term_search.rs8
-rw-r--r--crates/hir/src/term_search/tactics.rs18
-rw-r--r--crates/ide-assists/src/assist_context.rs14
-rw-r--r--crates/ide-assists/src/handlers/add_braces.rs4
-rw-r--r--crates/ide-assists/src/handlers/add_explicit_dot_deref.rs2
-rw-r--r--crates/ide-assists/src/handlers/add_explicit_enum_discriminant.rs2
-rw-r--r--crates/ide-assists/src/handlers/add_explicit_type.rs2
-rw-r--r--crates/ide-assists/src/handlers/add_label_to_loop.rs4
-rw-r--r--crates/ide-assists/src/handlers/add_lifetime_to_type.rs2
-rw-r--r--crates/ide-assists/src/handlers/add_missing_impl_members.rs11
-rw-r--r--crates/ide-assists/src/handlers/add_missing_match_arms.rs12
-rw-r--r--crates/ide-assists/src/handlers/add_return_type.rs4
-rw-r--r--crates/ide-assists/src/handlers/add_turbo_fish.rs2
-rw-r--r--crates/ide-assists/src/handlers/apply_demorgan.rs9
-rw-r--r--crates/ide-assists/src/handlers/auto_import.rs8
-rw-r--r--crates/ide-assists/src/handlers/bind_unused_param.rs2
-rw-r--r--crates/ide-assists/src/handlers/change_visibility.rs4
-rw-r--r--crates/ide-assists/src/handlers/convert_bool_then.rs10
-rw-r--r--crates/ide-assists/src/handlers/convert_bool_to_enum.rs10
-rw-r--r--crates/ide-assists/src/handlers/convert_char_literal.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_closure_to_fn.rs10
-rw-r--r--crates/ide-assists/src/handlers/convert_comment_block.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_for_to_while_let.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs5
-rw-r--r--crates/ide-assists/src/handlers/convert_integer_literal.rs5
-rw-r--r--crates/ide-assists/src/handlers/convert_into_to_from.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs6
-rw-r--r--crates/ide-assists/src/handlers/convert_let_else_to_match.rs5
-rw-r--r--crates/ide-assists/src/handlers/convert_match_to_let_else.rs9
-rw-r--r--crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs12
-rw-r--r--crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_range_for_to_while.rs5
-rw-r--r--crates/ide-assists/src/handlers/convert_to_guarded_return.rs9
-rw-r--r--crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs8
-rw-r--r--crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs10
-rw-r--r--crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_while_to_loop.rs2
-rw-r--r--crates/ide-assists/src/handlers/destructure_struct_binding.rs22
-rw-r--r--crates/ide-assists/src/handlers/destructure_tuple_binding.rs29
-rw-r--r--crates/ide-assists/src/handlers/desugar_doc_comment.rs2
-rw-r--r--crates/ide-assists/src/handlers/desugar_try_expr.rs2
-rw-r--r--crates/ide-assists/src/handlers/expand_glob_import.rs24
-rw-r--r--crates/ide-assists/src/handlers/expand_rest_pattern.rs12
-rw-r--r--crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs2
-rw-r--r--crates/ide-assists/src/handlers/extract_function.rs90
-rw-r--r--crates/ide-assists/src/handlers/extract_module.rs12
-rw-r--r--crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs4
-rw-r--r--crates/ide-assists/src/handlers/extract_type_alias.rs2
-rw-r--r--crates/ide-assists/src/handlers/extract_variable.rs10
-rw-r--r--crates/ide-assists/src/handlers/fix_visibility.rs4
-rw-r--r--crates/ide-assists/src/handlers/flip_binexpr.rs4
-rw-r--r--crates/ide-assists/src/handlers/flip_comma.rs2
-rw-r--r--crates/ide-assists/src/handlers/flip_or_pattern.rs2
-rw-r--r--crates/ide-assists/src/handlers/flip_trait_bound.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_blanket_trait_impl.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_constant.rs4
-rw-r--r--crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_default_from_new.rs7
-rw-r--r--crates/ide-assists/src/handlers/generate_delegate_methods.rs5
-rw-r--r--crates/ide-assists/src/handlers/generate_delegate_trait.rs17
-rw-r--r--crates/ide-assists/src/handlers/generate_deref.rs6
-rw-r--r--crates/ide-assists/src/handlers/generate_derive.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_documentation_template.rs22
-rw-r--r--crates/ide-assists/src/handlers/generate_enum_is_method.rs5
-rw-r--r--crates/ide-assists/src/handlers/generate_enum_projection_method.rs9
-rw-r--r--crates/ide-assists/src/handlers/generate_enum_variant.rs6
-rw-r--r--crates/ide-assists/src/handlers/generate_fn_type_alias.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs7
-rw-r--r--crates/ide-assists/src/handlers/generate_function.rs59
-rw-r--r--crates/ide-assists/src/handlers/generate_getter_or_setter.rs16
-rw-r--r--crates/ide-assists/src/handlers/generate_impl.rs6
-rw-r--r--crates/ide-assists/src/handlers/generate_is_empty_from_len.rs7
-rw-r--r--crates/ide-assists/src/handlers/generate_mut_trait_impl.rs5
-rw-r--r--crates/ide-assists/src/handlers/generate_new.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_single_field_struct_from.rs4
-rw-r--r--crates/ide-assists/src/handlers/generate_trait_from_impl.rs5
-rw-r--r--crates/ide-assists/src/handlers/inline_call.rs8
-rw-r--r--crates/ide-assists/src/handlers/inline_const_as_literal.rs7
-rw-r--r--crates/ide-assists/src/handlers/inline_local_variable.rs2
-rw-r--r--crates/ide-assists/src/handlers/inline_macro.rs4
-rw-r--r--crates/ide-assists/src/handlers/inline_type_alias.rs6
-rw-r--r--crates/ide-assists/src/handlers/into_to_qualified_from.rs2
-rw-r--r--crates/ide-assists/src/handlers/introduce_named_lifetime.rs5
-rw-r--r--crates/ide-assists/src/handlers/introduce_named_type_parameter.rs2
-rw-r--r--crates/ide-assists/src/handlers/invert_if.rs2
-rw-r--r--crates/ide-assists/src/handlers/merge_imports.rs2
-rw-r--r--crates/ide-assists/src/handlers/merge_match_arms.rs8
-rw-r--r--crates/ide-assists/src/handlers/merge_nested_if.rs2
-rw-r--r--crates/ide-assists/src/handlers/move_bounds.rs2
-rw-r--r--crates/ide-assists/src/handlers/move_const_to_impl.rs2
-rw-r--r--crates/ide-assists/src/handlers/move_from_mod_rs.rs2
-rw-r--r--crates/ide-assists/src/handlers/move_guard.rs4
-rw-r--r--crates/ide-assists/src/handlers/move_module_to_file.rs2
-rw-r--r--crates/ide-assists/src/handlers/move_to_mod_rs.rs2
-rw-r--r--crates/ide-assists/src/handlers/normalize_import.rs2
-rw-r--r--crates/ide-assists/src/handlers/number_representation.rs5
-rw-r--r--crates/ide-assists/src/handlers/promote_local_to_const.rs2
-rw-r--r--crates/ide-assists/src/handlers/pull_assignment_up.rs8
-rw-r--r--crates/ide-assists/src/handlers/qualify_method_call.rs2
-rw-r--r--crates/ide-assists/src/handlers/qualify_path.rs2
-rw-r--r--crates/ide-assists/src/handlers/raw_string.rs10
-rw-r--r--crates/ide-assists/src/handlers/remove_dbg.rs2
-rw-r--r--crates/ide-assists/src/handlers/remove_else_branches.rs2
-rw-r--r--crates/ide-assists/src/handlers/remove_mut.rs2
-rw-r--r--crates/ide-assists/src/handlers/remove_parentheses.rs2
-rw-r--r--crates/ide-assists/src/handlers/remove_underscore.rs2
-rw-r--r--crates/ide-assists/src/handlers/remove_unused_imports.rs10
-rw-r--r--crates/ide-assists/src/handlers/remove_unused_param.rs4
-rw-r--r--crates/ide-assists/src/handlers/reorder_fields.rs4
-rw-r--r--crates/ide-assists/src/handlers/reorder_impl_items.rs4
-rw-r--r--crates/ide-assists/src/handlers/replace_arith_op.rs15
-rw-r--r--crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs4
-rw-r--r--crates/ide-assists/src/handlers/replace_if_let_with_match.rs18
-rw-r--r--crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs2
-rw-r--r--crates/ide-assists/src/handlers/replace_let_with_if_let.rs5
-rw-r--r--crates/ide-assists/src/handlers/replace_method_eager_lazy.rs10
-rw-r--r--crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs2
-rw-r--r--crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs4
-rw-r--r--crates/ide-assists/src/handlers/replace_string_with_char.rs10
-rw-r--r--crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs2
-rw-r--r--crates/ide-assists/src/handlers/sort_items.rs4
-rw-r--r--crates/ide-assists/src/handlers/split_import.rs2
-rw-r--r--crates/ide-assists/src/handlers/term_search.rs2
-rw-r--r--crates/ide-assists/src/handlers/toggle_async_sugar.rs4
-rw-r--r--crates/ide-assists/src/handlers/toggle_ignore.rs2
-rw-r--r--crates/ide-assists/src/handlers/toggle_macro_delimiter.rs2
-rw-r--r--crates/ide-assists/src/handlers/unmerge_imports.rs2
-rw-r--r--crates/ide-assists/src/handlers/unmerge_match_arm.rs2
-rw-r--r--crates/ide-assists/src/handlers/unnecessary_async.rs6
-rw-r--r--crates/ide-assists/src/handlers/unqualify_method_call.rs4
-rw-r--r--crates/ide-assists/src/handlers/unwrap_branch.rs6
-rw-r--r--crates/ide-assists/src/handlers/unwrap_return_type.rs2
-rw-r--r--crates/ide-assists/src/handlers/unwrap_tuple.rs2
-rw-r--r--crates/ide-assists/src/handlers/unwrap_type_to_generic_arg.rs5
-rw-r--r--crates/ide-assists/src/handlers/wrap_return_type.rs4
-rw-r--r--crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs12
-rw-r--r--crates/ide-assists/src/lib.rs2
-rw-r--r--crates/ide-assists/src/utils.rs15
-rw-r--r--crates/ide-assists/src/utils/ref_field_expr.rs6
-rw-r--r--crates/ide-completion/src/completions.rs80
-rw-r--r--crates/ide-completion/src/completions/attribute.rs4
-rw-r--r--crates/ide-completion/src/completions/attribute/cfg.rs2
-rw-r--r--crates/ide-completion/src/completions/attribute/derive.rs2
-rw-r--r--crates/ide-completion/src/completions/attribute/diagnostic.rs2
-rw-r--r--crates/ide-completion/src/completions/attribute/feature.rs2
-rw-r--r--crates/ide-completion/src/completions/attribute/lint.rs2
-rw-r--r--crates/ide-completion/src/completions/attribute/macro_use.rs2
-rw-r--r--crates/ide-completion/src/completions/attribute/repr.rs2
-rw-r--r--crates/ide-completion/src/completions/dot.rs14
-rw-r--r--crates/ide-completion/src/completions/env_vars.rs2
-rw-r--r--crates/ide-completion/src/completions/expr.rs10
-rw-r--r--crates/ide-completion/src/completions/extern_abi.rs2
-rw-r--r--crates/ide-completion/src/completions/extern_crate.rs2
-rw-r--r--crates/ide-completion/src/completions/field.rs4
-rw-r--r--crates/ide-completion/src/completions/flyimport.rs42
-rw-r--r--crates/ide-completion/src/completions/fn_param.rs8
-rw-r--r--crates/ide-completion/src/completions/format_string.rs2
-rw-r--r--crates/ide-completion/src/completions/item_list.rs10
-rw-r--r--crates/ide-completion/src/completions/item_list/trait_impl.rs32
-rw-r--r--crates/ide-completion/src/completions/keyword.rs2
-rw-r--r--crates/ide-completion/src/completions/lifetime.rs4
-rw-r--r--crates/ide-completion/src/completions/macro_def.rs2
-rw-r--r--crates/ide-completion/src/completions/mod_.rs2
-rw-r--r--crates/ide-completion/src/completions/pattern.rs4
-rw-r--r--crates/ide-completion/src/completions/postfix.rs8
-rw-r--r--crates/ide-completion/src/completions/postfix/format_like.rs2
-rw-r--r--crates/ide-completion/src/completions/ra_fixture.rs2
-rw-r--r--crates/ide-completion/src/completions/record.rs8
-rw-r--r--crates/ide-completion/src/completions/snippet.rs13
-rw-r--r--crates/ide-completion/src/completions/type.rs4
-rw-r--r--crates/ide-completion/src/completions/use_.rs2
-rw-r--r--crates/ide-completion/src/completions/vis.rs2
-rw-r--r--crates/ide-completion/src/context.rs20
-rw-r--r--crates/ide-completion/src/item.rs2
-rw-r--r--crates/ide-completion/src/render.rs50
-rw-r--r--crates/ide-completion/src/render/const_.rs7
-rw-r--r--crates/ide-completion/src/render/function.rs20
-rw-r--r--crates/ide-completion/src/render/literal.rs10
-rw-r--r--crates/ide-completion/src/render/macro_.rs8
-rw-r--r--crates/ide-completion/src/render/pattern.rs8
-rw-r--r--crates/ide-completion/src/render/type_alias.rs6
-rw-r--r--crates/ide-completion/src/render/union_literal.rs2
-rw-r--r--crates/ide-completion/src/render/variant.rs6
-rw-r--r--crates/ide-completion/src/snippet.rs7
-rw-r--r--crates/ide-db/src/active_parameter.rs2
-rw-r--r--crates/ide-db/src/path_transform.rs2
-rw-r--r--crates/ide-db/src/search.rs10
-rw-r--r--crates/ide-diagnostics/src/handlers/await_outside_of_async.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/bad_rtn.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/elided_lifetimes_in_path.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/expected_function.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/generic_default_refers_to_self.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/inactive_code.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/incoherent_impl.rs5
-rw-r--r--crates/ide-diagnostics/src/handlers/incorrect_case.rs7
-rw-r--r--crates/ide-diagnostics/src/handlers/incorrect_generics_len.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/incorrect_generics_order.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/invalid_cast.rs7
-rw-r--r--crates/ide-diagnostics/src/handlers/invalid_derive_target.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/invalid_lhs_of_assignment.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/macro_error.rs7
-rw-r--r--crates/ide-diagnostics/src/handlers/malformed_derive.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs6
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_fields.rs9
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_lifetime.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_match_arms.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_unsafe.rs7
-rw-r--r--crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/mutability_errors.rs7
-rw-r--r--crates/ide-diagnostics/src/handlers/no_such_field.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/non_exhaustive_record_expr.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/parenthesized_generic_args_without_fn_trait.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/pattern_arg_in_extern_fn.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/private_assoc_item.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/private_field.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/remove_trailing_return.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/trait_impl_incorrect_safety.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/trait_impl_missing_assoc_item.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/type_mismatch.rs14
-rw-r--r--crates/ide-diagnostics/src/handlers/type_must_be_known.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/typed_hole.rs7
-rw-r--r--crates/ide-diagnostics/src/handlers/undeclared_label.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unlinked_file.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/unreachable_label.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_assoc_item.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_extern_crate.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_field.rs12
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_ident.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_import.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_method.rs11
-rw-r--r--crates/ide-diagnostics/src/handlers/unresolved_module.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/unused_variables.rs2
-rw-r--r--crates/ide-diagnostics/src/lib.rs12
-rw-r--r--crates/ide/src/expand_macro.rs4
-rw-r--r--crates/ide/src/highlight_related.rs8
-rw-r--r--crates/ide/src/hover/render.rs4
-rw-r--r--crates/ide/src/inlay_hints.rs28
-rw-r--r--crates/mbe/src/lib.rs7
269 files changed, 1079 insertions, 949 deletions
diff --git a/crates/hir-def/src/attrs/docs.rs b/crates/hir-def/src/attrs/docs.rs
index 9a715b1968..0d01d54786 100644
--- a/crates/hir-def/src/attrs/docs.rs
+++ b/crates/hir-def/src/attrs/docs.rs
@@ -333,7 +333,7 @@ struct DocExprSourceCtx<'db> {
resolver: Resolver<'db>,
file_id: HirFileId,
ast_id_map: &'db AstIdMap,
- span_map: SpanMap,
+ span_map: SpanMap<'db>,
}
fn expand_doc_expr_via_macro_pipeline<'db>(
@@ -390,7 +390,7 @@ fn expand_doc_macro_call<'db>(
.value?;
expander.recursion_depth += 1;
- let parse = expander.db.parse_macro_expansion(call_id).value.0;
+ let parse = expander.db.parse_macro_expansion(call_id).value.0.clone();
let expr = parse.cast::<ast::Expr>().map(|parse| parse.tree())?;
expander.recursion_depth -= 1;
diff --git a/crates/hir-def/src/expr_store/expander.rs b/crates/hir-def/src/expr_store/expander.rs
index 2fffa02c13..c79a1db847 100644
--- a/crates/hir-def/src/expr_store/expander.rs
+++ b/crates/hir-def/src/expr_store/expander.rs
@@ -5,10 +5,8 @@ use std::mem;
use base_db::Crate;
use cfg::CfgOptions;
use drop_bomb::DropBomb;
-use hir_expand::AstId;
-use hir_expand::span_map::SpanMapRef;
use hir_expand::{
- ExpandError, ExpandErrorKind, ExpandResult, HirFileId, InFile, Lookup, MacroCallId,
+ AstId, ExpandError, ExpandErrorKind, ExpandResult, HirFileId, InFile, Lookup, MacroCallId,
eager::EagerCallBackFn, mod_path::ModPath, span_map::SpanMap,
};
use span::{AstIdMap, SyntaxContext};
@@ -23,7 +21,7 @@ use crate::{
#[derive(Debug)]
pub(super) struct Expander<'db> {
- span_map: SpanMap,
+ span_map: SpanMap<'db>,
current_file_id: HirFileId,
ast_id_map: &'db AstIdMap,
/// `recursion_depth == usize::MAX` indicates that the recursion limit has been reached.
@@ -58,11 +56,11 @@ impl<'db> Expander<'db> {
}
pub(super) fn hygiene_for_range(&self, db: &dyn DefDatabase, range: TextRange) -> HygieneId {
- match self.span_map.as_ref() {
- hir_expand::span_map::SpanMapRef::ExpansionSpanMap(span_map) => {
+ match self.span_map {
+ SpanMap::ExpansionSpanMap(span_map) => {
HygieneId::new(span_map.span_at(range.start()).ctx.opaque_and_semiopaque(db))
}
- hir_expand::span_map::SpanMapRef::RealSpanMap(_) => HygieneId::ROOT,
+ SpanMap::RealSpanMap(_) => HygieneId::ROOT,
}
}
@@ -193,15 +191,15 @@ impl<'db> Expander<'db> {
let res = db.parse_macro_expansion(call_id);
- let err = err.or(res.err);
+ let err = err.or_else(|| res.err.clone());
ExpandResult {
value: {
- let parse = res.value.0.cast::<T>();
+ let parse = res.value.0.clone().cast::<T>();
self.recursion_depth += 1;
let old_file_id = std::mem::replace(&mut self.current_file_id, call_id.into());
let old_span_map =
- std::mem::replace(&mut self.span_map, db.span_map(self.current_file_id));
+ std::mem::replace(&mut self.span_map, SpanMap::ExpansionSpanMap(&res.value.1));
let prev_ast_id_map =
mem::replace(&mut self.ast_id_map, db.ast_id_map(self.current_file_id));
let mark = Mark {
@@ -222,15 +220,15 @@ impl<'db> Expander<'db> {
}
#[inline]
- pub(super) fn span_map(&self) -> SpanMapRef<'_> {
- self.span_map.as_ref()
+ pub(super) fn span_map(&self) -> SpanMap<'_> {
+ self.span_map
}
}
#[derive(Debug)]
pub(super) struct Mark<'db> {
file_id: HirFileId,
- span_map: SpanMap,
+ span_map: SpanMap<'db>,
ast_id_map: &'db AstIdMap,
bomb: DropBomb,
}
diff --git a/crates/hir-def/src/expr_store/lower.rs b/crates/hir-def/src/expr_store/lower.rs
index 0de980bdf0..76c65361e5 100644
--- a/crates/hir-def/src/expr_store/lower.rs
+++ b/crates/hir-def/src/expr_store/lower.rs
@@ -15,7 +15,7 @@ use hir_expand::{
HirFileId, InFile, MacroDefId,
mod_path::ModPath,
name::{AsName, Name},
- span_map::SpanMapRef,
+ span_map::SpanMap,
};
use intern::{Symbol, sym};
use rustc_hash::FxHashMap;
@@ -597,7 +597,7 @@ impl<'db> ExprCollector<'db> {
}
#[inline]
- pub(crate) fn span_map(&self) -> SpanMapRef<'_> {
+ pub(crate) fn span_map(&self) -> SpanMap<'_> {
self.expander.span_map()
}
diff --git a/crates/hir-def/src/find_path.rs b/crates/hir-def/src/find_path.rs
index 78d0a2f0af..2a1b7f7cb0 100644
--- a/crates/hir-def/src/find_path.rs
+++ b/crates/hir-def/src/find_path.rs
@@ -675,7 +675,7 @@ mod tests {
let ast_path =
parsed_path_file.syntax_node().descendants().find_map(syntax::ast::Path::cast).unwrap();
let mod_path = ModPath::from_src(&db, ast_path, &mut |range| {
- db.span_map(pos.file_id.into()).as_ref().span_for_range(range).ctx
+ db.span_map(pos.file_id.into()).span_for_range(range).ctx
})
.unwrap();
diff --git a/crates/hir-def/src/item_tree/lower.rs b/crates/hir-def/src/item_tree/lower.rs
index 68b6cd79ae..91c2e60fd7 100644
--- a/crates/hir-def/src/item_tree/lower.rs
+++ b/crates/hir-def/src/item_tree/lower.rs
@@ -4,12 +4,7 @@ use std::cell::OnceCell;
use base_db::{Crate, FxIndexSet};
use cfg::CfgOptions;
-use hir_expand::{
- HirFileId,
- mod_path::PathKind,
- name::AsName,
- span_map::{SpanMap, SpanMapRef},
-};
+use hir_expand::{HirFileId, mod_path::PathKind, name::AsName, span_map::SpanMap};
use la_arena::Arena;
use span::{AstIdMap, FileAstId, SyntaxContext};
use syntax::{
@@ -32,7 +27,7 @@ pub(super) struct Ctx<'db> {
pub(super) db: &'db dyn DefDatabase,
tree: ItemTree,
source_ast_id_map: &'db AstIdMap,
- span_map: OnceCell<SpanMap>,
+ span_map: OnceCell<SpanMap<'db>>,
file: HirFileId,
cfg_options: OnceCell<&'db CfgOptions>,
krate: Crate,
@@ -60,8 +55,8 @@ impl<'db> Ctx<'db> {
self.cfg_options.get_or_init(|| self.krate.cfg_options(self.db))
}
- pub(super) fn span_map(&self) -> SpanMapRef<'_> {
- self.span_map.get_or_init(|| self.db.span_map(self.file)).as_ref()
+ pub(super) fn span_map(&self) -> SpanMap<'_> {
+ *self.span_map.get_or_init(|| self.db.span_map(self.file))
}
pub(super) fn lower_module_items(mut self, item_owner: &dyn HasModuleItem) -> ItemTree {
diff --git a/crates/hir-def/src/macro_expansion_tests/mod.rs b/crates/hir-def/src/macro_expansion_tests/mod.rs
index eabdada67c..357da4e672 100644
--- a/crates/hir-def/src/macro_expansion_tests/mod.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mod.rs
@@ -22,7 +22,7 @@ use hir_expand::{
builtin::quote::quote,
db::ExpandDatabase,
proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind},
- span_map::SpanMapRef,
+ span_map::SpanMap,
};
use intern::{Symbol, sym};
use itertools::Itertools;
@@ -142,10 +142,10 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
}
let mut expn_text = String::new();
- if let Some(err) = exp.err {
+ if let Some(err) = &exp.err {
format_to!(expn_text, "/* error: {} */", err.render_to_string(&db).message);
}
- let (parse, token_map) = exp.value;
+ let (parse, token_map) = &exp.value;
if expect_errors {
assert!(!parse.errors().is_empty(), "no parse errors in expansion");
for e in parse.errors() {
@@ -161,7 +161,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
}
let pp = pretty_print_macro_expansion(
parse.syntax_node(),
- SpanMapRef::ExpansionSpanMap(&token_map),
+ SpanMap::ExpansionSpanMap(token_map),
show_spans,
show_ctxt,
);
@@ -215,7 +215,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
}
let pp = pretty_print_macro_expansion(
src.value,
- db.span_map(src.file_id).as_ref(),
+ db.span_map(src.file_id),
show_spans,
show_ctxt,
);
@@ -230,7 +230,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
if let Some(macro_file) = src.file_id.macro_file() {
let pp = pretty_print_macro_expansion(
src.value.syntax().clone(),
- db.span_map(macro_file.into()).as_ref(),
+ db.span_map(macro_file.into()),
false,
false,
);
@@ -245,7 +245,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
{
let pp = pretty_print_macro_expansion(
src.value.syntax().clone(),
- db.span_map(macro_file.into()).as_ref(),
+ db.span_map(macro_file.into()),
false,
false,
);
@@ -309,7 +309,7 @@ fn reindent(indent: IndentLevel, pp: String) -> String {
fn pretty_print_macro_expansion(
expn: SyntaxNode,
- map: SpanMapRef<'_>,
+ map: SpanMap<'_>,
show_spans: bool,
show_ctxt: bool,
) -> String {
diff --git a/crates/hir-def/src/nameres/assoc.rs b/crates/hir-def/src/nameres/assoc.rs
index f5a852b39c..a1f1de90ef 100644
--- a/crates/hir-def/src/nameres/assoc.rs
+++ b/crates/hir-def/src/nameres/assoc.rs
@@ -138,7 +138,7 @@ struct AssocItemCollector<'db> {
def_map: &'db DefMap,
local_def_map: &'db LocalDefMap,
ast_id_map: &'db AstIdMap,
- span_map: SpanMap,
+ span_map: SpanMap<'db>,
cfg_options: &'db CfgOptions,
file_id: HirFileId,
diagnostics: Vec<DefDiagnostic>,
@@ -191,19 +191,18 @@ impl<'db> AssocItemCollector<'db> {
fn collect_item(&mut self, item: ast::AssocItem) {
let ast_id = self.ast_id_map.ast_id(&item);
- let attrs =
- match AttrsOrCfg::lower(self.db, &item, &|| self.cfg_options, self.span_map.as_ref()) {
- AttrsOrCfg::Enabled { attrs } => attrs,
- AttrsOrCfg::CfgDisabled(cfg) => {
- self.diagnostics.push(DefDiagnostic::unconfigured_code(
- self.module_id,
- InFile::new(self.file_id, ast_id.erase()),
- cfg.0,
- self.cfg_options.clone(),
- ));
- return;
- }
- };
+ let attrs = match AttrsOrCfg::lower(self.db, &item, &|| self.cfg_options, self.span_map) {
+ AttrsOrCfg::Enabled { attrs } => attrs,
+ AttrsOrCfg::CfgDisabled(cfg) => {
+ self.diagnostics.push(DefDiagnostic::unconfigured_code(
+ self.module_id,
+ InFile::new(self.file_id, ast_id.erase()),
+ cfg.0,
+ self.cfg_options.clone(),
+ ));
+ return;
+ }
+ };
let ast_id = InFile::new(self.file_id, ast_id.upcast());
'attrs: for (attr_id, attr) in attrs.as_ref().iter() {
@@ -357,7 +356,7 @@ impl<'db> AssocItemCollector<'db> {
return;
}
- let (syntax, span_map) = self.db.parse_macro_expansion(macro_call_id).value;
+ let (syntax, span_map) = &self.db.parse_macro_expansion(macro_call_id).value;
let old_file_id = mem::replace(&mut self.file_id, macro_call_id.into());
let old_ast_id_map = mem::replace(&mut self.ast_id_map, self.db.ast_id_map(self.file_id));
let old_span_map = mem::replace(&mut self.span_map, SpanMap::ExpansionSpanMap(span_map));
diff --git a/crates/hir-def/src/nameres/tests/incremental.rs b/crates/hir-def/src/nameres/tests/incremental.rs
index 0f1828abce..60ec3035fa 100644
--- a/crates/hir-def/src/nameres/tests/incremental.rs
+++ b/crates/hir-def/src/nameres/tests/incremental.rs
@@ -168,15 +168,15 @@ fn no() {}
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"EnumVariants::of_",
]
"#]],
@@ -185,7 +185,7 @@ fn no() {}
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"EnumVariants::of_",
]
"#]],
@@ -226,20 +226,20 @@ pub struct S {}
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"decl_macro_expander_shim",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"macro_def_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"macro_arg_shim",
]
"#]],
@@ -248,9 +248,9 @@ pub struct S {}
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"macro_arg_shim",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"ast_id_map",
"file_item_tree_query",
]
@@ -284,25 +284,25 @@ fn f() { foo }
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"crate_local_def_map",
"proc_macros_for_crate_shim",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"macro_def_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"expand_proc_macro_shim",
"macro_arg_shim",
"proc_macro_span_shim",
@@ -313,10 +313,10 @@ fn f() { foo }
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"macro_arg_shim",
"expand_proc_macro_shim",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"ast_id_map",
"file_item_tree_query",
]
@@ -408,37 +408,37 @@ pub struct S {}
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"crate_local_def_map",
"proc_macros_for_crate_shim",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"decl_macro_expander_shim",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"macro_def_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"macro_arg_shim",
"decl_macro_expander_shim",
"macro_def_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"macro_arg_shim",
"macro_def_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"expand_proc_macro_shim",
"macro_arg_shim",
"proc_macro_span_shim",
@@ -449,7 +449,7 @@ pub struct S {}
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"macro_arg_shim",
"decl_macro_expander_shim",
"macro_arg_shim",
@@ -518,35 +518,35 @@ m!(Z);
[crate_def_map.modules_for_file(&db, pos.file_id.file_id(&db)).next().unwrap()];
assert_eq!(module_data.scope.resolutions().count(), 4);
},
- &[("file_item_tree_query", 6), ("parse_macro_expansion_shim", 3)],
+ &[("file_item_tree_query", 6), ("parse_macro_expansion", 3)],
expect![[r#"
[
"crate_local_def_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"decl_macro_expander_shim",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"macro_def_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"macro_arg_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"macro_arg_shim",
"file_item_tree_query",
"ast_id_map",
- "parse_macro_expansion_shim",
+ "parse_macro_expansion",
"macro_arg_shim",
]
"#]],
@@ -568,13 +568,13 @@ m!(Z);
[crate_def_map.modules_for_file(&db, pos.file_id.file_id(&db)).next().unwrap()];
assert_eq!(module_data.scope.resolutions().count(), 4);
},
- &[("file_item_tree_query", 1), ("parse_macro_expansion_shim", 0)],
+ &[("file_item_tree_query", 1), ("parse_macro_expansion", 0)],
expect![[r#"
[
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"macro_arg_shim",
"macro_arg_shim",
"macro_arg_shim",
@@ -612,7 +612,7 @@ pub type Ty = ();
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
]
"#]],
);
@@ -632,7 +632,7 @@ pub type Ty = ();
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
]
"#]],
);
diff --git a/crates/hir-expand/src/attrs.rs b/crates/hir-expand/src/attrs.rs
index d1f962f7ff..395b997972 100644
--- a/crates/hir-expand/src/attrs.rs
+++ b/crates/hir-expand/src/attrs.rs
@@ -32,7 +32,7 @@ use crate::{
AstId,
db::ExpandDatabase,
mod_path::ModPath,
- span_map::SpanMapRef,
+ span_map::SpanMap,
tt::{self, TopSubtree},
};
@@ -422,7 +422,7 @@ impl AttrId {
));
let tt = syntax_bridge::syntax_node_to_token_tree(
tt.syntax(),
- SpanMapRef::RealSpanMap(&span_map),
+ SpanMap::RealSpanMap(&span_map),
span_map.span_for_range(tt.syntax().text_range()),
DocCommentDesugarMode::ProcMacro,
);
diff --git a/crates/hir-expand/src/cfg_process.rs b/crates/hir-expand/src/cfg_process.rs
index 6258fac0e9..81edc9f2cf 100644
--- a/crates/hir-expand/src/cfg_process.rs
+++ b/crates/hir-expand/src/cfg_process.rs
@@ -16,7 +16,7 @@ use crate::{
attrs::{AstPathExt, AttrId, expand_cfg_attr, is_item_tree_filtered_attr},
db::ExpandDatabase,
fixup::{self, SyntaxFixupUndoInfo},
- span_map::SpanMapRef,
+ span_map::SpanMap,
tt::{self, DelimSpan, Span},
};
@@ -51,7 +51,7 @@ fn macro_input_callback(
censor_item_tree_attr_ids: &[AttrId],
krate: Crate,
default_span: Span,
- span_map: SpanMapRef<'_>,
+ span_map: SpanMap<'_>,
) -> impl FnMut(&mut PreorderWithTokens, &WalkEvent<SyntaxElement>) -> (bool, Vec<tt::Leaf>) {
let cfg_options = OnceCell::new();
let cfg_options = move || *cfg_options.get_or_init(|| krate.cfg_options(db));
@@ -295,7 +295,7 @@ fn macro_input_callback(
pub(crate) fn attr_macro_input_to_token_tree(
db: &dyn ExpandDatabase,
node: &SyntaxNode,
- span_map: SpanMapRef<'_>,
+ span_map: SpanMap<'_>,
span: Span,
is_derive: bool,
censor_item_tree_attr_ids: &[AttrId],
diff --git a/crates/hir-expand/src/db.rs b/crates/hir-expand/src/db.rs
index 8dddddfabb..57c78748f8 100644
--- a/crates/hir-expand/src/db.rs
+++ b/crates/hir-expand/src/db.rs
@@ -17,7 +17,7 @@ use crate::{
fixup::{self, SyntaxFixupUndoInfo},
hygiene::{span_with_call_site_ctxt, span_with_def_site_ctxt, span_with_mixed_site_ctxt},
proc_macro::{CrateProcMacros, CustomProcMacroExpander, ProcMacros},
- span_map::{ExpansionSpanMap, RealSpanMap, SpanMap, SpanMapRef},
+ span_map::{ExpansionSpanMap, RealSpanMap, SpanMap},
tt,
};
/// This is just to ensure the types of smart_macro_arg and macro_arg are the same
@@ -67,21 +67,22 @@ pub trait ExpandDatabase: SourceDatabase {
fn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode;
/// Implementation for the macro case.
- #[salsa::lru(512)]
+ #[salsa::transparent]
fn parse_macro_expansion(
&self,
macro_file: MacroCallId,
- ) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)>;
+ ) -> &ExpandResult<(Parse<SyntaxNode>, ExpansionSpanMap)>;
#[salsa::transparent]
#[salsa::invoke(SpanMap::new)]
- fn span_map(&self, file_id: HirFileId) -> SpanMap;
+ fn span_map(&self, file_id: HirFileId) -> SpanMap<'_>;
#[salsa::transparent]
#[salsa::invoke(crate::span_map::expansion_span_map)]
- fn expansion_span_map(&self, file_id: MacroCallId) -> Arc<ExpansionSpanMap>;
+ fn expansion_span_map(&self, file_id: MacroCallId) -> &ExpansionSpanMap;
#[salsa::invoke(crate::span_map::real_span_map)]
- fn real_span_map(&self, file_id: EditionedFileId) -> Arc<RealSpanMap>;
+ #[salsa::transparent]
+ fn real_span_map(&self, file_id: EditionedFileId) -> &RealSpanMap;
/// Macro ids. That's probably the tricksiest bit in rust-analyzer, and the
/// reason why we use salsa at all.
@@ -181,7 +182,7 @@ pub fn expand_speculative(
let (_, _, span) = db.macro_arg_considering_derives(actual_macro_call, &loc.kind);
let span_map = RealSpanMap::absolute(span.anchor.file_id);
- let span_map = SpanMapRef::RealSpanMap(&span_map);
+ let span_map = SpanMap::RealSpanMap(&span_map);
// Build the subtree and token mapping for the speculative args
let (mut tt, undo_info) = match &loc.kind {
@@ -358,10 +359,11 @@ fn parse_or_expand(db: &dyn ExpandDatabase, file_id: HirFileId) -> SyntaxNode {
// FIXME: We should verify that the parsed node is one of the many macro node variants we expect
// instead of having it be untyped
+#[salsa_macros::tracked(returns(ref), lru = 512)]
fn parse_macro_expansion(
db: &dyn ExpandDatabase,
macro_file: MacroCallId,
-) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)> {
+) -> ExpandResult<(Parse<SyntaxNode>, ExpansionSpanMap)> {
let _p = tracing::info_span!("parse_macro_expansion").entered();
let loc = db.lookup_intern_macro_call(macro_file);
let expand_to = loc.expand_to();
@@ -377,7 +379,7 @@ fn parse_macro_expansion(
);
rev_token_map.matched_arm = matched_arm;
- ExpandResult { value: (parse, Arc::new(rev_token_map)), err }
+ ExpandResult { value: (parse, rev_token_map), err }
}
fn parse_macro_expansion_error(
@@ -385,21 +387,21 @@ fn parse_macro_expansion_error(
macro_call_id: MacroCallId,
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>> {
let e: ExpandResult<Arc<[SyntaxError]>> =
- db.parse_macro_expansion(macro_call_id).map(|it| Arc::from(it.0.errors()));
+ db.parse_macro_expansion(macro_call_id).as_ref().map(|it| Arc::from(it.0.errors()));
if e.value.is_empty() && e.err.is_none() { None } else { Some(Arc::new(e)) }
}
pub(crate) fn parse_with_map(
db: &dyn ExpandDatabase,
file_id: HirFileId,
-) -> (Parse<SyntaxNode>, SpanMap) {
+) -> (Parse<SyntaxNode>, SpanMap<'_>) {
match file_id {
HirFileId::FileId(file_id) => {
(file_id.parse(db).to_syntax(), SpanMap::RealSpanMap(db.real_span_map(file_id)))
}
HirFileId::MacroFile(macro_file) => {
- let (parse, map) = db.parse_macro_expansion(macro_file).value;
- (parse, SpanMap::ExpansionSpanMap(map))
+ let (parse, map) = &db.parse_macro_expansion(macro_file).value;
+ (parse.clone(), SpanMap::ExpansionSpanMap(map))
}
}
}
@@ -487,7 +489,7 @@ fn macro_arg(db: &dyn ExpandDatabase, id: MacroCallId) -> MacroArgResult {
let mut tt = syntax_bridge::syntax_node_to_token_tree(
tt.syntax(),
- map.as_ref(),
+ map,
span,
if loc.def.is_proc_macro() {
DocCommentDesugarMode::ProcMacro
@@ -522,7 +524,7 @@ fn macro_arg(db: &dyn ExpandDatabase, id: MacroCallId) -> MacroArgResult {
let (mut tt, undo_info) = attr_macro_input_to_token_tree(
db,
item_node.syntax(),
- map.as_ref(),
+ map,
span,
is_derive,
censor_item_tree_attr_ids,
diff --git a/crates/hir-expand/src/declarative.rs b/crates/hir-expand/src/declarative.rs
index 4b2c6e7351..aa745a2ccd 100644
--- a/crates/hir-expand/src/declarative.rs
+++ b/crates/hir-expand/src/declarative.rs
@@ -128,7 +128,7 @@ impl DeclarativeMacroExpander {
Some(arg) => {
let tt = syntax_bridge::syntax_node_to_token_tree(
arg.syntax(),
- map.as_ref(),
+ map,
map.span_for_range(
macro_rules.macro_rules_token().unwrap().text_range(),
),
@@ -152,14 +152,14 @@ impl DeclarativeMacroExpander {
let args = macro_def.args().map(|args| {
syntax_bridge::syntax_node_to_token_tree(
args.syntax(),
- map.as_ref(),
+ map,
span,
DocCommentDesugarMode::Mbe,
)
});
let body = syntax_bridge::syntax_node_to_token_tree(
body.syntax(),
- map.as_ref(),
+ map,
span,
DocCommentDesugarMode::Mbe,
);
diff --git a/crates/hir-expand/src/eager.rs b/crates/hir-expand/src/eager.rs
index 0b6124ebf3..6e95ff01c3 100644
--- a/crates/hir-expand/src/eager.rs
+++ b/crates/hir-expand/src/eager.rs
@@ -70,7 +70,7 @@ pub fn expand_eager_macro_input(
let ExpandResult { value: expanded_eager_input, err } = {
eager_macro_recur(
db,
- &arg_exp_map,
+ arg_exp_map,
&mut arg_map,
TextSize::new(0),
InFile::new(arg_id.into(), arg_exp.syntax_node()),
@@ -80,7 +80,7 @@ pub fn expand_eager_macro_input(
eager_callback,
)
};
- let err = parse_err.or(err);
+ let err = parse_err.clone().or(err);
if cfg!(debug_assertions) {
arg_map.finish();
}
@@ -117,15 +117,15 @@ pub fn expand_eager_macro_input(
ExpandResult { value: Some(db.intern_macro_call(loc)), err }
}
-fn lazy_expand(
- db: &dyn ExpandDatabase,
+fn lazy_expand<'db>(
+ db: &'db dyn ExpandDatabase,
def: &MacroDefId,
macro_call: &ast::MacroCall,
ast_id: AstId<ast::MacroCall>,
krate: Crate,
call_site: SyntaxContext,
eager_callback: EagerCallBackFn<'_>,
-) -> ExpandResult<(InFile<Parse<SyntaxNode>>, Arc<ExpansionSpanMap>)> {
+) -> ExpandResult<(InFile<Parse<SyntaxNode>>, &'db ExpansionSpanMap)> {
let expand_to = ExpandTo::from_call_site(macro_call);
let id = def.make_call(
db,
@@ -135,7 +135,9 @@ fn lazy_expand(
);
eager_callback(ast_id.map(|ast_id| (AstPtr::new(macro_call), ast_id)), id);
- db.parse_macro_expansion(id).map(|parse| (InFile::new(id.into(), parse.0), parse.1))
+ db.parse_macro_expansion(id)
+ .as_ref()
+ .map(|parse| (InFile::new(id.into(), parse.0.clone()), &parse.1))
}
fn eager_macro_recur(
@@ -232,7 +234,7 @@ fn eager_macro_recur(
syntax_node.clone_for_update(),
offset + syntax_node.text_range().len(),
)),
- err: err.or(err2),
+ err: err.clone().or_else(|| err2.clone()),
}
}
None => ExpandResult { value: None, err },
@@ -256,7 +258,7 @@ fn eager_macro_recur(
// replace macro inside
let ExpandResult { value, err: error } = eager_macro_recur(
db,
- &tm,
+ tm,
expanded_map,
offset,
// FIXME: We discard parse errors here
diff --git a/crates/hir-expand/src/files.rs b/crates/hir-expand/src/files.rs
index 71da560b15..09a5c9326e 100644
--- a/crates/hir-expand/src/files.rs
+++ b/crates/hir-expand/src/files.rs
@@ -328,7 +328,7 @@ impl<SN: Borrow<SyntaxNode>> InFile<SN> {
let FileRange { file_id: editioned_file_id, range } = map_node_range_up_rooted(
db,
- &db.expansion_span_map(file_id),
+ db.expansion_span_map(file_id),
self.value.borrow().text_range(),
)?;
@@ -371,7 +371,7 @@ impl InFile<SyntaxToken> {
HirFileId::MacroFile(mac_file) => {
let (range, ctxt) = span_for_offset(
db,
- &db.expansion_span_map(mac_file),
+ db.expansion_span_map(mac_file),
self.value.text_range().start(),
);
@@ -397,7 +397,7 @@ impl InFile<SyntaxToken> {
HirFileId::MacroFile(mac_file) => {
let (range, ctxt) = span_for_offset(
db,
- &db.expansion_span_map(mac_file),
+ db.expansion_span_map(mac_file),
self.value.text_range().start(),
);
@@ -411,7 +411,7 @@ impl InFile<SyntaxToken> {
impl InMacroFile<TextSize> {
pub fn original_file_range(self, db: &dyn db::ExpandDatabase) -> (FileRange, SyntaxContext) {
- span_for_offset(db, &db.expansion_span_map(self.file_id), self.value)
+ span_for_offset(db, db.expansion_span_map(self.file_id), self.value)
}
}
@@ -425,7 +425,7 @@ impl InFile<TextRange> {
(FileRange { file_id, range: self.value }, SyntaxContext::root(file_id.edition(db)))
}
HirFileId::MacroFile(mac_file) => {
- match map_node_range_up(db, &db.expansion_span_map(mac_file), self.value) {
+ match map_node_range_up(db, db.expansion_span_map(mac_file), self.value) {
Some(it) => it,
None => {
let loc = db.lookup_intern_macro_call(mac_file);
@@ -443,7 +443,7 @@ impl InFile<TextRange> {
match self.file_id {
HirFileId::FileId(file_id) => FileRange { file_id, range: self.value },
HirFileId::MacroFile(mac_file) => {
- match map_node_range_up_rooted(db, &db.expansion_span_map(mac_file), self.value) {
+ match map_node_range_up_rooted(db, db.expansion_span_map(mac_file), self.value) {
Some(it) => it,
_ => {
let loc = db.lookup_intern_macro_call(mac_file);
@@ -461,7 +461,7 @@ impl InFile<TextRange> {
match self.file_id {
HirFileId::FileId(file_id) => FileRange { file_id, range: self.value },
HirFileId::MacroFile(mac_file) => {
- match map_node_range_up_rooted(db, &db.expansion_span_map(mac_file), self.value) {
+ match map_node_range_up_rooted(db, db.expansion_span_map(mac_file), self.value) {
Some(it) => it,
_ => {
let loc = db.lookup_intern_macro_call(mac_file);
@@ -482,7 +482,7 @@ impl InFile<TextRange> {
SyntaxContext::root(file_id.edition(db)),
)),
HirFileId::MacroFile(mac_file) => {
- map_node_range_up(db, &db.expansion_span_map(mac_file), self.value)
+ map_node_range_up(db, db.expansion_span_map(mac_file), self.value)
}
}
}
@@ -494,7 +494,7 @@ impl InFile<TextRange> {
match self.file_id {
HirFileId::FileId(file_id) => Some(FileRange { file_id, range: self.value }),
HirFileId::MacroFile(mac_file) => {
- map_node_range_up_rooted(db, &db.expansion_span_map(mac_file), self.value)
+ map_node_range_up_rooted(db, db.expansion_span_map(mac_file), self.value)
}
}
}
@@ -516,7 +516,7 @@ impl<N: AstNode> InFile<N> {
let FileRange { file_id: editioned_file_id, range } = map_node_range_up_rooted(
db,
- &db.expansion_span_map(file_id),
+ db.expansion_span_map(file_id),
self.value.syntax().text_range(),
)?;
diff --git a/crates/hir-expand/src/fixup.rs b/crates/hir-expand/src/fixup.rs
index 424655ed65..b51ec39ce7 100644
--- a/crates/hir-expand/src/fixup.rs
+++ b/crates/hir-expand/src/fixup.rs
@@ -18,7 +18,7 @@ use triomphe::Arc;
use tt::{Spacing, TransformTtAction, transform_tt};
use crate::{
- span_map::SpanMapRef,
+ span_map::SpanMap,
tt::{self, Ident, Leaf, Punct, TopSubtree},
};
@@ -51,7 +51,7 @@ const FIXUP_DUMMY_RANGE: TextRange = TextRange::empty(TextSize::new(0));
const FIXUP_DUMMY_RANGE_END: TextSize = TextSize::new(!0);
pub(crate) fn fixup_syntax(
- span_map: SpanMapRef<'_>,
+ span_map: SpanMap<'_>,
node: &SyntaxNode,
call_site: Span,
mode: DocCommentDesugarMode,
@@ -402,7 +402,6 @@ mod tests {
use span::{Edition, EditionedFileId, FileId};
use syntax::TextRange;
use syntax_bridge::DocCommentDesugarMode;
- use triomphe::Arc;
use crate::{
fixup::reverse_fixups,
@@ -440,19 +439,19 @@ mod tests {
#[track_caller]
fn check(#[rust_analyzer::rust_fixture] ra_fixture: &str, mut expect: Expect) {
let parsed = syntax::SourceFile::parse(ra_fixture, span::Edition::CURRENT);
- let span_map = SpanMap::RealSpanMap(Arc::new(RealSpanMap::absolute(EditionedFileId::new(
+ let span_map = SpanMap::RealSpanMap(&RealSpanMap::absolute(EditionedFileId::new(
FileId::from_raw(0),
Edition::CURRENT,
- ))));
+ )));
let fixups = super::fixup_syntax(
- span_map.as_ref(),
+ span_map,
&parsed.syntax_node(),
span_map.span_for_range(TextRange::empty(0.into())),
DocCommentDesugarMode::Mbe,
);
let mut tt = syntax_bridge::syntax_node_to_token_tree_modified(
&parsed.syntax_node(),
- span_map.as_ref(),
+ span_map,
fixups.append,
fixups.remove,
span_map.span_for_range(TextRange::empty(0.into())),
@@ -494,7 +493,7 @@ mod tests {
// modulo token IDs and `Punct`s' spacing.
let original_as_tt = syntax_bridge::syntax_node_to_token_tree(
&parsed.syntax_node(),
- span_map.as_ref(),
+ span_map,
span_map.span_for_range(TextRange::empty(0.into())),
DocCommentDesugarMode::Mbe,
);
diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs
index 8d42a24e2f..fc2a07435b 100644
--- a/crates/hir-expand/src/lib.rs
+++ b/crates/hir-expand/src/lib.rs
@@ -491,7 +491,7 @@ impl MacroCallId {
}
/// Return expansion information if it is a macro-expansion file
- pub fn expansion_info(self, db: &dyn ExpandDatabase) -> ExpansionInfo {
+ pub fn expansion_info(self, db: &dyn ExpandDatabase) -> ExpansionInfo<'_> {
ExpansionInfo::new(db, self)
}
@@ -797,16 +797,16 @@ impl MacroCallKind {
// FIXME: can be expensive to create, we should check the use sites and maybe replace them with
// simpler function calls if the map is only used once
#[derive(Clone, Debug, PartialEq, Eq)]
-pub struct ExpansionInfo {
+pub struct ExpansionInfo<'db> {
expanded: InMacroFile<SyntaxNode>,
/// The argument TokenTree or item for attributes
arg: InFile<Option<SyntaxNode>>,
- exp_map: Arc<ExpansionSpanMap>,
- arg_map: SpanMap,
+ exp_map: &'db ExpansionSpanMap,
+ arg_map: SpanMap<'db>,
loc: MacroCallLoc,
}
-impl ExpansionInfo {
+impl<'db> ExpansionInfo<'db> {
pub fn expanded(&self) -> InMacroFile<SyntaxNode> {
self.expanded.clone()
}
@@ -872,7 +872,7 @@ impl ExpansionInfo {
offset: TextSize,
) -> (FileRange, SyntaxContext) {
debug_assert!(self.expanded.value.text_range().contains(offset));
- span_for_offset(db, &self.exp_map, offset)
+ span_for_offset(db, self.exp_map, offset)
}
/// Maps up the text range out of the expansion hierarchy back into the original file its from.
@@ -882,7 +882,7 @@ impl ExpansionInfo {
range: TextRange,
) -> Option<(FileRange, SyntaxContext)> {
debug_assert!(self.expanded.value.text_range().contains_range(range));
- map_node_range_up(db, &self.exp_map, range)
+ map_node_range_up(db, self.exp_map, range)
}
/// Maps up the text range out of the expansion into its macro call.
@@ -918,14 +918,14 @@ impl ExpansionInfo {
}
}
- pub fn new(db: &dyn ExpandDatabase, macro_file: MacroCallId) -> ExpansionInfo {
+ pub fn new(db: &'db dyn ExpandDatabase, macro_file: MacroCallId) -> ExpansionInfo<'db> {
let _p = tracing::info_span!("ExpansionInfo::new").entered();
let loc = db.lookup_intern_macro_call(macro_file);
let arg_tt = loc.kind.arg(db);
let arg_map = db.span_map(arg_tt.file_id);
- let (parse, exp_map) = db.parse_macro_expansion(macro_file).value;
+ let (parse, exp_map) = &db.parse_macro_expansion(macro_file).value;
let expanded = InMacroFile { file_id: macro_file, value: parse.syntax_node() };
ExpansionInfo { expanded, loc, arg: arg_tt, exp_map, arg_map }
diff --git a/crates/hir-expand/src/span_map.rs b/crates/hir-expand/src/span_map.rs
index aa8603341b..6a94df8b5a 100644
--- a/crates/hir-expand/src/span_map.rs
+++ b/crates/hir-expand/src/span_map.rs
@@ -2,7 +2,6 @@
use span::Span;
use syntax::{AstNode, TextRange, ast};
-use triomphe::Arc;
pub use span::RealSpanMap;
@@ -11,35 +10,21 @@ use crate::{HirFileId, MacroCallId, db::ExpandDatabase};
pub type ExpansionSpanMap = span::SpanMap;
/// Spanmap for a macro file or a real file
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub enum SpanMap {
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum SpanMap<'db> {
/// Spanmap for a macro file
- ExpansionSpanMap(Arc<ExpansionSpanMap>),
+ ExpansionSpanMap(&'db ExpansionSpanMap),
/// Spanmap for a real file
- RealSpanMap(Arc<RealSpanMap>),
+ RealSpanMap(&'db RealSpanMap),
}
-#[derive(Copy, Clone)]
-pub enum SpanMapRef<'a> {
- /// Spanmap for a macro file
- ExpansionSpanMap(&'a ExpansionSpanMap),
- /// Spanmap for a real file
- RealSpanMap(&'a RealSpanMap),
-}
-
-impl syntax_bridge::SpanMapper for SpanMap {
- fn span_for(&self, range: TextRange) -> Span {
- self.span_for_range(range)
- }
-}
-
-impl syntax_bridge::SpanMapper for SpanMapRef<'_> {
+impl syntax_bridge::SpanMapper for SpanMap<'_> {
fn span_for(&self, range: TextRange) -> Span {
self.span_for_range(range)
}
}
-impl SpanMap {
+impl<'db> SpanMap<'db> {
pub fn span_for_range(&self, range: TextRange) -> Span {
match self {
// FIXME: Is it correct for us to only take the span at the start? This feels somewhat
@@ -51,37 +36,22 @@ impl SpanMap {
}
}
- pub fn as_ref(&self) -> SpanMapRef<'_> {
- match self {
- Self::ExpansionSpanMap(span_map) => SpanMapRef::ExpansionSpanMap(span_map),
- Self::RealSpanMap(span_map) => SpanMapRef::RealSpanMap(span_map),
- }
- }
-
#[inline]
- pub(crate) fn new(db: &dyn ExpandDatabase, file_id: HirFileId) -> SpanMap {
+ pub(crate) fn new(db: &'db dyn ExpandDatabase, file_id: HirFileId) -> SpanMap<'db> {
match file_id {
HirFileId::FileId(file_id) => SpanMap::RealSpanMap(db.real_span_map(file_id)),
HirFileId::MacroFile(m) => {
- SpanMap::ExpansionSpanMap(db.parse_macro_expansion(m).value.1)
+ SpanMap::ExpansionSpanMap(&db.parse_macro_expansion(m).value.1)
}
}
}
}
-impl SpanMapRef<'_> {
- pub fn span_for_range(self, range: TextRange) -> Span {
- match self {
- Self::ExpansionSpanMap(span_map) => span_map.span_at(range.start()),
- Self::RealSpanMap(span_map) => span_map.span_for_range(range),
- }
- }
-}
-
+#[salsa_macros::tracked(returns(ref))]
pub(crate) fn real_span_map(
db: &dyn ExpandDatabase,
editioned_file_id: base_db::EditionedFileId,
-) -> Arc<RealSpanMap> {
+) -> RealSpanMap {
use syntax::ast::HasModuleItem;
let mut pairs = vec![(syntax::TextSize::new(0), span::ROOT_ERASED_FILE_AST_ID)];
let ast_id_map = db.ast_id_map(editioned_file_id.into());
@@ -134,16 +104,16 @@ pub(crate) fn real_span_map(
_ => (),
});
- Arc::new(RealSpanMap::from_file(
+ RealSpanMap::from_file(
editioned_file_id.span_file_id(db),
pairs.into_boxed_slice(),
tree.syntax().text_range().end(),
- ))
+ )
}
pub(crate) fn expansion_span_map(
db: &dyn ExpandDatabase,
file_id: MacroCallId,
-) -> Arc<ExpansionSpanMap> {
- db.parse_macro_expansion(file_id).value.1
+) -> &ExpansionSpanMap {
+ &db.parse_macro_expansion(file_id).value.1
}
diff --git a/crates/hir-ty/src/tests/incremental.rs b/crates/hir-ty/src/tests/incremental.rs
index 960155a8e4..02d8f6597d 100644
--- a/crates/hir-ty/src/tests/incremental.rs
+++ b/crates/hir-ty/src/tests/incremental.rs
@@ -36,7 +36,7 @@ fn foo() -> i32 {
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"InferenceResult::for_body_",
"FunctionSignature::of_",
"FunctionSignature::with_source_map_",
@@ -80,7 +80,7 @@ fn foo() -> i32 {
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"AttrFlags::query_",
"FunctionSignature::with_source_map_",
"FunctionSignature::of_",
@@ -125,7 +125,7 @@ fn baz() -> i32 {
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"InferenceResult::for_body_",
"FunctionSignature::of_",
"FunctionSignature::with_source_map_",
@@ -196,7 +196,7 @@ fn baz() -> i32 {
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"AttrFlags::query_",
"FunctionSignature::with_source_map_",
"FunctionSignature::of_",
@@ -249,7 +249,7 @@ $0",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"TraitImpls::for_crate_",
"lang_items",
"crate_lang_items",
@@ -286,7 +286,7 @@ pub struct NewStruct {
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"crate_local_def_map",
"TraitImpls::for_crate_",
"crate_lang_items",
@@ -324,7 +324,7 @@ $0",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"TraitImpls::for_crate_",
"lang_items",
"crate_lang_items",
@@ -362,7 +362,7 @@ pub enum SomeEnum {
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"crate_local_def_map",
"TraitImpls::for_crate_",
"crate_lang_items",
@@ -400,7 +400,7 @@ $0",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"TraitImpls::for_crate_",
"lang_items",
"crate_lang_items",
@@ -435,7 +435,7 @@ fn bar() -> f32 {
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"crate_local_def_map",
"TraitImpls::for_crate_",
"crate_lang_items",
@@ -477,7 +477,7 @@ $0",
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"TraitImpls::for_crate_",
"lang_items",
"crate_lang_items",
@@ -520,7 +520,7 @@ impl SomeStruct {
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"crate_local_def_map",
"TraitImpls::for_crate_",
"crate_lang_items",
@@ -578,7 +578,7 @@ fn main() {
"file_item_tree_query",
"ast_id_map",
"parse",
- "real_span_map_shim",
+ "real_span_map",
"TraitItems::query_with_diagnostics_",
"Body::of_",
"Body::with_source_map_",
@@ -674,7 +674,7 @@ fn main() {
"parse",
"ast_id_map",
"file_item_tree_query",
- "real_span_map_shim",
+ "real_span_map",
"crate_local_def_map",
"TraitItems::query_with_diagnostics_",
"Body::with_source_map_",
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 8488d6931e..6f5508691e 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -196,7 +196,7 @@ use {
hir_def::expr_store::path::Path,
hir_expand::{
name::AsName,
- span_map::{ExpansionSpanMap, RealSpanMap, SpanMap, SpanMapRef},
+ span_map::{ExpansionSpanMap, RealSpanMap, SpanMap},
},
};
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 252f4ac7f2..d2056b1e7c 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -166,7 +166,7 @@ pub struct Semantics<'db, DB: ?Sized> {
pub struct SemanticsImpl<'db> {
pub db: &'db dyn HirDatabase,
- s2d_cache: RefCell<SourceToDefCache>,
+ s2d_cache: RefCell<SourceToDefCache<'db>>,
/// MacroCall to its expansion's MacroCallId cache
macro_call_cache: RefCell<FxHashMap<InFile<ast::MacroCall>, MacroCallId>>,
}
@@ -548,7 +548,7 @@ impl<'db> SemanticsImpl<'db> {
}
pub fn expand(&self, file_id: MacroCallId) -> ExpandResult<SyntaxNode> {
- let res = self.db.parse_macro_expansion(file_id).map(|it| it.0.syntax_node());
+ let res = self.db.parse_macro_expansion(file_id).as_ref().map(|it| it.0.syntax_node());
self.cache(res.value.clone(), file_id.into());
res
}
@@ -648,7 +648,7 @@ impl<'db> SemanticsImpl<'db> {
let ExpandResult { value, err } = self.db.parse_macro_expansion(file_id);
let root_node = value.0.syntax_node();
self.cache(root_node.clone(), file_id.into());
- Some(ExpandResult { value: root_node, err })
+ Some(ExpandResult { value: root_node, err: err.clone() })
})
.collect();
Some(res)
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index d932198b43..a9c3395381 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -117,16 +117,16 @@ use tt::TextRange;
use crate::{InFile, InlineAsmOperand, db::HirDatabase, semantics::child_by_source::ChildBySource};
#[derive(Default)]
-pub(super) struct SourceToDefCache {
+pub(super) struct SourceToDefCache<'db> {
pub(super) dynmap_cache: FxHashMap<(ChildContainer, HirFileId), DynMap>,
- expansion_info_cache: FxHashMap<MacroCallId, ExpansionInfo>,
+ expansion_info_cache: FxHashMap<MacroCallId, ExpansionInfo<'db>>,
pub(super) file_to_def_cache: FxHashMap<FileId, SmallVec<[ModuleId; 1]>>,
pub(super) included_file_cache: FxHashMap<EditionedFileId, Option<MacroCallId>>,
/// Rootnode to HirFileId cache
pub(super) root_to_file_cache: FxHashMap<SyntaxNode, HirFileId>,
}
-impl SourceToDefCache {
+impl<'db> SourceToDefCache<'db> {
pub(super) fn cache(
root_to_file_cache: &mut FxHashMap<SyntaxNode, HirFileId>,
root_node: SyntaxNode,
@@ -156,9 +156,9 @@ impl SourceToDefCache {
pub(super) fn get_or_insert_expansion(
&mut self,
- db: &dyn HirDatabase,
+ db: &'db dyn HirDatabase,
macro_file: MacroCallId,
- ) -> &ExpansionInfo {
+ ) -> &ExpansionInfo<'db> {
self.expansion_info_cache.entry(macro_file).or_insert_with(|| {
let exp_info = macro_file.expansion_info(db);
@@ -172,7 +172,7 @@ impl SourceToDefCache {
pub(super) struct SourceToDefCtx<'db, 'cache> {
pub(super) db: &'db dyn HirDatabase,
- pub(super) cache: &'cache mut SourceToDefCache,
+ pub(super) cache: &'cache mut SourceToDefCache<'db>,
}
impl SourceToDefCtx<'_, '_> {
diff --git a/crates/hir/src/term_search.rs b/crates/hir/src/term_search.rs
index f2dc1ce798..af2371d493 100644
--- a/crates/hir/src/term_search.rs
+++ b/crates/hir/src/term_search.rs
@@ -214,11 +214,11 @@ impl<'db> LookupTable<'db> {
/// Context for the `term_search` function
#[derive(Debug)]
-pub struct TermSearchCtx<'db, DB: HirDatabase> {
+pub struct TermSearchCtx<'a, 'db, DB: HirDatabase> {
/// Semantics for the program
- pub sema: &'db Semantics<'db, DB>,
+ pub sema: &'a Semantics<'db, DB>,
/// Semantic scope, captures context for the term search
- pub scope: &'db SemanticsScope<'db>,
+ pub scope: &'a SemanticsScope<'db>,
/// Target / expected output type
pub goal: Type<'db>,
/// Configuration for term search
@@ -263,7 +263,7 @@ impl Default for TermSearchConfig {
/// Note that there are usually more ways we can get to the `goal` type but some are discarded to
/// reduce the memory consumption. It is also unlikely anyone is willing ti browse through
/// thousands of possible responses so we currently take first 10 from every tactic.
-pub fn term_search<'db, DB: HirDatabase>(ctx: &'db TermSearchCtx<'db, DB>) -> Vec<Expr<'db>> {
+pub fn term_search<'db, DB: HirDatabase>(ctx: &TermSearchCtx<'_, 'db, DB>) -> Vec<Expr<'db>> {
let module = ctx.scope.module();
let mut defs = FxHashSet::default();
defs.insert(ScopeDef::ModuleDef(ModuleDef::Module(module)));
diff --git a/crates/hir/src/term_search/tactics.rs b/crates/hir/src/term_search/tactics.rs
index c7ef4e5d5d..b11f7a1723 100644
--- a/crates/hir/src/term_search/tactics.rs
+++ b/crates/hir/src/term_search/tactics.rs
@@ -41,7 +41,7 @@ use super::{LookupTable, NewTypesKey, TermSearchCtx};
/// _Note that there is no use of calling this tactic in every iteration as the output does not
/// depend on the current state of `lookup`_
pub(super) fn trivial<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
) -> impl Iterator<Item = Expr<'db>> + use<'a, 'db, 'lt, DB> {
@@ -105,7 +105,7 @@ pub(super) fn trivial<'a, 'lt, 'db, DB: HirDatabase>(
/// _Note that there is no use of calling this tactic in every iteration as the output does not
/// depend on the current state of `lookup`_
pub(super) fn assoc_const<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
) -> impl Iterator<Item = Expr<'db>> + use<'a, 'db, 'lt, DB> {
@@ -153,7 +153,7 @@ pub(super) fn assoc_const<'a, 'lt, 'db, DB: HirDatabase>(
/// * `lookup` - Lookup table for types
/// * `should_continue` - Function that indicates when to stop iterating
pub(super) fn data_constructor<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
_defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
should_continue: &'a dyn std::ops::Fn() -> bool,
@@ -302,7 +302,7 @@ pub(super) fn data_constructor<'a, 'lt, 'db, DB: HirDatabase>(
/// * `lookup` - Lookup table for types
/// * `should_continue` - Function that indicates when to stop iterating
pub(super) fn free_function<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
should_continue: &'a dyn std::ops::Fn() -> bool,
@@ -437,7 +437,7 @@ pub(super) fn free_function<'a, 'lt, 'db, DB: HirDatabase>(
/// * `lookup` - Lookup table for types
/// * `should_continue` - Function that indicates when to stop iterating
pub(super) fn impl_method<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
_defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
should_continue: &'a dyn std::ops::Fn() -> bool,
@@ -556,7 +556,7 @@ pub(super) fn impl_method<'a, 'lt, 'db, DB: HirDatabase>(
/// * `lookup` - Lookup table for types
/// * `should_continue` - Function that indicates when to stop iterating
pub(super) fn struct_projection<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
_defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
should_continue: &'a dyn std::ops::Fn() -> bool,
@@ -598,7 +598,7 @@ pub(super) fn struct_projection<'a, 'lt, 'db, DB: HirDatabase>(
/// * `defs` - Set of items in scope at term search target location
/// * `lookup` - Lookup table for types
pub(super) fn famous_types<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
_defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
) -> impl Iterator<Item = Expr<'db>> + use<'a, 'db, 'lt, DB> {
@@ -632,7 +632,7 @@ pub(super) fn famous_types<'a, 'lt, 'db, DB: HirDatabase>(
/// * `lookup` - Lookup table for types
/// * `should_continue` - Function that indicates when to stop iterating
pub(super) fn impl_static_method<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
_defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
should_continue: &'a dyn std::ops::Fn() -> bool,
@@ -738,7 +738,7 @@ pub(super) fn impl_static_method<'a, 'lt, 'db, DB: HirDatabase>(
/// * `lookup` - Lookup table for types
/// * `should_continue` - Function that indicates when to stop iterating
pub(super) fn make_tuple<'a, 'lt, 'db, DB: HirDatabase>(
- ctx: &'a TermSearchCtx<'db, DB>,
+ ctx: &'a TermSearchCtx<'_, 'db, DB>,
_defs: &'a FxHashSet<ScopeDef>,
lookup: &'lt mut LookupTable<'db>,
should_continue: &'a dyn std::ops::Fn() -> bool,
diff --git a/crates/ide-assists/src/assist_context.rs b/crates/ide-assists/src/assist_context.rs
index 0b8f35bfc3..d8e097f0e2 100644
--- a/crates/ide-assists/src/assist_context.rs
+++ b/crates/ide-assists/src/assist_context.rs
@@ -45,9 +45,9 @@ pub(crate) use ide_db::source_change::SourceChangeBuilder;
/// Note, however, that we don't actually use such two-phase logic at the
/// moment, because the LSP API is pretty awkward in this place, and it's much
/// easier to just compute the edit eagerly :-)
-pub(crate) struct AssistContext<'a> {
+pub(crate) struct AssistContext<'a, 'db> {
pub(crate) config: &'a AssistConfig,
- pub(crate) sema: Semantics<'a, RootDatabase>,
+ pub(crate) sema: Semantics<'db, RootDatabase>,
frange: FileRange,
trimmed_range: TextRange,
source_file: SourceFile,
@@ -57,12 +57,12 @@ pub(crate) struct AssistContext<'a> {
covering_element: SyntaxElement,
}
-impl<'a> AssistContext<'a> {
+impl<'a, 'db> AssistContext<'a, 'db> {
pub(crate) fn new(
- sema: Semantics<'a, RootDatabase>,
+ sema: Semantics<'db, RootDatabase>,
config: &'a AssistConfig,
frange: FileRange,
- ) -> AssistContext<'a> {
+ ) -> AssistContext<'a, 'db> {
let source_file = sema.parse(frange.file_id);
let start = frange.range.start();
@@ -95,7 +95,7 @@ impl<'a> AssistContext<'a> {
}
}
- pub(crate) fn db(&self) -> &'a RootDatabase {
+ pub(crate) fn db(&self) -> &'db RootDatabase {
self.sema.db
}
@@ -165,7 +165,7 @@ pub(crate) struct Assists {
}
impl Assists {
- pub(crate) fn new(ctx: &AssistContext<'_>, resolve: AssistResolveStrategy) -> Assists {
+ pub(crate) fn new(ctx: &AssistContext<'_, '_>, resolve: AssistResolveStrategy) -> Assists {
Assists {
resolve,
file: ctx.frange.file_id.file_id(ctx.db()),
diff --git a/crates/ide-assists/src/handlers/add_braces.rs b/crates/ide-assists/src/handlers/add_braces.rs
index c5ec88ffb8..4bd987a371 100644
--- a/crates/ide-assists/src/handlers/add_braces.rs
+++ b/crates/ide-assists/src/handlers/add_braces.rs
@@ -44,7 +44,7 @@ use crate::{AssistContext, AssistId, Assists};
// };
// }
// ```
-pub(crate) fn add_braces(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_braces(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (expr_type, expr) = get_replacement_node(ctx)?;
acc.add(
@@ -74,7 +74,7 @@ enum ParentType {
Assignment,
}
-fn get_replacement_node(ctx: &AssistContext<'_>) -> Option<(ParentType, ast::Expr)> {
+fn get_replacement_node(ctx: &AssistContext<'_, '_>) -> Option<(ParentType, ast::Expr)> {
let node = ctx.find_node_at_offset::<Either<ast::MatchArm, ast::ClosureExpr>>();
let (parent_type, body) = if let Some(eq_token) = ctx.find_token_syntax_at_offset(T![=]) {
let parent = eq_token.parent()?;
diff --git a/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs b/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs
index 1809b8f305..40d48bee3c 100644
--- a/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs
+++ b/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs
@@ -29,7 +29,7 @@ use crate::{AssistContext, Assists};
// ```
pub(crate) fn add_explicit_method_call_deref(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
if ctx.has_empty_selection() {
return None;
diff --git a/crates/ide-assists/src/handlers/add_explicit_enum_discriminant.rs b/crates/ide-assists/src/handlers/add_explicit_enum_discriminant.rs
index 75c5f84b85..db9f9dc074 100644
--- a/crates/ide-assists/src/handlers/add_explicit_enum_discriminant.rs
+++ b/crates/ide-assists/src/handlers/add_explicit_enum_discriminant.rs
@@ -30,7 +30,7 @@ use crate::{AssistContext, Assists, utils::add_group_separators};
// ```
pub(crate) fn add_explicit_enum_discriminant(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let enum_node = ctx.find_node_at_offset::<ast::Enum>()?;
let enum_def = ctx.sema.to_def(&enum_node)?;
diff --git a/crates/ide-assists/src/handlers/add_explicit_type.rs b/crates/ide-assists/src/handlers/add_explicit_type.rs
index 0dd01b67e8..53de25c454 100644
--- a/crates/ide-assists/src/handlers/add_explicit_type.rs
+++ b/crates/ide-assists/src/handlers/add_explicit_type.rs
@@ -20,7 +20,7 @@ use crate::{AssistContext, AssistId, Assists};
// let x: i32 = 92;
// }
// ```
-pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let syntax_node = ctx.find_node_at_offset::<Either<LetStmt, Param>>()?;
let (ascribed_ty, expr, pat) = if let Either::Left(let_stmt) = syntax_node {
let cursor_in_range = {
diff --git a/crates/ide-assists/src/handlers/add_label_to_loop.rs b/crates/ide-assists/src/handlers/add_label_to_loop.rs
index 41e9b6cc84..b2194ab3dc 100644
--- a/crates/ide-assists/src/handlers/add_label_to_loop.rs
+++ b/crates/ide-assists/src/handlers/add_label_to_loop.rs
@@ -30,7 +30,7 @@ use crate::{AssistContext, AssistId, Assists};
// }
// }
// ```
-pub(crate) fn add_label_to_loop(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_label_to_loop(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let loop_expr = ctx.find_node_at_offset::<ast::AnyHasLoopBody>()?;
let loop_kw = loop_token(&loop_expr)?;
if loop_expr.label().is_some() || !loop_kw.text_range().contains_inclusive(ctx.offset()) {
@@ -86,7 +86,7 @@ fn loop_token(loop_expr: &ast::AnyHasLoopBody) -> Option<syntax::SyntaxToken> {
fn insert_label_after_token(
editor: &SyntaxEditor,
token: &SyntaxToken,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
builder: &mut SourceChangeBuilder,
) {
let make = editor.make();
diff --git a/crates/ide-assists/src/handlers/add_lifetime_to_type.rs b/crates/ide-assists/src/handlers/add_lifetime_to_type.rs
index 265ee3d2d4..dc847dcdbe 100644
--- a/crates/ide-assists/src/handlers/add_lifetime_to_type.rs
+++ b/crates/ide-assists/src/handlers/add_lifetime_to_type.rs
@@ -22,7 +22,7 @@ use crate::{AssistContext, AssistId, Assists};
// y: u32,
// }
// ```
-pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let ref_type_focused = ctx.find_node_at_offset::<ast::RefType>()?;
if ref_type_focused.lifetime().is_some_and(|lifetime| lifetime.text() != "'_") {
return None;
diff --git a/crates/ide-assists/src/handlers/add_missing_impl_members.rs b/crates/ide-assists/src/handlers/add_missing_impl_members.rs
index d1f1f9f123..20f27dc728 100644
--- a/crates/ide-assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/ide-assists/src/handlers/add_missing_impl_members.rs
@@ -45,7 +45,10 @@ use crate::{
// }
// }
// ```
-pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_missing_impl_members(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
add_missing_impl_members_inner(
acc,
ctx,
@@ -89,7 +92,7 @@ pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext<'_
// ```
pub(crate) fn add_missing_default_members(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
add_missing_impl_members_inner(
acc,
@@ -103,7 +106,7 @@ pub(crate) fn add_missing_default_members(
fn add_missing_impl_members_inner(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
mode: DefaultMethods,
ignore_items: IgnoreAssocItems,
assist_id: &'static str,
@@ -224,7 +227,7 @@ fn add_missing_impl_members_inner(
fn try_gen_trait_body(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
func: &ast::Fn,
trait_ref: hir::TraitRef<'_>,
impl_def: &ast::Impl,
diff --git a/crates/ide-assists/src/handlers/add_missing_match_arms.rs b/crates/ide-assists/src/handlers/add_missing_match_arms.rs
index f2d71a1dfe..667a1d7813 100644
--- a/crates/ide-assists/src/handlers/add_missing_match_arms.rs
+++ b/crates/ide-assists/src/handlers/add_missing_match_arms.rs
@@ -38,7 +38,7 @@ use crate::{AssistContext, AssistId, Assists, utils};
// }
// }
// ```
-pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let match_expr = ctx.find_node_at_offset_with_descend::<ast::MatchExpr>()?;
let match_arm_list = match_expr.match_arm_list()?;
let arm_list_range = ctx.sema.original_range_opt(match_arm_list.syntax())?;
@@ -303,7 +303,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>)
}
fn cursor_at_trivial_match_arm_list(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
match_expr: &MatchExpr,
match_arm_list: &MatchArmList,
) -> Option<()> {
@@ -357,7 +357,7 @@ struct ArmsEdit {
}
impl ArmsEdit {
- fn remove_wildcard_arms(&mut self, ctx: &AssistContext<'_>, editor: &SyntaxEditor) {
+ fn remove_wildcard_arms(&mut self, ctx: &AssistContext<'_, '_>, editor: &SyntaxEditor) {
for arm in self.match_arm_list.arms() {
if !matches!(arm.pat(), Some(Pat::WildcardPat(_))) {
self.last_arm = Some(arm);
@@ -417,7 +417,7 @@ impl ArmsEdit {
fn add_comma_after_last_arm(
&self,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
editor: &SyntaxEditor,
) {
@@ -432,7 +432,7 @@ impl ArmsEdit {
fn cover_edit_range(
&self,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
node: &impl AstNode,
) -> Option<std::ops::RangeInclusive<syntax::SyntaxElement>> {
let range = ctx.sema.original_range_opt(node.syntax())?;
@@ -581,7 +581,7 @@ fn resolve_array_of_enum_def(
}
fn build_pat(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
module: hir::Module,
var: ExtendedVariant,
diff --git a/crates/ide-assists/src/handlers/add_return_type.rs b/crates/ide-assists/src/handlers/add_return_type.rs
index 7934a80bfa..e7203a96bb 100644
--- a/crates/ide-assists/src/handlers/add_return_type.rs
+++ b/crates/ide-assists/src/handlers/add_return_type.rs
@@ -16,7 +16,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
// fn foo() -> i32 { 42i32 }
// ```
-pub(crate) fn add_return_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_return_type(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (fn_type, tail_expr, builder_edit_pos) = extract_tail(ctx)?;
let module = ctx.sema.scope(tail_expr.syntax())?.module();
let ty = ctx.sema.type_of_expr(&peel_blocks(tail_expr.clone()))?.adjusted();
@@ -133,7 +133,7 @@ fn peel_blocks(mut expr: ast::Expr) -> ast::Expr {
expr
}
-fn extract_tail(ctx: &AssistContext<'_>) -> Option<(FnType, ast::Expr, InsertOrReplace)> {
+fn extract_tail(ctx: &AssistContext<'_, '_>) -> Option<(FnType, ast::Expr, InsertOrReplace)> {
let node = ctx.find_node_at_offset::<Either<ast::ClosureExpr, ast::Fn>>()?;
let (fn_type, tail_expr, return_type_range, action) = match node {
Either::Left(closure) => {
diff --git a/crates/ide-assists/src/handlers/add_turbo_fish.rs b/crates/ide-assists/src/handlers/add_turbo_fish.rs
index dcd2124f7b..53205910c8 100644
--- a/crates/ide-assists/src/handlers/add_turbo_fish.rs
+++ b/crates/ide-assists/src/handlers/add_turbo_fish.rs
@@ -28,7 +28,7 @@ use crate::{
// let x = make::<${0:_}>();
// }
// ```
-pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let turbofish_target =
ctx.find_node_at_offset::<ast::PathSegment>().map(Either::Left).or_else(|| {
let callable_expr = ctx.find_node_at_offset::<ast::CallableExpr>()?;
diff --git a/crates/ide-assists/src/handlers/apply_demorgan.rs b/crates/ide-assists/src/handlers/apply_demorgan.rs
index 31e7f1c176..10262445a2 100644
--- a/crates/ide-assists/src/handlers/apply_demorgan.rs
+++ b/crates/ide-assists/src/handlers/apply_demorgan.rs
@@ -37,7 +37,7 @@ use crate::{AssistContext, AssistId, Assists, utils::invert_boolean_expression};
// if !(x == 4 && y >= 3.14) {}
// }
// ```
-pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let mut bin_expr = if let Some(not) = ctx.find_token_syntax_at_offset(T![!])
&& let Some(NodeOrToken::Node(next)) = not.next_sibling_or_token()
&& let Some(paren) = ast::ParenExpr::cast(next)
@@ -189,7 +189,10 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti
// }
// }
// ```
-pub(crate) fn apply_demorgan_iterator(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn apply_demorgan_iterator(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let method_call: ast::MethodCallExpr = ctx.find_node_at_offset().or_else(|| {
let parent = ctx.find_token_syntax_at_offset(T![!])?.parent()?;
match ast::PrefixExpr::cast(parent)?.expr()? {
@@ -253,7 +256,7 @@ pub(crate) fn apply_demorgan_iterator(acc: &mut Assists, ctx: &AssistContext<'_>
/// Ensures that the method call is to `Iterator::all` or `Iterator::any`.
fn validate_method_call_expr(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
method_call: &ast::MethodCallExpr,
) -> Option<(ast::NameRef, ast::Expr)> {
let name_ref = method_call.name_ref()?;
diff --git a/crates/ide-assists/src/handlers/auto_import.rs b/crates/ide-assists/src/handlers/auto_import.rs
index f9d618790c..9bfb47e69d 100644
--- a/crates/ide-assists/src/handlers/auto_import.rs
+++ b/crates/ide-assists/src/handlers/auto_import.rs
@@ -91,7 +91,7 @@ use crate::{AssistContext, AssistId, Assists, GroupLabel};
// }
// # pub mod std { pub mod collections { pub struct HashMap { } } }
// ```
-pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let cfg = ctx.config.import_path_config();
let (import_assets, syntax_under_caret, expected) = find_importable_node(ctx)?;
@@ -170,8 +170,8 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<
Some(())
}
-pub(super) fn find_importable_node<'a: 'db, 'db>(
- ctx: &'a AssistContext<'db>,
+pub(super) fn find_importable_node<'db>(
+ ctx: &AssistContext<'_, 'db>,
) -> Option<(ImportAssets<'db>, SyntaxNode, Option<Type<'db>>)> {
// Deduplicate this with the `expected_type_and_name` logic for completions
let expected = |expr_or_pat: Either<ast::Expr, ast::Pat>| match expr_or_pat {
@@ -248,7 +248,7 @@ fn group_label(import_candidate: &ImportCandidate<'_>) -> GroupLabel {
/// Determine how relevant a given import is in the current context. Higher scores are more
/// relevant.
pub(crate) fn relevance_score(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
import: &LocatedImport,
expected: Option<&Type<'_>>,
current_module: Option<&Module>,
diff --git a/crates/ide-assists/src/handlers/bind_unused_param.rs b/crates/ide-assists/src/handlers/bind_unused_param.rs
index 50e4a367e9..5d3d8127ba 100644
--- a/crates/ide-assists/src/handlers/bind_unused_param.rs
+++ b/crates/ide-assists/src/handlers/bind_unused_param.rs
@@ -18,7 +18,7 @@ use syntax::{
// let _ = x;
// }
// ```
-pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let param: ast::Param = ctx.find_node_at_offset()?;
let Some(ast::Pat::IdentPat(ident_pat)) = param.pat() else { return None };
diff --git a/crates/ide-assists/src/handlers/change_visibility.rs b/crates/ide-assists/src/handlers/change_visibility.rs
index 7119d5b9c2..f17197a750 100644
--- a/crates/ide-assists/src/handlers/change_visibility.rs
+++ b/crates/ide-assists/src/handlers/change_visibility.rs
@@ -21,14 +21,14 @@ use crate::{AssistContext, AssistId, Assists, utils::vis_offset};
// ```
// pub(crate) fn frobnicate() {}
// ```
-pub(crate) fn change_visibility(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn change_visibility(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
if let Some(vis) = ctx.find_node_at_offset::<ast::Visibility>() {
return change_vis(acc, vis);
}
add_vis(acc, ctx)
}
-fn add_vis(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+fn add_vis(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let item_keyword = ctx.token_at_offset().find(|leaf| {
matches!(
leaf.kind(),
diff --git a/crates/ide-assists/src/handlers/convert_bool_then.rs b/crates/ide-assists/src/handlers/convert_bool_then.rs
index a2a71bcba6..5ecc11ccc5 100644
--- a/crates/ide-assists/src/handlers/convert_bool_then.rs
+++ b/crates/ide-assists/src/handlers/convert_bool_then.rs
@@ -38,7 +38,10 @@ use crate::{
// cond.then(|| val)
// }
// ```
-pub(crate) fn convert_if_to_bool_then(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_if_to_bool_then(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
// FIXME applies to match as well
let expr = ctx.find_node_at_offset::<ast::IfExpr>()?;
if !expr.if_token()?.text_range().contains_inclusive(ctx.offset()) {
@@ -153,7 +156,10 @@ pub(crate) fn convert_if_to_bool_then(acc: &mut Assists, ctx: &AssistContext<'_>
// }
// }
// ```
-pub(crate) fn convert_bool_then_to_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_bool_then_to_if(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let name_ref = ctx.find_node_at_offset::<ast::NameRef>()?;
let mcall = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast)?;
let receiver = mcall.receiver()?;
diff --git a/crates/ide-assists/src/handlers/convert_bool_to_enum.rs b/crates/ide-assists/src/handlers/convert_bool_to_enum.rs
index 231c447ec3..456a4d1fcf 100644
--- a/crates/ide-assists/src/handlers/convert_bool_to_enum.rs
+++ b/crates/ide-assists/src/handlers/convert_bool_to_enum.rs
@@ -52,7 +52,7 @@ use crate::{
// }
// }
// ```
-pub(crate) fn convert_bool_to_enum(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_bool_to_enum(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let BoolNodeData { target_node, name, ty_annotation, initializer, definition } =
find_bool_node(ctx)?;
let target_module = ctx.sema.scope(&target_node)?.module().nearest_non_block_module(ctx.db());
@@ -101,7 +101,7 @@ struct BoolNodeData {
}
/// Attempts to find an appropriate node to apply the action to.
-fn find_bool_node(ctx: &AssistContext<'_>) -> Option<BoolNodeData> {
+fn find_bool_node(ctx: &AssistContext<'_, '_>) -> Option<BoolNodeData> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
if let Some(ident_pat) = name.syntax().parent().and_then(ast::IdentPat::cast) {
@@ -208,7 +208,7 @@ fn bool_expr_to_enum_expr(expr: ast::Expr, make: &SyntaxFactory) -> ast::Expr {
/// Replaces all usages of the target identifier, both when read and written to.
fn replace_usages(
edit: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
usages: UsageSearchResult,
target_definition: Definition,
target_module: &hir::Module,
@@ -338,7 +338,7 @@ struct FileReferenceWithImport {
}
fn augment_references_with_imports(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
references: Vec<FileReference>,
target_module: &hir::Module,
make: &SyntaxFactory,
@@ -469,7 +469,7 @@ fn find_method_call_expr_usage(name: &ast::NameLike) -> Option<ast::Expr> {
/// Adds the definition of the new enum before the target node.
fn add_enum_def(
edit: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
usages: &UsageSearchResult,
target_node: SyntaxNode,
target_module: &hir::Module,
diff --git a/crates/ide-assists/src/handlers/convert_char_literal.rs b/crates/ide-assists/src/handlers/convert_char_literal.rs
index 0a50ba86ba..b23525665a 100644
--- a/crates/ide-assists/src/handlers/convert_char_literal.rs
+++ b/crates/ide-assists/src/handlers/convert_char_literal.rs
@@ -12,7 +12,7 @@ use crate::{AssistContext, AssistId, Assists, GroupLabel};
// ```
// const _: char = '\x61';
// ```
-pub(crate) fn convert_char_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_char_literal(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
if !ctx.has_empty_selection() {
return None;
}
diff --git a/crates/ide-assists/src/handlers/convert_closure_to_fn.rs b/crates/ide-assists/src/handlers/convert_closure_to_fn.rs
index acade43397..026b139b54 100644
--- a/crates/ide-assists/src/handlers/convert_closure_to_fn.rs
+++ b/crates/ide-assists/src/handlers/convert_closure_to_fn.rs
@@ -51,7 +51,7 @@ use crate::assist_context::{AssistContext, Assists};
// closure("abc", &mut s);
// }
// ```
-pub(crate) fn convert_closure_to_fn(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_closure_to_fn(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let closure = ctx.find_node_at_offset::<ast::ClosureExpr>()?;
if ctx.find_node_at_offset::<ast::Expr>() != Some(ast::Expr::ClosureExpr(closure.clone())) {
// Not inside the parameter list.
@@ -346,7 +346,7 @@ pub(crate) fn convert_closure_to_fn(acc: &mut Assists, ctx: &AssistContext<'_>)
}
fn compute_closure_type_params(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
mentioned_generic_params: FxHashSet<hir::GenericParam>,
closure: &ast::ClosureExpr,
) -> (Option<ast::GenericParamList>, Option<ast::WhereClause>) {
@@ -527,7 +527,7 @@ fn wrap_capture_in_deref_if_needed(
make::expr_prefix(T![*], capture_name).into()
}
-fn capture_as_arg(ctx: &AssistContext<'_>, capture: &ClosureCapture<'_>) -> ast::Expr {
+fn capture_as_arg(ctx: &AssistContext<'_, '_>, capture: &ClosureCapture<'_>) -> ast::Expr {
let place = parse_expr_from_str(
&capture.display_place_source_code(ctx.db(), ctx.edition()),
ctx.edition(),
@@ -548,7 +548,7 @@ fn capture_as_arg(ctx: &AssistContext<'_>, capture: &ClosureCapture<'_>) -> ast:
fn handle_calls(
builder: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
closure_name: Option<&ast::IdentPat>,
captures_as_args: &[ast::Expr],
closure: &ast::ClosureExpr,
@@ -590,7 +590,7 @@ fn handle_calls(
fn handle_call(
builder: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
closure_ref: ast::Expr,
captures_as_args: &[ast::Expr],
) -> Option<()> {
diff --git a/crates/ide-assists/src/handlers/convert_comment_block.rs b/crates/ide-assists/src/handlers/convert_comment_block.rs
index f242fe8314..d950b6df21 100644
--- a/crates/ide-assists/src/handlers/convert_comment_block.rs
+++ b/crates/ide-assists/src/handlers/convert_comment_block.rs
@@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, Assists};
// comment
// */
// ```
-pub(crate) fn convert_comment_block(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_comment_block(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let comment = ctx.find_token_at_offset::<ast::Comment>()?;
// Only allow comments which are alone on their line
if let Some(prev) = comment.syntax().prev_token() {
diff --git a/crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs b/crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs
index 187cc74306..11a3c64188 100644
--- a/crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs
+++ b/crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs
@@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn convert_comment_from_or_to_doc(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let comment = ctx.find_token_at_offset::<ast::Comment>()?;
diff --git a/crates/ide-assists/src/handlers/convert_for_to_while_let.rs b/crates/ide-assists/src/handlers/convert_for_to_while_let.rs
index 9eb4c0584b..d45c4292b8 100644
--- a/crates/ide-assists/src/handlers/convert_for_to_while_let.rs
+++ b/crates/ide-assists/src/handlers/convert_for_to_while_let.rs
@@ -32,7 +32,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn convert_for_loop_to_while_let(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let for_loop = ctx.find_node_at_offset::<ast::ForExpr>()?;
let iterable = for_loop.iterable()?;
diff --git a/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs b/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs
index 18f3ced414..3e11ee804a 100644
--- a/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs
+++ b/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs
@@ -33,7 +33,10 @@ use crate::{AssistContext, AssistId, Assists};
// }
// }
// ```
-pub(crate) fn convert_from_to_tryfrom(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_from_to_tryfrom(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let impl_ = ctx.find_node_at_offset::<ast::Impl>()?;
let trait_ty = impl_.trait_()?;
diff --git a/crates/ide-assists/src/handlers/convert_integer_literal.rs b/crates/ide-assists/src/handlers/convert_integer_literal.rs
index bc76ade97f..c92ad2a7c9 100644
--- a/crates/ide-assists/src/handlers/convert_integer_literal.rs
+++ b/crates/ide-assists/src/handlers/convert_integer_literal.rs
@@ -13,7 +13,10 @@ use crate::{AssistContext, AssistId, Assists, GroupLabel};
// ```
// const _: i32 = 0b1010;
// ```
-pub(crate) fn convert_integer_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_integer_literal(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
if !ctx.has_empty_selection() {
return None;
}
diff --git a/crates/ide-assists/src/handlers/convert_into_to_from.rs b/crates/ide-assists/src/handlers/convert_into_to_from.rs
index 2fcde15874..a01a66e7b1 100644
--- a/crates/ide-assists/src/handlers/convert_into_to_from.rs
+++ b/crates/ide-assists/src/handlers/convert_into_to_from.rs
@@ -33,7 +33,7 @@ use crate::{AssistContext, AssistId, Assists};
// }
// }
// ```
-pub(crate) fn convert_into_to_from(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_into_to_from(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let impl_ = ctx.find_node_at_offset::<ast::Impl>()?;
let src_type = impl_.self_ty()?;
let ast_trait = impl_.trait_()?;
diff --git a/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs
index cc5cc490f1..9506a96318 100644
--- a/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs
+++ b/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs
@@ -33,7 +33,7 @@ use crate::{AssistContext, AssistId, Assists, utils::wrap_paren};
// ```
pub(crate) fn convert_iter_for_each_to_for(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let method = ctx.find_node_at_offset::<ast::MethodCallExpr>()?;
@@ -98,7 +98,7 @@ pub(crate) fn convert_iter_for_each_to_for(
// ```
pub(crate) fn convert_for_loop_with_for_each(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let for_loop = ctx.find_node_at_offset::<ast::ForExpr>()?;
let iterable = for_loop.iterable()?;
@@ -205,7 +205,7 @@ fn impls_core_iter(sema: &hir::Semantics<'_, ide_db::RootDatabase>, iterable: &a
}
fn validate_method_call_expr(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
expr: ast::MethodCallExpr,
) -> Option<(ast::Expr, ast::Expr)> {
let name_ref = expr.name_ref()?;
diff --git a/crates/ide-assists/src/handlers/convert_let_else_to_match.rs b/crates/ide-assists/src/handlers/convert_let_else_to_match.rs
index 1ae12390ee..721e2d8789 100644
--- a/crates/ide-assists/src/handlers/convert_let_else_to_match.rs
+++ b/crates/ide-assists/src/handlers/convert_let_else_to_match.rs
@@ -24,7 +24,10 @@ use crate::{AssistContext, AssistId, Assists};
// };
// }
// ```
-pub(crate) fn convert_let_else_to_match(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_let_else_to_match(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let (editor, _) = SyntaxEditor::new(ctx.source_file().syntax().clone());
// Should focus on the `else` token to trigger
let let_stmt = ctx
diff --git a/crates/ide-assists/src/handlers/convert_match_to_let_else.rs b/crates/ide-assists/src/handlers/convert_match_to_let_else.rs
index bc49acc1ef..b41ae6788b 100644
--- a/crates/ide-assists/src/handlers/convert_match_to_let_else.rs
+++ b/crates/ide-assists/src/handlers/convert_match_to_let_else.rs
@@ -29,7 +29,10 @@ use crate::{
// let Some(val) = opt else { return };
// }
// ```
-pub(crate) fn convert_match_to_let_else(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_match_to_let_else(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let let_stmt: ast::LetStmt = ctx.find_node_at_offset()?;
let pat = let_stmt.pat()?;
if ctx.offset() > pat.syntax().text_range().end() {
@@ -71,7 +74,7 @@ pub(crate) fn convert_match_to_let_else(acc: &mut Assists, ctx: &AssistContext<'
// Given a match expression, find extracting and diverging arms.
fn find_arms(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
match_expr: &ast::MatchExpr,
) -> Option<(ast::MatchArm, ast::MatchArm)> {
let arms = match_expr.match_arm_list()?.arms().collect::<Vec<_>>();
@@ -99,7 +102,7 @@ fn find_arms(
}
// Given an extracting arm, find the extracted variable.
-fn find_extracted_variable(ctx: &AssistContext<'_>, arm: &ast::MatchArm) -> Option<Vec<Name>> {
+fn find_extracted_variable(ctx: &AssistContext<'_, '_>, arm: &ast::MatchArm) -> Option<Vec<Name>> {
match arm.expr()? {
ast::Expr::PathExpr(path) => {
let name_ref = path.syntax().descendants().find_map(ast::NameRef::cast)?;
diff --git a/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs b/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs
index 5b691dba5e..72418f1559 100644
--- a/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs
+++ b/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs
@@ -54,7 +54,7 @@ use crate::{
// ```
pub(crate) fn convert_named_struct_to_tuple_struct(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
// XXX: We don't currently provide this assist for struct definitions inside macros, but if we
// are to lift this limitation, don't forget to make `edit_struct_def()` consider macro files
@@ -92,7 +92,7 @@ pub(crate) fn convert_named_struct_to_tuple_struct(
}
fn edit_struct_def(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
builder: &mut SourceChangeBuilder,
strukt: &Either<ast::Struct, ast::Variant>,
record_fields: ast::RecordFieldList,
@@ -153,7 +153,7 @@ fn edit_struct_def(
}
fn edit_struct_references(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
builder: &mut SourceChangeBuilder,
strukt: Either<hir::Struct, hir::EnumVariant>,
) {
@@ -174,7 +174,7 @@ fn edit_struct_references(
}
fn process_struct_name_reference(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
r: FileReference,
edit: &SyntaxEditor,
source: &ast::SourceFile,
@@ -227,7 +227,7 @@ fn process_struct_name_reference(
}
fn record_to_tuple_struct_like<T, I>(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
source: &ast::SourceFile,
editor: &SyntaxEditor,
field_list: T,
@@ -282,7 +282,7 @@ where
}
fn edit_field_references(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
builder: &mut SourceChangeBuilder,
fields: impl Iterator<Item = ast::RecordField>,
) {
diff --git a/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs b/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs
index c0fd69779a..d0e82d69eb 100644
--- a/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs
+++ b/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs
@@ -29,7 +29,7 @@ use crate::assist_context::{AssistContext, Assists};
// ```
pub(crate) fn convert_nested_function_to_closure(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
let function = name.syntax().parent().and_then(ast::Fn::cast)?;
diff --git a/crates/ide-assists/src/handlers/convert_range_for_to_while.rs b/crates/ide-assists/src/handlers/convert_range_for_to_while.rs
index c83f8b0765..7026b5bafd 100644
--- a/crates/ide-assists/src/handlers/convert_range_for_to_while.rs
+++ b/crates/ide-assists/src/handlers/convert_range_for_to_while.rs
@@ -35,7 +35,10 @@ use crate::assist_context::{AssistContext, Assists};
// }
// }
// ```
-pub(crate) fn convert_range_for_to_while(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_range_for_to_while(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let (editor, _) = SyntaxEditor::new(ctx.source_file().syntax().clone());
let make = editor.make();
let for_kw = ctx.find_token_syntax_at_offset(T![for])?;
diff --git a/crates/ide-assists/src/handlers/convert_to_guarded_return.rs b/crates/ide-assists/src/handlers/convert_to_guarded_return.rs
index 44ca57281e..74392ca7c1 100644
--- a/crates/ide-assists/src/handlers/convert_to_guarded_return.rs
+++ b/crates/ide-assists/src/handlers/convert_to_guarded_return.rs
@@ -59,7 +59,10 @@ use crate::{
// let Some(x) = foo() else { return };
// }
// ```
-pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_to_guarded_return(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
match ctx.find_node_at_offset::<Either<ast::LetStmt, ast::IfExpr>>()? {
Either::Left(let_stmt) => let_stmt_to_guarded_return(let_stmt, acc, ctx),
Either::Right(if_expr) => if_expr_to_guarded_return(if_expr, acc, ctx),
@@ -69,7 +72,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext<'
fn if_expr_to_guarded_return(
if_expr: ast::IfExpr,
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let make = SyntaxFactory::without_mappings();
let cond = if_expr.condition()?;
@@ -174,7 +177,7 @@ fn if_expr_to_guarded_return(
fn let_stmt_to_guarded_return(
let_stmt: ast::LetStmt,
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let pat = let_stmt.pat()?;
let expr = let_stmt.initializer()?;
diff --git a/crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs b/crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs
index 254ff7280f..46e2917f72 100644
--- a/crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs
+++ b/crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs
@@ -51,7 +51,7 @@ use crate::assist_context::{AssistContext, Assists};
// ```
pub(crate) fn convert_tuple_return_type_to_struct(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
let type_ref = ret_type.ty()?;
@@ -104,7 +104,7 @@ pub(crate) fn convert_tuple_return_type_to_struct(
/// Replaces tuple usages with the corresponding tuple struct pattern.
fn replace_usages(
edit: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
usages: &UsageSearchResult,
struct_name: &str,
target_module: &hir::Module,
@@ -177,7 +177,7 @@ fn node_to_pats(node: SyntaxNode) -> Option<Vec<ast::Pat>> {
fn augment_references_with_imports(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
references: &[FileReference],
struct_name: &str,
target_module: &hir::Module,
@@ -232,7 +232,7 @@ fn augment_references_with_imports(
fn add_tuple_struct_def(
edit: &mut SourceChangeBuilder,
syntax_factory: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
usages: &UsageSearchResult,
parent: &SyntaxNode,
tuple_ty: &ast::TupleType,
diff --git a/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs b/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs
index afbcf024b9..a6a47d78a8 100644
--- a/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs
+++ b/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs
@@ -58,7 +58,7 @@ use crate::{
// ```
pub(crate) fn convert_tuple_struct_to_named_struct(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let strukt_or_variant = ctx
.find_node_at_offset::<ast::Struct>()
@@ -140,7 +140,7 @@ fn edit_struct_def(
}
fn edit_struct_references(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
edit: &mut SourceChangeBuilder,
strukt: Either<hir::Struct, hir::EnumVariant>,
names: &[ast::Name],
@@ -164,7 +164,7 @@ fn edit_struct_references(
}
fn process_struct_name_reference(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
r: FileReference,
editor: &SyntaxEditor,
source: &ast::SourceFile,
@@ -229,7 +229,7 @@ fn process_struct_name_reference(
}
fn process_delimiter(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
source: &ast::SourceFile,
editor: &SyntaxEditor,
list: &impl AstNode,
@@ -270,7 +270,7 @@ fn process_delimiter(
}
fn edit_field_references(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
edit: &mut SourceChangeBuilder,
fields: impl Iterator<Item = ast::TupleField>,
names: &[ast::Name],
diff --git a/crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs b/crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs
index 1af5db17f0..73b373dbcb 100644
--- a/crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs
+++ b/crates/ide-assists/src/handlers/convert_two_arm_bool_match_to_matches_macro.rs
@@ -25,7 +25,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn convert_two_arm_bool_match_to_matches_macro(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
use ArmBodyExpression::*;
let match_expr = ctx.find_node_at_offset::<ast::MatchExpr>()?;
diff --git a/crates/ide-assists/src/handlers/convert_while_to_loop.rs b/crates/ide-assists/src/handlers/convert_while_to_loop.rs
index 793e7465c1..94920569a0 100644
--- a/crates/ide-assists/src/handlers/convert_while_to_loop.rs
+++ b/crates/ide-assists/src/handlers/convert_while_to_loop.rs
@@ -38,7 +38,7 @@ use crate::{
// }
// }
// ```
-pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let while_kw = ctx.find_token_syntax_at_offset(T![while])?;
let while_expr = while_kw.parent().and_then(ast::WhileExpr::cast)?;
let while_body = while_expr.loop_body()?;
diff --git a/crates/ide-assists/src/handlers/destructure_struct_binding.rs b/crates/ide-assists/src/handlers/destructure_struct_binding.rs
index 6e6c7fcbfb..2b5b2ca13b 100644
--- a/crates/ide-assists/src/handlers/destructure_struct_binding.rs
+++ b/crates/ide-assists/src/handlers/destructure_struct_binding.rs
@@ -47,7 +47,10 @@ use crate::{
// let baz2 = &baz;
// }
// ```
-pub(crate) fn destructure_struct_binding(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn destructure_struct_binding(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let target = ctx.find_node_at_offset::<Target>()?;
let data = collect_data(target, ctx)?;
@@ -119,7 +122,7 @@ impl AstNode for Target {
}
fn destructure_struct_binding_impl(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
builder: &mut SourceChangeBuilder,
data: &StructEditData,
) {
@@ -173,7 +176,7 @@ impl StructEditData {
}
}
-fn collect_data(target: Target, ctx: &AssistContext<'_>) -> Option<StructEditData> {
+fn collect_data(target: Target, ctx: &AssistContext<'_, '_>) -> Option<StructEditData> {
let ty = target.ty(&ctx.sema)?;
let hir::Adt::Struct(struct_type) = ty.strip_references().as_adt()? else { return None };
@@ -246,7 +249,7 @@ fn collect_data(target: Target, ctx: &AssistContext<'_>) -> Option<StructEditDat
}
fn get_names_in_scope(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
target: &Target,
usages: &[FileReference],
) -> Option<FxHashSet<SmolStr>> {
@@ -270,7 +273,7 @@ fn get_names_in_scope(
}
fn destructure_pat(
- _ctx: &AssistContext<'_>,
+ _ctx: &AssistContext<'_, '_>,
editor: &SyntaxEditor,
data: &StructEditData,
field_names: &[(SmolStr, SmolStr)],
@@ -313,7 +316,10 @@ fn destructure_pat(
data.apply_to_destruct(new_pat, editor);
}
-fn generate_field_names(ctx: &AssistContext<'_>, data: &StructEditData) -> Vec<(SmolStr, SmolStr)> {
+fn generate_field_names(
+ ctx: &AssistContext<'_, '_>,
+ data: &StructEditData,
+) -> Vec<(SmolStr, SmolStr)> {
match data.kind {
hir::StructKind::Tuple => data
.visible_fields
@@ -348,7 +354,7 @@ fn new_field_name(base_name: SmolStr, names_in_scope: &FxHashSet<SmolStr>) -> Sm
}
fn update_usages(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
editor: &SyntaxEditor,
data: &StructEditData,
field_names: &FxHashMap<SmolStr, SmolStr>,
@@ -367,7 +373,7 @@ fn update_usages(
}
fn build_usage_edit(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
data: &StructEditData,
usage: &FileReference,
diff --git a/crates/ide-assists/src/handlers/destructure_tuple_binding.rs b/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
index 09a554234a..2755962362 100644
--- a/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
+++ b/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
@@ -34,7 +34,10 @@ use crate::{
// let v = _0;
// }
// ```
-pub(crate) fn destructure_tuple_binding(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn destructure_tuple_binding(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, false)
}
@@ -58,7 +61,7 @@ pub(crate) fn destructure_tuple_binding(acc: &mut Assists, ctx: &AssistContext<'
// ```
pub(crate) fn destructure_tuple_binding_impl(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
with_sub_pattern: bool,
) -> Option<()> {
let ident_pat = ctx.find_node_at_offset::<ast::IdentPat>()?;
@@ -84,7 +87,7 @@ pub(crate) fn destructure_tuple_binding_impl(
}
fn destructure_tuple_edit_impl(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
edit: &mut SourceChangeBuilder,
data: &TupleData,
in_sub_pattern: bool,
@@ -102,7 +105,7 @@ fn destructure_tuple_edit_impl(
edit.add_file_edits(ctx.vfs_file_id(), editor);
}
-fn collect_data(ident_pat: IdentPat, ctx: &AssistContext<'_>) -> Option<TupleData> {
+fn collect_data(ident_pat: IdentPat, ctx: &AssistContext<'_, '_>) -> Option<TupleData> {
if ident_pat.at_token().is_some() {
// Cannot destructure pattern with sub-pattern:
// Only IdentPat can have sub-pattern,
@@ -168,7 +171,7 @@ struct TupleData {
usages: Option<Vec<FileReference>>,
}
fn edit_tuple_assignment(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
edit: &mut SourceChangeBuilder,
editor: &SyntaxEditor,
data: &TupleData,
@@ -235,7 +238,7 @@ impl AssignmentEdit {
fn edit_tuple_usages(
data: &TupleData,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
in_sub_pattern: bool,
) -> Option<Vec<EditTupleUsage>> {
@@ -258,7 +261,7 @@ fn edit_tuple_usages(
Some(edits)
}
fn edit_tuple_usage(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
usage: &FileReference,
data: &TupleData,
@@ -275,7 +278,7 @@ fn edit_tuple_usage(
}
fn edit_tuple_field_usage(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
data: &TupleData,
index: TupleIndex,
@@ -305,7 +308,7 @@ enum EditTupleUsage {
impl EditTupleUsage {
fn apply(
self,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
edit: &mut SourceChangeBuilder,
syntax_editor: &SyntaxEditor,
) {
@@ -371,7 +374,7 @@ mod tests {
// Tests for direct tuple destructure:
// `let $0t = (1,2);` -> `let (_0, _1) = (1,2);`
- fn assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+ fn assist(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, false)
}
@@ -1180,10 +1183,10 @@ fn main {
use super::*;
use crate::tests::check_assist_by_label;
- fn assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+ fn assist(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, true)
}
- fn in_place_assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+ fn in_place_assist(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, false)
}
@@ -1251,7 +1254,7 @@ fn main() {
#[test]
fn trigger_both_destructure_tuple_assists() {
- fn assist(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+ fn assist(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
destructure_tuple_binding_impl(acc, ctx, true)
}
let text = r#"
diff --git a/crates/ide-assists/src/handlers/desugar_doc_comment.rs b/crates/ide-assists/src/handlers/desugar_doc_comment.rs
index 74bb0ba3f6..e6784a0c3b 100644
--- a/crates/ide-assists/src/handlers/desugar_doc_comment.rs
+++ b/crates/ide-assists/src/handlers/desugar_doc_comment.rs
@@ -24,7 +24,7 @@ use crate::{
// #[doc = r"Multi-line
// comment"]
// ```
-pub(crate) fn desugar_doc_comment(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn desugar_doc_comment(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let comment = ctx.find_token_at_offset::<ast::Comment>()?;
// Only allow doc comments
let placement = comment.kind().doc?;
diff --git a/crates/ide-assists/src/handlers/desugar_try_expr.rs b/crates/ide-assists/src/handlers/desugar_try_expr.rs
index fc894f0fe9..5e1cd7700d 100644
--- a/crates/ide-assists/src/handlers/desugar_try_expr.rs
+++ b/crates/ide-assists/src/handlers/desugar_try_expr.rs
@@ -50,7 +50,7 @@ use crate::assist_context::{AssistContext, Assists};
// };
// }
// ```
-pub(crate) fn desugar_try_expr(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn desugar_try_expr(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let question_tok = ctx.find_token_syntax_at_offset(T![?])?;
let try_expr = question_tok.parent().and_then(ast::TryExpr::cast)?;
diff --git a/crates/ide-assists/src/handlers/expand_glob_import.rs b/crates/ide-assists/src/handlers/expand_glob_import.rs
index 1c8cbf5af5..24ffc6787d 100644
--- a/crates/ide-assists/src/handlers/expand_glob_import.rs
+++ b/crates/ide-assists/src/handlers/expand_glob_import.rs
@@ -41,7 +41,7 @@ use crate::{
//
// fn qux(bar: Bar, baz: Baz) {}
// ```
-pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let star = ctx.find_token_syntax_at_offset(T![*])?;
let use_tree = star.parent().and_then(ast::UseTree::cast)?;
let use_item = star.parent_ancestors().find_map(ast::Use::cast)?;
@@ -99,7 +99,7 @@ pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext<'_>) ->
//
// pub use foo::{Bar, Baz};
// ```
-pub(crate) fn expand_glob_reexport(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn expand_glob_reexport(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let star = ctx.find_token_syntax_at_offset(T![*])?;
let use_tree = star.parent().and_then(ast::UseTree::cast)?;
let use_item = star.parent_ancestors().find_map(ast::Use::cast)?;
@@ -140,7 +140,7 @@ pub(crate) fn expand_glob_reexport(acc: &mut Assists, ctx: &AssistContext<'_>) -
}
fn build_expanded_import(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
builder: &mut SourceChangeBuilder,
use_tree: UseTree,
use_item: Use,
@@ -237,7 +237,7 @@ fn find_parent_and_path(
}
}
-fn def_is_referenced_in(def: Definition, ctx: &AssistContext<'_>) -> bool {
+fn def_is_referenced_in(def: Definition, ctx: &AssistContext<'_, '_>) -> bool {
let search_scope = SearchScope::single_file(ctx.file_id());
def.usages(&ctx.sema).in_scope(&search_scope).at_least_one()
}
@@ -251,7 +251,11 @@ struct Ref {
}
impl Ref {
- fn from_scope_def(ctx: &AssistContext<'_>, name: Name, scope_def: ScopeDef) -> Option<Self> {
+ fn from_scope_def(
+ ctx: &AssistContext<'_, '_>,
+ name: Name,
+ scope_def: ScopeDef,
+ ) -> Option<Self> {
match scope_def {
ScopeDef::ModuleDef(def) => Some(Ref {
visible_name: name,
@@ -267,7 +271,7 @@ impl Ref {
struct Refs(Vec<Ref>);
impl Refs {
- fn used_refs(&self, ctx: &AssistContext<'_>) -> Refs {
+ fn used_refs(&self, ctx: &AssistContext<'_, '_>) -> Refs {
Refs(
self.0
.clone()
@@ -297,7 +301,7 @@ impl Refs {
}
fn find_refs_in_mod(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
expandable: Expandable,
visible_from: Module,
must_be_pub: bool,
@@ -325,8 +329,8 @@ fn find_refs_in_mod(
}
}
-fn is_visible_from(ctx: &AssistContext<'_>, expandable: &Expandable, from: Module) -> bool {
- fn is_mod_visible_from(ctx: &AssistContext<'_>, module: Module, from: Module) -> bool {
+fn is_visible_from(ctx: &AssistContext<'_, '_>, expandable: &Expandable, from: Module) -> bool {
+ fn is_mod_visible_from(ctx: &AssistContext<'_, '_>, module: Module, from: Module) -> bool {
match module.parent(ctx.db()) {
Some(parent) => {
module.visibility(ctx.db()).is_visible_from(ctx.db(), from.into())
@@ -366,7 +370,7 @@ fn is_visible_from(ctx: &AssistContext<'_>, expandable: &Expandable, from: Modul
// use foo::*$0;
// use baz::Baz;
// ↑ ---------------
-fn find_imported_defs(ctx: &AssistContext<'_>, use_item: Use) -> Vec<Definition> {
+fn find_imported_defs(ctx: &AssistContext<'_, '_>, use_item: Use) -> Vec<Definition> {
[Direction::Prev, Direction::Next]
.into_iter()
.flat_map(|dir| {
diff --git a/crates/ide-assists/src/handlers/expand_rest_pattern.rs b/crates/ide-assists/src/handlers/expand_rest_pattern.rs
index dc4976e8c2..4aa11b4e03 100644
--- a/crates/ide-assists/src/handlers/expand_rest_pattern.rs
+++ b/crates/ide-assists/src/handlers/expand_rest_pattern.rs
@@ -29,7 +29,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
fn expand_record_rest_pattern(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
record_pat: ast::RecordPat,
rest_pat: ast::RestPat,
) -> Option<()> {
@@ -92,7 +92,7 @@ fn expand_record_rest_pattern(
// ```
fn expand_tuple_struct_rest_pattern(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
pat: ast::TupleStructPat,
rest_pat: ast::RestPat,
) -> Option<()> {
@@ -171,7 +171,7 @@ fn expand_tuple_struct_rest_pattern(
// ```
fn expand_tuple_rest_pattern(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
pat: ast::TuplePat,
rest_pat: ast::RestPat,
) -> Option<()> {
@@ -233,7 +233,7 @@ fn expand_tuple_rest_pattern(
// ```
fn expand_slice_rest_pattern(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
pat: ast::SlicePat,
rest_pat: ast::RestPat,
) -> Option<()> {
@@ -277,7 +277,7 @@ fn expand_slice_rest_pattern(
)
}
-pub(crate) fn expand_rest_pattern(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn expand_rest_pattern(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let rest_pat = ctx.find_node_at_offset::<ast::RestPat>()?;
let parent = rest_pat.syntax().parent()?;
match_ast! {
@@ -292,7 +292,7 @@ pub(crate) fn expand_rest_pattern(acc: &mut Assists, ctx: &AssistContext<'_>) ->
}
fn gen_unnamed_pat(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
name_gen: &mut NameGenerator,
ty: &hir::Type<'_>,
diff --git a/crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs b/crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs
index c87ded9dc4..178477c746 100644
--- a/crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs
+++ b/crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs
@@ -30,7 +30,7 @@ use syntax::{
pub(crate) fn extract_expressions_from_format_string(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let fmt_string = ctx.find_token_at_offset::<ast::String>()?;
let tt = fmt_string.syntax().parent().and_then(ast::TokenTree::cast)?;
diff --git a/crates/ide-assists/src/handlers/extract_function.rs b/crates/ide-assists/src/handlers/extract_function.rs
index c5fd0201e9..a8aa0d6e5d 100644
--- a/crates/ide-assists/src/handlers/extract_function.rs
+++ b/crates/ide-assists/src/handlers/extract_function.rs
@@ -64,7 +64,7 @@ use crate::{
// let k = m + n;
// }
// ```
-pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let range = ctx.selection_trimmed();
if range.is_empty() {
return None;
@@ -452,7 +452,7 @@ struct OutlivedLocal {
struct LocalUsages(ide_db::search::UsageSearchResult);
impl LocalUsages {
- fn find_local_usages(ctx: &AssistContext<'_>, var: Local) -> Self {
+ fn find_local_usages(ctx: &AssistContext<'_, '_>, var: Local) -> Self {
Self(
Definition::Local(var)
.usages(&ctx.sema)
@@ -467,7 +467,7 @@ impl LocalUsages {
}
impl<'db> Function<'db> {
- fn return_type(&self, ctx: &AssistContext<'db>) -> FunType<'db> {
+ fn return_type(&self, ctx: &AssistContext<'_, 'db>) -> FunType<'db> {
match &self.ret_ty {
RetType::Expr(ty) if ty.is_unit() => FunType::Unit,
RetType::Expr(ty) => FunType::Single(ty.clone()),
@@ -482,7 +482,7 @@ impl<'db> Function<'db> {
}
}
- fn self_param_adt(&self, ctx: &AssistContext<'_>) -> Option<ast::Adt> {
+ fn self_param_adt(&self, ctx: &AssistContext<'_, '_>) -> Option<ast::Adt> {
let self_param = self.self_param.as_ref()?;
let def = ctx.sema.to_def(self_param)?;
let adt = def.ty(ctx.db()).strip_references().as_adt()?;
@@ -510,7 +510,7 @@ impl<'db> Param<'db> {
fn to_arg(
&self,
make: &SyntaxFactory,
- ctx: &AssistContext<'db>,
+ ctx: &AssistContext<'_, 'db>,
edition: Edition,
) -> ast::Expr {
let var = path_expr_from_local(make, ctx, self.var, edition);
@@ -524,7 +524,7 @@ impl<'db> Param<'db> {
fn to_param(
&self,
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
module: hir::Module,
edition: Edition,
) -> ast::Param {
@@ -551,7 +551,7 @@ impl<'db> Param<'db> {
impl<'db> TryKind<'db> {
fn of_ty(
ty: hir::Type<'db>,
- ctx: &AssistContext<'db>,
+ ctx: &AssistContext<'_, 'db>,
edition: Edition,
) -> Option<TryKind<'db>> {
if ty.is_unknown() {
@@ -587,7 +587,7 @@ impl<'db> FlowKind<'db> {
}
}
- fn expr_ty(&self, ctx: &AssistContext<'db>) -> Option<hir::Type<'db>> {
+ fn expr_ty(&self, ctx: &AssistContext<'_, 'db>) -> Option<hir::Type<'db>> {
match self {
FlowKind::Return(Some(expr)) | FlowKind::Break(_, Some(expr)) => {
ctx.sema.type_of_expr(expr).map(TypeInfo::adjusted)
@@ -957,7 +957,7 @@ impl FunctionBody {
))
}
- fn return_ty<'db>(&self, ctx: &AssistContext<'db>) -> Option<RetType<'db>> {
+ fn return_ty<'db>(&self, ctx: &AssistContext<'_, 'db>) -> Option<RetType<'db>> {
match self.tail_expr() {
Some(expr) => ctx.sema.type_of_expr(&expr).map(TypeInfo::original).map(RetType::Expr),
None => Some(RetType::Stmt),
@@ -967,7 +967,7 @@ impl FunctionBody {
/// Local variables defined inside `body` that are accessed outside of it
fn ret_values<'a>(
&self,
- ctx: &'a AssistContext<'_>,
+ ctx: &'a AssistContext<'_, '_>,
parent: &SyntaxNode,
) -> impl Iterator<Item = OutlivedLocal> + 'a {
let parent = parent.clone();
@@ -980,7 +980,7 @@ impl FunctionBody {
/// Analyses the function body for external control flow.
fn external_control_flow<'db>(
&self,
- ctx: &AssistContext<'db>,
+ ctx: &AssistContext<'_, 'db>,
container_info: &ContainerInfo<'db>,
) -> Option<ControlFlow<'db>> {
let mut ret_expr = None;
@@ -1070,7 +1070,7 @@ impl FunctionBody {
/// Computes additional info that affects param type and mutability
fn extracted_function_params<'db>(
&self,
- ctx: &AssistContext<'db>,
+ ctx: &AssistContext<'_, 'db>,
container_info: &ContainerInfo<'db>,
locals: FxIndexSet<Local>,
) -> Vec<Param<'db>> {
@@ -1167,7 +1167,7 @@ fn generic_parents(parent: &SyntaxNode) -> Vec<GenericParent> {
/// checks if relevant var is used with `&mut` access inside body
fn has_exclusive_usages(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
usages: &LocalUsages,
body: &FunctionBody,
) -> bool {
@@ -1181,7 +1181,7 @@ fn has_exclusive_usages(
fn reference_is_exclusive(
reference: &FileReference,
node: &dyn HasTokenAtOffset,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> bool {
// FIXME: this quite an incorrect way to go about doing this :-)
// `FileReference` is an IDE-type --- it encapsulates data communicated to the human,
@@ -1204,7 +1204,7 @@ fn reference_is_exclusive(
}
/// checks if this expr requires `&mut` access, recurses on field access
-fn expr_require_exclusive_access(ctx: &AssistContext<'_>, expr: &ast::Expr) -> Option<bool> {
+fn expr_require_exclusive_access(ctx: &AssistContext<'_, '_>, expr: &ast::Expr) -> Option<bool> {
if let ast::Expr::MacroExpr(_) = expr {
// FIXME: expand macro and check output for mutable usages of the variable?
return None;
@@ -1324,7 +1324,7 @@ fn locals_defined_in_body(
/// Returns usage details if local variable is used after(outside of) body
fn local_outlives_body(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
body_range: TextRange,
local: Local,
parent: &SyntaxNode,
@@ -1349,7 +1349,7 @@ fn local_outlives_body(
/// checks if the relevant local was defined before(outside of) body
fn is_defined_outside_of_body(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
body: &FunctionBody,
src: &LocalSource,
) -> bool {
@@ -1417,10 +1417,10 @@ fn impl_type_name(impl_node: &ast::Impl) -> Option<String> {
Some(impl_node.self_ty()?.to_string())
}
-fn make_call(
+fn make_call<'db>(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
- fun: &Function<'_>,
+ ctx: &AssistContext<'_, 'db>,
+ fun: &Function<'db>,
indent: IndentLevel,
) -> SyntaxNode {
let ret_ty = fun.return_type(ctx);
@@ -1598,7 +1598,7 @@ impl<'db> FlowHandler<'db> {
fn path_expr_from_local(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
var: Local,
edition: Edition,
) -> ast::Expr {
@@ -1606,10 +1606,10 @@ fn path_expr_from_local(
make.expr_path(make.ident_path(&name))
}
-fn format_function(
- ctx: &AssistContext<'_>,
+fn format_function<'db>(
+ ctx: &AssistContext<'_, 'db>,
module: hir::Module,
- fun: &Function<'_>,
+ fun: &Function<'db>,
old_indent: IndentLevel,
make: &SyntaxFactory,
) -> ast::Fn {
@@ -1635,10 +1635,10 @@ fn format_function(
)
}
-fn make_generic_params_and_where_clause(
- ctx: &AssistContext<'_>,
+fn make_generic_params_and_where_clause<'db>(
+ ctx: &AssistContext<'_, 'db>,
make: &SyntaxFactory,
- fun: &Function<'_>,
+ fun: &Function<'db>,
) -> (Option<ast::GenericParamList>, Option<ast::WhereClause>) {
let used_type_params = fun.type_params(ctx);
@@ -1648,10 +1648,10 @@ fn make_generic_params_and_where_clause(
(generic_param_list, where_clause)
}
-fn make_generic_param_list(
- ctx: &AssistContext<'_>,
+fn make_generic_param_list<'db>(
+ ctx: &AssistContext<'_, 'db>,
make: &SyntaxFactory,
- fun: &Function<'_>,
+ fun: &Function<'db>,
used_type_params: &[TypeParam],
) -> Option<ast::GenericParamList> {
let mut generic_params = fun
@@ -1673,7 +1673,7 @@ fn make_generic_param_list(
}
fn param_is_required(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
param: &ast::GenericParam,
used_type_params: &[TypeParam],
) -> bool {
@@ -1687,7 +1687,7 @@ fn param_is_required(
}
fn make_where_clause(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
fun: &Function<'_>,
used_type_params: &[TypeParam],
@@ -1707,7 +1707,7 @@ fn make_where_clause(
}
fn pred_is_required(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
pred: &ast::WherePred,
used_type_params: &[TypeParam],
) -> bool {
@@ -1717,7 +1717,7 @@ fn pred_is_required(
}
}
-fn resolved_type_param(ctx: &AssistContext<'_>, pred: &ast::WherePred) -> Option<TypeParam> {
+fn resolved_type_param(ctx: &AssistContext<'_, '_>, pred: &ast::WherePred) -> Option<TypeParam> {
let path = match pred.ty()? {
ast::Type::PathType(path_type) => path_type.path(),
_ => None,
@@ -1731,7 +1731,7 @@ fn resolved_type_param(ctx: &AssistContext<'_>, pred: &ast::WherePred) -> Option
impl<'db> Function<'db> {
/// Collect all the `TypeParam`s used in the `body` and `params`.
- fn type_params(&self, ctx: &AssistContext<'db>) -> Vec<TypeParam> {
+ fn type_params(&self, ctx: &AssistContext<'_, 'db>) -> Vec<TypeParam> {
let type_params_in_descendant_paths =
self.body.descendant_paths().filter_map(|it| match ctx.sema.resolve_path(&it) {
Some(PathResolution::TypeParam(type_param)) => Some(type_param),
@@ -1744,7 +1744,7 @@ impl<'db> Function<'db> {
fn make_param_list(
&self,
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
module: hir::Module,
edition: Edition,
) -> ast::ParamList {
@@ -1775,7 +1775,7 @@ impl<'db> Function<'db> {
fn make_ret_ty(
&self,
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, 'db>,
module: hir::Module,
) -> Option<ast::RetType> {
let fun_ty = self.return_type(ctx);
@@ -1825,7 +1825,7 @@ impl<'db> FunType<'db> {
fn make_ty(
&self,
make: &SyntaxFactory,
- ctx: &AssistContext<'db>,
+ ctx: &AssistContext<'_, 'db>,
module: hir::Module,
) -> ast::Type {
match self {
@@ -1849,11 +1849,11 @@ impl<'db> FunType<'db> {
}
}
-fn make_body(
+fn make_body<'db>(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, 'db>,
old_indent: IndentLevel,
- fun: &Function<'_>,
+ fun: &Function<'db>,
) -> ast::BlockExpr {
let ret_ty = fun.return_type(ctx);
let handler = FlowHandler::from_ret_ty(fun, &ret_ty);
@@ -2045,7 +2045,7 @@ fn with_tail_expr(
make.hacky_block_expr(elements, Some(tail_expr))
}
-fn format_type(ty: &hir::Type<'_>, ctx: &AssistContext<'_>, module: hir::Module) -> String {
+fn format_type(ty: &hir::Type<'_>, ctx: &AssistContext<'_, '_>, module: hir::Module) -> String {
ty.display_source_code(ctx.db(), module.into(), true).ok().unwrap_or_else(|| "_".to_owned())
}
@@ -2057,7 +2057,7 @@ fn is_inherit_attr(attr: &ast::Attr) -> bool {
fn make_ty(
make: &SyntaxFactory,
ty: &hir::Type<'_>,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
module: hir::Module,
) -> ast::Type {
let ty_str = format_type(ty, ctx, module);
@@ -2065,7 +2065,7 @@ fn make_ty(
}
fn rewrite_body_segment(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
to_this_param: Option<ast::SelfParam>,
params: &[Param<'_>],
handler: &FlowHandler<'_>,
@@ -2086,7 +2086,7 @@ fn fix_param_usages(
editor: &SyntaxEditor,
source_syntax: &SyntaxNode,
syntax: &SyntaxNode,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
to_this_param: Option<Local>,
params: &[Param<'_>],
) {
diff --git a/crates/ide-assists/src/handlers/extract_module.rs b/crates/ide-assists/src/handlers/extract_module.rs
index dcbeaefa21..9e06a17337 100644
--- a/crates/ide-assists/src/handlers/extract_module.rs
+++ b/crates/ide-assists/src/handlers/extract_module.rs
@@ -52,7 +52,7 @@ use super::remove_unused_param::range_to_remove;
// name + 2
// }
// ```
-pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
if ctx.has_empty_selection() {
return None;
}
@@ -267,7 +267,7 @@ fn extract_child_target(
impl Module {
fn get_usages_and_record_fields(
&self,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
replace_range: TextRange,
) -> (FxHashMap<FileId, Vec<(TextRange, String)>>, Vec<SyntaxNode>, FxHashMap<TextSize, ast::Use>)
{
@@ -356,7 +356,7 @@ impl Module {
fn expand_and_group_usages_file_wise(
&self,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
replace_range: TextRange,
node_def: Definition,
refs_in_files: &mut FxHashMap<FileId, Vec<(TextRange, String)>>,
@@ -449,7 +449,7 @@ impl Module {
fn resolve_imports(
&mut self,
module: Option<ast::Module>,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Vec<TextRange> {
let mut imports_to_remove = vec![];
let mut node_set = FxHashSet::default();
@@ -491,7 +491,7 @@ impl Module {
def: Definition,
use_node: &SyntaxNode,
curr_parent_module: &Option<ast::Module>,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<TextRange> {
//We only need to find in the current file
let selection_range = ctx.selection_trimmed();
@@ -689,7 +689,7 @@ fn check_intersection_and_push(
fn check_def_in_mod_and_out_sel(
def: Definition,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
curr_parent_module: &Option<ast::Module>,
selection_range: TextRange,
curr_file_id: FileId,
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 9a884bc1da..37867d656c 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
@@ -40,7 +40,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn extract_struct_from_enum_variant(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let field_list = extract_field_list_if_applicable(&variant)?;
@@ -416,7 +416,7 @@ fn apply_references(
}
fn process_references(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
visited_modules: &mut FxHashSet<Module>,
enum_module_def: &ModuleDef,
variant_hir_name: &Name,
diff --git a/crates/ide-assists/src/handlers/extract_type_alias.rs b/crates/ide-assists/src/handlers/extract_type_alias.rs
index eda35eba45..a654b681d1 100644
--- a/crates/ide-assists/src/handlers/extract_type_alias.rs
+++ b/crates/ide-assists/src/handlers/extract_type_alias.rs
@@ -25,7 +25,7 @@ use crate::{AssistContext, AssistId, Assists};
// field: Type,
// }
// ```
-pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
if ctx.has_empty_selection() {
return None;
}
diff --git a/crates/ide-assists/src/handlers/extract_variable.rs b/crates/ide-assists/src/handlers/extract_variable.rs
index c5c57c76b4..d4a0490f16 100644
--- a/crates/ide-assists/src/handlers/extract_variable.rs
+++ b/crates/ide-assists/src/handlers/extract_variable.rs
@@ -65,7 +65,7 @@ use crate::{AssistContext, AssistId, Assists, utils::is_body_const};
// VAR_NAME * 4;
// }
// ```
-pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let node = if ctx.has_empty_selection() {
if let Some(t) = ctx.token_at_offset().find(|it| it.kind() == T![;]) {
t.parent().and_then(ast::ExprStmt::cast)?.syntax().clone()
@@ -332,7 +332,7 @@ fn peel_parens(mut expr: ast::Expr) -> ast::Expr {
/// Check whether the node is a valid expression which can be extracted to a variable.
/// In general that's true for any expression, but in some cases that would produce invalid code.
-fn valid_target_expr(ctx: &AssistContext<'_>) -> impl Fn(SyntaxNode) -> Option<ast::Expr> {
+fn valid_target_expr(ctx: &AssistContext<'_, '_>) -> impl Fn(SyntaxNode) -> Option<ast::Expr> {
let selection = ctx.selection_trimmed();
move |node| match node.kind() {
SyntaxKind::LOOP_EXPR | SyntaxKind::LET_EXPR => None,
@@ -383,7 +383,7 @@ impl ExtractionKind {
fn get_name_and_expr(
&self,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
to_extract: &ast::Expr,
) -> (String, SyntaxNode) {
// We only do this sort of extraction for fields because they should have lowercase names
@@ -416,7 +416,7 @@ impl ExtractionKind {
}
}
-fn get_literal_name(ctx: &AssistContext<'_>, expr: &ast::Expr) -> Option<String> {
+fn get_literal_name(ctx: &AssistContext<'_, '_>, expr: &ast::Expr) -> Option<String> {
let ast::Expr::Literal(literal) = expr else {
return None;
};
@@ -512,7 +512,7 @@ impl Anchor {
}
}
-fn like_const_value(ctx: &AssistContext<'_>, path_resolution: hir::PathResolution) -> bool {
+fn like_const_value(ctx: &AssistContext<'_, '_>, path_resolution: hir::PathResolution) -> bool {
let db = ctx.db();
let adt_like_const_value = |adt: Option<hir::Adt>| matches!(adt, Some(hir::Adt::Struct(s)) if s.kind(db) == hir::StructKind::Unit);
match path_resolution {
diff --git a/crates/ide-assists/src/handlers/fix_visibility.rs b/crates/ide-assists/src/handlers/fix_visibility.rs
index d8714dd49c..d0f5c7c500 100644
--- a/crates/ide-assists/src/handlers/fix_visibility.rs
+++ b/crates/ide-assists/src/handlers/fix_visibility.rs
@@ -30,11 +30,11 @@ use crate::{AssistContext, AssistId, Assists};
// m::frobnicate();
// }
// ```
-pub(crate) fn fix_visibility(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn fix_visibility(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
add_vis_to_referenced_module_def(acc, ctx)
}
-fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let path: ast::Path = ctx.find_node_at_offset()?;
let qualifier = path.qualifier()?;
let name_ref = path.segment()?.name_ref()?;
diff --git a/crates/ide-assists/src/handlers/flip_binexpr.rs b/crates/ide-assists/src/handlers/flip_binexpr.rs
index 17911150f5..d47f5c83cd 100644
--- a/crates/ide-assists/src/handlers/flip_binexpr.rs
+++ b/crates/ide-assists/src/handlers/flip_binexpr.rs
@@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, Assists};
// let _ = 2 + 90;
// }
// ```
-pub(crate) fn flip_binexpr(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn flip_binexpr(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let expr = ctx.find_node_at_offset::<BinExpr>()?;
let lhs = expr.lhs()?;
let rhs = expr.rhs()?;
@@ -114,7 +114,7 @@ impl From<ast::BinaryOp> for FlipAction {
// let _ = ..90;
// }
// ```
-pub(crate) fn flip_range_expr(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn flip_range_expr(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let range_expr = ctx.find_node_at_offset::<ast::RangeExpr>()?;
let op = range_expr.op_token()?;
let start = range_expr.start();
diff --git a/crates/ide-assists/src/handlers/flip_comma.rs b/crates/ide-assists/src/handlers/flip_comma.rs
index 65dc36cdca..00d659adc1 100644
--- a/crates/ide-assists/src/handlers/flip_comma.rs
+++ b/crates/ide-assists/src/handlers/flip_comma.rs
@@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, Assists};
// ((3, 4), (1, 2));
// }
// ```
-pub(crate) fn flip_comma(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn flip_comma(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let comma = ctx.find_token_syntax_at_offset(T![,])?;
let prev = non_trivia_sibling(comma.clone().into(), Direction::Prev)?;
let next = non_trivia_sibling(comma.clone().into(), Direction::Next)?;
diff --git a/crates/ide-assists/src/handlers/flip_or_pattern.rs b/crates/ide-assists/src/handlers/flip_or_pattern.rs
index bd56331f41..c60c6a2a98 100644
--- a/crates/ide-assists/src/handlers/flip_or_pattern.rs
+++ b/crates/ide-assists/src/handlers/flip_or_pattern.rs
@@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, Assists};
// let (b | a) = 1;
// }
// ```
-pub(crate) fn flip_or_pattern(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn flip_or_pattern(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
// Only flip on the `|` token
let pipe = ctx.find_token_syntax_at_offset(T![|])?;
diff --git a/crates/ide-assists/src/handlers/flip_trait_bound.rs b/crates/ide-assists/src/handlers/flip_trait_bound.rs
index dfd280efa6..77d5c042c9 100644
--- a/crates/ide-assists/src/handlers/flip_trait_bound.rs
+++ b/crates/ide-assists/src/handlers/flip_trait_bound.rs
@@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
// fn foo<T: Copy + Clone>() { }
// ```
-pub(crate) fn flip_trait_bound(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn flip_trait_bound(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
// Only flip on the `+` token
let plus = ctx.find_token_syntax_at_offset(T![+])?;
diff --git a/crates/ide-assists/src/handlers/generate_blanket_trait_impl.rs b/crates/ide-assists/src/handlers/generate_blanket_trait_impl.rs
index 0bb90f187c..e99dd81066 100644
--- a/crates/ide-assists/src/handlers/generate_blanket_trait_impl.rs
+++ b/crates/ide-assists/src/handlers/generate_blanket_trait_impl.rs
@@ -58,7 +58,7 @@ use syntax::{
// ```
pub(crate) fn generate_blanket_trait_impl(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
let traitd = ast::Trait::cast(name.syntax().parent()?)?;
diff --git a/crates/ide-assists/src/handlers/generate_constant.rs b/crates/ide-assists/src/handlers/generate_constant.rs
index fce0ce3994..6c5042b14f 100644
--- a/crates/ide-assists/src/handlers/generate_constant.rs
+++ b/crates/ide-assists/src/handlers/generate_constant.rs
@@ -31,7 +31,7 @@ use syntax::{
// }
// ```
-pub(crate) fn generate_constant(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_constant(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let constant_token = ctx.find_node_at_offset::<ast::NameRef>()?;
if constant_token.to_string().chars().any(|it| !(it.is_uppercase() || it == '_')) {
cov_mark::hit!(not_constant_name);
@@ -113,7 +113,7 @@ fn get_text_for_generate_constant(
}
fn target_data_for_generate_constant(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
current_module: Module,
constant_module: Module,
) -> Option<(TextSize, IndentLevel, Option<FileId>, String)> {
diff --git a/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs b/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs
index b4a17c376a..4470791f4d 100644
--- a/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs
+++ b/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs
@@ -30,7 +30,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn generate_default_from_enum_variant(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let variant_name = variant.name()?;
diff --git a/crates/ide-assists/src/handlers/generate_default_from_new.rs b/crates/ide-assists/src/handlers/generate_default_from_new.rs
index 739b631736..34ab3c4304 100644
--- a/crates/ide-assists/src/handlers/generate_default_from_new.rs
+++ b/crates/ide-assists/src/handlers/generate_default_from_new.rs
@@ -44,7 +44,10 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_default_from_new(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let fn_node = ctx.find_node_at_offset::<ast::Fn>()?;
let fn_name = fn_node.name()?;
@@ -154,7 +157,7 @@ fn generate_default_impl(make: &SyntaxFactory, impl_: &ast::Impl, self_ty: ast::
)
}
-fn is_default_implemented(ctx: &AssistContext<'_>, impl_: &Impl) -> bool {
+fn is_default_implemented(ctx: &AssistContext<'_, '_>, impl_: &Impl) -> bool {
let db = ctx.sema.db;
let impl_ = ctx.sema.to_def(impl_);
let impl_def = match impl_ {
diff --git a/crates/ide-assists/src/handlers/generate_delegate_methods.rs b/crates/ide-assists/src/handlers/generate_delegate_methods.rs
index 9486aa6f01..a209e5fc29 100644
--- a/crates/ide-assists/src/handlers/generate_delegate_methods.rs
+++ b/crates/ide-assists/src/handlers/generate_delegate_methods.rs
@@ -48,7 +48,10 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_delegate_methods(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
if !ctx.config.code_action_grouping {
return None;
}
diff --git a/crates/ide-assists/src/handlers/generate_delegate_trait.rs b/crates/ide-assists/src/handlers/generate_delegate_trait.rs
index 6639f10c1f..ed15998219 100644
--- a/crates/ide-assists/src/handlers/generate_delegate_trait.rs
+++ b/crates/ide-assists/src/handlers/generate_delegate_trait.rs
@@ -86,7 +86,10 @@ use syntax::{
// }
// }
// ```
-pub(crate) fn generate_delegate_trait(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_delegate_trait(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
if !ctx.config.code_action_grouping {
return None;
}
@@ -118,7 +121,7 @@ struct Field {
impl Field {
pub(crate) fn new(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
f: Either<ast::RecordField, (ast::TupleField, ast::TupleFieldList)>,
) -> Option<Field> {
let db = ctx.sema.db;
@@ -202,7 +205,7 @@ impl Struct {
Some(Struct { name, strukt: s })
}
- pub(crate) fn delegate(&self, field: Field, acc: &mut Assists, ctx: &AssistContext<'_>) {
+ pub(crate) fn delegate(&self, field: Field, acc: &mut Assists, ctx: &AssistContext<'_, '_>) {
let db = ctx.db();
for (index, delegee) in field.impls.iter().enumerate() {
@@ -249,7 +252,7 @@ impl Struct {
}
fn generate_impl(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
strukt: &Struct,
field_ty: &ast::Type,
field_name: &str,
@@ -412,7 +415,7 @@ fn generate_impl(
}
fn transform_impl<N: ast::AstNode>(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
strukt: &ast::Struct,
old_impl: &ast::Impl,
args: &Option<GenericArgList>,
@@ -638,7 +641,7 @@ fn generate_args_for_impl(
}
fn rename_strukt_args<N>(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
strukt: &ast::Struct,
item: &N,
args: &GenericArgList,
@@ -654,7 +657,7 @@ where
N::cast(transform.apply(item.syntax()))
}
-fn has_self_type(trait_: hir::Trait, ctx: &AssistContext<'_>) -> bool {
+fn has_self_type(trait_: hir::Trait, ctx: &AssistContext<'_, '_>) -> bool {
ctx.sema
.source(trait_)
.and_then(|src| {
diff --git a/crates/ide-assists/src/handlers/generate_deref.rs b/crates/ide-assists/src/handlers/generate_deref.rs
index a5bdf80ac7..9d1b257af4 100644
--- a/crates/ide-assists/src/handlers/generate_deref.rs
+++ b/crates/ide-assists/src/handlers/generate_deref.rs
@@ -38,11 +38,11 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_deref(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
generate_record_deref(acc, ctx).or_else(|| generate_tuple_deref(acc, ctx))
}
-fn generate_record_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+fn generate_record_deref(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field = ctx.find_node_at_offset::<ast::RecordField>()?;
@@ -84,7 +84,7 @@ fn generate_record_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<(
)
}
-fn generate_tuple_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+fn generate_tuple_deref(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field = ctx.find_node_at_offset::<ast::TupleField>()?;
let field_list = ctx.find_node_at_offset::<ast::TupleFieldList>()?;
diff --git a/crates/ide-assists/src/handlers/generate_derive.rs b/crates/ide-assists/src/handlers/generate_derive.rs
index 0129b1db39..f293e956bc 100644
--- a/crates/ide-assists/src/handlers/generate_derive.rs
+++ b/crates/ide-assists/src/handlers/generate_derive.rs
@@ -25,7 +25,7 @@ use crate::{AssistContext, AssistId, Assists};
// y: u32,
// }
// ```
-pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let cap = ctx.config.snippet_cap?;
let nominal = ctx.find_node_at_offset::<ast::Adt>()?;
let target = nominal.syntax().text_range();
diff --git a/crates/ide-assists/src/handlers/generate_documentation_template.rs b/crates/ide-assists/src/handlers/generate_documentation_template.rs
index 77232dfebd..89adda9386 100644
--- a/crates/ide-assists/src/handlers/generate_documentation_template.rs
+++ b/crates/ide-assists/src/handlers/generate_documentation_template.rs
@@ -43,7 +43,7 @@ use crate::assist_context::{AssistContext, Assists};
// ```
pub(crate) fn generate_documentation_template(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
let ast_func = name.syntax().parent().and_then(ast::Fn::cast)?;
@@ -95,7 +95,7 @@ pub(crate) fn generate_documentation_template(
// /// ```
// pub fn add(a: i32, b: i32) -> i32 { a + b }
// ```
-pub(crate) fn generate_doc_example(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_doc_example(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let tok: ast::Comment = ctx.find_token_at_offset()?;
let node = tok.syntax().parent()?;
let last_doc_token =
@@ -127,7 +127,7 @@ pub(crate) fn generate_doc_example(acc: &mut Assists, ctx: &AssistContext<'_>) -
)
}
-fn make_example_for_fn(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<String> {
+fn make_example_for_fn(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>) -> Option<String> {
if !is_public(ast_func, ctx)? {
// Doctests for private items can't actually name the item, so they're pretty useless.
return None;
@@ -182,7 +182,7 @@ fn make_example_for_fn(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<St
Some(example)
}
-fn introduction_builder(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<String> {
+fn introduction_builder(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>) -> Option<String> {
let hir_func = ctx.sema.to_def(ast_func)?;
let container = hir_func.as_assoc_item(ctx.db())?.container(ctx.db());
if let hir::AssocItemContainer::Impl(imp) = container {
@@ -281,7 +281,7 @@ fn safety_builder(ast_func: &ast::Fn) -> Option<Vec<String>> {
}
/// Checks if the function is public / exported
-fn is_public(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<bool> {
+fn is_public(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>) -> Option<bool> {
let hir_func = ctx.sema.to_def(ast_func)?;
Some(
hir_func.visibility(ctx.db()) == Visibility::Public
@@ -290,7 +290,7 @@ fn is_public(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<bool> {
}
/// Checks that all parent modules of the function are public / exported
-fn all_parent_mods_public(hir_func: &hir::Function, ctx: &AssistContext<'_>) -> bool {
+fn all_parent_mods_public(hir_func: &hir::Function, ctx: &AssistContext<'_, '_>) -> bool {
let mut module = hir_func.module(ctx.db());
loop {
if let Some(parent) = module.parent(ctx.db()) {
@@ -305,7 +305,7 @@ fn all_parent_mods_public(hir_func: &hir::Function, ctx: &AssistContext<'_>) ->
}
/// Returns the name of the current crate
-fn crate_name(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> Option<String> {
+fn crate_name(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>) -> Option<String> {
let krate = ctx.sema.scope(ast_func.syntax())?.krate();
Some(krate.display_name(ctx.db())?.to_string())
}
@@ -378,7 +378,7 @@ fn self_partial_type(ast_func: &ast::Fn) -> Option<String> {
}
/// Helper function to determine if the function is in a trait implementation
-fn is_in_trait_impl(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> bool {
+fn is_in_trait_impl(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>) -> bool {
ctx.sema
.to_def(ast_func)
.and_then(|hir_func| hir_func.as_assoc_item(ctx.db()))
@@ -387,7 +387,7 @@ fn is_in_trait_impl(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> bool {
}
/// Helper function to determine if the function definition is in a trait definition
-fn is_in_trait_def(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> bool {
+fn is_in_trait_def(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>) -> bool {
ctx.sema
.to_def(ast_func)
.and_then(|hir_func| hir_func.as_assoc_item(ctx.db()))
@@ -490,7 +490,7 @@ fn string_vec_from(string_array: &[&str]) -> Vec<String> {
}
/// Helper function to build the path of the module in the which is the node
-fn build_path(ast_func: &ast::Fn, ctx: &AssistContext<'_>, edition: Edition) -> Option<String> {
+fn build_path(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>, edition: Edition) -> Option<String> {
let crate_name = crate_name(ast_func, ctx)?;
let leaf = self_partial_type(ast_func)
.or_else(|| ast_func.name().map(|n| n.to_string()))
@@ -508,7 +508,7 @@ fn return_type(ast_func: &ast::Fn) -> Option<ast::Type> {
}
/// Helper function to determine if the function returns some data
-fn returns_a_value(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> bool {
+fn returns_a_value(ast_func: &ast::Fn, ctx: &AssistContext<'_, '_>) -> bool {
ctx.sema
.to_def(ast_func)
.map(|hir_func| hir_func.ret_type(ctx.db()))
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 e2783811f7..867eaf4c29 100644
--- a/crates/ide-assists/src/handlers/generate_enum_is_method.rs
+++ b/crates/ide-assists/src/handlers/generate_enum_is_method.rs
@@ -40,7 +40,10 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_enum_is_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_enum_is_method(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let parent_enum = ast::Adt::Enum(variant.parent_enum());
let variants = variant
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 9a97ad1e8f..4cdc801ec1 100644
--- a/crates/ide-assists/src/handlers/generate_enum_projection_method.rs
+++ b/crates/ide-assists/src/handlers/generate_enum_projection_method.rs
@@ -40,7 +40,7 @@ use crate::{
// ```
pub(crate) fn generate_enum_try_into_method(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
generate_enum_projection_method(
acc,
@@ -85,7 +85,10 @@ pub(crate) fn generate_enum_try_into_method(
// }
// }
// ```
-pub(crate) fn generate_enum_as_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_enum_as_method(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
generate_enum_projection_method(
acc,
ctx,
@@ -113,7 +116,7 @@ struct ProjectionProps {
fn generate_enum_projection_method(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
assist_id: &'static str,
assist_description: &str,
props: ProjectionProps,
diff --git a/crates/ide-assists/src/handlers/generate_enum_variant.rs b/crates/ide-assists/src/handlers/generate_enum_variant.rs
index 9b4d44d8b5..fb43e3eaa3 100644
--- a/crates/ide-assists/src/handlers/generate_enum_variant.rs
+++ b/crates/ide-assists/src/handlers/generate_enum_variant.rs
@@ -32,7 +32,7 @@ use crate::assist_context::{AssistContext, Assists};
// let country = Countries::Lesotho;
// }
// ```
-pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let path: ast::Path = ctx.find_node_at_offset()?;
let parent = PathParent::new(&path)?;
@@ -104,7 +104,7 @@ impl PathParent {
fn make_field_list(
&self,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
) -> Option<ast::FieldList> {
let scope = ctx.sema.scope(self.syntax())?;
@@ -156,7 +156,7 @@ fn name_from_field_shorthand(field: &ast::RecordExprField) -> Option<String> {
}
fn expr_ty(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
arg: ast::Expr,
scope: &hir::SemanticsScope<'_>,
diff --git a/crates/ide-assists/src/handlers/generate_fn_type_alias.rs b/crates/ide-assists/src/handlers/generate_fn_type_alias.rs
index 55e5083811..a9f5ab6976 100644
--- a/crates/ide-assists/src/handlers/generate_fn_type_alias.rs
+++ b/crates/ide-assists/src/handlers/generate_fn_type_alias.rs
@@ -36,7 +36,7 @@ use crate::{AssistContext, Assists};
// unsafe fn foo(n: i32) -> i32 { 42i32 }
// ```
-pub(crate) fn generate_fn_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_fn_type_alias(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
let func = &name.syntax().parent()?;
let func_node = ast::Fn::cast(func.clone())?;
diff --git a/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs
index 76246c3e8e..52df6182ac 100644
--- a/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs
@@ -27,7 +27,7 @@ use crate::{
// ```
pub(crate) fn generate_from_impl_for_enum(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let adt = ast::Adt::Enum(variant.parent_enum());
@@ -107,7 +107,10 @@ struct VariantInfo {
ty: ast::Type,
}
-fn selected_variants(ctx: &AssistContext<'_>, variant: &ast::Variant) -> Option<Vec<VariantInfo>> {
+fn selected_variants(
+ ctx: &AssistContext<'_, '_>,
+ variant: &ast::Variant,
+) -> Option<Vec<VariantInfo>> {
variant
.parent_enum()
.variant_list()?
diff --git a/crates/ide-assists/src/handlers/generate_function.rs b/crates/ide-assists/src/handlers/generate_function.rs
index baf795754f..14dd4061e7 100644
--- a/crates/ide-assists/src/handlers/generate_function.rs
+++ b/crates/ide-assists/src/handlers/generate_function.rs
@@ -53,11 +53,11 @@ use crate::{
// }
//
// ```
-pub(crate) fn generate_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_function(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
gen_fn(acc, ctx).or_else(|| gen_method(acc, ctx))
}
-fn gen_fn(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+fn gen_fn(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let path_expr: ast::PathExpr = ctx.find_node_at_offset()?;
let call = path_expr.syntax().parent().and_then(ast::CallExpr::cast)?;
let path = path_expr.path()?;
@@ -104,7 +104,7 @@ impl TargetInfo {
}
fn fn_target_info(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
path: ast::Path,
call: &CallExpr,
fn_name: &str,
@@ -134,7 +134,7 @@ fn fn_target_info(
}
}
-fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let call: ast::MethodCallExpr = ctx.find_node_at_offset()?;
if ctx.sema.resolve_method_call(&call).is_some() {
return None;
@@ -182,7 +182,7 @@ fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
fn add_func_to_accumulator(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
text_range: TextRange,
function_builder: FunctionBuilder,
file: FileId,
@@ -204,7 +204,7 @@ fn add_func_to_accumulator(
}
fn get_adt_source(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
adt: &hir::Adt,
fn_name: &str,
) -> Option<(Option<ast::Impl>, FileId)> {
@@ -236,7 +236,7 @@ impl FunctionBuilder {
/// The function is generated in `target_module` or next to `call`
fn from_call(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
call: &ast::CallExpr,
fn_name: &str,
target_module: Option<Module>,
@@ -307,7 +307,7 @@ impl FunctionBuilder {
fn from_method_call(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
call: &ast::MethodCallExpr,
name: &ast::NameRef,
receiver_ty: Type<'_>,
@@ -399,7 +399,7 @@ impl FunctionBuilder {
/// user can change the `todo!` function body.
fn make_return_type(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
expr: &ast::Expr,
target_module: Module,
necessary_generic_params: &mut FxHashSet<hir::GenericParam>,
@@ -424,7 +424,7 @@ fn make_return_type(
fn make_fn_body_as_new_function(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
fn_name: &str,
adt_info: &Option<AdtInfo>,
edition: Edition,
@@ -475,7 +475,7 @@ fn make_fn_body_as_new_function(
}
fn get_fn_target_info(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
target_module: Option<Module>,
call: CallExpr,
) -> Option<TargetInfo> {
@@ -484,7 +484,7 @@ fn get_fn_target_info(
}
fn get_fn_target(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
target_module: Option<Module>,
call: CallExpr,
) -> Option<(GeneratedFunctionTarget, FileId)> {
@@ -501,7 +501,7 @@ fn get_fn_target(
}
fn get_method_target(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
impl_: &Option<ast::Impl>,
adt: &Adt,
) -> Option<GeneratedFunctionTarget> {
@@ -513,7 +513,7 @@ fn get_method_target(
}
fn assoc_fn_target_info(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
call: &CallExpr,
adt: hir::Adt,
fn_name: &str,
@@ -558,7 +558,7 @@ impl GeneratedFunctionTarget {
&self,
edit: &mut SourceChangeBuilder,
file: FileId,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
function_builder: &FunctionBuilder,
adt: Adt,
cap: Option<SnippetCap>,
@@ -719,7 +719,7 @@ impl GeneratedFunctionTarget {
fn insert_rendered_impl(
editor: &SyntaxEditor,
edit: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
function_builder: &FunctionBuilder,
adt: Adt,
position: Position,
@@ -801,7 +801,7 @@ impl AdtInfo {
/// Computes parameter list for the generated function.
fn fn_args(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
target_module: Module,
call: ast::CallableExpr,
necessary_generic_params: &mut FxHashSet<hir::GenericParam>,
@@ -837,7 +837,7 @@ fn fn_args(
/// use the Rename functionality.
fn fn_generic_params(
make: &SyntaxFactory,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
necessary_params: FxHashSet<hir::GenericParam>,
target: &GeneratedFunctionTarget,
) -> Option<(Option<ast::GenericParamList>, Option<ast::WhereClause>)> {
@@ -901,7 +901,7 @@ fn fn_generic_params(
}
fn params_and_where_preds_in_scope(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> (Vec<ast::GenericParam>, Vec<ast::WherePred>) {
let Some(body) = containing_body(ctx) else {
return Default::default();
@@ -942,7 +942,7 @@ fn params_and_where_preds_in_scope(
(generic_params, where_clauses)
}
-fn containing_body(ctx: &AssistContext<'_>) -> Option<hir::DefWithBody> {
+fn containing_body(ctx: &AssistContext<'_, '_>) -> Option<hir::DefWithBody> {
let item: ast::Item = ctx.find_node_at_offset()?;
let def = match item {
ast::Item::Fn(it) => ctx.sema.to_def(&it)?.into(),
@@ -954,7 +954,7 @@ fn containing_body(ctx: &AssistContext<'_>) -> Option<hir::DefWithBody> {
}
fn get_bounds_in_scope<D>(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
def: D,
) -> (impl Iterator<Item = ast::GenericParam>, impl Iterator<Item = ast::WherePred>)
where
@@ -1020,7 +1020,7 @@ struct WherePredWithParams {
}
fn compute_contained_params_in_generic_param(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
node: ast::GenericParam,
) -> Option<ParamBoundWithParams> {
match &node {
@@ -1049,7 +1049,7 @@ fn compute_contained_params_in_generic_param(
}
fn compute_contained_params_in_where_pred(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
node: ast::WherePred,
) -> Option<WherePredWithParams> {
let self_ty = node.ty()?;
@@ -1070,7 +1070,10 @@ fn compute_contained_params_in_where_pred(
Some(WherePredWithParams { node, self_ty_params, other_params })
}
-fn filter_generic_params(ctx: &AssistContext<'_>, node: SyntaxNode) -> Option<hir::GenericParam> {
+fn filter_generic_params(
+ ctx: &AssistContext<'_, '_>,
+ node: SyntaxNode,
+) -> Option<hir::GenericParam> {
let path = ast::Path::cast(node)?;
match ctx.sema.resolve_path(&path)? {
PathResolution::TypeParam(it) => Some(it.into()),
@@ -1165,7 +1168,7 @@ fn filter_unnecessary_bounds(
fn filter_bounds_in_scope(
generic_params: &mut Vec<ParamBoundWithParams>,
where_preds: &mut Vec<WherePredWithParams>,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
target: &GeneratedFunctionTarget,
) -> Option<()> {
let target_impl = target.parent().ancestors().find_map(ast::Impl::cast)?;
@@ -1248,13 +1251,13 @@ fn fn_arg_name(sema: &Semantics<'_, RootDatabase>, arg_expr: &ast::Expr) -> Stri
}
fn fn_arg_type(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
target_module: Module,
fn_arg: &ast::Expr,
generic_params: &mut FxHashSet<hir::GenericParam>,
) -> String {
fn maybe_displayed_type(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
target_module: Module,
fn_arg: &ast::Expr,
generic_params: &mut FxHashSet<hir::GenericParam>,
@@ -1347,7 +1350,7 @@ enum Visibility {
fn calculate_necessary_visibility(
current_module: Module,
target_module: Module,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Visibility {
let db = ctx.db();
let current_module = current_module.nearest_non_block_module(db);
diff --git a/crates/ide-assists/src/handlers/generate_getter_or_setter.rs b/crates/ide-assists/src/handlers/generate_getter_or_setter.rs
index b884581041..c8ab54474c 100644
--- a/crates/ide-assists/src/handlers/generate_getter_or_setter.rs
+++ b/crates/ide-assists/src/handlers/generate_getter_or_setter.rs
@@ -35,7 +35,7 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
// This if condition denotes two modes this assist can work in:
// - First is acting upon selection of record fields
// - Next is acting upon a single record field
@@ -124,7 +124,7 @@ pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt
// }
// }
// ```
-pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
generate_getter_impl(acc, ctx, false)
}
@@ -149,7 +149,7 @@ pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt
// }
// }
// ```
-pub(crate) fn generate_getter_mut(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_getter_mut(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
generate_getter_impl(acc, ctx, true)
}
@@ -175,7 +175,7 @@ enum AssistType {
pub(crate) fn generate_getter_impl(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
mutable: bool,
) -> Option<()> {
let (strukt, info_of_record_fields, fn_names) =
@@ -215,7 +215,7 @@ pub(crate) fn generate_getter_impl(
}
fn generate_getter_from_info(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
info: &AssistInfo,
record_field_info: &RecordFieldInfo,
make: &SyntaxFactory,
@@ -329,7 +329,7 @@ fn generate_setter_from_info(
}
fn extract_and_parse(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
assist_type: AssistType,
) -> Option<(ast::Struct, Vec<RecordFieldInfo>, Vec<String>)> {
// This if condition denotes two modes assists can work in:
@@ -411,7 +411,7 @@ fn parse_record_field(
}
fn items(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
info_of_record_fields: Vec<RecordFieldInfo>,
assist_info: &AssistInfo,
make: &SyntaxFactory,
@@ -432,7 +432,7 @@ fn items(
fn build_source_change(
builder: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
info_of_record_fields: Vec<RecordFieldInfo>,
assist_info: AssistInfo,
) {
diff --git a/crates/ide-assists/src/handlers/generate_impl.rs b/crates/ide-assists/src/handlers/generate_impl.rs
index 27a1eb6439..ab0eb56fcf 100644
--- a/crates/ide-assists/src/handlers/generate_impl.rs
+++ b/crates/ide-assists/src/handlers/generate_impl.rs
@@ -45,7 +45,7 @@ fn insert_impl(editor: &SyntaxEditor, impl_: &ast::Impl, nominal: &impl AstNodeE
//
// impl<T: Clone> Ctx<T> {$0}
// ```
-pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let nominal = ctx.find_node_at_offset::<ast::Adt>()?;
let name = nominal.name()?;
let target = nominal.syntax().text_range();
@@ -93,7 +93,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Optio
//
// impl<T: Clone> ${1:_} for Ctx<T> {$0}
// ```
-pub(crate) fn generate_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let nominal = ctx.find_node_at_offset::<ast::Adt>()?;
let name = nominal.name()?;
let target = nominal.syntax().text_range();
@@ -149,7 +149,7 @@ pub(crate) fn generate_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_>) ->
// }
// }
// ```
-pub(crate) fn generate_impl_trait(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_impl_trait(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
let trait_ = ast::Trait::cast(name.syntax().parent()?)?;
let target_scope = ctx.sema.scope(trait_.syntax())?;
diff --git a/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs b/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs
index f10b21b13e..39f304cac9 100644
--- a/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs
+++ b/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs
@@ -39,7 +39,10 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_is_empty_from_len(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_is_empty_from_len(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let fn_node = ctx.find_node_at_offset::<ast::Fn>()?;
let fn_name = fn_node.name()?;
@@ -86,7 +89,7 @@ pub(crate) fn generate_is_empty_from_len(acc: &mut Assists, ctx: &AssistContext<
}
fn get_impl_method(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
impl_: &ast::Impl,
fn_name: &Name,
) -> Option<hir::Function> {
diff --git a/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs b/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs
index acf0819222..fd095dd9b2 100644
--- a/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs
+++ b/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs
@@ -44,7 +44,10 @@ use crate::{AssistContext, AssistId, Assists};
// }
// }
// ```
-pub(crate) fn generate_mut_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_mut_trait_impl(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let impl_def = ctx.find_node_at_offset::<ast::Impl>()?;
let indent = impl_def.indent_level();
diff --git a/crates/ide-assists/src/handlers/generate_new.rs b/crates/ide-assists/src/handlers/generate_new.rs
index 756dc3d0fa..40adfceaae 100644
--- a/crates/ide-assists/src/handlers/generate_new.rs
+++ b/crates/ide-assists/src/handlers/generate_new.rs
@@ -33,7 +33,7 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field_list: Vec<(String, ast::Type)> = match strukt.kind() {
StructKind::Record(named) => {
diff --git a/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs b/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs
index 265a632a8c..23c7b2b7c8 100644
--- a/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs
+++ b/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs
@@ -47,7 +47,7 @@ use crate::{
// ```
pub(crate) fn generate_single_field_struct_from(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let strukt_name = ctx.find_node_at_offset::<ast::Name>()?;
let adt = ast::Adt::cast(strukt_name.syntax().parent()?)?;
@@ -179,7 +179,7 @@ fn make_adt_constructor(
}
fn make_constructors(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
module: hir::Module,
types: &[ast::Type],
) -> Vec<Option<ast::Expr>> {
diff --git a/crates/ide-assists/src/handlers/generate_trait_from_impl.rs b/crates/ide-assists/src/handlers/generate_trait_from_impl.rs
index 049398de8c..d5f0eb234c 100644
--- a/crates/ide-assists/src/handlers/generate_trait_from_impl.rs
+++ b/crates/ide-assists/src/handlers/generate_trait_from_impl.rs
@@ -68,7 +68,10 @@ use syntax::{
// const_maker! {i32, 7}
// }
// ```
-pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn generate_trait_from_impl(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
// Get AST Node
let impl_ast = ctx.find_node_at_offset::<ast::Impl>()?;
diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs
index c6a0b22d47..d95456fd3f 100644
--- a/crates/ide-assists/src/handlers/inline_call.rs
+++ b/crates/ide-assists/src/handlers/inline_call.rs
@@ -69,7 +69,7 @@ use crate::{
// };
// }
// ```
-pub(crate) fn inline_into_callers(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn inline_into_callers(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let def_file = ctx.file_id();
let vfs_def_file = ctx.vfs_file_id();
let name = ctx.find_node_at_offset::<ast::Name>()?;
@@ -219,7 +219,7 @@ pub(super) fn split_refs_and_uses<T: ast::AstNode>(
// };
// }
// ```
-pub(crate) fn inline_call(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn inline_call(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let name_ref: ast::NameRef = ctx.find_node_at_offset()?;
let call_info = CallInfo::from_name_ref(
name_ref.clone(),
@@ -350,7 +350,7 @@ fn inline(
cov_mark::hit!(inline_call_defined_in_macro);
let span_map = sema.db.expansion_span_map(macro_file);
let body_prettified =
- prettify_macro_expansion(sema.db, fn_body.syntax().clone(), &span_map, *krate);
+ prettify_macro_expansion(sema.db, fn_body.syntax().clone(), span_map, *krate);
if let Some(body) = ast::BlockExpr::cast(body_prettified) { body } else { fn_body.clone() }
} else {
fn_body.clone()
@@ -496,7 +496,7 @@ fn inline(
let param_ty_prettified = prettify_macro_expansion(
sema.db,
param_ty.syntax().clone(),
- &span_map,
+ span_map,
*krate,
);
ast::Type::cast(param_ty_prettified).unwrap_or(param_ty)
diff --git a/crates/ide-assists/src/handlers/inline_const_as_literal.rs b/crates/ide-assists/src/handlers/inline_const_as_literal.rs
index b11d3792bc..46cedea967 100644
--- a/crates/ide-assists/src/handlers/inline_const_as_literal.rs
+++ b/crates/ide-assists/src/handlers/inline_const_as_literal.rs
@@ -22,7 +22,10 @@ use crate::{AssistContext, AssistId, Assists};
// "Hello, World!"
// }
// ```
-pub(crate) fn inline_const_as_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn inline_const_as_literal(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let variable = ctx.find_node_at_offset::<ast::PathExpr>()?;
if let hir::PathResolution::Def(hir::ModuleDef::Const(konst)) =
@@ -57,7 +60,7 @@ pub(crate) fn inline_const_as_literal(acc: &mut Assists, ctx: &AssistContext<'_>
}
fn validate_type_recursively(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
ty_hir: Option<&hir::Type<'_>>,
refed: bool,
fuel: i32,
diff --git a/crates/ide-assists/src/handlers/inline_local_variable.rs b/crates/ide-assists/src/handlers/inline_local_variable.rs
index bf9bc394b3..531adf62ba 100644
--- a/crates/ide-assists/src/handlers/inline_local_variable.rs
+++ b/crates/ide-assists/src/handlers/inline_local_variable.rs
@@ -32,7 +32,7 @@ use crate::{
// (1 + 2) * 4;
// }
// ```
-pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let file_id = ctx.file_id();
let range = ctx.selection_trimmed();
let InlineData { let_stmt, delete_let, references, target } =
diff --git a/crates/ide-assists/src/handlers/inline_macro.rs b/crates/ide-assists/src/handlers/inline_macro.rs
index ef9b5d093f..002791b88d 100644
--- a/crates/ide-assists/src/handlers/inline_macro.rs
+++ b/crates/ide-assists/src/handlers/inline_macro.rs
@@ -35,7 +35,7 @@ use crate::{AssistContext, AssistId, Assists};
// println!("{number}");
// }
// ```
-pub(crate) fn inline_macro(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn inline_macro(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let unexpanded = ctx.find_node_at_offset::<ast::MacroCall>()?;
let macro_call = ctx.sema.to_def(&unexpanded)?;
let target_crate_id = ctx.sema.file_to_module_def(ctx.vfs_file_id())?.krate(ctx.db()).into();
@@ -51,7 +51,7 @@ pub(crate) fn inline_macro(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
let span_map = ctx.sema.db.expansion_span_map(macro_call);
// Don't call `prettify_macro_expansion()` outside the actual assist action; it does some heavy rowan tree manipulation,
// which can be very costly for big macros when it is done *even without the assist being invoked*.
- let expanded = prettify_macro_expansion(ctx.db(), expanded, &span_map, target_crate_id);
+ let expanded = prettify_macro_expansion(ctx.db(), expanded, span_map, target_crate_id);
let expanded = ast::edit::indent(&expanded, unexpanded.indent_level());
editor.replace(unexpanded.syntax(), expanded);
builder.add_file_edits(ctx.vfs_file_id(), editor);
diff --git a/crates/ide-assists/src/handlers/inline_type_alias.rs b/crates/ide-assists/src/handlers/inline_type_alias.rs
index 9c7d266057..e4a1314f5b 100644
--- a/crates/ide-assists/src/handlers/inline_type_alias.rs
+++ b/crates/ide-assists/src/handlers/inline_type_alias.rs
@@ -45,7 +45,7 @@ use super::inline_call::split_refs_and_uses;
// let _: i32 = 3;
// }
// ```
-pub(crate) fn inline_type_alias_uses(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn inline_type_alias_uses(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let name = ctx.find_node_at_offset::<ast::Name>()?;
let ast_alias = name.syntax().parent().and_then(ast::TypeAlias::cast)?;
@@ -125,7 +125,7 @@ pub(crate) fn inline_type_alias_uses(acc: &mut Assists, ctx: &AssistContext<'_>)
// let a: Vec<u32>;
// }
// ```
-pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let alias_instance = ctx.find_node_at_offset::<ast::PathType>()?;
let concrete_type;
let replacement;
@@ -412,7 +412,7 @@ fn create_replacement(
editor.finish().new_root().clone()
}
-fn get_type_alias(ctx: &AssistContext<'_>, path: &ast::PathType) -> Option<ast::TypeAlias> {
+fn get_type_alias(ctx: &AssistContext<'_, '_>, path: &ast::PathType) -> Option<ast::TypeAlias> {
let resolved_path = ctx.sema.resolve_path(&path.path()?)?;
// We need the generics in the correct order to be able to map any provided
diff --git a/crates/ide-assists/src/handlers/into_to_qualified_from.rs b/crates/ide-assists/src/handlers/into_to_qualified_from.rs
index 47b273535a..9f8b08f4f8 100644
--- a/crates/ide-assists/src/handlers/into_to_qualified_from.rs
+++ b/crates/ide-assists/src/handlers/into_to_qualified_from.rs
@@ -36,7 +36,7 @@ use crate::assist_context::{AssistContext, Assists};
// let b: B = B::from(a);
// }
// ```
-pub(crate) fn into_to_qualified_from(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn into_to_qualified_from(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let method_call: ast::MethodCallExpr = ctx.find_node_at_offset()?;
let nameref = method_call.name_ref()?;
let receiver = method_call.receiver()?;
diff --git a/crates/ide-assists/src/handlers/introduce_named_lifetime.rs b/crates/ide-assists/src/handlers/introduce_named_lifetime.rs
index 2cbeae1d19..986989952f 100644
--- a/crates/ide-assists/src/handlers/introduce_named_lifetime.rs
+++ b/crates/ide-assists/src/handlers/introduce_named_lifetime.rs
@@ -34,7 +34,10 @@ static ASSIST_LABEL: &str = "Introduce named lifetime";
// }
// }
// ```
-pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn introduce_named_lifetime(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
// FIXME: How can we handle renaming any one of multiple anonymous lifetimes?
// FIXME: should also add support for the case fun(f: &Foo) -> &$0Foo
let lifetime =
diff --git a/crates/ide-assists/src/handlers/introduce_named_type_parameter.rs b/crates/ide-assists/src/handlers/introduce_named_type_parameter.rs
index c8ae13a833..06023476da 100644
--- a/crates/ide-assists/src/handlers/introduce_named_type_parameter.rs
+++ b/crates/ide-assists/src/handlers/introduce_named_type_parameter.rs
@@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn introduce_named_type_parameter(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let impl_trait_type = ctx.find_node_at_offset::<ast::ImplTraitType>()?;
let param = impl_trait_type.syntax().ancestors().find_map(ast::Param::cast)?;
diff --git a/crates/ide-assists/src/handlers/invert_if.rs b/crates/ide-assists/src/handlers/invert_if.rs
index c8cb7bb60f..9dda4bbb96 100644
--- a/crates/ide-assists/src/handlers/invert_if.rs
+++ b/crates/ide-assists/src/handlers/invert_if.rs
@@ -26,7 +26,7 @@ use crate::{
// if y { B } else { A }
// }
// ```
-pub(crate) fn invert_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn invert_if(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let if_keyword = ctx
.find_token_syntax_at_offset(T![if])
.or_else(|| ctx.find_token_syntax_at_offset(T![else]))?;
diff --git a/crates/ide-assists/src/handlers/merge_imports.rs b/crates/ide-assists/src/handlers/merge_imports.rs
index 1dd0833fad..dc40a6a640 100644
--- a/crates/ide-assists/src/handlers/merge_imports.rs
+++ b/crates/ide-assists/src/handlers/merge_imports.rs
@@ -27,7 +27,7 @@ use Edit::*;
// ```
// use std::{fmt::Formatter, io};
// ```
-pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (target, edits) = if ctx.has_empty_selection() {
// Merge a neighbor
cov_mark::hit!(merge_with_use_item_neighbors);
diff --git a/crates/ide-assists/src/handlers/merge_match_arms.rs b/crates/ide-assists/src/handlers/merge_match_arms.rs
index 6e84af5f91..f41769150c 100644
--- a/crates/ide-assists/src/handlers/merge_match_arms.rs
+++ b/crates/ide-assists/src/handlers/merge_match_arms.rs
@@ -33,7 +33,7 @@ use crate::{AssistContext, AssistId, Assists, TextRange};
// }
// }
// ```
-pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let current_arm = ctx.find_node_at_trimmed_offset::<ast::MatchArm>()?;
// Don't try to handle arms with guards for now - can add support for this later
if current_arm.guard().is_some() {
@@ -107,7 +107,7 @@ fn contains_placeholder(a: &ast::MatchArm) -> bool {
fn are_same_types(
current_arm_types: &FxHashMap<String, Option<Type<'_>>>,
arm: &ast::MatchArm,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> bool {
let arm_types = get_arm_types(ctx, arm);
for (other_arm_type_name, other_arm_type) in arm_types {
@@ -122,14 +122,14 @@ fn are_same_types(
}
fn get_arm_types<'db>(
- context: &AssistContext<'db>,
+ context: &AssistContext<'_, 'db>,
arm: &ast::MatchArm,
) -> FxHashMap<String, Option<Type<'db>>> {
let mut mapping: FxHashMap<String, Option<Type<'db>>> = FxHashMap::default();
fn recurse<'db>(
map: &mut FxHashMap<String, Option<Type<'db>>>,
- ctx: &AssistContext<'db>,
+ ctx: &AssistContext<'_, 'db>,
pat: &Option<ast::Pat>,
) {
if let Some(local_pat) = pat {
diff --git a/crates/ide-assists/src/handlers/merge_nested_if.rs b/crates/ide-assists/src/handlers/merge_nested_if.rs
index e491c043e1..bb3725a133 100644
--- a/crates/ide-assists/src/handlers/merge_nested_if.rs
+++ b/crates/ide-assists/src/handlers/merge_nested_if.rs
@@ -23,7 +23,7 @@ use crate::{
// if x == 3 && y == 4 { 1 }
// }
// ```
-pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let if_keyword = ctx.find_token_syntax_at_offset(T![if])?;
let expr = ast::IfExpr::cast(if_keyword.parent()?)?;
let if_range = if_keyword.text_range();
diff --git a/crates/ide-assists/src/handlers/move_bounds.rs b/crates/ide-assists/src/handlers/move_bounds.rs
index e044068ff7..3efc847141 100644
--- a/crates/ide-assists/src/handlers/move_bounds.rs
+++ b/crates/ide-assists/src/handlers/move_bounds.rs
@@ -24,7 +24,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn move_bounds_to_where_clause(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
diff --git a/crates/ide-assists/src/handlers/move_const_to_impl.rs b/crates/ide-assists/src/handlers/move_const_to_impl.rs
index 86bdf3f8b4..4071f16a9f 100644
--- a/crates/ide-assists/src/handlers/move_const_to_impl.rs
+++ b/crates/ide-assists/src/handlers/move_const_to_impl.rs
@@ -42,7 +42,7 @@ use crate::assist_context::{AssistContext, Assists};
// }
// }
// ```
-pub(crate) fn move_const_to_impl(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn move_const_to_impl(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let db = ctx.db();
let const_: ast::Const = ctx.find_node_at_offset()?;
// Don't show the assist when the cursor is at the const's body.
diff --git a/crates/ide-assists/src/handlers/move_from_mod_rs.rs b/crates/ide-assists/src/handlers/move_from_mod_rs.rs
index a36d3136a1..21a8c53e8c 100644
--- a/crates/ide-assists/src/handlers/move_from_mod_rs.rs
+++ b/crates/ide-assists/src/handlers/move_from_mod_rs.rs
@@ -20,7 +20,7 @@ use crate::{
// ```
// fn t() {}
// ```
-pub(crate) fn move_from_mod_rs(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn move_from_mod_rs(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let source_file = ctx.find_node_at_offset::<ast::SourceFile>()?;
let module = ctx.sema.file_to_module_def(ctx.vfs_file_id())?;
// Enable this assist if the user select all "meaningful" content in the source file
diff --git a/crates/ide-assists/src/handlers/move_guard.rs b/crates/ide-assists/src/handlers/move_guard.rs
index 7309cc6d06..7cd0d01238 100644
--- a/crates/ide-assists/src/handlers/move_guard.rs
+++ b/crates/ide-assists/src/handlers/move_guard.rs
@@ -38,7 +38,7 @@ use crate::{AssistContext, AssistId, Assists};
// }
// }
// ```
-pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let match_arm = ctx.find_node_at_offset::<MatchArm>()?;
let guard = match_arm.guard()?;
if ctx.offset() > guard.syntax().text_range().end() {
@@ -122,7 +122,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext<'_>)
// ```
pub(crate) fn move_arm_cond_to_match_guard(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?;
let match_pat = match_arm.pat()?;
diff --git a/crates/ide-assists/src/handlers/move_module_to_file.rs b/crates/ide-assists/src/handlers/move_module_to_file.rs
index 503003bc6b..3fec102275 100644
--- a/crates/ide-assists/src/handlers/move_module_to_file.rs
+++ b/crates/ide-assists/src/handlers/move_module_to_file.rs
@@ -24,7 +24,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
// mod foo;
// ```
-pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let module_ast = ctx.find_node_at_offset::<ast::Module>()?;
let module_items = module_ast.item_list()?;
diff --git a/crates/ide-assists/src/handlers/move_to_mod_rs.rs b/crates/ide-assists/src/handlers/move_to_mod_rs.rs
index 5e95b264fc..7407bd1a0c 100644
--- a/crates/ide-assists/src/handlers/move_to_mod_rs.rs
+++ b/crates/ide-assists/src/handlers/move_to_mod_rs.rs
@@ -20,7 +20,7 @@ use crate::{
// ```
// fn t() {}
// ```
-pub(crate) fn move_to_mod_rs(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn move_to_mod_rs(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let source_file = ctx.find_node_at_offset::<ast::SourceFile>()?;
let module = ctx.sema.file_to_module_def(ctx.vfs_file_id())?;
// Enable this assist if the user select all "meaningful" content in the source file
diff --git a/crates/ide-assists/src/handlers/normalize_import.rs b/crates/ide-assists/src/handlers/normalize_import.rs
index 36da1d1788..f97a3e583f 100644
--- a/crates/ide-assists/src/handlers/normalize_import.rs
+++ b/crates/ide-assists/src/handlers/normalize_import.rs
@@ -17,7 +17,7 @@ use crate::{
// ```
// use std::{fmt::Formatter, io};
// ```
-pub(crate) fn normalize_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn normalize_import(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let use_item = if ctx.has_empty_selection() {
ctx.find_node_at_offset()?
} else {
diff --git a/crates/ide-assists/src/handlers/number_representation.rs b/crates/ide-assists/src/handlers/number_representation.rs
index fac81aefe0..a50f443d5d 100644
--- a/crates/ide-assists/src/handlers/number_representation.rs
+++ b/crates/ide-assists/src/handlers/number_representation.rs
@@ -15,7 +15,10 @@ const MIN_NUMBER_OF_DIGITS_TO_FORMAT: usize = 5;
// ```
// const _: i32 = 1_012_345;
// ```
-pub(crate) fn reformat_number_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn reformat_number_literal(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let literal = ctx.find_node_at_offset::<ast::Literal>()?;
let literal = match literal.kind() {
ast::LiteralKind::IntNumber(it) => it,
diff --git a/crates/ide-assists/src/handlers/promote_local_to_const.rs b/crates/ide-assists/src/handlers/promote_local_to_const.rs
index ed61d32eb6..23c88e65d6 100644
--- a/crates/ide-assists/src/handlers/promote_local_to_const.rs
+++ b/crates/ide-assists/src/handlers/promote_local_to_const.rs
@@ -39,7 +39,7 @@ use crate::{
// }
// }
// ```
-pub(crate) fn promote_local_to_const(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn promote_local_to_const(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let pat = ctx.find_node_at_offset::<ast::IdentPat>()?;
let name = pat.name()?;
if !pat.is_simple_ident() {
diff --git a/crates/ide-assists/src/handlers/pull_assignment_up.rs b/crates/ide-assists/src/handlers/pull_assignment_up.rs
index 082052c9d4..4024d51ffc 100644
--- a/crates/ide-assists/src/handlers/pull_assignment_up.rs
+++ b/crates/ide-assists/src/handlers/pull_assignment_up.rs
@@ -33,7 +33,7 @@ use crate::{
// };
// }
// ```
-pub(crate) fn pull_assignment_up(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn pull_assignment_up(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let assign_expr = ctx.find_node_at_offset::<ast::BinExpr>()?;
let op_kind = assign_expr.op_kind()?;
@@ -115,13 +115,13 @@ pub(crate) fn pull_assignment_up(acc: &mut Assists, ctx: &AssistContext<'_>) ->
)
}
-struct AssignmentsCollector<'a> {
- sema: &'a hir::Semantics<'a, ide_db::RootDatabase>,
+struct AssignmentsCollector<'a, 'db> {
+ sema: &'a hir::Semantics<'db, ide_db::RootDatabase>,
common_lhs: ast::Expr,
assignments: Vec<(ast::BinExpr, ast::Expr)>,
}
-impl AssignmentsCollector<'_> {
+impl AssignmentsCollector<'_, '_> {
fn collect_match(&mut self, match_expr: &ast::MatchExpr) -> Option<()> {
for arm in match_expr.match_arm_list()?.arms() {
match arm.expr()? {
diff --git a/crates/ide-assists/src/handlers/qualify_method_call.rs b/crates/ide-assists/src/handlers/qualify_method_call.rs
index d7885d5065..edf0a855c4 100644
--- a/crates/ide-assists/src/handlers/qualify_method_call.rs
+++ b/crates/ide-assists/src/handlers/qualify_method_call.rs
@@ -32,7 +32,7 @@ use crate::{
// Foo::foo(&foo);
// }
// ```
-pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let name: ast::NameRef = ctx.find_node_at_offset()?;
let call = name.syntax().parent().and_then(ast::MethodCallExpr::cast)?;
diff --git a/crates/ide-assists/src/handlers/qualify_path.rs b/crates/ide-assists/src/handlers/qualify_path.rs
index 18a31a2b42..cb48554083 100644
--- a/crates/ide-assists/src/handlers/qualify_path.rs
+++ b/crates/ide-assists/src/handlers/qualify_path.rs
@@ -34,7 +34,7 @@ use crate::{
// }
// # pub mod std { pub mod collections { pub struct HashMap { } } }
// ```
-pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (import_assets, syntax_under_caret, expected) = find_importable_node(ctx)?;
let cfg = ctx.config.import_path_config();
diff --git a/crates/ide-assists/src/handlers/raw_string.rs b/crates/ide-assists/src/handlers/raw_string.rs
index 8234a0374e..0a74515739 100644
--- a/crates/ide-assists/src/handlers/raw_string.rs
+++ b/crates/ide-assists/src/handlers/raw_string.rs
@@ -24,7 +24,7 @@ use crate::{
// r#"Hello, World!"#;
// }
// ```
-pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::AnyString>()?;
if token.is_raw() {
return None;
@@ -60,7 +60,7 @@ pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt
// "Hello, \"World!\"";
// }
// ```
-pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::AnyString>()?;
if !token.is_raw() {
return None;
@@ -97,7 +97,7 @@ pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
// r##"Hello, World!"##;
// }
// ```
-pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::AnyString>()?;
if !token.is_raw() {
return None;
@@ -128,7 +128,7 @@ pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()>
// r"Hello, World!";
// }
// ```
-pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let token = ctx.find_token_at_offset::<ast::AnyString>()?;
if !token.is_raw() {
return None;
@@ -160,7 +160,7 @@ fn replace_literal(
token: &impl AstToken,
new: &str,
builder: &mut SourceChangeBuilder,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) {
let old_token = token.syntax();
let parent = old_token.parent().expect("no parent token");
diff --git a/crates/ide-assists/src/handlers/remove_dbg.rs b/crates/ide-assists/src/handlers/remove_dbg.rs
index 778533be5a..91977c2b7f 100644
--- a/crates/ide-assists/src/handlers/remove_dbg.rs
+++ b/crates/ide-assists/src/handlers/remove_dbg.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, Assists};
// let x = 42 * (4 + 2);
// }
// ```
-pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (editor, _) = SyntaxEditor::new(ctx.source_file().syntax().clone());
let make = editor.make();
let macro_calls = if ctx.has_empty_selection() {
diff --git a/crates/ide-assists/src/handlers/remove_else_branches.rs b/crates/ide-assists/src/handlers/remove_else_branches.rs
index 0c03856417..a40d691e4c 100644
--- a/crates/ide-assists/src/handlers/remove_else_branches.rs
+++ b/crates/ide-assists/src/handlers/remove_else_branches.rs
@@ -35,7 +35,7 @@ use crate::{AssistContext, AssistId, Assists};
// let _x = 2;
// }
// ```
-pub(crate) fn remove_else_branches(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_else_branches(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let else_token = ctx.find_token_syntax_at_offset(T![else])?;
let else_branches = ctx
.find_node_at_range::<ast::IfExpr>()
diff --git a/crates/ide-assists/src/handlers/remove_mut.rs b/crates/ide-assists/src/handlers/remove_mut.rs
index 2a6024339f..db379809c5 100644
--- a/crates/ide-assists/src/handlers/remove_mut.rs
+++ b/crates/ide-assists/src/handlers/remove_mut.rs
@@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, Assists};
// fn feed(&self, amount: u32) {}
// }
// ```
-pub(crate) fn remove_mut(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_mut(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let mut_token = ctx.find_token_syntax_at_offset(T![mut])?;
let target = mut_token.text_range();
diff --git a/crates/ide-assists/src/handlers/remove_parentheses.rs b/crates/ide-assists/src/handlers/remove_parentheses.rs
index af249c97b9..d6606d181e 100644
--- a/crates/ide-assists/src/handlers/remove_parentheses.rs
+++ b/crates/ide-assists/src/handlers/remove_parentheses.rs
@@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, Assists};
// _ = 2 + 2;
// }
// ```
-pub(crate) fn remove_parentheses(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_parentheses(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let parens = ctx.find_node_at_offset::<ast::ParenExpr>()?;
let cursor_in_range =
diff --git a/crates/ide-assists/src/handlers/remove_underscore.rs b/crates/ide-assists/src/handlers/remove_underscore.rs
index 1de1c15cf7..efe5c945be 100644
--- a/crates/ide-assists/src/handlers/remove_underscore.rs
+++ b/crates/ide-assists/src/handlers/remove_underscore.rs
@@ -24,7 +24,7 @@ use crate::{AssistContext, Assists};
// foo = 2;
// }
// ```
-pub(crate) fn remove_underscore(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_underscore(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (text, text_range, def) = if let Some(name_ref) = ctx.find_node_at_offset::<ast::Name>() {
let text = name_ref.text();
if !text.starts_with('_') {
diff --git a/crates/ide-assists/src/handlers/remove_unused_imports.rs b/crates/ide-assists/src/handlers/remove_unused_imports.rs
index c38bdfdccf..c90623ceed 100644
--- a/crates/ide-assists/src/handlers/remove_unused_imports.rs
+++ b/crates/ide-assists/src/handlers/remove_unused_imports.rs
@@ -33,7 +33,7 @@ use crate::{AssistContext, AssistId, Assists};
// mod foo {
// }
// ```
-pub(crate) fn remove_unused_imports(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_unused_imports(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
// First, grab the uses that intersect with the current selection.
let selected_el = match ctx.covering_element() {
syntax::NodeOrToken::Node(n) => n,
@@ -132,7 +132,7 @@ pub(crate) fn remove_unused_imports(acc: &mut Assists, ctx: &AssistContext<'_>)
}
fn is_path_per_ns_unused_in_scope(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
u: &ast::UseTree,
scope: &mut Vec<SearchScope>,
path: &PathResolutionPerNs,
@@ -151,7 +151,7 @@ fn is_path_per_ns_unused_in_scope(
}
fn is_path_unused_in_scope(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
u: &ast::UseTree,
scope: &mut Vec<SearchScope>,
path: &[Option<PathResolution>],
@@ -167,7 +167,7 @@ fn is_path_unused_in_scope(
}
fn is_trait_unused_in_scope(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
u: &ast::UseTree,
scope: &mut Vec<SearchScope>,
t: &hir::Trait,
@@ -178,7 +178,7 @@ fn is_trait_unused_in_scope(
}
fn used_once_in_scope(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
def: Definition,
rename: Option<Rename>,
scopes: &Vec<SearchScope>,
diff --git a/crates/ide-assists/src/handlers/remove_unused_param.rs b/crates/ide-assists/src/handlers/remove_unused_param.rs
index b91d678c93..d7b0b5ea01 100644
--- a/crates/ide-assists/src/handlers/remove_unused_param.rs
+++ b/crates/ide-assists/src/handlers/remove_unused_param.rs
@@ -31,7 +31,7 @@ use crate::{
// frobnicate();
// }
// ```
-pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let param: ast::Param = ctx.find_node_at_offset()?;
let ident_pat = match param.pat()? {
ast::Pat::IdentPat(it) => it,
@@ -94,7 +94,7 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) ->
}
fn process_usages(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
builder: &mut SourceChangeBuilder,
editioned_file_id: EditionedFileId,
references: Vec<FileReference>,
diff --git a/crates/ide-assists/src/handlers/reorder_fields.rs b/crates/ide-assists/src/handlers/reorder_fields.rs
index facbab8019..9c9224b997 100644
--- a/crates/ide-assists/src/handlers/reorder_fields.rs
+++ b/crates/ide-assists/src/handlers/reorder_fields.rs
@@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, Assists};
// struct Foo {foo: i32, bar: i32};
// const test: Foo = Foo {foo: 1, bar: 0}
// ```
-pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let path = ctx.find_node_at_offset::<ast::Path>()?;
let record =
path.syntax().parent().and_then(<Either<ast::RecordExpr, ast::RecordPat>>::cast)?;
@@ -97,7 +97,7 @@ fn replace<T: AstNode + PartialEq>(
fn compute_fields_ranks(
path: &ast::Path,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<FxHashMap<String, usize>> {
let strukt = match ctx.sema.resolve_path(path) {
Some(hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(it)))) => it,
diff --git a/crates/ide-assists/src/handlers/reorder_impl_items.rs b/crates/ide-assists/src/handlers/reorder_impl_items.rs
index df5281895a..658947abe1 100644
--- a/crates/ide-assists/src/handlers/reorder_impl_items.rs
+++ b/crates/ide-assists/src/handlers/reorder_impl_items.rs
@@ -42,7 +42,7 @@ use crate::{AssistContext, AssistId, Assists};
// fn c() {}
// }
// ```
-pub(crate) fn reorder_impl_items(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn reorder_impl_items(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let impl_ast = ctx.find_node_at_offset::<ast::Impl>()?;
let items = impl_ast.assoc_item_list()?;
@@ -113,7 +113,7 @@ pub(crate) fn reorder_impl_items(acc: &mut Assists, ctx: &AssistContext<'_>) ->
fn compute_item_ranks(
path: &ast::Path,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<FxHashMap<String, usize>> {
let td = trait_definition(path, &ctx.sema)?;
diff --git a/crates/ide-assists/src/handlers/replace_arith_op.rs b/crates/ide-assists/src/handlers/replace_arith_op.rs
index a04f6f3833..9fadf1333f 100644
--- a/crates/ide-assists/src/handlers/replace_arith_op.rs
+++ b/crates/ide-assists/src/handlers/replace_arith_op.rs
@@ -24,7 +24,10 @@ use crate::{
// let x = 1.checked_add(2);
// }
// ```
-pub(crate) fn replace_arith_with_checked(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_arith_with_checked(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
replace_arith(acc, ctx, ArithKind::Checked)
}
@@ -45,7 +48,7 @@ pub(crate) fn replace_arith_with_checked(acc: &mut Assists, ctx: &AssistContext<
// ```
pub(crate) fn replace_arith_with_saturating(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
replace_arith(acc, ctx, ArithKind::Saturating)
}
@@ -67,12 +70,12 @@ pub(crate) fn replace_arith_with_saturating(
// ```
pub(crate) fn replace_arith_with_wrapping(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
replace_arith(acc, ctx, ArithKind::Wrapping)
}
-fn replace_arith(acc: &mut Assists, ctx: &AssistContext<'_>, kind: ArithKind) -> Option<()> {
+fn replace_arith(acc: &mut Assists, ctx: &AssistContext<'_, '_>, kind: ArithKind) -> Option<()> {
let (lhs, op, is_assign, rhs) = parse_binary_op(ctx)?;
let op_expr = lhs.syntax().parent()?;
@@ -103,7 +106,7 @@ fn replace_arith(acc: &mut Assists, ctx: &AssistContext<'_>, kind: ArithKind) ->
)
}
-fn is_primitive_int(ctx: &AssistContext<'_>, expr: &ast::Expr) -> bool {
+fn is_primitive_int(ctx: &AssistContext<'_, '_>, expr: &ast::Expr) -> bool {
match ctx.sema.type_of_expr(expr) {
Some(ty) => ty.adjusted().is_int_or_uint(),
_ => false,
@@ -111,7 +114,7 @@ fn is_primitive_int(ctx: &AssistContext<'_>, expr: &ast::Expr) -> bool {
}
/// Extract the operands of an arithmetic expression (e.g. `1 + 2` or `1.checked_add(2)`)
-fn parse_binary_op(ctx: &AssistContext<'_>) -> Option<(ast::Expr, ArithOp, bool, ast::Expr)> {
+fn parse_binary_op(ctx: &AssistContext<'_, '_>) -> Option<(ast::Expr, ArithOp, bool, ast::Expr)> {
if !ctx.has_empty_selection() {
return None;
}
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 da02d9db40..4e85b30b58 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
@@ -44,7 +44,7 @@ use crate::{
// ```
pub(crate) fn replace_derive_with_manual_impl(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let attr = ctx.find_node_at_offset_with_descend::<ast::Attr>()?;
let path = attr.path()?;
@@ -128,7 +128,7 @@ pub(crate) fn replace_derive_with_manual_impl(
fn add_assist(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
attr: &ast::Attr,
old_derives: &[ast::Path],
old_tree: &ast::TokenTree,
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 a47e3a4086..aa3f917f12 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
@@ -47,7 +47,10 @@ use crate::{
// }
// }
// ```
-pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_if_let_with_match(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let if_expr: ast::IfExpr = ctx.find_node_at_offset()?;
let available_range = TextRange::new(
if_expr.syntax().text_range().start(),
@@ -160,7 +163,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext<'
}
fn make_else_arm(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
make: &SyntaxFactory,
else_expr: Option<ast::Expr>,
conditionals: &[(Option<ast::Pat>, Option<ast::Expr>, ast::BlockExpr)],
@@ -223,7 +226,10 @@ fn make_else_arm(
// }
// }
// ```
-pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_match_with_if_let(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let match_expr: ast::MatchExpr = ctx.find_node_at_offset()?;
let match_arm_list = match_expr.match_arm_list()?;
let available_range = TextRange::new(
@@ -397,7 +403,7 @@ fn is_sad_pat(sema: &hir::Semantics<'_, RootDatabase>, pat: &ast::Pat) -> bool {
fn let_and_guard(
cond: &ast::Expr,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<(Option<(ast::Pat, ast::Expr)>, Option<ast::Expr>)> {
if let ast::Expr::ParenExpr(expr) = cond
&& let Some(sub_expr) = expr.expr()
@@ -454,7 +460,7 @@ fn and_bin_expr_left(expr: &ast::BinExpr) -> ast::BinExpr {
fn parse_matches_macro(
expr: &ast::Expr,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<(ast::Pat, ast::Expr, Option<ast::Expr>)> {
let ast::Expr::MacroExpr(macro_expr) = expr else { return None };
let macro_call = macro_expr.macro_call()?;
@@ -504,7 +510,7 @@ fn pretty_pat_inside_macro(
let pretty_node = hir::prettify_macro_expansion(
db,
pat,
- &db.expansion_span_map(file_id),
+ db.expansion_span_map(file_id),
scope.module().krate(db).into(),
);
ast::Pat::cast(pretty_node)
diff --git a/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs b/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs
index 802d5f72b9..f50614a66f 100644
--- a/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs
+++ b/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs
@@ -29,7 +29,7 @@ use crate::{
// ```
pub(crate) fn replace_is_method_with_if_let_method(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let has_cond = ctx.find_node_at_offset::<Either<ast::IfExpr, ast::WhileExpr>>()?;
diff --git a/crates/ide-assists/src/handlers/replace_let_with_if_let.rs b/crates/ide-assists/src/handlers/replace_let_with_if_let.rs
index 85e72130e0..29688d9b97 100644
--- a/crates/ide-assists/src/handlers/replace_let_with_if_let.rs
+++ b/crates/ide-assists/src/handlers/replace_let_with_if_let.rs
@@ -34,7 +34,10 @@ use crate::{AssistContext, AssistId, Assists};
//
// fn compute() -> Option<i32> { None }
// ```
-pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_let_with_if_let(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let let_kw = ctx.find_token_syntax_at_offset(T![let])?;
let let_stmt = let_kw.parent().and_then(ast::LetStmt::cast)?;
let init = let_stmt.initializer()?;
diff --git a/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs b/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs
index 6e4dd8cb73..7aa9a82109 100644
--- a/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs
+++ b/crates/ide-assists/src/handlers/replace_method_eager_lazy.rs
@@ -25,7 +25,10 @@ use crate::{AssistContext, Assists, utils::wrap_paren_in_call};
// a.unwrap_or_else(|| 2);
// }
// ```
-pub(crate) fn replace_with_lazy_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_with_lazy_method(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let call: ast::MethodCallExpr = ctx.find_node_at_offset()?;
let scope = ctx.sema.scope(call.syntax())?;
@@ -113,7 +116,10 @@ fn into_closure(param: &Expr, name_lazy: &str) -> Expr {
// a.unwrap_or(2);
// }
// ```
-pub(crate) fn replace_with_eager_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_with_eager_method(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let call: ast::MethodCallExpr = ctx.find_node_at_offset()?;
let scope = ctx.sema.scope(call.syntax())?;
diff --git a/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs b/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs
index 4372683016..979f832978 100644
--- a/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs
+++ b/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs
@@ -26,7 +26,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn replace_named_generic_with_impl(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
// finds `<P: AsRef<Path>>`
let type_param = ctx.find_node_at_offset::<ast::TypeParam>()?;
diff --git a/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs
index 92fd119184..0bd1ec12d0 100644
--- a/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs
+++ b/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs
@@ -29,7 +29,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
pub(crate) fn replace_qualified_name_with_use(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let original_path: ast::Path = ctx.find_node_at_offset()?;
// We don't want to mess with use statements
@@ -95,7 +95,7 @@ pub(crate) fn replace_qualified_name_with_use(
)
}
-fn target_path(ctx: &AssistContext<'_>, mut original_path: ast::Path) -> Option<ast::Path> {
+fn target_path(ctx: &AssistContext<'_, '_>, mut original_path: ast::Path) -> Option<ast::Path> {
let on_first = original_path.qualifier().is_none();
if on_first {
diff --git a/crates/ide-assists/src/handlers/replace_string_with_char.rs b/crates/ide-assists/src/handlers/replace_string_with_char.rs
index fb5b234d55..df22c472a4 100644
--- a/crates/ide-assists/src/handlers/replace_string_with_char.rs
+++ b/crates/ide-assists/src/handlers/replace_string_with_char.rs
@@ -22,7 +22,10 @@ use crate::{AssistContext, AssistId, Assists, utils::string_suffix};
// find('{');
// }
// ```
-pub(crate) fn replace_string_with_char(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_string_with_char(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let token = ctx.find_token_syntax_at_offset(STRING).and_then(ast::String::cast)?;
let value = token.value().ok()?;
let target = token.syntax().text_range();
@@ -64,7 +67,10 @@ pub(crate) fn replace_string_with_char(acc: &mut Assists, ctx: &AssistContext<'_
// find("{");
// }
// ```
-pub(crate) fn replace_char_with_string(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn replace_char_with_string(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let token = ctx.find_token_syntax_at_offset(CHAR)?;
let target = token.text_range();
diff --git a/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs b/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs
index a692259410..5e336523b4 100644
--- a/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs
+++ b/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs
@@ -28,7 +28,7 @@ use crate::{
// ```
pub(crate) fn replace_turbofish_with_explicit_type(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let let_stmt = ctx.find_node_at_offset::<LetStmt>()?;
diff --git a/crates/ide-assists/src/handlers/sort_items.rs b/crates/ide-assists/src/handlers/sort_items.rs
index 911fa9d14b..49b3cfb908 100644
--- a/crates/ide-assists/src/handlers/sort_items.rs
+++ b/crates/ide-assists/src/handlers/sort_items.rs
@@ -81,7 +81,7 @@ use crate::{AssistContext, AssistId, Assists, utils::get_methods};
// Cat { name: String, weight: f64 },
// }
// ```
-pub(crate) fn sort_items(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn sort_items(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
if ctx.has_empty_selection() {
cov_mark::hit!(not_applicable_if_no_selection);
return None;
@@ -150,7 +150,7 @@ fn add_sort_field_list_assist(acc: &mut Assists, field_list: Option<ast::FieldLi
fn add_sort_methods_assist(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
item_list: ast::AssocItemList,
) -> Option<()> {
let selection = ctx.selection_trimmed();
diff --git a/crates/ide-assists/src/handlers/split_import.rs b/crates/ide-assists/src/handlers/split_import.rs
index 1729a0667c..96f4f8e447 100644
--- a/crates/ide-assists/src/handlers/split_import.rs
+++ b/crates/ide-assists/src/handlers/split_import.rs
@@ -13,7 +13,7 @@ use crate::{AssistContext, AssistId, Assists};
// ```
// use std::{collections::HashMap};
// ```
-pub(crate) fn split_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn split_import(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let colon_colon = ctx.find_token_syntax_at_offset(T![::])?;
let path = ast::Path::cast(colon_colon.parent()?)?.qualifier()?;
diff --git a/crates/ide-assists/src/handlers/term_search.rs b/crates/ide-assists/src/handlers/term_search.rs
index 849dfa49dd..5642f10a6d 100644
--- a/crates/ide-assists/src/handlers/term_search.rs
+++ b/crates/ide-assists/src/handlers/term_search.rs
@@ -10,7 +10,7 @@ use syntax::{AstNode, ast};
use crate::assist_context::{AssistContext, Assists};
-pub(crate) fn term_search(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn term_search(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let unexpanded = ctx.find_node_at_offset::<ast::MacroCall>()?;
let syntax = unexpanded.syntax();
let goal_range = syntax.text_range();
diff --git a/crates/ide-assists/src/handlers/toggle_async_sugar.rs b/crates/ide-assists/src/handlers/toggle_async_sugar.rs
index fa6ccb9a5f..99be89ece1 100644
--- a/crates/ide-assists/src/handlers/toggle_async_sugar.rs
+++ b/crates/ide-assists/src/handlers/toggle_async_sugar.rs
@@ -27,7 +27,7 @@ use crate::{AssistContext, Assists};
// ```
pub(crate) fn sugar_impl_future_into_async(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let ret_type: ast::RetType = ctx.find_node_at_offset()?;
let function = ret_type.syntax().parent().and_then(ast::Fn::cast)?;
@@ -117,7 +117,7 @@ pub(crate) fn sugar_impl_future_into_async(
// ```
pub(crate) fn desugar_async_into_impl_future(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
) -> Option<()> {
let async_token = ctx.find_token_syntax_at_offset(SyntaxKind::ASYNC_KW)?;
let function = async_token.parent().and_then(ast::Fn::cast)?;
diff --git a/crates/ide-assists/src/handlers/toggle_ignore.rs b/crates/ide-assists/src/handlers/toggle_ignore.rs
index a088fb178d..35c304b387 100644
--- a/crates/ide-assists/src/handlers/toggle_ignore.rs
+++ b/crates/ide-assists/src/handlers/toggle_ignore.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, Assists, utils::test_related_attribute_syn}
// assert_eq!(2 + 2, 5);
// }
// ```
-pub(crate) fn toggle_ignore(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn toggle_ignore(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let attr: ast::Attr = ctx.find_node_at_offset()?;
let func = attr.syntax().parent().and_then(ast::Fn::cast)?;
let attr = test_related_attribute_syn(&func)?;
diff --git a/crates/ide-assists/src/handlers/toggle_macro_delimiter.rs b/crates/ide-assists/src/handlers/toggle_macro_delimiter.rs
index 4d375080f5..1dec094d9a 100644
--- a/crates/ide-assists/src/handlers/toggle_macro_delimiter.rs
+++ b/crates/ide-assists/src/handlers/toggle_macro_delimiter.rs
@@ -26,7 +26,7 @@ use crate::{AssistContext, Assists};
//
// sth!{ }
// ```
-pub(crate) fn toggle_macro_delimiter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn toggle_macro_delimiter(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
#[derive(Debug)]
enum MacroDelims {
LPar,
diff --git a/crates/ide-assists/src/handlers/unmerge_imports.rs b/crates/ide-assists/src/handlers/unmerge_imports.rs
index ab6317ad44..ec5c0929b4 100644
--- a/crates/ide-assists/src/handlers/unmerge_imports.rs
+++ b/crates/ide-assists/src/handlers/unmerge_imports.rs
@@ -21,7 +21,7 @@ use crate::{
// use std::fmt::{Debug};
// use std::fmt::Display;
// ```
-pub(crate) fn unmerge_imports(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unmerge_imports(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (editor, _) = SyntaxEditor::new(ctx.source_file().syntax().clone());
let make = editor.make();
let tree = ctx.find_node_at_offset::<ast::UseTree>()?;
diff --git a/crates/ide-assists/src/handlers/unmerge_match_arm.rs b/crates/ide-assists/src/handlers/unmerge_match_arm.rs
index 65300ccefd..555d3d2ee9 100644
--- a/crates/ide-assists/src/handlers/unmerge_match_arm.rs
+++ b/crates/ide-assists/src/handlers/unmerge_match_arm.rs
@@ -30,7 +30,7 @@ use crate::{AssistContext, AssistId, Assists};
// }
// }
// ```
-pub(crate) fn unmerge_match_arm(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unmerge_match_arm(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let pipe_token = ctx.find_token_syntax_at_offset(T![|])?;
let or_pat = ast::OrPat::cast(pipe_token.parent()?)?;
if or_pat.leading_pipe().is_some_and(|it| it == pipe_token) {
diff --git a/crates/ide-assists/src/handlers/unnecessary_async.rs b/crates/ide-assists/src/handlers/unnecessary_async.rs
index b9385775b4..5542180362 100644
--- a/crates/ide-assists/src/handlers/unnecessary_async.rs
+++ b/crates/ide-assists/src/handlers/unnecessary_async.rs
@@ -28,7 +28,7 @@ use crate::{AssistContext, Assists};
// pub fn foo() {}
// pub async fn bar() { foo() }
// ```
-pub(crate) fn unnecessary_async(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unnecessary_async(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let function: ast::Fn = ctx.find_node_at_offset()?;
// Do nothing if the cursor isn't on the async token.
@@ -91,7 +91,7 @@ pub(crate) fn unnecessary_async(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
}
fn find_all_references(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
def: &Definition,
) -> impl Iterator<Item = (EditionedFileId, FileReference)> {
def.usages(&ctx.sema).all().into_iter().flat_map(|(file_id, references)| {
@@ -101,7 +101,7 @@ fn find_all_references(
/// Finds the await expression for the given `NameRef`.
/// If no await expression is found, returns None.
-fn find_await_expression(ctx: &AssistContext<'_>, nameref: &NameRef) -> Option<ast::AwaitExpr> {
+fn find_await_expression(ctx: &AssistContext<'_, '_>, nameref: &NameRef) -> Option<ast::AwaitExpr> {
// From the nameref, walk up the tree to the await expression.
let await_expr = if let Some(path) = full_path_of_name_ref(nameref) {
// Function calls.
diff --git a/crates/ide-assists/src/handlers/unqualify_method_call.rs b/crates/ide-assists/src/handlers/unqualify_method_call.rs
index 045a272952..242ebc4063 100644
--- a/crates/ide-assists/src/handlers/unqualify_method_call.rs
+++ b/crates/ide-assists/src/handlers/unqualify_method_call.rs
@@ -22,7 +22,7 @@ use crate::{AssistContext, AssistId, Assists};
// }
// # mod std { pub mod ops { pub trait Add { fn add(self, _: Self) {} } impl Add for i32 {} } }
// ```
-pub(crate) fn unqualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unqualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let call = ctx.find_node_at_offset::<ast::CallExpr>()?;
let ast::Expr::PathExpr(path_expr) = call.expr()? else { return None };
let path = path_expr.path()?;
@@ -77,7 +77,7 @@ pub(crate) fn unqualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_>)
fn add_import(
qualifier: ast::Path,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
editor: &syntax::syntax_editor::SyntaxEditor,
) {
if let Some(path_segment) = qualifier.segment() {
diff --git a/crates/ide-assists/src/handlers/unwrap_branch.rs b/crates/ide-assists/src/handlers/unwrap_branch.rs
index dba8c03367..a018451f61 100644
--- a/crates/ide-assists/src/handlers/unwrap_branch.rs
+++ b/crates/ide-assists/src/handlers/unwrap_branch.rs
@@ -29,7 +29,7 @@ use crate::{AssistContext, AssistId, Assists};
// println!("foo");
// }
// ```
-pub(crate) fn unwrap_branch(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unwrap_branch(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let (editor, _) = SyntaxEditor::new(ctx.source_file().syntax().clone());
let place = unwrap_branch_place(ctx)?;
let target = place.syntax().text_range();
@@ -115,7 +115,7 @@ pub(crate) fn unwrap_branch(acc: &mut Assists, ctx: &AssistContext<'_>) -> Optio
// }
// }
// ```
-pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let l_curly_token = ctx.find_token_syntax_at_offset(T!['{'])?;
let block = l_curly_token.parent_ancestors().nth(1).and_then(ast::BlockExpr::cast)?;
let target = block.syntax().text_range();
@@ -182,7 +182,7 @@ fn wrap_let(assign: &ast::LetStmt, replacement: ast::BlockExpr) -> ast::BlockExp
try_wrap_assign().unwrap_or(replacement)
}
-fn unwrap_branch_place(ctx: &AssistContext<'_>) -> Option<ast::Expr> {
+fn unwrap_branch_place(ctx: &AssistContext<'_, '_>) -> Option<ast::Expr> {
if let Some(l_curly_token) = ctx.find_token_syntax_at_offset(T!['{']) {
let block = l_curly_token.parent_ancestors().nth(1).and_then(ast::BlockExpr::cast)?;
Some(block.into())
diff --git a/crates/ide-assists/src/handlers/unwrap_return_type.rs b/crates/ide-assists/src/handlers/unwrap_return_type.rs
index 1fe9ea4eb8..608c68ea85 100644
--- a/crates/ide-assists/src/handlers/unwrap_return_type.rs
+++ b/crates/ide-assists/src/handlers/unwrap_return_type.rs
@@ -37,7 +37,7 @@ use crate::{AssistContext, AssistId, Assists};
// fn foo() -> i32 { 42i32 }
// ```
-pub(crate) fn unwrap_return_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unwrap_return_type(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
let parent = ret_type.syntax().parent()?;
let body_expr = match_ast! {
diff --git a/crates/ide-assists/src/handlers/unwrap_tuple.rs b/crates/ide-assists/src/handlers/unwrap_tuple.rs
index e03274bbb3..7d0205afe3 100644
--- a/crates/ide-assists/src/handlers/unwrap_tuple.rs
+++ b/crates/ide-assists/src/handlers/unwrap_tuple.rs
@@ -25,7 +25,7 @@ use crate::{AssistContext, AssistId, Assists};
// let bar = "Bar";
// }
// ```
-pub(crate) fn unwrap_tuple(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unwrap_tuple(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let let_kw = ctx.find_token_syntax_at_offset(T![let])?;
let let_stmt = let_kw.parent().and_then(Either::<ast::LetStmt, ast::LetExpr>::cast)?;
let mut indent_level = let_stmt.indent_level();
diff --git a/crates/ide-assists/src/handlers/unwrap_type_to_generic_arg.rs b/crates/ide-assists/src/handlers/unwrap_type_to_generic_arg.rs
index 935ae18905..0c8e40bca1 100644
--- a/crates/ide-assists/src/handlers/unwrap_type_to_generic_arg.rs
+++ b/crates/ide-assists/src/handlers/unwrap_type_to_generic_arg.rs
@@ -21,7 +21,10 @@ use crate::{AssistContext, Assists};
// todo!()
// }
// ```
-pub(crate) fn unwrap_type_to_generic_arg(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn unwrap_type_to_generic_arg(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+) -> Option<()> {
let path_type = ctx.find_node_at_offset::<ast::PathType>()?;
let path = path_type.path()?;
let segment = path.segment()?;
diff --git a/crates/ide-assists/src/handlers/wrap_return_type.rs b/crates/ide-assists/src/handlers/wrap_return_type.rs
index ddc0af31c3..f9c103aab8 100644
--- a/crates/ide-assists/src/handlers/wrap_return_type.rs
+++ b/crates/ide-assists/src/handlers/wrap_return_type.rs
@@ -40,7 +40,7 @@ use crate::{AssistContext, AssistId, Assists};
// fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }
// ```
-pub(crate) fn wrap_return_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn wrap_return_type(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
let parent = ret_type.syntax().parent()?;
let body_expr = match_ast! {
@@ -212,7 +212,7 @@ impl WrapperKind {
// Try to find an wrapper type alias in the current scope (shadowing the default).
fn wrapper_alias<'db>(
- ctx: &AssistContext<'db>,
+ ctx: &AssistContext<'_, 'db>,
make: &SyntaxFactory,
core_wrapper: hir::Enum,
ast_ret_type: &ast::Type,
diff --git a/crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs b/crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs
index 635fab857d..94bd29049d 100644
--- a/crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs
+++ b/crates/ide-assists/src/handlers/wrap_unwrap_cfg_attr.rs
@@ -106,7 +106,7 @@ fn attempt_get_derive(attr: ast::Attr, ident: SyntaxToken) -> WrapUnwrapOption {
attempt_attr().unwrap_or_else(|| WrapUnwrapOption::WrapAttr(vec![attr]))
}
}
-pub(crate) fn wrap_unwrap_cfg_attr(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+pub(crate) fn wrap_unwrap_cfg_attr(acc: &mut Assists, ctx: &AssistContext<'_, '_>) -> Option<()> {
let option = if ctx.has_empty_selection() {
let ident = ctx.find_token_syntax_at_offset(T![ident]);
let attr = ctx.find_node_at_offset::<ast::Attr>();
@@ -161,7 +161,7 @@ pub(crate) fn wrap_unwrap_cfg_attr(acc: &mut Assists, ctx: &AssistContext<'_>) -
fn wrap_derive(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
attr: ast::Attr,
derive_element: TextRange,
) -> Option<()> {
@@ -232,7 +232,11 @@ fn wrap_derive(
Some(())
}
-fn wrap_cfg_attrs(acc: &mut Assists, ctx: &AssistContext<'_>, attrs: Vec<ast::Attr>) -> Option<()> {
+fn wrap_cfg_attrs(
+ acc: &mut Assists,
+ ctx: &AssistContext<'_, '_>,
+ attrs: Vec<ast::Attr>,
+) -> Option<()> {
let (first_attr, last_attr) = (attrs.first()?, attrs.last()?);
let range = first_attr.syntax().text_range().cover(last_attr.syntax().text_range());
let handle_source_change = |edit: &mut SourceChangeBuilder| {
@@ -268,7 +272,7 @@ fn wrap_cfg_attrs(acc: &mut Assists, ctx: &AssistContext<'_>, attrs: Vec<ast::At
fn unwrap_cfg_attr(
acc: &mut Assists,
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
meta: ast::CfgAttrMeta,
) -> Option<()> {
let top_attr = ast::Meta::from(meta.clone()).parent_attr()?;
diff --git a/crates/ide-assists/src/lib.rs b/crates/ide-assists/src/lib.rs
index 18ff63470d..eabcb8093e 100644
--- a/crates/ide-assists/src/lib.rs
+++ b/crates/ide-assists/src/lib.rs
@@ -102,7 +102,7 @@ pub fn assists(
mod handlers {
use crate::{AssistContext, Assists};
- pub(crate) type Handler = fn(&mut Assists, &AssistContext<'_>) -> Option<()>;
+ pub(crate) type Handler = fn(&mut Assists, &AssistContext<'_, '_>) -> Option<()>;
mod add_braces;
mod add_explicit_dot_deref;
diff --git a/crates/ide-assists/src/utils.rs b/crates/ide-assists/src/utils.rs
index 8efc1bb230..9d3af35ee5 100644
--- a/crates/ide-assists/src/utils.rs
+++ b/crates/ide-assists/src/utils.rs
@@ -222,7 +222,7 @@ pub fn add_trait_assoc_items_to_impl(
let item_prettified = prettify_macro_expansion(
sema.db,
original_item.syntax().clone(),
- &span_map,
+ span_map,
target_scope.krate().into(),
);
if let Some(formatted) = ast::AssocItem::cast(item_prettified) {
@@ -382,18 +382,21 @@ pub(crate) fn does_pat_match_variant(pat: &ast::Pat, var: &ast::Pat) -> bool {
pat_head == var_head
}
-pub(crate) fn does_pat_variant_nested_or_literal(ctx: &AssistContext<'_>, pat: &ast::Pat) -> bool {
+pub(crate) fn does_pat_variant_nested_or_literal(
+ ctx: &AssistContext<'_, '_>,
+ pat: &ast::Pat,
+) -> bool {
check_pat_variant_nested_or_literal_with_depth(ctx, pat, 0)
}
-fn check_pat_variant_from_enum(ctx: &AssistContext<'_>, pat: &ast::Pat) -> bool {
+fn check_pat_variant_from_enum(ctx: &AssistContext<'_, '_>, pat: &ast::Pat) -> bool {
ctx.sema.type_of_pat(pat).is_none_or(|ty: hir::TypeInfo<'_>| {
ty.adjusted().as_adt().is_some_and(|adt| matches!(adt, hir::Adt::Enum(_)))
})
}
fn check_pat_variant_nested_or_literal_with_depth(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
pat: &ast::Pat,
depth_after_refutable: usize,
) -> bool {
@@ -480,7 +483,7 @@ pub(crate) fn expr_fill_default(config: &AssistConfig) -> ast::Expr {
/// - `Some(None)`: no impl exists.
/// - `Some(Some(_))`: an impl exists, with no matching function names.
pub(crate) fn find_struct_impl(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
adt: &ast::Adt,
names: &[String],
) -> Option<Option<ast::Impl>> {
@@ -1029,7 +1032,7 @@ pub(crate) fn add_group_separators(s: &str, group_size: usize) -> String {
/// Replaces the record expression, handling field shorthands including inside macros.
pub(crate) fn replace_record_field_expr(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
edit: &mut SourceChangeBuilder,
record_field: ast::RecordExprField,
initializer: ast::Expr,
diff --git a/crates/ide-assists/src/utils/ref_field_expr.rs b/crates/ide-assists/src/utils/ref_field_expr.rs
index fc9bf210e4..d2b02b3373 100644
--- a/crates/ide-assists/src/utils/ref_field_expr.rs
+++ b/crates/ide-assists/src/utils/ref_field_expr.rs
@@ -13,7 +13,7 @@ use crate::AssistContext;
/// Decides whether the new path expression needs to be dereferenced and/or wrapped in parens.
/// Returns the relevant parent expression to replace and the [RefData].
pub(crate) fn determine_ref_and_parens(
- ctx: &AssistContext<'_>,
+ ctx: &AssistContext<'_, '_>,
field_expr: &FieldExpr,
) -> (ast::Expr, RefData) {
let s = field_expr.syntax();
@@ -62,8 +62,8 @@ pub(crate) fn determine_ref_and_parens(
// other combinations (`&value` -> `value`, `&&value` -> `&value`, `&value` -> `&&value`) might or might not be able to auto-ref/deref,
// but there might be trait implementations an added `&` might resolve to
// -> ONLY handle auto-ref from `value` to `&value`
- fn is_auto_ref(ctx: &AssistContext<'_>, call_expr: &MethodCallExpr) -> bool {
- fn impl_(ctx: &AssistContext<'_>, call_expr: &MethodCallExpr) -> Option<bool> {
+ fn is_auto_ref(ctx: &AssistContext<'_, '_>, call_expr: &MethodCallExpr) -> bool {
+ fn impl_(ctx: &AssistContext<'_, '_>, call_expr: &MethodCallExpr) -> Option<bool> {
let rec = call_expr.receiver()?;
let rec_ty = ctx.sema.type_of_expr(&rec)?.original();
// input must be actual value
diff --git a/crates/ide-completion/src/completions.rs b/crates/ide-completion/src/completions.rs
index ed972a1e2a..f3190bbbc8 100644
--- a/crates/ide-completion/src/completions.rs
+++ b/crates/ide-completion/src/completions.rs
@@ -87,7 +87,7 @@ impl Completions {
}
}
- pub(crate) fn add_keyword(&mut self, ctx: &CompletionContext<'_>, keyword: &'static str) {
+ pub(crate) fn add_keyword(&mut self, ctx: &CompletionContext<'_, '_>, keyword: &'static str) {
let item = CompletionItem::new(
CompletionItemKind::Keyword,
ctx.source_range(),
@@ -97,7 +97,7 @@ impl Completions {
item.add_to(self, ctx.db);
}
- pub(crate) fn add_nameref_keywords_with_colon(&mut self, ctx: &CompletionContext<'_>) {
+ pub(crate) fn add_nameref_keywords_with_colon(&mut self, ctx: &CompletionContext<'_, '_>) {
["self::", "crate::"].into_iter().for_each(|kw| self.add_keyword(ctx, kw));
if ctx.depth_from_crate_root > 0 {
@@ -107,7 +107,7 @@ impl Completions {
pub(crate) fn add_nameref_keywords_with_type_like(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
) {
let mut add_keyword = |kw| {
@@ -120,7 +120,7 @@ impl Completions {
}
}
- pub(crate) fn add_nameref_keywords(&mut self, ctx: &CompletionContext<'_>) {
+ pub(crate) fn add_nameref_keywords(&mut self, ctx: &CompletionContext<'_, '_>) {
["self", "crate"].into_iter().for_each(|kw| self.add_keyword(ctx, kw));
if ctx.depth_from_crate_root > 0 {
@@ -130,7 +130,7 @@ impl Completions {
pub(crate) fn add_type_keywords(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
) {
let mut add_keyword = |kw, snippet| {
@@ -145,7 +145,7 @@ impl Completions {
pub(crate) fn add_super_keyword(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
super_chain_len: Option<usize>,
) {
if let Some(len) = super_chain_len
@@ -158,7 +158,7 @@ impl Completions {
pub(crate) fn add_keyword_snippet_expr(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
incomplete_let: bool,
kw: &str,
snippet: &str,
@@ -185,7 +185,7 @@ impl Completions {
pub(crate) fn add_keyword_snippet(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
kw: &str,
snippet: &str,
) {
@@ -201,7 +201,7 @@ impl Completions {
pub(crate) fn add_expr(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
expr: &hir::term_search::Expr<'_>,
) {
if let Some(item) = render_expr(ctx, expr) {
@@ -211,7 +211,7 @@ impl Completions {
pub(crate) fn add_crate_roots(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
) {
ctx.process_all_names(&mut |name, res, doc_aliases| match res {
@@ -224,7 +224,7 @@ impl Completions {
pub(crate) fn add_path_resolution(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
local_name: hir::Name,
resolution: hir::ScopeDef,
@@ -246,7 +246,7 @@ impl Completions {
pub(crate) fn add_pattern_resolution(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
local_name: hir::Name,
resolution: hir::ScopeDef,
@@ -267,7 +267,7 @@ impl Completions {
pub(crate) fn add_enum_variants(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
e: hir::Enum,
) {
@@ -278,7 +278,7 @@ impl Completions {
pub(crate) fn add_module(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
module: hir::Module,
local_name: hir::Name,
@@ -295,7 +295,7 @@ impl Completions {
pub(crate) fn add_macro(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
mac: hir::Macro,
local_name: hir::Name,
@@ -316,7 +316,7 @@ impl Completions {
pub(crate) fn add_function(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
func: hir::Function,
local_name: Option<hir::Name>,
@@ -338,7 +338,7 @@ impl Completions {
pub(crate) fn add_method(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
dot_access: &DotAccess<'_>,
func: hir::Function,
receiver: Option<SmolStr>,
@@ -362,7 +362,7 @@ impl Completions {
pub(crate) fn add_method_with_import(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
dot_access: &DotAccess<'_>,
func: hir::Function,
import: LocatedImport,
@@ -386,7 +386,7 @@ impl Completions {
.add_to(self, ctx.db);
}
- pub(crate) fn add_const(&mut self, ctx: &CompletionContext<'_>, konst: hir::Const) {
+ pub(crate) fn add_const(&mut self, ctx: &CompletionContext<'_, '_>, konst: hir::Const) {
let is_private_editable = match ctx.is_visible(&konst) {
Visible::Yes => false,
Visible::Editable => true,
@@ -400,7 +400,7 @@ impl Completions {
pub(crate) fn add_type_alias(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
type_alias: hir::TypeAlias,
) {
let is_private_editable = match ctx.is_visible(&type_alias) {
@@ -416,7 +416,7 @@ impl Completions {
pub(crate) fn add_type_alias_with_eq(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
type_alias: hir::TypeAlias,
) {
if !ctx.check_stability(Some(&type_alias.attrs(ctx.db))) {
@@ -427,7 +427,7 @@ impl Completions {
pub(crate) fn add_qualified_enum_variant(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
variant: hir::EnumVariant,
path: hir::ModPath,
@@ -444,7 +444,7 @@ impl Completions {
pub(crate) fn add_enum_variant(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
variant: hir::EnumVariant,
local_name: Option<hir::Name>,
@@ -467,7 +467,7 @@ impl Completions {
pub(crate) fn add_field(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
dot_access: &DotAccess<'_>,
receiver: Option<SmolStr>,
field: hir::Field,
@@ -491,7 +491,7 @@ impl Completions {
pub(crate) fn add_struct_literal(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
strukt: hir::Struct,
path: Option<hir::ModPath>,
@@ -515,7 +515,7 @@ impl Completions {
pub(crate) fn add_union_literal(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
un: hir::Union,
path: Option<hir::ModPath>,
local_name: Option<hir::Name>,
@@ -536,7 +536,7 @@ impl Completions {
pub(crate) fn add_tuple_field(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
receiver: Option<SmolStr>,
field: usize,
ty: &hir::Type<'_>,
@@ -547,7 +547,7 @@ impl Completions {
self.add(item);
}
- pub(crate) fn add_lifetime(&mut self, ctx: &CompletionContext<'_>, name: hir::Name) {
+ pub(crate) fn add_lifetime(&mut self, ctx: &CompletionContext<'_, '_>, name: hir::Name) {
CompletionItem::new(
SymbolKind::LifetimeParam,
ctx.source_range(),
@@ -557,7 +557,7 @@ impl Completions {
.add_to(self, ctx.db)
}
- pub(crate) fn add_label(&mut self, ctx: &CompletionContext<'_>, name: hir::Name) {
+ pub(crate) fn add_label(&mut self, ctx: &CompletionContext<'_, '_>, name: hir::Name) {
CompletionItem::new(
SymbolKind::Label,
ctx.source_range(),
@@ -569,7 +569,7 @@ impl Completions {
pub(crate) fn add_variant_pat(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
path_ctx: Option<&PathCompletionCtx<'_>>,
variant: hir::EnumVariant,
@@ -590,7 +590,7 @@ impl Completions {
pub(crate) fn add_qualified_variant_pat(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
variant: hir::EnumVariant,
path: hir::ModPath,
@@ -611,7 +611,7 @@ impl Completions {
pub(crate) fn add_struct_pat(
&mut self,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
strukt: hir::Struct,
local_name: Option<hir::Name>,
@@ -629,7 +629,7 @@ impl Completions {
));
}
- pub(crate) fn suggest_name(&mut self, ctx: &CompletionContext<'_>, name: &str) {
+ pub(crate) fn suggest_name(&mut self, ctx: &CompletionContext<'_, '_>, name: &str) {
let item = CompletionItem::new(
CompletionItemKind::Binding,
ctx.source_range(),
@@ -644,10 +644,10 @@ impl Completions {
/// Skips variants that are visible with single segment paths.
fn enum_variants_with_paths(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
enum_: hir::Enum,
impl_: Option<&ast::Impl>,
- cb: impl Fn(&mut Completions, &CompletionContext<'_>, hir::EnumVariant, hir::ModPath),
+ cb: impl Fn(&mut Completions, &CompletionContext<'_, '_>, hir::EnumVariant, hir::ModPath),
) {
let mut process_variant = |variant: EnumVariant| {
let self_path = hir::ModPath::from_segments(
@@ -683,7 +683,7 @@ fn enum_variants_with_paths(
pub(super) fn complete_name(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
NameContext { name, kind }: &NameContext,
) {
match kind {
@@ -724,10 +724,10 @@ pub(super) fn complete_name(
}
}
-pub(super) fn complete_name_ref(
+pub(super) fn complete_name_ref<'db>(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
- NameRefContext { nameref, kind }: &NameRefContext<'_>,
+ ctx: &CompletionContext<'_, 'db>,
+ NameRefContext { nameref, kind }: &NameRefContext<'db>,
) {
match kind {
NameRefKind::Path(path_ctx) => {
@@ -813,7 +813,7 @@ pub(super) fn complete_name_ref(
fn complete_patterns(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
) {
flyimport::import_on_the_fly_pat(acc, ctx, pattern_ctx);
diff --git a/crates/ide-completion/src/completions/attribute.rs b/crates/ide-completion/src/completions/attribute.rs
index 0ce0dde2e2..df513dd8fd 100644
--- a/crates/ide-completion/src/completions/attribute.rs
+++ b/crates/ide-completion/src/completions/attribute.rs
@@ -31,7 +31,7 @@ pub(crate) use self::derive::complete_derive_path;
/// Complete inputs to known builtin attributes as well as derive attributes
pub(crate) fn complete_known_attribute_input(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
colon_prefix: bool,
fake_attribute_under_caret: &ast::TokenTreeMeta,
extern_crate: Option<&ast::ExternCrate>,
@@ -70,7 +70,7 @@ pub(crate) fn complete_known_attribute_input(
pub(crate) fn complete_attribute_path(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
&AttrCtx { kind, annotated_item_kind, ref derive_helpers }: &AttrCtx,
) {
diff --git a/crates/ide-completion/src/completions/attribute/cfg.rs b/crates/ide-completion/src/completions/attribute/cfg.rs
index 1bd6e6d9bf..1672e8e793 100644
--- a/crates/ide-completion/src/completions/attribute/cfg.rs
+++ b/crates/ide-completion/src/completions/attribute/cfg.rs
@@ -6,7 +6,7 @@ use syntax::{AstToken, Direction, NodeOrToken, SmolStr, SyntaxKind, algo, ast::I
use crate::{CompletionItem, completions::Completions, context::CompletionContext};
-pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext<'_>) {
+pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext<'_, '_>) {
let add_completion = |item: &str| {
let mut completion =
CompletionItem::new(SymbolKind::BuiltinAttr, ctx.source_range(), item, ctx.edition);
diff --git a/crates/ide-completion/src/completions/attribute/derive.rs b/crates/ide-completion/src/completions/attribute/derive.rs
index 57ea609a40..9e7dabbd01 100644
--- a/crates/ide-completion/src/completions/attribute/derive.rs
+++ b/crates/ide-completion/src/completions/attribute/derive.rs
@@ -12,7 +12,7 @@ use crate::{
pub(crate) fn complete_derive_path(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
existing_derives: &ExistingDerives,
) {
diff --git a/crates/ide-completion/src/completions/attribute/diagnostic.rs b/crates/ide-completion/src/completions/attribute/diagnostic.rs
index 0899bbff14..1a2e5652e1 100644
--- a/crates/ide-completion/src/completions/attribute/diagnostic.rs
+++ b/crates/ide-completion/src/completions/attribute/diagnostic.rs
@@ -9,7 +9,7 @@ use super::AttrCompletion;
pub(super) fn complete_on_unimplemented(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
existing_keys: &[ast::Expr],
) {
for attr in ATTRIBUTE_ARGS {
diff --git a/crates/ide-completion/src/completions/attribute/feature.rs b/crates/ide-completion/src/completions/attribute/feature.rs
index 1e6baca864..1bcf05faa8 100644
--- a/crates/ide-completion/src/completions/attribute/feature.rs
+++ b/crates/ide-completion/src/completions/attribute/feature.rs
@@ -10,7 +10,7 @@ use crate::{Completions, context::CompletionContext, item::CompletionItem};
pub(super) fn complete_feature(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
existing_features: &[ast::Path],
) {
for &Lint { label, description, .. } in FEATURES {
diff --git a/crates/ide-completion/src/completions/attribute/lint.rs b/crates/ide-completion/src/completions/attribute/lint.rs
index f810196bfe..2f957b5a55 100644
--- a/crates/ide-completion/src/completions/attribute/lint.rs
+++ b/crates/ide-completion/src/completions/attribute/lint.rs
@@ -10,7 +10,7 @@ use crate::{Completions, context::CompletionContext, item::CompletionItem};
pub(super) fn complete_lint(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
is_qualified: bool,
existing_lints: &[ast::Path],
) {
diff --git a/crates/ide-completion/src/completions/attribute/macro_use.rs b/crates/ide-completion/src/completions/attribute/macro_use.rs
index 9c0fe0055d..618cf6fd01 100644
--- a/crates/ide-completion/src/completions/attribute/macro_use.rs
+++ b/crates/ide-completion/src/completions/attribute/macro_use.rs
@@ -7,7 +7,7 @@ use crate::{Completions, context::CompletionContext, item::CompletionItem};
pub(super) fn complete_macro_use(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
extern_crate: Option<&ast::ExternCrate>,
existing_imports: &[ast::Path],
) {
diff --git a/crates/ide-completion/src/completions/attribute/repr.rs b/crates/ide-completion/src/completions/attribute/repr.rs
index b04358963a..63cddb365e 100644
--- a/crates/ide-completion/src/completions/attribute/repr.rs
+++ b/crates/ide-completion/src/completions/attribute/repr.rs
@@ -7,7 +7,7 @@ use crate::{Completions, context::CompletionContext, item::CompletionItem};
pub(super) fn complete_repr(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
existing_reprs: &[ast::Expr],
) {
for &ReprCompletion { label, snippet, lookup, collides } in REPR_COMPLETIONS {
diff --git a/crates/ide-completion/src/completions/dot.rs b/crates/ide-completion/src/completions/dot.rs
index 18c1992afa..31a8ed2c13 100644
--- a/crates/ide-completion/src/completions/dot.rs
+++ b/crates/ide-completion/src/completions/dot.rs
@@ -18,7 +18,7 @@ use crate::{
/// Complete dot accesses, i.e. fields or methods.
pub(crate) fn complete_dot(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
dot_access: &DotAccess<'_>,
) {
let receiver_ty = match dot_access {
@@ -126,7 +126,7 @@ pub(crate) fn complete_dot(
pub(crate) fn complete_undotted_self(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
expr_ctx: &PathExprCtx<'_>,
) {
@@ -198,7 +198,7 @@ pub(crate) fn complete_undotted_self(
fn complete_fields(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
receiver: &hir::Type<'_>,
mut named_field: impl FnMut(&mut Completions, hir::Field, hir::Type<'_>),
mut tuple_index: impl FnMut(&mut Completions, usize, hir::Type<'_>),
@@ -227,13 +227,13 @@ fn complete_fields(
}
fn complete_methods(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
receiver: &hir::Type<'_>,
traits_in_scope: &FxHashSet<hir::TraitId>,
f: impl FnMut(hir::Function),
) {
- struct Callback<'a, F> {
- ctx: &'a CompletionContext<'a>,
+ struct Callback<'a, 'db, F> {
+ ctx: &'a CompletionContext<'a, 'db>,
f: F,
// We deliberately deduplicate by function ID and not name, because while inherent methods cannot be
// duplicated, trait methods can. And it is still useful to show all of them (even when there
@@ -241,7 +241,7 @@ fn complete_methods(
seen_methods: FxHashSet<Function>,
}
- impl<F> MethodCandidateCallback for Callback<'_, F>
+ impl<F> MethodCandidateCallback for Callback<'_, '_, F>
where
F: FnMut(hir::Function),
{
diff --git a/crates/ide-completion/src/completions/env_vars.rs b/crates/ide-completion/src/completions/env_vars.rs
index 885d1a3075..30662877d6 100644
--- a/crates/ide-completion/src/completions/env_vars.rs
+++ b/crates/ide-completion/src/completions/env_vars.rs
@@ -47,7 +47,7 @@ const CARGO_DEFINED_VARS: &[(&str, &str)] = &[
pub(crate) fn complete_cargo_env_vars(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
original: &ast::String,
expanded: &ast::String,
) -> Option<()> {
diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs
index c15c67173e..a2a4cbac21 100644
--- a/crates/ide-completion/src/completions/expr.rs
+++ b/crates/ide-completion/src/completions/expr.rs
@@ -12,14 +12,14 @@ use crate::{
context::{PathCompletionCtx, PathExprCtx, Qualified},
};
-struct PathCallback<'a, F> {
- ctx: &'a CompletionContext<'a>,
+struct PathCallback<'a, 'db, F> {
+ ctx: &'a CompletionContext<'a, 'db>,
acc: &'a mut Completions,
add_assoc_item: F,
seen: FxHashSet<hir::AssocItem>,
}
-impl<F> PathCandidateCallback for PathCallback<'_, F>
+impl<F> PathCandidateCallback for PathCallback<'_, '_, F>
where
F: FnMut(&mut Completions, hir::AssocItem),
{
@@ -46,7 +46,7 @@ where
pub(crate) fn complete_expr_path(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
expr_ctx: &PathExprCtx<'_>,
) {
@@ -458,7 +458,7 @@ pub(crate) fn complete_expr_path(
pub(crate) fn complete_expr(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
) {
let _p = tracing::info_span!("complete_expr").entered();
diff --git a/crates/ide-completion/src/completions/extern_abi.rs b/crates/ide-completion/src/completions/extern_abi.rs
index 570d1a0a2d..b00b2e1907 100644
--- a/crates/ide-completion/src/completions/extern_abi.rs
+++ b/crates/ide-completion/src/completions/extern_abi.rs
@@ -43,7 +43,7 @@ const SUPPORTED_CALLING_CONVENTIONS: &[&str] = &[
pub(crate) fn complete_extern_abi(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
expanded: &ast::String,
) -> Option<()> {
if !expanded.syntax().parent().is_some_and(|it| ast::Abi::can_cast(it.kind())) {
diff --git a/crates/ide-completion/src/completions/extern_crate.rs b/crates/ide-completion/src/completions/extern_crate.rs
index 91202e8b32..819db549d4 100644
--- a/crates/ide-completion/src/completions/extern_crate.rs
+++ b/crates/ide-completion/src/completions/extern_crate.rs
@@ -8,7 +8,7 @@ use crate::{CompletionItem, CompletionItemKind, context::CompletionContext};
use super::Completions;
-pub(crate) fn complete_extern_crate(acc: &mut Completions, ctx: &CompletionContext<'_>) {
+pub(crate) fn complete_extern_crate(acc: &mut Completions, ctx: &CompletionContext<'_, '_>) {
let imported_extern_crates: Vec<Name> = ctx.scope.extern_crate_decls().collect();
for (name, module) in ctx.scope.extern_crates() {
diff --git a/crates/ide-completion/src/completions/field.rs b/crates/ide-completion/src/completions/field.rs
index 26afa9c8ad..b4f7e1839d 100644
--- a/crates/ide-completion/src/completions/field.rs
+++ b/crates/ide-completion/src/completions/field.rs
@@ -7,7 +7,7 @@ use crate::{
pub(crate) fn complete_field_list_tuple_variant(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
) {
if ctx.qualifier_ctx.vis_node.is_some() {
@@ -28,7 +28,7 @@ pub(crate) fn complete_field_list_tuple_variant(
pub(crate) fn complete_field_list_record_variant(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
) {
if ctx.qualifier_ctx.vis_node.is_none() {
let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet);
diff --git a/crates/ide-completion/src/completions/flyimport.rs b/crates/ide-completion/src/completions/flyimport.rs
index 2cf87baf33..b350647b9a 100644
--- a/crates/ide-completion/src/completions/flyimport.rs
+++ b/crates/ide-completion/src/completions/flyimport.rs
@@ -108,10 +108,10 @@ use crate::{
// The feature can be forcefully turned off in the settings with the `rust-analyzer.completion.autoimport.enable` flag.
// Note that having this flag set to `true` does not guarantee that the feature is enabled: your client needs to have the corresponding
// capability enabled.
-pub(crate) fn import_on_the_fly_path(
+pub(crate) fn import_on_the_fly_path<'db>(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
- path_ctx: &PathCompletionCtx<'_>,
+ ctx: &CompletionContext<'_, 'db>,
+ path_ctx: &PathCompletionCtx<'db>,
) -> Option<()> {
if !ctx.config.enable_imports_on_the_fly {
return None;
@@ -155,7 +155,7 @@ pub(crate) fn import_on_the_fly_path(
pub(crate) fn import_on_the_fly_pat(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
) -> Option<()> {
if !ctx.config.enable_imports_on_the_fly {
@@ -178,10 +178,10 @@ pub(crate) fn import_on_the_fly_pat(
)
}
-pub(crate) fn import_on_the_fly_dot(
+pub(crate) fn import_on_the_fly_dot<'db>(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
- dot_access: &DotAccess<'_>,
+ ctx: &CompletionContext<'_, 'db>,
+ dot_access: &DotAccess<'db>,
) -> Option<()> {
if !ctx.config.enable_imports_on_the_fly {
return None;
@@ -206,11 +206,11 @@ pub(crate) fn import_on_the_fly_dot(
)
}
-fn import_on_the_fly(
+fn import_on_the_fly<'db>(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
- path_ctx @ PathCompletionCtx { kind, .. }: &PathCompletionCtx<'_>,
- import_assets: ImportAssets<'_>,
+ ctx: &CompletionContext<'_, 'db>,
+ path_ctx @ PathCompletionCtx { kind, .. }: &PathCompletionCtx<'db>,
+ import_assets: ImportAssets<'db>,
position: SyntaxNode,
potential_import_name: String,
) -> Option<()> {
@@ -292,11 +292,11 @@ fn import_on_the_fly(
Some(())
}
-fn import_on_the_fly_pat_(
+fn import_on_the_fly_pat_<'db>(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, 'db>,
pattern_ctx: &PatternContext,
- import_assets: ImportAssets<'_>,
+ import_assets: ImportAssets<'db>,
position: SyntaxNode,
potential_import_name: String,
) -> Option<()> {
@@ -338,11 +338,11 @@ fn import_on_the_fly_pat_(
Some(())
}
-fn import_on_the_fly_method(
+fn import_on_the_fly_method<'db>(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
- dot_access: &DotAccess<'_>,
- import_assets: ImportAssets<'_>,
+ ctx: &CompletionContext<'_, 'db>,
+ dot_access: &DotAccess<'db>,
+ import_assets: ImportAssets<'db>,
position: SyntaxNode,
potential_import_name: String,
) -> Option<()> {
@@ -378,7 +378,7 @@ fn import_on_the_fly_method(
Some(())
}
-fn filter_excluded_flyimport(ctx: &CompletionContext<'_>, import: &LocatedImport) -> bool {
+fn filter_excluded_flyimport(ctx: &CompletionContext<'_, '_>, import: &LocatedImport) -> bool {
let def = import.item_to_import.into_module_def();
let is_exclude_flyimport = ctx.exclude_flyimport.get(&def).copied();
@@ -400,14 +400,14 @@ fn filter_excluded_flyimport(ctx: &CompletionContext<'_>, import: &LocatedImport
true
}
-fn import_name(ctx: &CompletionContext<'_>) -> String {
+fn import_name(ctx: &CompletionContext<'_, '_>) -> String {
let token_kind = ctx.token.kind();
if token_kind.is_any_identifier() { ctx.token.to_string() } else { String::new() }
}
fn import_assets_for_path<'db>(
- ctx: &CompletionContext<'db>,
+ ctx: &CompletionContext<'_, 'db>,
path: Option<&ast::Path>,
potential_import_name: &str,
qualifier: Option<ast::Path>,
diff --git a/crates/ide-completion/src/completions/fn_param.rs b/crates/ide-completion/src/completions/fn_param.rs
index bd0b69215c..f1e8e5f39e 100644
--- a/crates/ide-completion/src/completions/fn_param.rs
+++ b/crates/ide-completion/src/completions/fn_param.rs
@@ -22,7 +22,7 @@ use crate::{
/// Also complete parameters for closure or local functions from the surrounding defined locals.
pub(crate) fn complete_fn_param(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
) -> Option<()> {
let (ParamContext { param_list, kind, param, .. }, impl_or_trait) = match pattern_ctx {
@@ -78,7 +78,7 @@ pub(crate) fn complete_fn_param(
}
fn fill_fn_params(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
function: &ast::Fn,
param_list: &ast::ParamList,
current_param: &ast::Param,
@@ -139,7 +139,7 @@ fn fill_fn_params(
}
fn params_from_stmt_list_scope(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
stmt_list: ast::StmtList,
mut cb: impl FnMut(hir::Name, String),
) {
@@ -196,7 +196,7 @@ fn should_add_self_completions(
}
}
-fn comma_wrapper(ctx: &CompletionContext<'_>) -> Option<(impl Fn(&str) -> SmolStr, TextRange)> {
+fn comma_wrapper(ctx: &CompletionContext<'_, '_>) -> Option<(impl Fn(&str) -> SmolStr, TextRange)> {
let param =
ctx.original_token.parent_ancestors().find(|node| node.kind() == SyntaxKind::PARAM)?;
diff --git a/crates/ide-completion/src/completions/format_string.rs b/crates/ide-completion/src/completions/format_string.rs
index eaacd8d1a8..1e52402185 100644
--- a/crates/ide-completion/src/completions/format_string.rs
+++ b/crates/ide-completion/src/completions/format_string.rs
@@ -10,7 +10,7 @@ use crate::{CompletionItem, CompletionItemKind, Completions, context::Completion
/// Complete identifiers in format strings.
pub(crate) fn format_string(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
original: &ast::String,
expanded: &ast::String,
) {
diff --git a/crates/ide-completion/src/completions/item_list.rs b/crates/ide-completion/src/completions/item_list.rs
index 39048e4400..1b26cab263 100644
--- a/crates/ide-completion/src/completions/item_list.rs
+++ b/crates/ide-completion/src/completions/item_list.rs
@@ -9,7 +9,7 @@ pub(crate) mod trait_impl;
pub(crate) fn complete_item_list_in_expr(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
expr_ctx: &PathExprCtx<'_>,
) {
@@ -24,7 +24,7 @@ pub(crate) fn complete_item_list_in_expr(
pub(crate) fn complete_item_list(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
kind: &ItemListKind,
) {
@@ -72,7 +72,11 @@ pub(crate) fn complete_item_list(
}
}
-fn add_keywords(acc: &mut Completions, ctx: &CompletionContext<'_>, kind: Option<&ItemListKind>) {
+fn add_keywords(
+ acc: &mut Completions,
+ ctx: &CompletionContext<'_, '_>,
+ kind: Option<&ItemListKind>,
+) {
let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet);
let in_item_list = matches!(kind, Some(ItemListKind::SourceFile | ItemListKind::Module) | None);
diff --git a/crates/ide-completion/src/completions/item_list/trait_impl.rs b/crates/ide-completion/src/completions/item_list/trait_impl.rs
index 9bac34885c..99d37b699f 100644
--- a/crates/ide-completion/src/completions/item_list/trait_impl.rs
+++ b/crates/ide-completion/src/completions/item_list/trait_impl.rs
@@ -59,7 +59,7 @@ enum ImplCompletionKind {
pub(crate) fn complete_trait_impl_const(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
name: &Option<ast::Name>,
) -> Option<()> {
complete_trait_impl_name(acc, ctx, name, ImplCompletionKind::Const)
@@ -67,7 +67,7 @@ pub(crate) fn complete_trait_impl_const(
pub(crate) fn complete_trait_impl_type_alias(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
name: &Option<ast::Name>,
) -> Option<()> {
complete_trait_impl_name(acc, ctx, name, ImplCompletionKind::TypeAlias)
@@ -75,7 +75,7 @@ pub(crate) fn complete_trait_impl_type_alias(
pub(crate) fn complete_trait_impl_fn(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
name: &Option<ast::Name>,
) -> Option<()> {
complete_trait_impl_name(acc, ctx, name, ImplCompletionKind::Fn)
@@ -83,7 +83,7 @@ pub(crate) fn complete_trait_impl_fn(
fn complete_trait_impl_name(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
name: &Option<ast::Name>,
kind: ImplCompletionKind,
) -> Option<()> {
@@ -122,7 +122,7 @@ fn complete_trait_impl_name(
pub(crate) fn complete_trait_impl_item_by_name(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
name_ref: &Option<ast::NameRef>,
impl_: &Option<ast::Impl>,
@@ -149,7 +149,7 @@ pub(crate) fn complete_trait_impl_item_by_name(
fn complete_trait_impl(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
kind: ImplCompletionKind,
replacement_range: TextRange,
impl_def: &ast::Impl,
@@ -178,7 +178,7 @@ fn complete_trait_impl(
fn add_function_impl(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
replacement_range: TextRange,
func: hir::Function,
impl_def: hir::Impl,
@@ -198,7 +198,7 @@ fn add_function_impl(
fn add_function_impl_(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
replacement_range: TextRange,
func: hir::Function,
impl_def: hir::Impl,
@@ -257,7 +257,7 @@ enum AsyncSugaring {
/// Transform a relevant associated item to inline generics from the impl, remove attrs and docs, etc.
fn get_transformed_assoc_item(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
assoc_item: ast::AssocItem,
impl_def: hir::Impl,
) -> Option<ast::AssocItem> {
@@ -281,7 +281,7 @@ fn get_transformed_assoc_item(
/// Transform a relevant associated item to inline generics from the impl, remove attrs and docs, etc.
fn get_transformed_fn(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
fn_: ast::Fn,
impl_def: hir::Impl,
async_: AsyncSugaring,
@@ -363,7 +363,7 @@ fn get_transformed_fn(
fn add_type_alias_impl(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
replacement_range: TextRange,
type_alias: hir::TypeAlias,
impl_def: hir::Impl,
@@ -444,7 +444,7 @@ fn add_type_alias_impl(
fn add_const_impl(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
replacement_range: TextRange,
const_: hir::Const,
impl_def: hir::Impl,
@@ -486,13 +486,13 @@ fn add_const_impl(
}
fn make_const_compl_syntax(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
const_: &ast::Const,
macro_file: Option<MacroCallId>,
) -> SmolStr {
let const_ = if let Some(macro_file) = macro_file {
let span_map = ctx.db.expansion_span_map(macro_file);
- prettify_macro_expansion(ctx.db, const_.syntax().clone(), &span_map, ctx.krate.into())
+ prettify_macro_expansion(ctx.db, const_.syntax().clone(), span_map, ctx.krate.into())
} else {
const_.syntax().clone()
};
@@ -514,13 +514,13 @@ fn make_const_compl_syntax(
}
fn function_declaration(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
node: &ast::Fn,
macro_file: Option<MacroCallId>,
) -> String {
let node = if let Some(macro_file) = macro_file {
let span_map = ctx.db.expansion_span_map(macro_file);
- prettify_macro_expansion(ctx.db, node.syntax().clone(), &span_map, ctx.krate.into())
+ prettify_macro_expansion(ctx.db, node.syntax().clone(), span_map, ctx.krate.into())
} else {
node.syntax().clone()
};
diff --git a/crates/ide-completion/src/completions/keyword.rs b/crates/ide-completion/src/completions/keyword.rs
index fbb3cde968..f7dd1589ae 100644
--- a/crates/ide-completion/src/completions/keyword.rs
+++ b/crates/ide-completion/src/completions/keyword.rs
@@ -6,7 +6,7 @@ use crate::{CompletionContext, Completions};
pub(crate) fn complete_for_and_where(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
keyword_item: &ast::Item,
) {
let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet);
diff --git a/crates/ide-completion/src/completions/lifetime.rs b/crates/ide-completion/src/completions/lifetime.rs
index 8902cd09ce..6291b42a03 100644
--- a/crates/ide-completion/src/completions/lifetime.rs
+++ b/crates/ide-completion/src/completions/lifetime.rs
@@ -17,7 +17,7 @@ use crate::{
/// Completes lifetimes.
pub(crate) fn complete_lifetime(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
lifetime_ctx: &LifetimeContext,
) {
let &LifetimeContext { kind: LifetimeKind::Lifetime { in_lifetime_param_bound, def }, .. } =
@@ -44,7 +44,7 @@ pub(crate) fn complete_lifetime(
/// Completes labels.
pub(crate) fn complete_label(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
lifetime_ctx: &LifetimeContext,
) {
if !matches!(lifetime_ctx, LifetimeContext { kind: LifetimeKind::LabelRef, .. }) {
diff --git a/crates/ide-completion/src/completions/macro_def.rs b/crates/ide-completion/src/completions/macro_def.rs
index 2c8e7a2e62..884b4dd966 100644
--- a/crates/ide-completion/src/completions/macro_def.rs
+++ b/crates/ide-completion/src/completions/macro_def.rs
@@ -4,7 +4,7 @@ use ide_db::SymbolKind;
use crate::{CompletionItem, Completions, context::CompletionContext};
-pub(crate) fn complete_macro_segment(acc: &mut Completions, ctx: &CompletionContext<'_>) {
+pub(crate) fn complete_macro_segment(acc: &mut Completions, ctx: &CompletionContext<'_, '_>) {
for &label in MACRO_SEGMENTS {
let item =
CompletionItem::new(SymbolKind::BuiltinAttr, ctx.source_range(), label, ctx.edition);
diff --git a/crates/ide-completion/src/completions/mod_.rs b/crates/ide-completion/src/completions/mod_.rs
index 3333300045..a8c6c82aac 100644
--- a/crates/ide-completion/src/completions/mod_.rs
+++ b/crates/ide-completion/src/completions/mod_.rs
@@ -14,7 +14,7 @@ use crate::{CompletionItem, Completions, context::CompletionContext};
/// Complete mod declaration, i.e. `mod $0;`
pub(crate) fn complete_mod(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
mod_under_caret: &ast::Module,
) -> Option<()> {
if mod_under_caret.item_list().is_some() {
diff --git a/crates/ide-completion/src/completions/pattern.rs b/crates/ide-completion/src/completions/pattern.rs
index e7597bf95c..7b887fb7d7 100644
--- a/crates/ide-completion/src/completions/pattern.rs
+++ b/crates/ide-completion/src/completions/pattern.rs
@@ -12,7 +12,7 @@ use crate::{
/// Completes constants and paths in unqualified patterns.
pub(crate) fn complete_pattern(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
) {
let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet);
@@ -128,7 +128,7 @@ pub(crate) fn complete_pattern(
pub(crate) fn complete_pattern_path(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
) {
match qualified {
diff --git a/crates/ide-completion/src/completions/postfix.rs b/crates/ide-completion/src/completions/postfix.rs
index 8a754a6b27..5966bfcd63 100644
--- a/crates/ide-completion/src/completions/postfix.rs
+++ b/crates/ide-completion/src/completions/postfix.rs
@@ -31,7 +31,7 @@ use crate::{
pub(crate) fn complete_postfix(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
dot_access: &DotAccess<'_>,
) {
if !ctx.config.enable_postfix_completions {
@@ -479,7 +479,7 @@ fn include_references(initial_element: &ast::Expr) -> (ast::Expr, String) {
}
fn build_postfix_snippet_builder<'ctx>(
- ctx: &'ctx CompletionContext<'_>,
+ ctx: &'ctx CompletionContext<'_, '_>,
cap: SnippetCap,
receiver: &'ctx ast::Expr,
) -> Option<impl Fn(&str, &str, String) -> Builder + 'ctx> {
@@ -495,7 +495,7 @@ fn build_postfix_snippet_builder<'ctx>(
// Wrapping impl Fn in an option ruins lifetime inference for the parameters in a way that
// can't be annotated for the closure, hence fix it by constructing it without the Option first
fn build<'ctx>(
- ctx: &'ctx CompletionContext<'_>,
+ ctx: &'ctx CompletionContext<'_, '_>,
cap: SnippetCap,
delete_range: TextRange,
) -> impl Fn(&str, &str, String) -> Builder + 'ctx {
@@ -525,7 +525,7 @@ fn build_postfix_snippet_builder<'ctx>(
fn add_custom_postfix_completions(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
postfix_snippet: impl Fn(&str, &str, String) -> Builder,
receiver_text: &str,
) -> Option<()> {
diff --git a/crates/ide-completion/src/completions/postfix/format_like.rs b/crates/ide-completion/src/completions/postfix/format_like.rs
index 6b0e9f31c4..3b22e8a266 100644
--- a/crates/ide-completion/src/completions/postfix/format_like.rs
+++ b/crates/ide-completion/src/completions/postfix/format_like.rs
@@ -44,7 +44,7 @@ static SNIPPET_RETURNS_NON_UNIT: &[&str] = &["format"];
pub(crate) fn add_format_like_completions(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
dot_receiver: &ast::Expr,
cap: SnippetCap,
receiver_text: &ast::String,
diff --git a/crates/ide-completion/src/completions/ra_fixture.rs b/crates/ide-completion/src/completions/ra_fixture.rs
index 5a8881edc7..08ad37b7f2 100644
--- a/crates/ide-completion/src/completions/ra_fixture.rs
+++ b/crates/ide-completion/src/completions/ra_fixture.rs
@@ -14,7 +14,7 @@ use crate::{
pub(crate) fn complete_ra_fixture(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
original: &ast::String,
expanded: &ast::String,
) -> Option<()> {
diff --git a/crates/ide-completion/src/completions/record.rs b/crates/ide-completion/src/completions/record.rs
index 12c564af5c..1238a91dad 100644
--- a/crates/ide-completion/src/completions/record.rs
+++ b/crates/ide-completion/src/completions/record.rs
@@ -13,7 +13,7 @@ use crate::{
pub(crate) fn complete_record_pattern_fields(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
pattern_ctx: &PatternContext,
) {
if let PatternContext { record_pat: Some(record_pat), .. } = pattern_ctx {
@@ -44,7 +44,7 @@ pub(crate) fn complete_record_pattern_fields(
pub(crate) fn complete_record_expr_fields(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
record_expr: &ast::RecordExpr,
&dot_prefix: &bool,
) {
@@ -98,7 +98,7 @@ pub(crate) fn complete_record_expr_fields(
pub(crate) fn add_default_update(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
ty: Option<&hir::TypeInfo<'_>>,
) {
let default_trait = ctx.famous_defs().core_default_Default();
@@ -127,7 +127,7 @@ pub(crate) fn add_default_update(
fn complete_fields(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
missing_fields: Vec<(hir::Field, hir::Type<'_>)>,
) {
for (field, ty) in missing_fields {
diff --git a/crates/ide-completion/src/completions/snippet.rs b/crates/ide-completion/src/completions/snippet.rs
index 04450aea75..7432c5226b 100644
--- a/crates/ide-completion/src/completions/snippet.rs
+++ b/crates/ide-completion/src/completions/snippet.rs
@@ -10,7 +10,7 @@ use crate::{
pub(crate) fn complete_expr_snippet(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
&PathExprCtx { in_block_expr, .. }: &PathExprCtx<'_>,
) {
@@ -50,7 +50,7 @@ macro_rules! $1 {
pub(crate) fn complete_item_snippet(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
kind: &ItemListKind,
) {
@@ -117,7 +117,12 @@ macro_rules! $1 {
}
}
-fn snippet(ctx: &CompletionContext<'_>, cap: SnippetCap, label: &str, snippet: &str) -> Builder {
+fn snippet(
+ ctx: &CompletionContext<'_, '_>,
+ cap: SnippetCap,
+ label: &str,
+ snippet: &str,
+) -> Builder {
let mut item =
CompletionItem::new(CompletionItemKind::Snippet, ctx.source_range(), label, ctx.edition);
item.insert_snippet(cap, snippet);
@@ -126,7 +131,7 @@ fn snippet(ctx: &CompletionContext<'_>, cap: SnippetCap, label: &str, snippet: &
fn add_custom_completions(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
cap: SnippetCap,
scope: SnippetScope,
) -> Option<()> {
diff --git a/crates/ide-completion/src/completions/type.rs b/crates/ide-completion/src/completions/type.rs
index 20bbf0dd8b..0b2b6682aa 100644
--- a/crates/ide-completion/src/completions/type.rs
+++ b/crates/ide-completion/src/completions/type.rs
@@ -11,7 +11,7 @@ use crate::{
pub(crate) fn complete_type_path(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
location: &TypeLocation,
) {
@@ -217,7 +217,7 @@ pub(crate) fn complete_type_path(
pub(crate) fn complete_ascribed_type(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
ascription: &TypeAscriptionTarget,
) -> Option<()> {
diff --git a/crates/ide-completion/src/completions/use_.rs b/crates/ide-completion/src/completions/use_.rs
index f39b641649..1ff7dd6def 100644
--- a/crates/ide-completion/src/completions/use_.rs
+++ b/crates/ide-completion/src/completions/use_.rs
@@ -12,7 +12,7 @@ use crate::{
pub(crate) fn complete_use_path(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, use_tree_parent, .. }: &PathCompletionCtx<'_>,
name_ref: &Option<ast::NameRef>,
) {
diff --git a/crates/ide-completion/src/completions/vis.rs b/crates/ide-completion/src/completions/vis.rs
index 28d906d91c..49a52f2986 100644
--- a/crates/ide-completion/src/completions/vis.rs
+++ b/crates/ide-completion/src/completions/vis.rs
@@ -7,7 +7,7 @@ use crate::{
pub(crate) fn complete_vis_path(
acc: &mut Completions,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
&has_in_token: &bool,
) {
diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs
index b9520e9132..f7fced3f06 100644
--- a/crates/ide-completion/src/context.rs
+++ b/crates/ide-completion/src/context.rs
@@ -458,10 +458,10 @@ pub(crate) enum ParamKind {
/// `CompletionContext` is created early during completion to figure out, where
/// exactly is the cursor, syntax-wise.
#[derive(Debug)]
-pub(crate) struct CompletionContext<'a> {
- pub(crate) sema: Semantics<'a, RootDatabase>,
- pub(crate) scope: SemanticsScope<'a>,
- pub(crate) db: &'a RootDatabase,
+pub(crate) struct CompletionContext<'a, 'db> {
+ pub(crate) sema: Semantics<'db, RootDatabase>,
+ pub(crate) scope: SemanticsScope<'db>,
+ pub(crate) db: &'db RootDatabase,
pub(crate) config: &'a CompletionConfig<'a>,
pub(crate) position: FilePosition,
@@ -487,7 +487,7 @@ pub(crate) struct CompletionContext<'a> {
/// This is usually the parameter name of the function argument we are completing.
pub(crate) expected_name: Option<NameOrNameRef>,
/// The expected type of what we are completing.
- pub(crate) expected_type: Option<Type<'a>>,
+ pub(crate) expected_type: Option<Type<'db>>,
pub(crate) qualifier_ctx: QualifierCtx,
@@ -523,7 +523,7 @@ pub(crate) enum CompleteSemicolon {
CompleteComma,
}
-impl CompletionContext<'_> {
+impl<'db> CompletionContext<'_, 'db> {
/// The range of the identifier that is being completed.
pub(crate) fn source_range(&self) -> TextRange {
let kind = self.original_token.kind();
@@ -540,7 +540,7 @@ impl CompletionContext<'_> {
}
}
- pub(crate) fn famous_defs(&self) -> FamousDefs<'_, '_> {
+ pub(crate) fn famous_defs(&self) -> FamousDefs<'_, 'db> {
FamousDefs(&self.sema, self.krate)
}
@@ -732,13 +732,13 @@ impl CompletionContext<'_> {
}
// CompletionContext construction
-impl<'db> CompletionContext<'db> {
+impl<'a, 'db> CompletionContext<'a, 'db> {
pub(crate) fn new(
db: &'db RootDatabase,
position @ FilePosition { file_id, offset }: FilePosition,
- config: &'db CompletionConfig<'db>,
+ config: &'a CompletionConfig<'a>,
trigger_character: Option<char>,
- ) -> Option<(CompletionContext<'db>, CompletionAnalysis<'db>)> {
+ ) -> Option<(CompletionContext<'a, 'db>, CompletionAnalysis<'db>)> {
let _p = tracing::info_span!("CompletionContext::new").entered();
let sema = Semantics::new(db);
diff --git a/crates/ide-completion/src/item.rs b/crates/ide-completion/src/item.rs
index 6b34bf07bb..cfadec6287 100644
--- a/crates/ide-completion/src/item.rs
+++ b/crates/ide-completion/src/item.rs
@@ -535,7 +535,7 @@ pub(crate) struct Builder {
impl Builder {
pub(crate) fn from_resolution(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
local_name: hir::Name,
resolution: hir::ScopeDef,
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs
index d24ebab55d..50b44b57c5 100644
--- a/crates/ide-completion/src/render.rs
+++ b/crates/ide-completion/src/render.rs
@@ -35,15 +35,15 @@ use crate::{
};
/// Interface for data and methods required for items rendering.
#[derive(Debug, Clone)]
-pub(crate) struct RenderContext<'a> {
- completion: &'a CompletionContext<'a>,
+pub(crate) struct RenderContext<'a, 'db> {
+ completion: &'a CompletionContext<'a, 'db>,
is_private_editable: bool,
import_to_add: Option<LocatedImport>,
doc_aliases: Vec<SmolStr>,
}
-impl<'a> RenderContext<'a> {
- pub(crate) fn new(completion: &'a CompletionContext<'a>) -> RenderContext<'a> {
+impl<'a, 'db> RenderContext<'a, 'db> {
+ pub(crate) fn new(completion: &'a CompletionContext<'a, 'db>) -> RenderContext<'a, 'db> {
RenderContext {
completion,
is_private_editable: false,
@@ -136,7 +136,7 @@ impl<'a> RenderContext<'a> {
}
pub(crate) fn render_field(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
dot_access: &DotAccess<'_>,
receiver: Option<SmolStr>,
field: hir::Field,
@@ -213,7 +213,7 @@ fn field_with_receiver(receiver: Option<&str>, field_name: &str) -> SmolStr {
}
pub(crate) fn render_tuple_field(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
receiver: Option<SmolStr>,
field: usize,
ty: &hir::Type<'_>,
@@ -235,7 +235,7 @@ pub(crate) fn render_tuple_field(
pub(crate) fn render_type_inference(
ty_string: String,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
) -> CompletionItem {
let mut builder = CompletionItem::new(
@@ -254,7 +254,7 @@ pub(crate) fn render_type_inference(
}
pub(crate) fn render_path_resolution(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
local_name: hir::Name,
resolution: ScopeDef,
@@ -263,7 +263,7 @@ pub(crate) fn render_path_resolution(
}
pub(crate) fn render_pattern_resolution(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
pattern_ctx: &PatternContext,
local_name: hir::Name,
resolution: ScopeDef,
@@ -272,7 +272,7 @@ pub(crate) fn render_pattern_resolution(
}
pub(crate) fn render_resolution_with_import(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
import_edit: LocatedImport,
) -> Option<Builder> {
@@ -285,7 +285,7 @@ pub(crate) fn render_resolution_with_import(
}
pub(crate) fn render_resolution_with_import_pat(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
pattern_ctx: &PatternContext,
import_edit: LocatedImport,
) -> Option<Builder> {
@@ -295,7 +295,7 @@ pub(crate) fn render_resolution_with_import_pat(
}
pub(crate) fn render_expr(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
expr: &hir::term_search::Expr<'_>,
) -> Option<Builder> {
let mut i = 1;
@@ -358,7 +358,7 @@ pub(crate) fn render_expr(
fn get_import_name(
resolution: ScopeDef,
- ctx: &RenderContext<'_>,
+ ctx: &RenderContext<'_, '_>,
import_edit: &LocatedImport,
) -> Option<hir::Name> {
// FIXME: Temporary workaround for handling aliased import.
@@ -376,7 +376,7 @@ fn get_import_name(
fn scope_def_to_name(
resolution: ScopeDef,
- ctx: &RenderContext<'_>,
+ ctx: &RenderContext<'_, '_>,
import_edit: &LocatedImport,
) -> Option<hir::Name> {
Some(match resolution {
@@ -388,7 +388,7 @@ fn scope_def_to_name(
}
fn render_resolution_pat(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
pattern_ctx: &PatternContext,
local_name: hir::Name,
import_to_add: Option<LocatedImport>,
@@ -406,7 +406,7 @@ fn render_resolution_pat(
}
fn render_resolution_path(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
local_name: hir::Name,
import_to_add: Option<LocatedImport>,
@@ -515,7 +515,7 @@ fn render_resolution_path(
}
fn render_resolution_simple_(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
local_name: &hir::Name,
import_to_add: Option<LocatedImport>,
resolution: ScopeDef,
@@ -589,7 +589,7 @@ fn scope_def_docs(db: &RootDatabase, resolution: ScopeDef) -> Option<Documentati
}
}
-fn scope_def_is_deprecated(ctx: &RenderContext<'_>, resolution: ScopeDef) -> bool {
+fn scope_def_is_deprecated(ctx: &RenderContext<'_, '_>, resolution: ScopeDef) -> bool {
let db = ctx.db();
match resolution {
ScopeDef::ModuleDef(hir::ModuleDef::EnumVariant(it)) => ctx.is_variant_deprecated(it),
@@ -605,7 +605,7 @@ fn scope_def_is_deprecated(ctx: &RenderContext<'_>, resolution: ScopeDef) -> boo
}
pub(crate) fn render_type_keyword_snippet(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
label: &str,
snippet: &str,
@@ -629,7 +629,7 @@ pub(crate) fn render_type_keyword_snippet(
}
fn adds_ret_type_arrow(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
item: &mut Builder,
insert_text: String,
@@ -648,7 +648,7 @@ fn adds_ret_type_arrow(
// FIXME: This checks types without possible coercions which some completions might want to do
fn match_types(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
ty1: &hir::Type<'_>,
ty2: &hir::Type<'_>,
) -> Option<CompletionRelevanceTypeMatch> {
@@ -662,7 +662,7 @@ fn match_types(
}
fn compute_type_match(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
completion_ty: &hir::Type<'_>,
) -> Option<CompletionRelevanceTypeMatch> {
let expected_type = ctx.expected_type.as_ref()?;
@@ -696,12 +696,12 @@ fn compute_has_local_inherent_impl(
.any(|imp| imp.trait_(db).is_none() && imp.module(db) == curr_module)
}
-fn compute_exact_name_match(ctx: &CompletionContext<'_>, completion_name: &str) -> bool {
+fn compute_exact_name_match(ctx: &CompletionContext<'_, '_>, completion_name: &str) -> bool {
ctx.expected_name.as_ref().is_some_and(|name| name.text() == completion_name)
}
fn compute_ref_match(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
completion_ty: &hir::Type<'_>,
) -> Option<CompletionItemRefMode> {
let expected_type = ctx.expected_type.as_ref()?;
@@ -736,7 +736,7 @@ fn compute_ref_match(
}
fn path_ref_match(
- completion: &CompletionContext<'_>,
+ completion: &CompletionContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
ty: &hir::Type<'_>,
item: &mut Builder,
diff --git a/crates/ide-completion/src/render/const_.rs b/crates/ide-completion/src/render/const_.rs
index 134a77a899..c14fc1704c 100644
--- a/crates/ide-completion/src/render/const_.rs
+++ b/crates/ide-completion/src/render/const_.rs
@@ -6,12 +6,15 @@ use syntax::ToSmolStr;
use crate::{item::CompletionItem, render::RenderContext};
-pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> {
+pub(crate) fn render_const(
+ ctx: RenderContext<'_, '_>,
+ const_: hir::Const,
+) -> Option<CompletionItem> {
let _p = tracing::info_span!("render_const").entered();
render(ctx, const_)
}
-fn render(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> {
+fn render(ctx: RenderContext<'_, '_>, const_: hir::Const) -> Option<CompletionItem> {
let db = ctx.db();
let name = const_.name(db)?;
let (name, escaped_name) =
diff --git a/crates/ide-completion/src/render/function.rs b/crates/ide-completion/src/render/function.rs
index 18151cffcd..97d5a25f49 100644
--- a/crates/ide-completion/src/render/function.rs
+++ b/crates/ide-completion/src/render/function.rs
@@ -27,7 +27,7 @@ enum FuncKind<'ctx> {
}
pub(crate) fn render_fn(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
local_name: Option<hir::Name>,
func: hir::Function,
@@ -37,7 +37,7 @@ pub(crate) fn render_fn(
}
pub(crate) fn render_method(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
dot_access: &DotAccess<'_>,
receiver: Option<SmolStr>,
local_name: Option<hir::Name>,
@@ -48,7 +48,7 @@ pub(crate) fn render_method(
}
fn render(
- ctx @ RenderContext { completion, .. }: RenderContext<'_>,
+ ctx @ RenderContext { completion, .. }: RenderContext<'_, '_>,
local_name: Option<hir::Name>,
func: hir::Function,
func_kind: FuncKind<'_>,
@@ -183,7 +183,7 @@ fn render(
fn compute_return_type_match(
db: &dyn HirDatabase,
- ctx: &RenderContext<'_>,
+ ctx: &RenderContext<'_, '_>,
self_type: hir::Type<'_>,
ret_type: &hir::Type<'_>,
) -> CompletionRelevanceReturnType {
@@ -210,7 +210,7 @@ fn compute_return_type_match(
pub(super) fn add_call_parens<'b>(
builder: &'b mut Builder,
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
cap: SnippetCap,
name: SmolStr,
escaped_name: SmolStr,
@@ -286,7 +286,7 @@ pub(super) fn add_call_parens<'b>(
builder.label(SmolStr::from_iter([&name, label_suffix])).insert_snippet(cap, snippet)
}
-fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type<'_>) -> &'static str {
+fn ref_of_param(ctx: &CompletionContext<'_, '_>, arg: &str, ty: &hir::Type<'_>) -> &'static str {
if let Some(derefed_ty) = ty.remove_ref() {
for (name, local) in ctx.locals.iter().sorted_by_key(|&(k, _)| k.clone()) {
if name.as_str() == arg {
@@ -301,7 +301,7 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type<'_>) -> &
""
}
-fn detail(ctx: &CompletionContext<'_>, func: hir::Function) -> String {
+fn detail(ctx: &CompletionContext<'_, '_>, func: hir::Function) -> String {
let mut ret_ty = func.ret_type(ctx.db);
let mut detail = String::new();
@@ -327,7 +327,7 @@ fn detail(ctx: &CompletionContext<'_>, func: hir::Function) -> String {
detail
}
-fn detail_full(ctx: &CompletionContext<'_>, func: hir::Function) -> String {
+fn detail_full(ctx: &CompletionContext<'_, '_>, func: hir::Function) -> String {
let signature = format!("{}", func.display(ctx.db, ctx.display_target));
let mut detail = String::with_capacity(signature.len());
@@ -342,7 +342,7 @@ fn detail_full(ctx: &CompletionContext<'_>, func: hir::Function) -> String {
detail
}
-fn params_display(ctx: &CompletionContext<'_>, detail: &mut String, func: hir::Function) {
+fn params_display(ctx: &CompletionContext<'_, '_>, detail: &mut String, func: hir::Function) {
if let Some(self_param) = func.self_param(ctx.db) {
format_to!(detail, "{}", self_param.display(ctx.db, ctx.display_target));
let assoc_fn_params = func.assoc_fn_params(ctx.db);
@@ -368,7 +368,7 @@ fn params_display(ctx: &CompletionContext<'_>, detail: &mut String, func: hir::F
}
fn params<'db>(
- ctx: &CompletionContext<'db>,
+ ctx: &CompletionContext<'_, 'db>,
func: hir::Function,
func_kind: &FuncKind<'_>,
has_dot_receiver: bool,
diff --git a/crates/ide-completion/src/render/literal.rs b/crates/ide-completion/src/render/literal.rs
index eb03e27cd9..9e0cec62e6 100644
--- a/crates/ide-completion/src/render/literal.rs
+++ b/crates/ide-completion/src/render/literal.rs
@@ -20,7 +20,7 @@ use crate::{
};
pub(crate) fn render_variant_lit(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
local_name: Option<hir::Name>,
variant: hir::EnumVariant,
@@ -34,7 +34,7 @@ pub(crate) fn render_variant_lit(
}
pub(crate) fn render_struct_literal(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
strukt: hir::Struct,
path: Option<hir::ModPath>,
@@ -48,7 +48,7 @@ pub(crate) fn render_struct_literal(
}
fn render(
- ctx @ RenderContext { completion, .. }: RenderContext<'_>,
+ ctx @ RenderContext { completion, .. }: RenderContext<'_, '_>,
path_ctx: &PathCompletionCtx<'_>,
thing: Variant,
name: hir::Name,
@@ -154,7 +154,7 @@ enum Variant {
}
impl Variant {
- fn fields(self, ctx: &CompletionContext<'_>) -> Option<Vec<hir::Field>> {
+ fn fields(self, ctx: &CompletionContext<'_, '_>) -> Option<Vec<hir::Field>> {
let fields = match self {
Variant::Struct(it) => it.fields(ctx.db),
Variant::EnumVariant(it) => it.fields(ctx.db),
@@ -187,7 +187,7 @@ impl Variant {
}
}
- fn is_deprecated(self, ctx: &RenderContext<'_>) -> bool {
+ fn is_deprecated(self, ctx: &RenderContext<'_, '_>) -> bool {
match self {
Variant::Struct(it) => {
ctx.is_deprecated(it, None /* structs can't be assoc items */)
diff --git a/crates/ide-completion/src/render/macro_.rs b/crates/ide-completion/src/render/macro_.rs
index ff4cf9a75b..85a0761c17 100644
--- a/crates/ide-completion/src/render/macro_.rs
+++ b/crates/ide-completion/src/render/macro_.rs
@@ -11,7 +11,7 @@ use crate::{
};
pub(crate) fn render_macro(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
PathCompletionCtx { kind, has_macro_bang, has_call_parens, .. }: &PathCompletionCtx<'_>,
name: hir::Name,
@@ -22,7 +22,7 @@ pub(crate) fn render_macro(
}
pub(crate) fn render_macro_pat(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
_pattern_ctx: &PatternContext,
name: hir::Name,
macro_: hir::Macro,
@@ -32,7 +32,7 @@ pub(crate) fn render_macro_pat(
}
fn render(
- ctx @ RenderContext { completion, .. }: RenderContext<'_>,
+ ctx @ RenderContext { completion, .. }: RenderContext<'_, '_>,
is_use_path: bool,
has_macro_bang: bool,
has_call_parens: bool,
@@ -91,7 +91,7 @@ fn render(
}
fn label(
- ctx: &RenderContext<'_>,
+ ctx: &RenderContext<'_, '_>,
needs_bang: bool,
bra: &str,
ket: &str,
diff --git a/crates/ide-completion/src/render/pattern.rs b/crates/ide-completion/src/render/pattern.rs
index 022e97e4f7..392ecbc302 100644
--- a/crates/ide-completion/src/render/pattern.rs
+++ b/crates/ide-completion/src/render/pattern.rs
@@ -15,7 +15,7 @@ use crate::{
};
pub(crate) fn render_struct_pat(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
pattern_ctx: &PatternContext,
strukt: hir::Struct,
local_name: Option<Name>,
@@ -44,7 +44,7 @@ pub(crate) fn render_struct_pat(
}
pub(crate) fn render_variant_pat(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
pattern_ctx: &PatternContext,
path_ctx: Option<&PathCompletionCtx<'_>>,
variant: hir::EnumVariant,
@@ -104,7 +104,7 @@ pub(crate) fn render_variant_pat(
}
fn build_completion(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
label: SmolStr,
lookup: SmolStr,
pat: String,
@@ -140,7 +140,7 @@ fn build_completion(
}
fn render_pat(
- ctx: &RenderContext<'_>,
+ ctx: &RenderContext<'_, '_>,
pattern_ctx: &PatternContext,
name: &str,
kind: StructKind,
diff --git a/crates/ide-completion/src/render/type_alias.rs b/crates/ide-completion/src/render/type_alias.rs
index 2b79ca2deb..ce1be2d551 100644
--- a/crates/ide-completion/src/render/type_alias.rs
+++ b/crates/ide-completion/src/render/type_alias.rs
@@ -7,7 +7,7 @@ use syntax::{SmolStr, ToSmolStr};
use crate::{item::CompletionItem, render::RenderContext};
pub(crate) fn render_type_alias(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
type_alias: hir::TypeAlias,
) -> Option<CompletionItem> {
let _p = tracing::info_span!("render_type_alias").entered();
@@ -15,7 +15,7 @@ pub(crate) fn render_type_alias(
}
pub(crate) fn render_type_alias_with_eq(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
type_alias: hir::TypeAlias,
) -> Option<CompletionItem> {
let _p = tracing::info_span!("render_type_alias_with_eq").entered();
@@ -23,7 +23,7 @@ pub(crate) fn render_type_alias_with_eq(
}
fn render(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
type_alias: hir::TypeAlias,
with_eq: bool,
) -> Option<CompletionItem> {
diff --git a/crates/ide-completion/src/render/union_literal.rs b/crates/ide-completion/src/render/union_literal.rs
index 7164c94fde..e7ee59d489 100644
--- a/crates/ide-completion/src/render/union_literal.rs
+++ b/crates/ide-completion/src/render/union_literal.rs
@@ -14,7 +14,7 @@ use crate::{
};
pub(crate) fn render_union_literal(
- ctx: RenderContext<'_>,
+ ctx: RenderContext<'_, '_>,
un: hir::Union,
path: Option<hir::ModPath>,
local_name: Option<Name>,
diff --git a/crates/ide-completion/src/render/variant.rs b/crates/ide-completion/src/render/variant.rs
index ce35ab135f..f86af6cdcb 100644
--- a/crates/ide-completion/src/render/variant.rs
+++ b/crates/ide-completion/src/render/variant.rs
@@ -17,7 +17,7 @@ pub(crate) struct RenderedLiteral {
/// Render a record type (or sub-type) to a `RenderedCompound`. Use `None` for
/// the `name` argument for an anonymous type.
pub(crate) fn render_record_lit(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
snippet_cap: Option<SnippetCap>,
fields: &[hir::Field],
path: &str,
@@ -63,7 +63,7 @@ pub(crate) fn render_record_lit(
/// Render a tuple type (or sub-type) to a `RenderedCompound`. Use `None` for
/// the `name` argument for an anonymous type.
pub(crate) fn render_tuple_lit(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
snippet_cap: Option<SnippetCap>,
fields: &[hir::Field],
path: &str,
@@ -93,7 +93,7 @@ pub(crate) fn render_tuple_lit(
/// fields, plus a boolean for whether the list is comprehensive (contains no
/// private fields and its item is not marked `#[non_exhaustive]`).
pub(crate) fn visible_fields(
- ctx: &CompletionContext<'_>,
+ ctx: &CompletionContext<'_, '_>,
fields: &[hir::Field],
item: impl HasAttrs + HasCrate + Copy,
) -> Option<(Vec<hir::Field>, bool)> {
diff --git a/crates/ide-completion/src/snippet.rs b/crates/ide-completion/src/snippet.rs
index d326098f94..67ca9db230 100644
--- a/crates/ide-completion/src/snippet.rs
+++ b/crates/ide-completion/src/snippet.rs
@@ -150,7 +150,7 @@ impl Snippet {
}
/// Returns [`None`] if the required items do not resolve.
- pub(crate) fn imports(&self, ctx: &CompletionContext<'_>) -> Option<Vec<LocatedImport>> {
+ pub(crate) fn imports(&self, ctx: &CompletionContext<'_, '_>) -> Option<Vec<LocatedImport>> {
import_edits(ctx, &self.requires)
}
@@ -163,7 +163,10 @@ impl Snippet {
}
}
-fn import_edits(ctx: &CompletionContext<'_>, requires: &[ModPath]) -> Option<Vec<LocatedImport>> {
+fn import_edits(
+ ctx: &CompletionContext<'_, '_>,
+ requires: &[ModPath],
+) -> Option<Vec<LocatedImport>> {
let import_cfg = ctx.config.find_path_config(ctx.is_nightly);
let resolve = |import| {
diff --git a/crates/ide-db/src/active_parameter.rs b/crates/ide-db/src/active_parameter.rs
index 8bd4c6c46b..506645261b 100644
--- a/crates/ide-db/src/active_parameter.rs
+++ b/crates/ide-db/src/active_parameter.rs
@@ -27,7 +27,7 @@ impl<'db> ActiveParameter<'db> {
/// Returns information about the call argument this token is part of.
pub fn at_arg(
- sema: &'db Semantics<'db, RootDatabase>,
+ sema: &Semantics<'db, RootDatabase>,
list: ast::ArgList,
at: TextSize,
) -> Option<Self> {
diff --git a/crates/ide-db/src/path_transform.rs b/crates/ide-db/src/path_transform.rs
index e66f645c00..83991a85e0 100644
--- a/crates/ide-db/src/path_transform.rs
+++ b/crates/ide-db/src/path_transform.rs
@@ -151,7 +151,7 @@ impl<'a> PathTransform<'a> {
prettify_macro_expansion(
db,
node,
- &db.expansion_span_map(file_id),
+ db.expansion_span_map(file_id),
self.target_scope.module().krate(db).into(),
)
}
diff --git a/crates/ide-db/src/search.rs b/crates/ide-db/src/search.rs
index f41e293070..d59df3601f 100644
--- a/crates/ide-db/src/search.rs
+++ b/crates/ide-db/src/search.rs
@@ -440,7 +440,7 @@ impl Definition {
}
}
- pub fn usages<'a>(self, sema: &'a Semantics<'_, RootDatabase>) -> FindUsages<'a> {
+ pub fn usages<'a, 'db>(self, sema: &'a Semantics<'db, RootDatabase>) -> FindUsages<'a, 'db> {
FindUsages {
def: self,
rename: None,
@@ -456,10 +456,10 @@ impl Definition {
}
#[derive(Clone)]
-pub struct FindUsages<'a> {
+pub struct FindUsages<'a, 'db> {
def: Definition,
rename: Option<&'a Rename>,
- sema: &'a Semantics<'a, RootDatabase>,
+ sema: &'a Semantics<'db, RootDatabase>,
scope: Option<&'a SearchScope>,
/// The container of our definition should it be an assoc item
assoc_item_container: Option<hir::AssocItemContainer>,
@@ -473,7 +473,7 @@ pub struct FindUsages<'a> {
exclude_library_files: bool,
}
-impl<'a> FindUsages<'a> {
+impl<'a, 'db> FindUsages<'a, 'db> {
/// Enable searching for `Self` when the definition is a type or `self` for modules.
pub fn include_self_refs(mut self) -> Self {
self.include_self_kw_refs = def_to_ty(self.sema, &self.def);
@@ -858,7 +858,7 @@ impl<'a> FindUsages<'a> {
}
fn search(
- this: &FindUsages<'_>,
+ this: &FindUsages<'_, '_>,
finder: &Finder<'_>,
name: &str,
files: impl Iterator<Item = (Arc<str>, EditionedFileId, TextRange)>,
diff --git a/crates/ide-diagnostics/src/handlers/await_outside_of_async.rs b/crates/ide-diagnostics/src/handlers/await_outside_of_async.rs
index 7cadff84fb..e6adac9da7 100644
--- a/crates/ide-diagnostics/src/handlers/await_outside_of_async.rs
+++ b/crates/ide-diagnostics/src/handlers/await_outside_of_async.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticsContext, adjusted_display_range};
//
// This diagnostic is triggered if the `await` keyword is used outside of an async function or block
pub(crate) fn await_outside_of_async(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::AwaitOutsideOfAsync,
) -> Diagnostic {
let display_range =
diff --git a/crates/ide-diagnostics/src/handlers/bad_rtn.rs b/crates/ide-diagnostics/src/handlers/bad_rtn.rs
index ae42a88c31..c84b29dbe2 100644
--- a/crates/ide-diagnostics/src/handlers/bad_rtn.rs
+++ b/crates/ide-diagnostics/src/handlers/bad_rtn.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// Diagnostic: bad-rtn
//
// This diagnostic is shown when a RTN (Return Type Notation, `Type::method(..): Send`) is written in an improper place.
-pub(crate) fn bad_rtn(ctx: &DiagnosticsContext<'_>, d: &hir::BadRtn) -> Diagnostic {
+pub(crate) fn bad_rtn(ctx: &DiagnosticsContext<'_, '_>, d: &hir::BadRtn) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::Ra("bad-rtn", Severity::Error),
diff --git a/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs b/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs
index 02f3cab565..b7265c47b6 100644
--- a/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs
+++ b/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if the `break` keyword is used outside of a loop.
pub(crate) fn break_outside_of_loop(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::BreakOutsideOfLoop,
) -> Diagnostic {
let message = if d.bad_value_break {
diff --git a/crates/ide-diagnostics/src/handlers/elided_lifetimes_in_path.rs b/crates/ide-diagnostics/src/handlers/elided_lifetimes_in_path.rs
index b284d9b351..8df9959859 100644
--- a/crates/ide-diagnostics/src/handlers/elided_lifetimes_in_path.rs
+++ b/crates/ide-diagnostics/src/handlers/elided_lifetimes_in_path.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// This diagnostic is triggered when lifetimes are elided in paths. It is a lint only for some cases,
// and a hard error for others.
pub(crate) fn elided_lifetimes_in_path(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::ElidedLifetimesInPath,
) -> Diagnostic {
if d.hard_error {
diff --git a/crates/ide-diagnostics/src/handlers/expected_function.rs b/crates/ide-diagnostics/src/handlers/expected_function.rs
index afd1687ae0..25e9dc09eb 100644
--- a/crates/ide-diagnostics/src/handlers/expected_function.rs
+++ b/crates/ide-diagnostics/src/handlers/expected_function.rs
@@ -6,7 +6,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if a call is made on something that is not callable.
pub(crate) fn expected_function(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::ExpectedFunction<'_>,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs b/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs
index 9ae6f013c7..515878fd47 100644
--- a/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs
+++ b/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs
@@ -12,7 +12,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
// This diagnostic is shown when generic arguments are provided for a type that does not accept
// generic arguments.
pub(crate) fn generic_args_prohibited(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::GenericArgsProhibited,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
@@ -42,7 +42,7 @@ fn describe_reason(reason: GenericArgsProhibitedReason) -> String {
format!("generic arguments are not allowed on {kind}")
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::GenericArgsProhibited) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::GenericArgsProhibited) -> Option<Vec<Assist>> {
let file_id = d.args.file_id.file_id()?;
let syntax = d.args.to_node(ctx.sema.db);
let range = match &syntax {
diff --git a/crates/ide-diagnostics/src/handlers/generic_default_refers_to_self.rs b/crates/ide-diagnostics/src/handlers/generic_default_refers_to_self.rs
index 3d38159c4f..926c517bc9 100644
--- a/crates/ide-diagnostics/src/handlers/generic_default_refers_to_self.rs
+++ b/crates/ide-diagnostics/src/handlers/generic_default_refers_to_self.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is shown when a generic default refers to `Self`
pub(crate) fn generic_default_refers_to_self(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::GenericDefaultRefersToSelf,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/inactive_code.rs b/crates/ide-diagnostics/src/handlers/inactive_code.rs
index be4fe763a0..09f3e8bfb3 100644
--- a/crates/ide-diagnostics/src/handlers/inactive_code.rs
+++ b/crates/ide-diagnostics/src/handlers/inactive_code.rs
@@ -7,7 +7,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, Severity};
//
// This diagnostic is shown for code with inactive `#[cfg]` attributes.
pub(crate) fn inactive_code(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::InactiveCode,
) -> Option<Diagnostic> {
// If there's inactive code somewhere in a macro, don't propagate to the call-site.
diff --git a/crates/ide-diagnostics/src/handlers/incoherent_impl.rs b/crates/ide-diagnostics/src/handlers/incoherent_impl.rs
index a0c364b001..bd8b804af4 100644
--- a/crates/ide-diagnostics/src/handlers/incoherent_impl.rs
+++ b/crates/ide-diagnostics/src/handlers/incoherent_impl.rs
@@ -6,7 +6,10 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, adjusted_display_ran
// Diagnostic: incoherent-impl
//
// This diagnostic is triggered if the targe type of an impl is from a foreign crate.
-pub(crate) fn incoherent_impl(ctx: &DiagnosticsContext<'_>, d: &hir::IncoherentImpl) -> Diagnostic {
+pub(crate) fn incoherent_impl(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::IncoherentImpl,
+) -> Diagnostic {
let display_range = adjusted_display_range(ctx, InFile::new(d.file_id, d.impl_), &|node| {
Some(TextRange::new(
node.syntax().text_range().start(),
diff --git a/crates/ide-diagnostics/src/handlers/incorrect_case.rs b/crates/ide-diagnostics/src/handlers/incorrect_case.rs
index 5a456504e1..bda3f9bf0a 100644
--- a/crates/ide-diagnostics/src/handlers/incorrect_case.rs
+++ b/crates/ide-diagnostics/src/handlers/incorrect_case.rs
@@ -13,7 +13,10 @@ use crate::{
// Diagnostic: incorrect-ident-case
//
// This diagnostic is triggered if an item name doesn't follow [Rust naming convention](https://doc.rust-lang.org/1.0.0/style/style/naming/README.html).
-pub(crate) fn incorrect_case(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCase) -> Diagnostic {
+pub(crate) fn incorrect_case(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::IncorrectCase,
+) -> Diagnostic {
let code = match d.expected_case {
CaseType::LowerSnakeCase => DiagnosticCode::RustcLint("non_snake_case"),
CaseType::UpperSnakeCase => DiagnosticCode::RustcLint("non_upper_case_globals"),
@@ -33,7 +36,7 @@ pub(crate) fn incorrect_case(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCas
.with_fixes(fixes(ctx, d))
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCase) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::IncorrectCase) -> Option<Vec<Assist>> {
let root = ctx.sema.db.parse_or_expand(d.file);
let name_node = d.ident.to_node(&root);
let def = NameClass::classify(&ctx.sema, &name_node)?.defined()?;
diff --git a/crates/ide-diagnostics/src/handlers/incorrect_generics_len.rs b/crates/ide-diagnostics/src/handlers/incorrect_generics_len.rs
index 2a31a41fbc..9c04d2be8a 100644
--- a/crates/ide-diagnostics/src/handlers/incorrect_generics_len.rs
+++ b/crates/ide-diagnostics/src/handlers/incorrect_generics_len.rs
@@ -5,7 +5,7 @@ use hir::IncorrectGenericsLenKind;
//
// This diagnostic is triggered if the number of generic arguments does not match their declaration.
pub(crate) fn incorrect_generics_len(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::IncorrectGenericsLen,
) -> Diagnostic {
let owner_description = d.def.description();
diff --git a/crates/ide-diagnostics/src/handlers/incorrect_generics_order.rs b/crates/ide-diagnostics/src/handlers/incorrect_generics_order.rs
index b71586d6be..c2b70a204e 100644
--- a/crates/ide-diagnostics/src/handlers/incorrect_generics_order.rs
+++ b/crates/ide-diagnostics/src/handlers/incorrect_generics_order.rs
@@ -6,7 +6,7 @@ use syntax::SyntaxKind;
//
// This diagnostic is triggered the order of provided generic arguments does not match their declaration.
pub(crate) fn incorrect_generics_order(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::IncorrectGenericsOrder,
) -> Diagnostic {
let provided_description = match d.provided_arg.value.kind() {
diff --git a/crates/ide-diagnostics/src/handlers/invalid_cast.rs b/crates/ide-diagnostics/src/handlers/invalid_cast.rs
index 405d8df685..ba7556cd8b 100644
--- a/crates/ide-diagnostics/src/handlers/invalid_cast.rs
+++ b/crates/ide-diagnostics/src/handlers/invalid_cast.rs
@@ -18,7 +18,10 @@ macro_rules! format_ty {
// Diagnostic: invalid-cast
//
// This diagnostic is triggered if the code contains an illegal cast
-pub(crate) fn invalid_cast(ctx: &DiagnosticsContext<'_>, d: &hir::InvalidCast<'_>) -> Diagnostic {
+pub(crate) fn invalid_cast(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::InvalidCast<'_>,
+) -> Diagnostic {
let display_range = ctx.sema.diagnostics_display_range(d.expr.map(|it| it.into()));
let (code, message) = match d.error {
CastError::CastToBool => (
@@ -111,7 +114,7 @@ pub(crate) fn invalid_cast(ctx: &DiagnosticsContext<'_>, d: &hir::InvalidCast<'_
//
// This diagnostic is triggered when casting to an unsized type
pub(crate) fn cast_to_unsized(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::CastToUnsized<'_>,
) -> Diagnostic {
let display_range = ctx.sema.diagnostics_display_range(d.expr.map(|it| it.into()));
diff --git a/crates/ide-diagnostics/src/handlers/invalid_derive_target.rs b/crates/ide-diagnostics/src/handlers/invalid_derive_target.rs
index 9aa7aed169..8522041b52 100644
--- a/crates/ide-diagnostics/src/handlers/invalid_derive_target.rs
+++ b/crates/ide-diagnostics/src/handlers/invalid_derive_target.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// This diagnostic is shown when the derive attribute is used on an item other than a `struct`,
// `enum` or `union`.
pub(crate) fn invalid_derive_target(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::InvalidDeriveTarget,
) -> Diagnostic {
let display_range = ctx.sema.diagnostics_display_range_for_range(d.range);
diff --git a/crates/ide-diagnostics/src/handlers/invalid_lhs_of_assignment.rs b/crates/ide-diagnostics/src/handlers/invalid_lhs_of_assignment.rs
index 02716f2b86..225d3e0b46 100644
--- a/crates/ide-diagnostics/src/handlers/invalid_lhs_of_assignment.rs
+++ b/crates/ide-diagnostics/src/handlers/invalid_lhs_of_assignment.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if the left-hand side of an assignment can't be assigned to.
pub(crate) fn invalid_lhs_of_assignment(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::InvalidLhsOfAssignment,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/macro_error.rs b/crates/ide-diagnostics/src/handlers/macro_error.rs
index a44b043f43..b6571e02ef 100644
--- a/crates/ide-diagnostics/src/handlers/macro_error.rs
+++ b/crates/ide-diagnostics/src/handlers/macro_error.rs
@@ -11,7 +11,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, Severity};
// Diagnostic: proc-macro-disabled
//
// This diagnostic is shown for proc macros that have been specifically disabled via `rust-analyzer.procMacro.ignored`.
-pub(crate) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) -> Diagnostic {
+pub(crate) fn macro_error(ctx: &DiagnosticsContext<'_, '_>, d: &hir::MacroError) -> Diagnostic {
// Use more accurate position if available.
let display_range = ctx.sema.diagnostics_display_range_for_range(d.range);
Diagnostic::new(
@@ -25,7 +25,10 @@ pub(crate) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) ->
// Diagnostic: macro-def-error
//
// This diagnostic is shown for macro expansion errors.
-pub(crate) fn macro_def_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroDefError) -> Diagnostic {
+pub(crate) fn macro_def_error(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::MacroDefError,
+) -> Diagnostic {
// Use more accurate position if available.
let display_range = match d.name {
Some(name) => ctx.sema.diagnostics_display_range_for_range(d.node.with_value(name)),
diff --git a/crates/ide-diagnostics/src/handlers/malformed_derive.rs b/crates/ide-diagnostics/src/handlers/malformed_derive.rs
index 7d0c71f4fa..c7d8991f45 100644
--- a/crates/ide-diagnostics/src/handlers/malformed_derive.rs
+++ b/crates/ide-diagnostics/src/handlers/malformed_derive.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is shown when the derive attribute has invalid input.
pub(crate) fn malformed_derive(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::MalformedDerive,
) -> Diagnostic {
let display_range = ctx.sema.diagnostics_display_range_for_range(d.range);
diff --git a/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs b/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
index b900a8f5cc..179f9dcec5 100644
--- a/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
+++ b/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
@@ -12,7 +12,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, adjusted_display_ran
//
// This diagnostic is triggered if a function is invoked with an incorrect amount of arguments.
pub(crate) fn mismatched_tuple_struct_pat_arg_count(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::MismatchedTupleStructPatArgCount,
) -> Diagnostic {
let s = if d.found == 1 { "" } else { "s" };
@@ -33,7 +33,7 @@ pub(crate) fn mismatched_tuple_struct_pat_arg_count(
//
// This diagnostic is triggered if a function is invoked with an incorrect amount of arguments.
pub(crate) fn mismatched_arg_count(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::MismatchedArgCount,
) -> Diagnostic {
let s = if d.expected == 1 { "" } else { "s" };
@@ -47,7 +47,7 @@ pub(crate) fn mismatched_arg_count(
}
fn invalid_args_range(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
source: InFile<AstPtr<Either<ast::Expr, ast::Pat>>>,
expected: usize,
found: usize,
diff --git a/crates/ide-diagnostics/src/handlers/missing_fields.rs b/crates/ide-diagnostics/src/handlers/missing_fields.rs
index 117702923b..206d8caf90 100644
--- a/crates/ide-diagnostics/src/handlers/missing_fields.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_fields.rs
@@ -33,7 +33,10 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
//
// let a = A { a: 10 };
// ```
-pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Diagnostic {
+pub(crate) fn missing_fields(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::MissingFields,
+) -> Diagnostic {
let mut message = String::from("missing structure fields:\n");
for (field, _) in &d.missed_fields {
format_to!(message, "- {}\n", field.display(ctx.sema.db, ctx.edition));
@@ -51,7 +54,7 @@ pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingField
.with_fixes(fixes(ctx, d))
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::MissingFields) -> Option<Vec<Assist>> {
// Note that although we could add a diagnostics to
// fill the missing tuple field, e.g :
// `struct A(usize);`
@@ -202,7 +205,7 @@ fn make_ty(
}
fn get_default_constructor(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::MissingFields,
ty: &Type<'_>,
) -> Option<ast::Expr> {
diff --git a/crates/ide-diagnostics/src/handlers/missing_lifetime.rs b/crates/ide-diagnostics/src/handlers/missing_lifetime.rs
index b10cdaa14e..760bb7309d 100644
--- a/crates/ide-diagnostics/src/handlers/missing_lifetime.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_lifetime.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered when a lifetime argument is missing.
pub(crate) fn missing_lifetime(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::MissingLifetime,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
index 8cd41f7aed..7bc7955c4e 100644
--- a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if `match` block is missing one or more match arms.
pub(crate) fn missing_match_arms(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::MissingMatchArms,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/missing_unsafe.rs b/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
index 3351f5dc1c..38cf548cc6 100644
--- a/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
@@ -10,7 +10,10 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
// Diagnostic: missing-unsafe
//
// This diagnostic is triggered if an operation marked as `unsafe` is used outside of an `unsafe` function or block.
-pub(crate) fn missing_unsafe(ctx: &DiagnosticsContext<'_>, d: &hir::MissingUnsafe) -> Diagnostic {
+pub(crate) fn missing_unsafe(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::MissingUnsafe,
+) -> Diagnostic {
let code = match d.lint {
UnsafeLint::HardError => DiagnosticCode::RustcHardError("E0133"),
UnsafeLint::UnsafeOpInUnsafeFn => DiagnosticCode::RustcLint("unsafe_op_in_unsafe_fn"),
@@ -38,7 +41,7 @@ fn display_unsafety_reason(reason: UnsafetyReason) -> &'static str {
}
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingUnsafe) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::MissingUnsafe) -> Option<Vec<Assist>> {
// The fixit will not work correctly for macro expansions, so we don't offer it in that case.
if d.node.file_id.is_macro() {
return None;
diff --git a/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs b/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
index 6331090d9c..e61719acf5 100644
--- a/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
+++ b/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
@@ -5,7 +5,7 @@ use hir::HirDisplay;
//
// This diagnostic is triggered on moving non copy things out of references.
pub(crate) fn moved_out_of_ref(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::MovedOutOfRef<'_>,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/mutability_errors.rs b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
index 9a5ad375dc..31becd1d74 100644
--- a/crates/ide-diagnostics/src/handlers/mutability_errors.rs
+++ b/crates/ide-diagnostics/src/handlers/mutability_errors.rs
@@ -8,7 +8,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
// Diagnostic: need-mut
//
// This diagnostic is triggered on mutating an immutable variable.
-pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Option<Diagnostic> {
+pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_, '_>, d: &hir::NeedMut) -> Option<Diagnostic> {
let root = ctx.sema.db.parse_or_expand(d.span.file_id);
let node = d.span.value.to_node(&root);
let mut span = d.span;
@@ -63,7 +63,10 @@ pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Option
// Diagnostic: unused-mut
//
// This diagnostic is triggered when a mutable variable isn't actually mutated.
-pub(crate) fn unused_mut(ctx: &DiagnosticsContext<'_>, d: &hir::UnusedMut) -> Option<Diagnostic> {
+pub(crate) fn unused_mut(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::UnusedMut,
+) -> Option<Diagnostic> {
let ast = d.local.primary_source(ctx.sema.db).syntax_ptr();
let fixes = (|| {
let file_id = ast.file_id.file_id()?;
diff --git a/crates/ide-diagnostics/src/handlers/no_such_field.rs b/crates/ide-diagnostics/src/handlers/no_such_field.rs
index 944622bb1d..7959fddc75 100644
--- a/crates/ide-diagnostics/src/handlers/no_such_field.rs
+++ b/crates/ide-diagnostics/src/handlers/no_such_field.rs
@@ -15,7 +15,7 @@ use crate::{
// Diagnostic: no-such-field
//
// This diagnostic is triggered if created structure does not have field provided in record.
-pub(crate) fn no_such_field(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField) -> Diagnostic {
+pub(crate) fn no_such_field(ctx: &DiagnosticsContext<'_, '_>, d: &hir::NoSuchField) -> Diagnostic {
let (code, message) = if d.private.is_some() {
("E0451", "field is private")
} else if let VariantId::EnumVariantId(_) = d.variant {
@@ -30,7 +30,7 @@ pub(crate) fn no_such_field(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField)
.with_fixes(fixes(ctx, d))
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::NoSuchField) -> Option<Vec<Assist>> {
// FIXME: quickfix for pattern
let root = ctx.sema.db.parse_or_expand(d.field.file_id);
match &d.field.value.to_node(&root) {
diff --git a/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
index bc10e82854..ee2f6bf319 100644
--- a/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
+++ b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
@@ -12,7 +12,7 @@ use crate::{Assist, Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
// This diagnostic is triggered if a `let` statement without an `else` branch has a non-exhaustive
// pattern.
pub(crate) fn non_exhaustive_let(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::NonExhaustiveLet,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/non_exhaustive_record_expr.rs b/crates/ide-diagnostics/src/handlers/non_exhaustive_record_expr.rs
index 9dbce4d1f4..be9c07b1ac 100644
--- a/crates/ide-diagnostics/src/handlers/non_exhaustive_record_expr.rs
+++ b/crates/ide-diagnostics/src/handlers/non_exhaustive_record_expr.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// This diagnostic is triggered if a struct expression constructs a `#[non_exhaustive]`
// struct from another crate.
pub(crate) fn non_exhaustive_record_expr(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::NonExhaustiveRecordExpr,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/parenthesized_generic_args_without_fn_trait.rs b/crates/ide-diagnostics/src/handlers/parenthesized_generic_args_without_fn_trait.rs
index 68f2b19657..44fc9f482b 100644
--- a/crates/ide-diagnostics/src/handlers/parenthesized_generic_args_without_fn_trait.rs
+++ b/crates/ide-diagnostics/src/handlers/parenthesized_generic_args_without_fn_trait.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// This diagnostic is shown when a `Fn`-trait-style generic parameters (`Trait(A, B) -> C`)
// was used on non-`Fn` trait/type.
pub(crate) fn parenthesized_generic_args_without_fn_trait(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::ParenthesizedGenericArgsWithoutFnTrait,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/pattern_arg_in_extern_fn.rs b/crates/ide-diagnostics/src/handlers/pattern_arg_in_extern_fn.rs
index 36031865fc..459ec175b1 100644
--- a/crates/ide-diagnostics/src/handlers/pattern_arg_in_extern_fn.rs
+++ b/crates/ide-diagnostics/src/handlers/pattern_arg_in_extern_fn.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if a pattern was declared as an argument in a foreign function declaration.
pub(crate) fn pattern_arg_in_extern_fn(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::PatternArgInExternFn,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/private_assoc_item.rs b/crates/ide-diagnostics/src/handlers/private_assoc_item.rs
index 6d33ae0cf9..92f3c6961e 100644
--- a/crates/ide-diagnostics/src/handlers/private_assoc_item.rs
+++ b/crates/ide-diagnostics/src/handlers/private_assoc_item.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// This diagnostic is triggered if the referenced associated item is not visible from the current
// module.
pub(crate) fn private_assoc_item(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::PrivateAssocItem,
) -> Diagnostic {
// FIXME: add quickfix
diff --git a/crates/ide-diagnostics/src/handlers/private_field.rs b/crates/ide-diagnostics/src/handlers/private_field.rs
index 90c27bdcef..9515afed76 100644
--- a/crates/ide-diagnostics/src/handlers/private_field.rs
+++ b/crates/ide-diagnostics/src/handlers/private_field.rs
@@ -10,7 +10,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
// Diagnostic: private-field
//
// This diagnostic is triggered if the accessed field is not visible from the current module.
-pub(crate) fn private_field(ctx: &DiagnosticsContext<'_>, d: &hir::PrivateField) -> Diagnostic {
+pub(crate) fn private_field(ctx: &DiagnosticsContext<'_, '_>, d: &hir::PrivateField) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::RustcHardError("E0616"),
diff --git a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs
index 2ec41d0528..fb1470b69f 100644
--- a/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs
+++ b/crates/ide-diagnostics/src/handlers/remove_trailing_return.rs
@@ -10,7 +10,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, adjusted_display_ran
// This diagnostic is triggered when there is a redundant `return` at the end of a function
// or closure.
pub(crate) fn remove_trailing_return(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &RemoveTrailingReturn,
) -> Option<Diagnostic> {
if d.return_expr.file_id.macro_file().is_some() {
@@ -36,7 +36,7 @@ pub(crate) fn remove_trailing_return(
)
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveTrailingReturn) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &RemoveTrailingReturn) -> Option<Vec<Assist>> {
let root = ctx.sema.db.parse_or_expand(d.return_expr.file_id);
let return_expr = d.return_expr.value.to_node(&root);
let stmt = return_expr.syntax().parent().and_then(ast::ExprStmt::cast);
diff --git a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
index 04f48ae3db..aa7b57e292 100644
--- a/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
+++ b/crates/ide-diagnostics/src/handlers/remove_unnecessary_else.rs
@@ -19,7 +19,7 @@ use crate::{
// This diagnostic is triggered when there is an `else` block for an `if` expression whose
// then branch diverges (e.g. ends with a `return`, `continue`, `break` e.t.c).
pub(crate) fn remove_unnecessary_else(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &RemoveUnnecessaryElse,
) -> Option<Diagnostic> {
if d.if_expr.file_id.macro_file().is_some() {
@@ -40,7 +40,7 @@ pub(crate) fn remove_unnecessary_else(
)
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &RemoveUnnecessaryElse) -> Option<Vec<Assist>> {
let root = ctx.sema.db.parse_or_expand(d.if_expr.file_id);
let if_expr = d.if_expr.value.to_node(&root);
let if_expr = ctx.sema.original_ast_node(if_expr)?;
diff --git a/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs b/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
index 37ce5f583f..f974c55023 100644
--- a/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
+++ b/crates/ide-diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
@@ -12,7 +12,7 @@ use crate::{Assist, Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
//
// This diagnostic is triggered when `.filter_map(..).next()` is used, rather than the more concise `.find_map(..)`.
pub(crate) fn replace_filter_map_next_with_find_map(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::ReplaceFilterMapNextWithFindMap,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
@@ -26,7 +26,7 @@ pub(crate) fn replace_filter_map_next_with_find_map(
}
fn fixes(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::ReplaceFilterMapNextWithFindMap,
) -> Option<Vec<Assist>> {
let root = ctx.sema.db.parse_or_expand(d.file);
diff --git a/crates/ide-diagnostics/src/handlers/trait_impl_incorrect_safety.rs b/crates/ide-diagnostics/src/handlers/trait_impl_incorrect_safety.rs
index c5b2f499d3..9e7393c89c 100644
--- a/crates/ide-diagnostics/src/handlers/trait_impl_incorrect_safety.rs
+++ b/crates/ide-diagnostics/src/handlers/trait_impl_incorrect_safety.rs
@@ -7,7 +7,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, Severity, adjusted_d
//
// Diagnoses incorrect safety annotations of trait impls.
pub(crate) fn trait_impl_incorrect_safety(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TraitImplIncorrectSafety,
) -> Diagnostic {
Diagnostic::new(
diff --git a/crates/ide-diagnostics/src/handlers/trait_impl_missing_assoc_item.rs b/crates/ide-diagnostics/src/handlers/trait_impl_missing_assoc_item.rs
index 2c05544701..5f5e155bd7 100644
--- a/crates/ide-diagnostics/src/handlers/trait_impl_missing_assoc_item.rs
+++ b/crates/ide-diagnostics/src/handlers/trait_impl_missing_assoc_item.rs
@@ -8,7 +8,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, adjusted_display_ran
//
// Diagnoses missing trait items in a trait impl.
pub(crate) fn trait_impl_missing_assoc_item(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TraitImplMissingAssocItems,
) -> Diagnostic {
let missing = d.missing.iter().format_with(", ", |(name, item), f| {
diff --git a/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs b/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs
index 96911d4781..a9dc0d5d72 100644
--- a/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs
+++ b/crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs
@@ -6,7 +6,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// Only traits defined in the current crate can be implemented for arbitrary types
pub(crate) fn trait_impl_orphan(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TraitImplOrphan,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs b/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs
index 6a380481d4..ee972f2d1d 100644
--- a/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs
+++ b/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs
@@ -16,7 +16,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// Diagnoses redundant trait items in a trait impl.
pub(crate) fn trait_impl_redundant_assoc_item(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TraitImplRedundantAssocItems,
) -> Diagnostic {
let db = ctx.sema.db;
@@ -74,7 +74,7 @@ pub(crate) fn trait_impl_redundant_assoc_item(
/// add assoc item into the trait def body
fn quickfix_for_redundant_assoc_item(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TraitImplRedundantAssocItems,
redundant_item_def: String,
range: TextRange,
diff --git a/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/crates/ide-diagnostics/src/handlers/type_mismatch.rs
index a845e0b59a..d469405d61 100644
--- a/crates/ide-diagnostics/src/handlers/type_mismatch.rs
+++ b/crates/ide-diagnostics/src/handlers/type_mismatch.rs
@@ -20,7 +20,7 @@ use crate::{Assist, Diagnostic, DiagnosticCode, DiagnosticsContext, adjusted_dis
// This diagnostic is triggered when the type of an expression or pattern does not match
// the expected type.
pub(crate) fn type_mismatch(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TypeMismatch<'_>,
) -> Option<Diagnostic> {
if d.expected.is_unknown() || d.actual.is_unknown() {
@@ -64,7 +64,7 @@ pub(crate) fn type_mismatch(
)
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::TypeMismatch<'_>) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::TypeMismatch<'_>) -> Option<Vec<Assist>> {
let mut fixes = Vec::new();
if let Some(expr_ptr) = d.expr_or_pat.value.cast::<ast::Expr>() {
@@ -80,7 +80,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::TypeMismatch<'_>) -> Option<Vec<
}
fn add_reference(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TypeMismatch<'_>,
expr_ptr: &InFile<AstPtr<ast::Expr>>,
acc: &mut Vec<Assist>,
@@ -102,7 +102,7 @@ fn add_reference(
}
fn add_missing_ok_or_some(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TypeMismatch<'_>,
expr_ptr: &InFile<AstPtr<ast::Expr>>,
acc: &mut Vec<Assist>,
@@ -197,7 +197,7 @@ fn add_missing_ok_or_some(
}
fn remove_unnecessary_wrapper(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TypeMismatch<'_>,
expr_ptr: &InFile<AstPtr<ast::Expr>>,
acc: &mut Vec<Assist>,
@@ -279,7 +279,7 @@ fn remove_unnecessary_wrapper(
}
fn remove_semicolon(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TypeMismatch<'_>,
expr_ptr: &InFile<AstPtr<ast::Expr>>,
acc: &mut Vec<Assist>,
@@ -310,7 +310,7 @@ fn remove_semicolon(
}
fn str_ref_to_owned(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::TypeMismatch<'_>,
expr_ptr: &InFile<AstPtr<ast::Expr>>,
acc: &mut Vec<Assist>,
diff --git a/crates/ide-diagnostics/src/handlers/type_must_be_known.rs b/crates/ide-diagnostics/src/handlers/type_must_be_known.rs
index 08bcc738cb..ad86df407a 100644
--- a/crates/ide-diagnostics/src/handlers/type_must_be_known.rs
+++ b/crates/ide-diagnostics/src/handlers/type_must_be_known.rs
@@ -9,7 +9,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered when rust-analyzer cannot infer some type.
pub(crate) fn type_must_be_known<'db>(
- ctx: &DiagnosticsContext<'db>,
+ ctx: &DiagnosticsContext<'db, '_>,
d: &hir::TypeMustBeKnown<'db>,
) -> Diagnostic {
let mut at_point = d.at_point.map(|it| it.syntax_node_ptr());
diff --git a/crates/ide-diagnostics/src/handlers/typed_hole.rs b/crates/ide-diagnostics/src/handlers/typed_hole.rs
index ddd1dd402e..e000d6388a 100644
--- a/crates/ide-diagnostics/src/handlers/typed_hole.rs
+++ b/crates/ide-diagnostics/src/handlers/typed_hole.rs
@@ -20,7 +20,10 @@ use syntax::AstNode;
// Diagnostic: typed-hole
//
// This diagnostic is triggered when an underscore expression is used in an invalid position.
-pub(crate) fn typed_hole(ctx: &DiagnosticsContext<'_>, d: &hir::TypedHole<'_>) -> Diagnostic {
+pub(crate) fn typed_hole<'db>(
+ ctx: &DiagnosticsContext<'_, 'db>,
+ d: &hir::TypedHole<'db>,
+) -> Diagnostic {
let display_range = ctx.sema.diagnostics_display_range(d.expr.map(|it| it.into()));
let (message, fixes) = if d.expected.is_unknown() {
("`_` expressions may only appear on the left-hand side of an assignment".to_owned(), None)
@@ -41,7 +44,7 @@ pub(crate) fn typed_hole(ctx: &DiagnosticsContext<'_>, d: &hir::TypedHole<'_>) -
.with_fixes(fixes)
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::TypedHole<'_>) -> Option<Vec<Assist>> {
+fn fixes<'db>(ctx: &DiagnosticsContext<'_, 'db>, d: &hir::TypedHole<'db>) -> Option<Vec<Assist>> {
let db = ctx.sema.db;
let root = db.parse_or_expand(d.expr.file_id);
let (original_range, _) =
diff --git a/crates/ide-diagnostics/src/handlers/undeclared_label.rs b/crates/ide-diagnostics/src/handlers/undeclared_label.rs
index f81d34377d..1bab4f453f 100644
--- a/crates/ide-diagnostics/src/handlers/undeclared_label.rs
+++ b/crates/ide-diagnostics/src/handlers/undeclared_label.rs
@@ -2,7 +2,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// Diagnostic: undeclared-label
pub(crate) fn undeclared_label(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UndeclaredLabel,
) -> Diagnostic {
let name = &d.name;
diff --git a/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs b/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs
index 5627393f31..b652456c09 100644
--- a/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs
+++ b/crates/ide-diagnostics/src/handlers/unimplemented_builtin_macro.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, Severity};
//
// This diagnostic is shown for builtin macros which are not yet implemented by rust-analyzer
pub(crate) fn unimplemented_builtin_macro(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnimplementedBuiltinMacro,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/unlinked_file.rs b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
index 570319c347..dc6ae6f08b 100644
--- a/crates/ide-diagnostics/src/handlers/unlinked_file.rs
+++ b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
@@ -20,7 +20,7 @@ use crate::{Assist, Diagnostic, DiagnosticCode, DiagnosticsContext, Severity, fi
// This diagnostic is shown for files that are not included in any crate, or files that are part of
// crates rust-analyzer failed to discover. The file will not have IDE features available.
pub(crate) fn unlinked_file(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
acc: &mut Vec<Diagnostic>,
file_id: FileId,
) {
@@ -73,7 +73,7 @@ pub(crate) fn unlinked_file(
}
fn fixes(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
file_id: FileId,
trigger_range: TextRange,
) -> Option<Vec<Assist>> {
diff --git a/crates/ide-diagnostics/src/handlers/unreachable_label.rs b/crates/ide-diagnostics/src/handlers/unreachable_label.rs
index 0c9e0d6ce4..52138b7cd5 100644
--- a/crates/ide-diagnostics/src/handlers/unreachable_label.rs
+++ b/crates/ide-diagnostics/src/handlers/unreachable_label.rs
@@ -2,7 +2,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// Diagnostic: unreachable-label
pub(crate) fn unreachable_label(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnreachableLabel,
) -> Diagnostic {
let name = &d.name;
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_assoc_item.rs b/crates/ide-diagnostics/src/handlers/unresolved_assoc_item.rs
index f181021bdc..7797c665fd 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_assoc_item.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_assoc_item.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if the referenced associated item does not exist.
pub(crate) fn unresolved_assoc_item(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedAssocItem,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_extern_crate.rs b/crates/ide-diagnostics/src/handlers/unresolved_extern_crate.rs
index 7c3eacf7e3..2c1f1e7283 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_extern_crate.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_extern_crate.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate.
pub(crate) fn unresolved_extern_crate(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedExternCrate,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_field.rs b/crates/ide-diagnostics/src/handlers/unresolved_field.rs
index 59ec259adf..78e13677cf 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_field.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_field.rs
@@ -22,7 +22,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, adjusted_display_ran
//
// This diagnostic is triggered if a field does not exist on a given type.
pub(crate) fn unresolved_field(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedField<'_>,
) -> Diagnostic {
let method_suffix = if d.method_with_same_name_exists {
@@ -52,7 +52,7 @@ pub(crate) fn unresolved_field(
.with_fixes(fixes(ctx, d))
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField<'_>) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::UnresolvedField<'_>) -> Option<Vec<Assist>> {
let mut fixes = Vec::new();
if d.method_with_same_name_exists {
fixes.extend(method_fix(ctx, &d.expr));
@@ -62,7 +62,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField<'_>) -> Option<V
}
// FIXME: Add Snippet Support
-fn field_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField<'_>) -> Option<Assist> {
+fn field_fix(ctx: &DiagnosticsContext<'_, '_>, d: &hir::UnresolvedField<'_>) -> Option<Assist> {
// Get the FileRange of the invalid field access
let root = ctx.sema.db.parse_or_expand(d.expr.file_id);
let expr = d.expr.value.to_node(&root).left()?;
@@ -101,7 +101,7 @@ fn field_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField<'_>) -> Opti
}
fn add_variant_to_union(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
adt_union: Union,
field_name: &str,
suggested_type: Type,
@@ -129,7 +129,7 @@ fn add_variant_to_union(
}
fn add_field_to_struct_fix(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
adt_struct: Struct,
field_name: &str,
suggested_type: Type,
@@ -263,7 +263,7 @@ fn record_field_layout(
// FIXME: We should fill out the call here, move the cursor and trigger signature help
fn method_fix(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
expr_ptr: &InFile<AstPtr<Either<ast::Expr, ast::Pat>>>,
) -> Option<Assist> {
let root = ctx.sema.db.parse_or_expand(expr_ptr.file_id);
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_ident.rs b/crates/ide-diagnostics/src/handlers/unresolved_ident.rs
index 801023dabd..6ecf0be825 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_ident.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_ident.rs
@@ -4,7 +4,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered if an expr-position ident is invalid.
pub(crate) fn unresolved_ident(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedIdent,
) -> Diagnostic {
let mut range =
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_import.rs b/crates/ide-diagnostics/src/handlers/unresolved_import.rs
index 0da535d11b..f9a125de13 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_import.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_import.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// This diagnostic is triggered if rust-analyzer is unable to resolve a path in
// a `use` declaration.
pub(crate) fn unresolved_import(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedImport,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs b/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs
index 030c82ca0b..9be7ef6fe7 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs
@@ -5,7 +5,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// This diagnostic is triggered if rust-analyzer is unable to resolve the path
// to a macro in a macro invocation.
pub(crate) fn unresolved_macro_call(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedMacroCall,
) -> Diagnostic {
let display_range = ctx.sema.diagnostics_display_range_for_range(d.range);
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_method.rs b/crates/ide-diagnostics/src/handlers/unresolved_method.rs
index bd5d134348..93caf281f0 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_method.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_method.rs
@@ -17,7 +17,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, adjusted_display_ran
//
// This diagnostic is triggered if a method does not exist on a given type.
pub(crate) fn unresolved_method(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedMethodCall<'_>,
) -> Diagnostic {
let suffix = if d.field_with_same_name.is_some() {
@@ -49,7 +49,10 @@ pub(crate) fn unresolved_method(
.with_fixes(fixes(ctx, d))
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall<'_>) -> Option<Vec<Assist>> {
+fn fixes(
+ ctx: &DiagnosticsContext<'_, '_>,
+ d: &hir::UnresolvedMethodCall<'_>,
+) -> Option<Vec<Assist>> {
let field_fix = if let Some(ty) = &d.field_with_same_name {
field_fix(ctx, d, ty)
} else {
@@ -71,7 +74,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall<'_>) -> Opt
}
fn field_fix(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedMethodCall<'_>,
ty: &hir::Type<'_>,
) -> Option<Assist> {
@@ -108,7 +111,7 @@ fn field_fix(
}
fn assoc_func_fix(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedMethodCall<'_>,
) -> Option<Assist> {
if let Some(f) = d.assoc_func_with_same_name {
diff --git a/crates/ide-diagnostics/src/handlers/unresolved_module.rs b/crates/ide-diagnostics/src/handlers/unresolved_module.rs
index 1a409d7e76..1e0e9105d8 100644
--- a/crates/ide-diagnostics/src/handlers/unresolved_module.rs
+++ b/crates/ide-diagnostics/src/handlers/unresolved_module.rs
@@ -9,7 +9,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext, fix};
//
// This diagnostic is triggered if rust-analyzer is unable to discover referred module.
pub(crate) fn unresolved_module(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnresolvedModule,
) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
@@ -32,7 +32,7 @@ pub(crate) fn unresolved_module(
.with_fixes(fixes(ctx, d))
}
-fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedModule) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_, '_>, d: &hir::UnresolvedModule) -> Option<Vec<Assist>> {
let root = ctx.sema.db.parse_or_expand(d.decl.file_id);
let unresolved_module = d.decl.value.to_node(&root);
Some(
diff --git a/crates/ide-diagnostics/src/handlers/unused_variables.rs b/crates/ide-diagnostics/src/handlers/unused_variables.rs
index 52a2f44fd0..afc74445f4 100644
--- a/crates/ide-diagnostics/src/handlers/unused_variables.rs
+++ b/crates/ide-diagnostics/src/handlers/unused_variables.rs
@@ -14,7 +14,7 @@ use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
//
// This diagnostic is triggered when a local variable is not used.
pub(crate) fn unused_variables(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
d: &hir::UnusedVariable,
) -> Option<Diagnostic> {
let ast = d.local.primary_source(ctx.sema.db).syntax_ptr();
diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs
index 7c07f8fd6c..335e4b047c 100644
--- a/crates/ide-diagnostics/src/lib.rs
+++ b/crates/ide-diagnostics/src/lib.rs
@@ -195,7 +195,7 @@ impl Diagnostic {
}
fn new_with_syntax_node_ptr(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
code: DiagnosticCode,
message: impl Into<String>,
node: InFile<SyntaxNodePtr>,
@@ -281,17 +281,17 @@ impl DiagnosticsConfig {
}
}
-struct DiagnosticsContext<'a> {
+struct DiagnosticsContext<'a, 'db> {
config: &'a DiagnosticsConfig,
- sema: Semantics<'a, RootDatabase>,
+ sema: Semantics<'db, RootDatabase>,
resolve: &'a AssistResolveStrategy,
edition: Edition,
display_target: DisplayTarget,
is_nightly: bool,
}
-impl<'a> DiagnosticsContext<'a> {
- fn db(&self) -> &'a RootDatabase {
+impl<'db> DiagnosticsContext<'_, 'db> {
+ fn db(&self) -> &'db RootDatabase {
self.sema.db
}
}
@@ -778,7 +778,7 @@ fn unresolved_fix(id: &'static str, label: &str, target: TextRange) -> Assist {
}
fn adjusted_display_range<N: AstNode>(
- ctx: &DiagnosticsContext<'_>,
+ ctx: &DiagnosticsContext<'_, '_>,
diag_ptr: InFile<AstPtr<N>>,
adj: &dyn Fn(N) -> Option<TextRange>,
) -> FileRange {
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs
index cc322d2b9e..8415220c14 100644
--- a/crates/ide/src/expand_macro.rs
+++ b/crates/ide/src/expand_macro.rs
@@ -72,7 +72,7 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
SyntaxKind::MACRO_ITEMS,
position.file_id,
expansion,
- &expansion_span_map,
+ expansion_span_map,
krate,
);
if let Some(err) = err {
@@ -163,7 +163,7 @@ fn expand_macro_recur(
result_span_map.merge(
TextRange::at(offset_in_original_node, macro_call.syntax().text_range().len()),
expanded.text_range().len(),
- &expansion_span_map,
+ expansion_span_map,
);
Some(expand(sema, expanded, error, result_span_map, u32::from(offset_in_original_node) as i32))
}
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index e6ef7b8949..12ce457ea6 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -695,14 +695,14 @@ fn merge_map(res: &mut HighlightMap, new: Option<HighlightMap>) {
/// Preorder walk all the expression's child expressions.
/// For macro calls, the callback will be called on the expanded expressions after
/// visiting the macro call itself.
-struct WalkExpandedExprCtx<'a> {
- sema: &'a Semantics<'a, RootDatabase>,
+struct WalkExpandedExprCtx<'a, 'db> {
+ sema: &'a Semantics<'db, RootDatabase>,
depth: usize,
check_ctx: &'static dyn Fn(&ast::Expr) -> bool,
}
-impl<'a> WalkExpandedExprCtx<'a> {
- fn new(sema: &'a Semantics<'a, RootDatabase>) -> Self {
+impl<'a, 'db> WalkExpandedExprCtx<'a, 'db> {
+ fn new(sema: &'a Semantics<'db, RootDatabase>) -> Self {
Self { sema, depth: 0, check_ctx: &is_closure_or_blk_with_modif }
}
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index 4d712bf0f0..4f60321e32 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -544,7 +544,7 @@ pub(super) fn definition(
let mut body = source.value.body()?.syntax().clone();
if let Some(macro_file) = source.file_id.macro_file() {
let span_map = db.expansion_span_map(macro_file);
- body = prettify_macro_expansion(db, body, &span_map, it.krate(db).into());
+ body = prettify_macro_expansion(db, body, span_map, it.krate(db).into());
}
if env::var_os("RA_DEV").is_some() {
format!("{body}\n{}", render_const_eval_error(db, err, display_target))
@@ -576,7 +576,7 @@ pub(super) fn definition(
let mut body = source.value.body()?.syntax().clone();
if let Some(macro_file) = source.file_id.macro_file() {
let span_map = db.expansion_span_map(macro_file);
- body = prettify_macro_expansion(db, body, &span_map, it.krate(db).into());
+ body = prettify_macro_expansion(db, body, span_map, it.krate(db).into());
}
if env::var_os("RA_DEV").is_some() {
format!("{body}\n{}", render_const_eval_error(db, err, display_target))
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 0d2239c71f..a15366fea9 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -687,21 +687,21 @@ impl fmt::Debug for InlayHintLabelPart {
}
#[derive(Debug)]
-struct InlayHintLabelBuilder<'a> {
- sema: &'a Semantics<'a, RootDatabase>,
+struct InlayHintLabelBuilder<'a, 'db> {
+ sema: &'a Semantics<'db, RootDatabase>,
result: InlayHintLabel,
last_part: String,
resolve: bool,
location: Option<LazyProperty<FileRange>>,
}
-impl fmt::Write for InlayHintLabelBuilder<'_> {
+impl fmt::Write for InlayHintLabelBuilder<'_, '_> {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.last_part.write_str(s)
}
}
-impl HirWrite for InlayHintLabelBuilder<'_> {
+impl HirWrite for InlayHintLabelBuilder<'_, '_> {
fn start_location_link(&mut self, def: ModuleDefId) {
never!(self.location.is_some(), "location link is already started");
self.make_new_part();
@@ -737,7 +737,7 @@ impl HirWrite for InlayHintLabelBuilder<'_> {
}
}
-impl InlayHintLabelBuilder<'_> {
+impl InlayHintLabelBuilder<'_, '_> {
fn make_new_part(&mut self) {
let text = take(&mut self.last_part);
if !text.is_empty() {
@@ -755,18 +755,18 @@ impl InlayHintLabelBuilder<'_> {
}
}
-fn label_of_ty(
- famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>,
+fn label_of_ty<'db>(
+ famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, 'db>,
config: &InlayHintsConfig<'_>,
- ty: &hir::Type<'_>,
+ ty: &hir::Type<'db>,
display_target: DisplayTarget,
) -> Option<InlayHintLabel> {
- fn rec(
- sema: &Semantics<'_, RootDatabase>,
- famous_defs: &FamousDefs<'_, '_>,
+ fn rec<'db>(
+ sema: &Semantics<'db, RootDatabase>,
+ famous_defs: &FamousDefs<'_, 'db>,
mut max_length: Option<usize>,
- ty: &hir::Type<'_>,
- label_builder: &mut InlayHintLabelBuilder<'_>,
+ ty: &hir::Type<'db>,
+ label_builder: &mut InlayHintLabelBuilder<'_, '_>,
config: &InlayHintsConfig<'_>,
display_target: DisplayTarget,
) -> Result<(), HirDisplayError> {
@@ -790,7 +790,7 @@ fn label_of_ty(
)
});
- let module_def_location = |label_builder: &mut InlayHintLabelBuilder<'_>,
+ let module_def_location = |label_builder: &mut InlayHintLabelBuilder<'_, '_>,
def: ModuleDef,
name| {
let def = def.try_into();
diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs
index 936cf178f0..76fdac097f 100644
--- a/crates/mbe/src/lib.rs
+++ b/crates/mbe/src/lib.rs
@@ -374,6 +374,13 @@ impl<T, E> ValueResult<T, E> {
ValueResult { value: f(self.value), err: self.err }
}
+ pub fn as_ref(&self) -> ValueResult<&T, E>
+ where
+ E: Clone,
+ {
+ ValueResult { value: &self.value, err: self.err.clone() }
+ }
+
pub fn map_err<E2>(self, f: impl FnOnce(E) -> E2) -> ValueResult<T, E2> {
ValueResult { value: self.value, err: self.err.map(f) }
}