Unnamed repository; edit this file 'description' to name the repository.
Run cargo fix --edition-idioms
Amos Wenger 2022-07-20
parent 23d25a3 · commit 816f7fe
-rw-r--r--crates/base-db/src/change.rs2
-rw-r--r--crates/base-db/src/input.rs4
-rw-r--r--crates/base-db/src/lib.rs4
-rw-r--r--crates/cfg/src/cfg_expr.rs2
-rw-r--r--crates/hir-def/src/generics.rs10
-rw-r--r--crates/hir-def/src/nameres/collector.rs2
-rw-r--r--crates/hir-def/src/path.rs4
-rw-r--r--crates/hir-def/src/path/lower.rs6
-rw-r--r--crates/hir-def/src/test_db.rs2
-rw-r--r--crates/hir-def/src/type_ref.rs10
-rw-r--r--crates/hir-expand/src/mod_path.rs2
-rw-r--r--crates/hir-expand/src/name.rs6
-rw-r--r--crates/hir-ty/src/autoderef.rs6
-rw-r--r--crates/hir-ty/src/builder.rs2
-rw-r--r--crates/hir-ty/src/diagnostics/match_check.rs6
-rw-r--r--crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs2
-rw-r--r--crates/hir-ty/src/display.rs52
-rw-r--r--crates/hir-ty/src/infer.rs16
-rw-r--r--crates/hir-ty/src/infer/unify.rs4
-rw-r--r--crates/hir-ty/src/interner.rs2
-rw-r--r--crates/hir-ty/src/lower.rs4
-rw-r--r--crates/hir-ty/src/method_resolution.rs14
-rw-r--r--crates/hir-ty/src/test_db.rs2
-rw-r--r--crates/hir-ty/src/tls.rs4
-rw-r--r--crates/hir-ty/src/utils.rs2
-rw-r--r--crates/hir/src/display.rs50
-rw-r--r--crates/hir/src/lib.rs8
-rw-r--r--crates/hir/src/semantics.rs10
-rw-r--r--crates/hir/src/symbols.rs2
-rw-r--r--crates/ide-assists/src/assist_context.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.rs2
-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.rs8
-rw-r--r--crates/ide-assists/src/handlers/add_missing_match_arms.rs8
-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.rs2
-rw-r--r--crates/ide-assists/src/handlers/auto_import.rs6
-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_comment_block.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_integer_literal.rs2
-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.rs10
-rw-r--r--crates/ide-assists/src/handlers/convert_let_else_to_match.rs4
-rw-r--r--crates/ide-assists/src/handlers/convert_to_guarded_return.rs2
-rw-r--r--crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs8
-rw-r--r--crates/ide-assists/src/handlers/convert_while_to_loop.rs2
-rw-r--r--crates/ide-assists/src/handlers/destructure_tuple_binding.rs30
-rw-r--r--crates/ide-assists/src/handlers/expand_glob_import.rs14
-rw-r--r--crates/ide-assists/src/handlers/extract_function.rs78
-rw-r--r--crates/ide-assists/src/handlers/extract_module.rs14
-rw-r--r--crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs6
-rw-r--r--crates/ide-assists/src/handlers/extract_type_alias.rs2
-rw-r--r--crates/ide-assists/src/handlers/extract_variable.rs4
-rw-r--r--crates/ide-assists/src/handlers/fix_visibility.rs6
-rw-r--r--crates/ide-assists/src/handlers/flip_binexpr.rs2
-rw-r--r--crates/ide-assists/src/handlers/flip_comma.rs2
-rw-r--r--crates/ide-assists/src/handlers/flip_trait_bound.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.rs4
-rw-r--r--crates/ide-assists/src/handlers/generate_delegate_methods.rs2
-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.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_enum_projection_method.rs6
-rw-r--r--crates/ide-assists/src/handlers/generate_enum_variant.rs4
-rw-r--r--crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_function.rs30
-rw-r--r--crates/ide-assists/src/handlers/generate_getter.rs6
-rw-r--r--crates/ide-assists/src/handlers/generate_impl.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_is_empty_from_len.rs4
-rw-r--r--crates/ide-assists/src/handlers/generate_new.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_setter.rs2
-rw-r--r--crates/ide-assists/src/handlers/inline_call.rs6
-rw-r--r--crates/ide-assists/src/handlers/inline_local_variable.rs6
-rw-r--r--crates/ide-assists/src/handlers/inline_type_alias.rs4
-rw-r--r--crates/ide-assists/src/handlers/introduce_named_generic.rs2
-rw-r--r--crates/ide-assists/src/handlers/introduce_named_lifetime.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/move_bounds.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/number_representation.rs2
-rw-r--r--crates/ide-assists/src/handlers/promote_local_to_const.rs4
-rw-r--r--crates/ide-assists/src/handlers/pull_assignment_up.rs4
-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.rs8
-rw-r--r--crates/ide-assists/src/handlers/remove_dbg.rs2
-rw-r--r--crates/ide-assists/src/handlers/remove_mut.rs2
-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.rs6
-rw-r--r--crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs6
-rw-r--r--crates/ide-assists/src/handlers/replace_if_let_with_match.rs12
-rw-r--r--crates/ide-assists/src/handlers/replace_let_with_if_let.rs2
-rw-r--r--crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs2
-rw-r--r--crates/ide-assists/src/handlers/replace_string_with_char.rs4
-rw-r--r--crates/ide-assists/src/handlers/replace_try_expr_with_match.rs2
-rw-r--r--crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs2
-rw-r--r--crates/ide-assists/src/handlers/sort_items.rs2
-rw-r--r--crates/ide-assists/src/handlers/split_import.rs2
-rw-r--r--crates/ide-assists/src/handlers/toggle_ignore.rs2
-rw-r--r--crates/ide-assists/src/handlers/unmerge_use.rs2
-rw-r--r--crates/ide-assists/src/handlers/unnecessary_async.rs6
-rw-r--r--crates/ide-assists/src/handlers/unwrap_block.rs2
-rw-r--r--crates/ide-assists/src/handlers/unwrap_result_return_type.rs2
-rw-r--r--crates/ide-assists/src/handlers/wrap_return_type_in_result.rs2
-rw-r--r--crates/ide-assists/src/lib.rs2
-rw-r--r--crates/ide-assists/src/tests.rs2
-rw-r--r--crates/ide-assists/src/utils.rs22
-rw-r--r--crates/ide-completion/src/completions.rs68
-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/lint.rs2
-rw-r--r--crates/ide-completion/src/completions/attribute/repr.rs2
-rw-r--r--crates/ide-completion/src/completions/dot.rs8
-rw-r--r--crates/ide-completion/src/completions/expr.rs2
-rw-r--r--crates/ide-completion/src/completions/extern_abi.rs2
-rw-r--r--crates/ide-completion/src/completions/field.rs4
-rw-r--r--crates/ide-completion/src/completions/flyimport.rs16
-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.rs6
-rw-r--r--crates/ide-completion/src/completions/item_list/trait_impl.rs22
-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/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/record.rs10
-rw-r--r--crates/ide-completion/src/completions/snippet.rs8
-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.rs2
-rw-r--r--crates/ide-completion/src/context/analysis.rs16
-rw-r--r--crates/ide-completion/src/item.rs4
-rw-r--r--crates/ide-completion/src/render.rs10
-rw-r--r--crates/ide-completion/src/render/function.rs8
-rw-r--r--crates/ide-completion/src/render/literal.rs2
-rw-r--r--crates/ide-completion/src/render/union_literal.rs2
-rw-r--r--crates/ide-completion/src/render/variant.rs2
-rw-r--r--crates/ide-completion/src/snippet.rs4
-rw-r--r--crates/ide-db/src/active_parameter.rs6
-rw-r--r--crates/ide-db/src/defs.rs20
-rw-r--r--crates/ide-db/src/helpers.rs2
-rw-r--r--crates/ide-db/src/imports/import_assets.rs32
-rw-r--r--crates/ide-db/src/lib.rs2
-rw-r--r--crates/ide-db/src/path_transform.rs2
-rw-r--r--crates/ide-db/src/rename.rs12
-rw-r--r--crates/ide-db/src/search.rs6
-rw-r--r--crates/ide-db/src/symbol_index.rs2
-rw-r--r--crates/ide-db/src/syntax_helpers/node_ext.rs2
-rw-r--r--crates/ide-db/src/tests/sourcegen_lints.rs2
-rw-r--r--crates/ide-db/src/traits.rs4
-rw-r--r--crates/ide-db/src/ty_filter.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/no_such_field.rs2
-rw-r--r--crates/ide-diagnostics/src/handlers/unlinked_file.rs4
-rw-r--r--crates/ide-ssr/src/from_comment.rs2
-rw-r--r--crates/ide-ssr/src/matching.rs24
-rw-r--r--crates/ide-ssr/src/nester.rs6
-rw-r--r--crates/ide-ssr/src/resolving.rs2
-rw-r--r--crates/ide-ssr/src/tests.rs2
-rw-r--r--crates/ide/src/doc_links.rs8
-rw-r--r--crates/ide/src/doc_links/tests.rs4
-rw-r--r--crates/ide/src/expand_macro.rs8
-rw-r--r--crates/ide/src/extend_selection.rs4
-rw-r--r--crates/ide/src/goto_definition.rs4
-rw-r--r--crates/ide/src/goto_implementation.rs6
-rw-r--r--crates/ide/src/highlight_related.rs10
-rw-r--r--crates/ide/src/hover.rs8
-rw-r--r--crates/ide/src/hover/render.rs16
-rw-r--r--crates/ide/src/inlay_hints.rs34
-rw-r--r--crates/ide/src/references.rs8
-rw-r--r--crates/ide/src/rename.rs6
-rw-r--r--crates/ide/src/runnables.rs20
-rw-r--r--crates/ide/src/signature_help.rs4
-rw-r--r--crates/ide/src/static_index.rs4
-rw-r--r--crates/ide/src/status.rs6
-rw-r--r--crates/ide/src/syntax_highlighting.rs2
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs20
-rw-r--r--crates/ide/src/syntax_highlighting/inject.rs4
-rw-r--r--crates/mbe/src/expander/matcher.rs6
-rw-r--r--crates/mbe/src/expander/transcriber.rs6
-rw-r--r--crates/mbe/src/lib.rs2
-rw-r--r--crates/mbe/src/parser.rs4
-rw-r--r--crates/mbe/src/to_parser_input.rs2
-rw-r--r--crates/parser/src/grammar.rs54
-rw-r--r--crates/parser/src/grammar/attributes.rs8
-rw-r--r--crates/parser/src/grammar/expressions.rs42
-rw-r--r--crates/parser/src/grammar/expressions/atom.rs46
-rw-r--r--crates/parser/src/grammar/generic_args.rs12
-rw-r--r--crates/parser/src/grammar/generic_params.rs28
-rw-r--r--crates/parser/src/grammar/items.rs30
-rw-r--r--crates/parser/src/grammar/items/adt.rs18
-rw-r--r--crates/parser/src/grammar/items/consts.rs6
-rw-r--r--crates/parser/src/grammar/items/traits.rs10
-rw-r--r--crates/parser/src/grammar/items/use_item.rs6
-rw-r--r--crates/parser/src/grammar/params.rs18
-rw-r--r--crates/parser/src/grammar/paths.rs20
-rw-r--r--crates/parser/src/grammar/patterns.rs44
-rw-r--r--crates/parser/src/grammar/types.rs38
-rw-r--r--crates/parser/src/lib.rs6
-rw-r--r--crates/parser/src/parser.rs8
-rw-r--r--crates/parser/src/shortcuts.rs2
-rw-r--r--crates/proc-macro-srv/src/abis/abi_1_58/mod.rs2
-rw-r--r--crates/proc-macro-srv/src/abis/abi_1_63/mod.rs2
-rw-r--r--crates/proc-macro-srv/src/abis/abi_1_64/mod.rs2
-rw-r--r--crates/profile/src/memory_usage.rs4
-rw-r--r--crates/rust-analyzer/src/bin/logger.rs2
-rw-r--r--crates/rust-analyzer/tests/slow-tests/support.rs2
-rw-r--r--crates/syntax/src/ast/node_ext.rs2
-rw-r--r--crates/syntax/src/syntax_error.rs2
-rw-r--r--crates/syntax/src/tests/ast_src.rs2
-rw-r--r--crates/syntax/src/token_text.rs8
-rw-r--r--crates/test-utils/src/lib.rs2
-rw-r--r--crates/tt/src/buffer.rs6
-rw-r--r--crates/tt/src/lib.rs12
-rw-r--r--lib/la-arena/src/lib.rs6
230 files changed, 888 insertions, 888 deletions
diff --git a/crates/base-db/src/change.rs b/crates/base-db/src/change.rs
index 7e645d0fa8..b57f234576 100644
--- a/crates/base-db/src/change.rs
+++ b/crates/base-db/src/change.rs
@@ -17,7 +17,7 @@ pub struct Change {
}
impl fmt::Debug for Change {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut d = fmt.debug_struct("Change");
if let Some(roots) = &self.roots {
d.field("roots", roots);
diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs
index 459b82599f..9b5a10acfb 100644
--- a/crates/base-db/src/input.rs
+++ b/crates/base-db/src/input.rs
@@ -104,7 +104,7 @@ impl CrateName {
}
impl fmt::Display for CrateName {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
@@ -187,7 +187,7 @@ impl From<CrateName> for CrateDisplayName {
}
impl fmt::Display for CrateDisplayName {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.crate_name.fmt(f)
}
}
diff --git a/crates/base-db/src/lib.rs b/crates/base-db/src/lib.rs
index f55b82e8ab..2d0a95b09d 100644
--- a/crates/base-db/src/lib.rs
+++ b/crates/base-db/src/lib.rs
@@ -57,7 +57,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
pub trait FileLoader {
/// Text of the file.
fn file_text(&self, file_id: FileId) -> Arc<String>;
- fn resolve_path(&self, path: AnchoredPath) -> Option<FileId>;
+ fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
}
@@ -116,7 +116,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
fn file_text(&self, file_id: FileId) -> Arc<String> {
SourceDatabaseExt::file_text(self.0, file_id)
}
- fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
+ fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
// FIXME: this *somehow* should be platform agnostic...
let source_root = self.0.file_source_root(path.anchor);
let source_root = self.0.source_root(source_root);
diff --git a/crates/cfg/src/cfg_expr.rs b/crates/cfg/src/cfg_expr.rs
index 5db5e5d390..fd9e31ed3b 100644
--- a/crates/cfg/src/cfg_expr.rs
+++ b/crates/cfg/src/cfg_expr.rs
@@ -85,7 +85,7 @@ impl CfgExpr {
}
}
-fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> {
+fn next_cfg_expr(it: &mut SliceIter<'_, tt::TokenTree>) -> Option<CfgExpr> {
let name = match it.next() {
None => return None,
Some(tt::TokenTree::Leaf(tt::Leaf::Ident(ident))) => ident.text.clone(),
diff --git a/crates/hir-def/src/generics.rs b/crates/hir-def/src/generics.rs
index eec960aa7d..2397cf5015 100644
--- a/crates/hir-def/src/generics.rs
+++ b/crates/hir-def/src/generics.rs
@@ -195,7 +195,7 @@ impl GenericParams {
}
}
- pub(crate) fn fill(&mut self, lower_ctx: &LowerCtx, node: &dyn HasGenericParams) {
+ pub(crate) fn fill(&mut self, lower_ctx: &LowerCtx<'_>, node: &dyn HasGenericParams) {
if let Some(params) = node.generic_param_list() {
self.fill_params(lower_ctx, params)
}
@@ -206,7 +206,7 @@ impl GenericParams {
pub(crate) fn fill_bounds(
&mut self,
- lower_ctx: &LowerCtx,
+ lower_ctx: &LowerCtx<'_>,
node: &dyn ast::HasTypeBounds,
target: Either<TypeRef, LifetimeRef>,
) {
@@ -217,7 +217,7 @@ impl GenericParams {
}
}
- fn fill_params(&mut self, lower_ctx: &LowerCtx, params: ast::GenericParamList) {
+ fn fill_params(&mut self, lower_ctx: &LowerCtx<'_>, params: ast::GenericParamList) {
for type_or_const_param in params.type_or_const_params() {
match type_or_const_param {
ast::TypeOrConstParam::Type(type_param) => {
@@ -259,7 +259,7 @@ impl GenericParams {
}
}
- fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) {
+ fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx<'_>, where_clause: ast::WhereClause) {
for pred in where_clause.predicates() {
let target = if let Some(type_ref) = pred.ty() {
Either::Left(TypeRef::from_ast(lower_ctx, type_ref))
@@ -293,7 +293,7 @@ impl GenericParams {
fn add_where_predicate_from_bound(
&mut self,
- lower_ctx: &LowerCtx,
+ lower_ctx: &LowerCtx<'_>,
bound: ast::TypeBound,
hrtb_lifetimes: Option<&Box<[Name]>>,
target: Either<TypeRef, LifetimeRef>,
diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs
index 317e21538b..5f40d26a2e 100644
--- a/crates/hir-def/src/nameres/collector.rs
+++ b/crates/hir-def/src/nameres/collector.rs
@@ -1509,7 +1509,7 @@ impl ModCollector<'_, '_> {
let module = self.def_collector.def_map.module_id(self.module_id);
let def_map = &mut self.def_collector.def_map;
let update_def =
- |def_collector: &mut DefCollector, id, name: &Name, vis, has_constructor| {
+ |def_collector: &mut DefCollector<'_>, id, name: &Name, vis, has_constructor| {
def_collector.def_map.modules[self.module_id].scope.declare(id);
def_collector.update(
self.module_id,
diff --git a/crates/hir-def/src/path.rs b/crates/hir-def/src/path.rs
index 3aade788d7..7af7e5574d 100644
--- a/crates/hir-def/src/path.rs
+++ b/crates/hir-def/src/path.rs
@@ -88,7 +88,7 @@ pub enum GenericArg {
impl Path {
/// Converts an `ast::Path` to `Path`. Works with use trees.
/// It correctly handles `$crate` based path from macro call.
- pub fn from_src(path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
+ pub fn from_src(path: ast::Path, ctx: &LowerCtx<'_>) -> Option<Path> {
lower::lower_path(path, ctx)
}
@@ -188,7 +188,7 @@ impl<'a> PathSegments<'a> {
}
impl GenericArgs {
- pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::GenericArgList) -> Option<GenericArgs> {
+ pub(crate) fn from_ast(lower_ctx: &LowerCtx<'_>, node: ast::GenericArgList) -> Option<GenericArgs> {
lower::lower_generic_args(lower_ctx, node)
}
diff --git a/crates/hir-def/src/path/lower.rs b/crates/hir-def/src/path/lower.rs
index b6a24cd4ab..0428f1a398 100644
--- a/crates/hir-def/src/path/lower.rs
+++ b/crates/hir-def/src/path/lower.rs
@@ -15,7 +15,7 @@ use crate::{
/// Converts an `ast::Path` to `Path`. Works with use trees.
/// It correctly handles `$crate` based path from macro call.
-pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
+pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx<'_>) -> Option<Path> {
let mut kind = PathKind::Plain;
let mut type_anchor = None;
let mut segments = Vec::new();
@@ -149,7 +149,7 @@ pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
}
pub(super) fn lower_generic_args(
- lower_ctx: &LowerCtx,
+ lower_ctx: &LowerCtx<'_>,
node: ast::GenericArgList,
) -> Option<GenericArgs> {
let mut args = Vec::new();
@@ -196,7 +196,7 @@ pub(super) fn lower_generic_args(
/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)
/// -> Z` (which desugars to `Fn<(X, Y), Output=Z>`).
fn lower_generic_args_from_fn_path(
- ctx: &LowerCtx,
+ ctx: &LowerCtx<'_>,
params: Option<ast::ParamList>,
ret_type: Option<ast::RetType>,
) -> Option<GenericArgs> {
diff --git a/crates/hir-def/src/test_db.rs b/crates/hir-def/src/test_db.rs
index baf71731f4..9cdc18d6b6 100644
--- a/crates/hir-def/src/test_db.rs
+++ b/crates/hir-def/src/test_db.rs
@@ -73,7 +73,7 @@ impl FileLoader for TestDB {
fn file_text(&self, file_id: FileId) -> Arc<String> {
FileLoaderDelegate(self).file_text(file_id)
}
- fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
+ fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
diff --git a/crates/hir-def/src/type_ref.rs b/crates/hir-def/src/type_ref.rs
index 6be78745f1..97aeed819a 100644
--- a/crates/hir-def/src/type_ref.rs
+++ b/crates/hir-def/src/type_ref.rs
@@ -86,7 +86,7 @@ pub struct TraitRef {
impl TraitRef {
/// Converts an `ast::PathType` to a `hir::TraitRef`.
- pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Option<Self> {
+ pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Option<Self> {
// FIXME: Use `Path::from_src`
match node {
ast::Type::PathType(path) => {
@@ -159,7 +159,7 @@ pub enum TraitBoundModifier {
impl TypeRef {
/// Converts an `ast::TypeRef` to a `hir::TypeRef`.
- pub fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
+ pub fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Self {
match node {
ast::Type::ParenType(inner) => TypeRef::from_ast_opt(ctx, inner.ty()),
ast::Type::TupleType(inner) => {
@@ -245,7 +245,7 @@ impl TypeRef {
}
}
- pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::Type>) -> Self {
+ pub(crate) fn from_ast_opt(ctx: &LowerCtx<'_>, node: Option<ast::Type>) -> Self {
match node {
Some(node) => TypeRef::from_ast(ctx, node),
None => TypeRef::Error,
@@ -320,7 +320,7 @@ impl TypeRef {
}
pub(crate) fn type_bounds_from_ast(
- lower_ctx: &LowerCtx,
+ lower_ctx: &LowerCtx<'_>,
type_bounds_opt: Option<ast::TypeBoundList>,
) -> Vec<Interned<TypeBound>> {
if let Some(type_bounds) = type_bounds_opt {
@@ -331,7 +331,7 @@ pub(crate) fn type_bounds_from_ast(
}
impl TypeBound {
- pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::TypeBound) -> Self {
+ pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::TypeBound) -> Self {
let lower_path_type = |path_type: ast::PathType| ctx.lower_path(path_type.path()?);
match node.kind() {
diff --git a/crates/hir-expand/src/mod_path.rs b/crates/hir-expand/src/mod_path.rs
index 05e8c585c9..fea09521e8 100644
--- a/crates/hir-expand/src/mod_path.rs
+++ b/crates/hir-expand/src/mod_path.rs
@@ -102,7 +102,7 @@ impl ModPath {
}
}
- pub fn escaped(&self) -> EscapedModPath {
+ pub fn escaped(&self) -> EscapedModPath<'_> {
EscapedModPath(self)
}
diff --git a/crates/hir-expand/src/name.rs b/crates/hir-expand/src/name.rs
index 6b48258f37..85b0a7735f 100644
--- a/crates/hir-expand/src/name.rs
+++ b/crates/hir-expand/src/name.rs
@@ -21,7 +21,7 @@ enum Repr {
}
impl fmt::Display for Name {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 {
Repr::Text(text) => fmt::Display::fmt(&text, f),
Repr::TupleField(idx) => fmt::Display::fmt(&idx, f),
@@ -35,7 +35,7 @@ fn is_raw_identifier(name: &str) -> bool {
}
impl<'a> fmt::Display for EscapedName<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 .0 {
Repr::Text(text) => {
if is_raw_identifier(text) {
@@ -142,7 +142,7 @@ impl Name {
}
}
- pub fn escaped(&self) -> EscapedName {
+ pub fn escaped(&self) -> EscapedName<'_> {
EscapedName(self)
}
}
diff --git a/crates/hir-ty/src/autoderef.rs b/crates/hir-ty/src/autoderef.rs
index 22cb856535..837049cea3 100644
--- a/crates/hir-ty/src/autoderef.rs
+++ b/crates/hir-ty/src/autoderef.rs
@@ -70,7 +70,7 @@ impl Iterator for Autoderef<'_, '_> {
}
}
-pub(crate) fn autoderef_step(table: &mut InferenceTable, ty: Ty) -> Option<(AutoderefKind, Ty)> {
+pub(crate) fn autoderef_step(table: &mut InferenceTable<'_>, ty: Ty) -> Option<(AutoderefKind, Ty)> {
if let Some(derefed) = builtin_deref(&ty) {
Some((AutoderefKind::Builtin, table.resolve_ty_shallow(derefed)))
} else {
@@ -94,7 +94,7 @@ pub fn autoderef<'a>(
v.into_iter()
}
-pub(crate) fn deref(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
+pub(crate) fn deref(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
let _p = profile::span("deref");
autoderef_step(table, ty).map(|(_, ty)| ty)
}
@@ -107,7 +107,7 @@ fn builtin_deref(ty: &Ty) -> Option<&Ty> {
}
}
-fn deref_by_trait(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
+fn deref_by_trait(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
let _p = profile::span("deref_by_trait");
if table.resolve_ty_shallow(&ty).inference_var(Interner).is_some() {
// don't try to deref unknown variables
diff --git a/crates/hir-ty/src/builder.rs b/crates/hir-ty/src/builder.rs
index 23587cc6d0..94d7806cb6 100644
--- a/crates/hir-ty/src/builder.rs
+++ b/crates/hir-ty/src/builder.rs
@@ -111,7 +111,7 @@ impl<D> TyBuilder<D> {
this
}
- pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable) -> Self {
+ pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable<'_>) -> Self {
self.fill(|x| match x {
ParamKind::Type => GenericArgData::Ty(table.new_type_var()).intern(Interner),
ParamKind::Const(ty) => {
diff --git a/crates/hir-ty/src/diagnostics/match_check.rs b/crates/hir-ty/src/diagnostics/match_check.rs
index 61cab7be03..d51ad72bd2 100644
--- a/crates/hir-ty/src/diagnostics/match_check.rs
+++ b/crates/hir-ty/src/diagnostics/match_check.rs
@@ -292,7 +292,7 @@ impl<'a> PatCtxt<'a> {
}
impl HirDisplay for Pat {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match &*self.kind {
PatKind::Wild => write!(f, "_"),
PatKind::Binding { name, subpattern } => {
@@ -394,11 +394,11 @@ impl HirDisplay for Pat {
struct WriteWith<F>(F)
where
- F: Fn(&mut HirFormatter) -> Result<(), HirDisplayError>;
+ F: Fn(&mut HirFormatter<'_>) -> Result<(), HirDisplayError>;
impl<F> HirDisplay for WriteWith<F>
where
- F: Fn(&mut HirFormatter) -> Result<(), HirDisplayError>,
+ F: Fn(&mut HirFormatter<'_>) -> Result<(), HirDisplayError>,
{
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
(self.0)(f)
diff --git a/crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs b/crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs
index f92d79949d..bbbe539c13 100644
--- a/crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs
+++ b/crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs
@@ -144,7 +144,7 @@ impl IntRange {
}
}
- fn to_pat(&self, _cx: &MatchCheckCtx, ty: Ty) -> Pat {
+ fn to_pat(&self, _cx: &MatchCheckCtx<'_, '_>, ty: Ty) -> Pat {
match ty.kind(Interner) {
TyKind::Scalar(Scalar::Bool) => {
let kind = match self.boundaries() {
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index 2609a60794..6cd3e2b382 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -45,7 +45,7 @@ pub struct HirFormatter<'a> {
}
pub trait HirDisplay {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError>;
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>;
/// Returns a `Display`able type that is human-readable.
fn into_displayable<'a>(
@@ -162,7 +162,7 @@ impl<'a> HirFormatter<'a> {
}
/// This allows using the `write!` macro directly with a `HirFormatter`.
- pub fn write_fmt(&mut self, args: fmt::Arguments) -> Result<(), HirDisplayError> {
+ pub fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> Result<(), HirDisplayError> {
// We write to a buffer first to track output size
self.buf.clear();
fmt::write(&mut self.buf, args)?;
@@ -247,7 +247,7 @@ impl<'a, T> fmt::Display for HirDisplayWrapper<'a, T>
where
T: HirDisplay,
{
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.t.hir_fmt(&mut HirFormatter {
db: self.db,
fmt: f,
@@ -270,19 +270,19 @@ where
const TYPE_HINT_TRUNCATION: &str = "…";
impl<T: HirDisplay> HirDisplay for &'_ T {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
HirDisplay::hir_fmt(*self, f)
}
}
impl<T: HirDisplay + Internable> HirDisplay for Interned<T> {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
HirDisplay::hir_fmt(self.as_ref(), f)
}
}
impl HirDisplay for ProjectionTy {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@@ -302,7 +302,7 @@ impl HirDisplay for ProjectionTy {
}
impl HirDisplay for OpaqueTy {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@@ -312,7 +312,7 @@ impl HirDisplay for OpaqueTy {
}
impl HirDisplay for GenericArg {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self.interned() {
crate::GenericArgData::Ty(ty) => ty.hir_fmt(f),
crate::GenericArgData::Lifetime(lt) => lt.hir_fmt(f),
@@ -322,7 +322,7 @@ impl HirDisplay for GenericArg {
}
impl HirDisplay for Const {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let data = self.interned();
match data.value {
ConstValue::BoundVar(idx) => idx.hir_fmt(f),
@@ -339,13 +339,13 @@ impl HirDisplay for Const {
}
impl HirDisplay for BoundVar {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "?{}.{}", self.debruijn.depth(), self.index)
}
}
impl HirDisplay for Ty {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@@ -790,7 +790,7 @@ impl HirDisplay for Ty {
}
impl HirDisplay for CallableSig {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "fn(")?;
f.write_joined(self.params(), ", ")?;
if self.is_varargs {
@@ -839,7 +839,7 @@ pub fn write_bounds_like_dyn_trait_with_prefix(
prefix: &str,
predicates: &[QuantifiedWhereClause],
default_sized: SizedByDefault,
- f: &mut HirFormatter,
+ f: &mut HirFormatter<'_>,
) -> Result<(), HirDisplayError> {
write!(f, "{}", prefix)?;
if !predicates.is_empty()
@@ -855,7 +855,7 @@ pub fn write_bounds_like_dyn_trait_with_prefix(
fn write_bounds_like_dyn_trait(
predicates: &[QuantifiedWhereClause],
default_sized: SizedByDefault,
- f: &mut HirFormatter,
+ f: &mut HirFormatter<'_>,
) -> Result<(), HirDisplayError> {
// Note: This code is written to produce nice results (i.e.
// corresponding to surface Rust) for types that can occur in
@@ -952,7 +952,7 @@ fn write_bounds_like_dyn_trait(
Ok(())
}
-fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter, use_as: bool) -> Result<(), HirDisplayError> {
+fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter<'_>, use_as: bool) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@@ -973,13 +973,13 @@ fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter, use_as: bool) -> Result<()
}
impl HirDisplay for TraitRef {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
fmt_trait_ref(self, f, false)
}
}
impl HirDisplay for WhereClause {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
if f.should_truncate() {
return write!(f, "{}", TYPE_HINT_TRUNCATION);
}
@@ -1007,7 +1007,7 @@ impl HirDisplay for WhereClause {
}
impl HirDisplay for LifetimeOutlives {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.a.hir_fmt(f)?;
write!(f, ": ")?;
self.b.hir_fmt(f)
@@ -1015,13 +1015,13 @@ impl HirDisplay for LifetimeOutlives {
}
impl HirDisplay for Lifetime {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.interned().hir_fmt(f)
}
}
impl HirDisplay for LifetimeData {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
LifetimeData::BoundVar(idx) => idx.hir_fmt(f),
LifetimeData::InferenceVar(_) => write!(f, "_"),
@@ -1040,7 +1040,7 @@ impl HirDisplay for LifetimeData {
}
impl HirDisplay for DomainGoal {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
DomainGoal::Holds(wc) => {
write!(f, "Holds(")?;
@@ -1056,7 +1056,7 @@ impl HirDisplay for DomainGoal {
pub fn write_visibility(
module_id: ModuleId,
vis: Visibility,
- f: &mut HirFormatter,
+ f: &mut HirFormatter<'_>,
) -> Result<(), HirDisplayError> {
match vis {
Visibility::Public => write!(f, "pub "),
@@ -1078,7 +1078,7 @@ pub fn write_visibility(
}
impl HirDisplay for TypeRef {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
TypeRef::Never => write!(f, "!")?,
TypeRef::Placeholder => write!(f, "_")?,
@@ -1177,7 +1177,7 @@ impl HirDisplay for TypeRef {
}
impl HirDisplay for TypeBound {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
TypeBound::Path(path, modifier) => {
match modifier {
@@ -1197,7 +1197,7 @@ impl HirDisplay for TypeBound {
}
impl HirDisplay for Path {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match (self.type_anchor(), self.kind()) {
(Some(anchor), _) => {
write!(f, "<")?;
@@ -1301,7 +1301,7 @@ impl HirDisplay for Path {
}
impl HirDisplay for hir_def::path::GenericArg {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
hir_def::path::GenericArg::Type(ty) => ty.hir_fmt(f),
hir_def::path::GenericArg::Const(c) => write!(f, "{}", c),
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index c7c8deaaee..0a64b929a1 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -130,7 +130,7 @@ trait PatLike: Into<ExprOrPatId> + Copy {
type BindingMode: Copy;
fn infer(
- this: &mut InferenceContext,
+ this: &mut InferenceContext<'_>,
id: Self,
expected_ty: &Ty,
default_bm: Self::BindingMode,
@@ -140,7 +140,7 @@ trait PatLike: Into<ExprOrPatId> + Copy {
impl PatLike for ExprId {
type BindingMode = ();
- fn infer(this: &mut InferenceContext, id: Self, expected_ty: &Ty, _: Self::BindingMode) -> Ty {
+ fn infer(this: &mut InferenceContext<'_>, id: Self, expected_ty: &Ty, _: Self::BindingMode) -> Ty {
this.infer_assignee_expr(id, expected_ty)
}
}
@@ -149,7 +149,7 @@ impl PatLike for PatId {
type BindingMode = BindingMode;
fn infer(
- this: &mut InferenceContext,
+ this: &mut InferenceContext<'_>,
id: Self,
expected_ty: &Ty,
default_bm: Self::BindingMode,
@@ -971,7 +971,7 @@ impl Expectation {
/// which still is useful, because it informs integer literals and the like.
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
/// for examples of where this comes up,.
- fn rvalue_hint(table: &mut unify::InferenceTable, ty: Ty) -> Self {
+ fn rvalue_hint(table: &mut unify::InferenceTable<'_>, ty: Ty) -> Self {
// FIXME: do struct_tail_without_normalization
match table.resolve_ty_shallow(&ty).kind(Interner) {
TyKind::Slice(_) | TyKind::Str | TyKind::Dyn(_) => Expectation::RValueLikeUnsized(ty),
@@ -984,7 +984,7 @@ impl Expectation {
Expectation::None
}
- fn resolve(&self, table: &mut unify::InferenceTable) -> Expectation {
+ fn resolve(&self, table: &mut unify::InferenceTable<'_>) -> Expectation {
match self {
Expectation::None => Expectation::None,
Expectation::HasType(t) => Expectation::HasType(table.resolve_ty_shallow(t)),
@@ -994,7 +994,7 @@ impl Expectation {
}
}
- fn to_option(&self, table: &mut unify::InferenceTable) -> Option<Ty> {
+ fn to_option(&self, table: &mut unify::InferenceTable<'_>) -> Option<Ty> {
match self.resolve(table) {
Expectation::None => None,
Expectation::HasType(t) |
@@ -1003,7 +1003,7 @@ impl Expectation {
}
}
- fn only_has_type(&self, table: &mut unify::InferenceTable) -> Option<Ty> {
+ fn only_has_type(&self, table: &mut unify::InferenceTable<'_>) -> Option<Ty> {
match self {
Expectation::HasType(t) => Some(table.resolve_ty_shallow(t)),
// Expectation::Castable(_) |
@@ -1028,7 +1028,7 @@ impl Expectation {
/// an expected type. Otherwise, we might write parts of the type
/// when checking the 'then' block which are incompatible with the
/// 'else' branch.
- fn adjust_for_branches(&self, table: &mut unify::InferenceTable) -> Expectation {
+ fn adjust_for_branches(&self, table: &mut unify::InferenceTable<'_>) -> Expectation {
match self {
Expectation::HasType(ety) => {
let ety = table.resolve_ty_shallow(ety);
diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs
index 014109f03d..e77b55670b 100644
--- a/crates/hir-ty/src/infer/unify.rs
+++ b/crates/hir-ty/src/infer/unify.rs
@@ -43,7 +43,7 @@ where
impl<T: HasInterner<Interner = Interner>> Canonicalized<T> {
pub(super) fn apply_solution(
&self,
- ctx: &mut InferenceTable,
+ ctx: &mut InferenceTable<'_>,
solution: Canonical<Substitution>,
) {
// the solution may contain new variables, which we need to convert to new inference vars
@@ -391,7 +391,7 @@ impl<'a> InferenceTable<'a> {
self.pending_obligations = snapshot.pending_obligations;
}
- pub(crate) fn run_in_snapshot<T>(&mut self, f: impl FnOnce(&mut InferenceTable) -> T) -> T {
+ pub(crate) fn run_in_snapshot<T>(&mut self, f: impl FnOnce(&mut InferenceTable<'_>) -> T) -> T {
let snapshot = self.snapshot();
let result = f(self);
self.rollback_to(snapshot);
diff --git a/crates/hir-ty/src/interner.rs b/crates/hir-ty/src/interner.rs
index c34c4b8a7c..ca76e08fdd 100644
--- a/crates/hir-ty/src/interner.rs
+++ b/crates/hir-ty/src/interner.rs
@@ -168,7 +168,7 @@ impl chalk_ir::interner::Interner for Interner {
}
fn debug_separator_trait_ref(
- separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>,
+ separator_trait_ref: &chalk_ir::SeparatorTraitRef<'_, Interner>,
fmt: &mut fmt::Formatter<'_>,
) -> Option<fmt::Result> {
Some(write!(fmt, "{:?}", separator_trait_ref.debug(Interner)))
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index 1605c932d6..a9420514a2 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -106,7 +106,7 @@ impl<'a> TyLoweringContext<'a> {
pub fn with_debruijn<T>(
&self,
debruijn: DebruijnIndex,
- f: impl FnOnce(&TyLoweringContext) -> T,
+ f: impl FnOnce(&TyLoweringContext<'_>) -> T,
) -> T {
let opaque_ty_data_vec = self.opaque_type_data.take();
let expander = self.expander.take();
@@ -130,7 +130,7 @@ impl<'a> TyLoweringContext<'a> {
pub fn with_shifted_in<T>(
&self,
debruijn: DebruijnIndex,
- f: impl FnOnce(&TyLoweringContext) -> T,
+ f: impl FnOnce(&TyLoweringContext<'_>) -> T,
) -> T {
self.with_debruijn(self.in_binders.shifted_in_from(debruijn), f)
}
diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs
index d2081d22d7..b5810ad054 100644
--- a/crates/hir-ty/src/method_resolution.rs
+++ b/crates/hir-ty/src/method_resolution.rs
@@ -492,7 +492,7 @@ pub struct ReceiverAdjustments {
}
impl ReceiverAdjustments {
- pub(crate) fn apply(&self, table: &mut InferenceTable, ty: Ty) -> (Ty, Vec<Adjustment>) {
+ pub(crate) fn apply(&self, table: &mut InferenceTable<'_>, ty: Ty) -> (Ty, Vec<Adjustment>) {
let mut ty = ty;
let mut adjust = Vec::new();
for _ in 0..self.autoderefs {
@@ -597,7 +597,7 @@ pub fn lookup_impl_method(
fn find_matching_impl(
mut impls: impl Iterator<Item = ImplId>,
- table: &mut InferenceTable,
+ table: &mut InferenceTable<'_>,
self_ty: &Ty,
) -> Option<Arc<ImplData>> {
let db = table.db;
@@ -856,7 +856,7 @@ fn iterate_method_candidates_for_self_ty(
fn iterate_trait_method_candidates(
self_ty: &Ty,
- table: &mut InferenceTable,
+ table: &mut InferenceTable<'_>,
traits_in_scope: &FxHashSet<TraitId>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
@@ -922,7 +922,7 @@ fn iterate_trait_method_candidates(
fn iterate_inherent_methods(
self_ty: &Ty,
- table: &mut InferenceTable,
+ table: &mut InferenceTable<'_>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
receiver_adjustments: Option<ReceiverAdjustments>,
@@ -975,7 +975,7 @@ fn iterate_inherent_methods(
fn impls_for_self_ty(
impls: &InherentImpls,
self_ty: &Ty,
- table: &mut InferenceTable,
+ table: &mut InferenceTable<'_>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
receiver_adjustments: Option<ReceiverAdjustments>,
@@ -1017,7 +1017,7 @@ pub fn resolve_indexing_op(
}
fn is_valid_candidate(
- table: &mut InferenceTable,
+ table: &mut InferenceTable<'_>,
name: Option<&Name>,
receiver_ty: Option<&Ty>,
item: AssocItemId,
@@ -1161,7 +1161,7 @@ fn generic_implements_goal(
}
fn autoderef_method_receiver(
- table: &mut InferenceTable,
+ table: &mut InferenceTable<'_>,
ty: Ty,
) -> (Vec<Canonical<Ty>>, Vec<ReceiverAdjustments>) {
let (mut deref_chain, mut adjustments): (Vec<_>, Vec<_>) = (Vec::new(), Vec::new());
diff --git a/crates/hir-ty/src/test_db.rs b/crates/hir-ty/src/test_db.rs
index ee6c2fa4f8..dc7252f707 100644
--- a/crates/hir-ty/src/test_db.rs
+++ b/crates/hir-ty/src/test_db.rs
@@ -77,7 +77,7 @@ impl FileLoader for TestDB {
fn file_text(&self, file_id: FileId) -> Arc<String> {
FileLoaderDelegate(self).file_text(file_id)
}
- fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
+ fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
diff --git a/crates/hir-ty/src/tls.rs b/crates/hir-ty/src/tls.rs
index 0600fd7c6d..547850b021 100644
--- a/crates/hir-ty/src/tls.rs
+++ b/crates/hir-ty/src/tls.rs
@@ -104,7 +104,7 @@ mod unsafe_tls {
use crate::db::HirDatabase;
use scoped_tls::scoped_thread_local;
- scoped_thread_local!(static PROGRAM: DebugContext);
+ scoped_thread_local!(static PROGRAM: DebugContext<'_>);
pub(crate) fn with_current_program<R>(
op: impl for<'a> FnOnce(Option<&'a DebugContext<'a>>) -> R,
@@ -127,7 +127,7 @@ mod unsafe_tls {
// `with_current_program`, which hides the lifetime through the `for`
// type.
let static_p: &DebugContext<'static> =
- unsafe { std::mem::transmute::<&DebugContext, &DebugContext<'static>>(&ctx) };
+ unsafe { std::mem::transmute::<&DebugContext<'_>, &DebugContext<'static>>(&ctx) };
PROGRAM.set(static_p, op)
}
}
diff --git a/crates/hir-ty/src/utils.rs b/crates/hir-ty/src/utils.rs
index 2e14479368..83319755da 100644
--- a/crates/hir-ty/src/utils.rs
+++ b/crates/hir-ty/src/utils.rs
@@ -130,7 +130,7 @@ pub fn all_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> SmallVec<[Trai
/// `all_super_traits` is that we keep track of type parameters; for example if
/// we have `Self: Trait<u32, i32>` and `Trait<T, U>: OtherTrait<U>` we'll get
/// `Self: OtherTrait<i32>`.
-pub(super) fn all_super_trait_refs(db: &dyn HirDatabase, trait_ref: TraitRef) -> SuperTraits {
+pub(super) fn all_super_trait_refs(db: &dyn HirDatabase, trait_ref: TraitRef) -> SuperTraits<'_> {
SuperTraits { db, seen: iter::once(trait_ref.trait_id).collect(), stack: vec![trait_ref] }
}
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs
index b4fd70d082..dda9d4a9d5 100644
--- a/crates/hir/src/display.rs
+++ b/crates/hir/src/display.rs
@@ -23,7 +23,7 @@ use crate::{
};
impl HirDisplay for Function {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let data = f.db.function_data(self.id);
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
if data.has_default_kw() {
@@ -48,7 +48,7 @@ impl HirDisplay for Function {
f.write_char('(')?;
- let write_self_param = |ty: &TypeRef, f: &mut HirFormatter| match ty {
+ let write_self_param = |ty: &TypeRef, f: &mut HirFormatter<'_>| match ty {
TypeRef::Path(p) if p.is_self_type() => f.write_str("self"),
TypeRef::Reference(inner, lifetime, mut_) if matches!(&**inner,TypeRef::Path(p) if p.is_self_type()) =>
{
@@ -129,7 +129,7 @@ impl HirDisplay for Function {
}
impl HirDisplay for Adt {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
Adt::Struct(it) => it.hir_fmt(f),
Adt::Union(it) => it.hir_fmt(f),
@@ -139,7 +139,7 @@ impl HirDisplay for Adt {
}
impl HirDisplay for Struct {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
f.write_str("struct ")?;
write!(f, "{}", self.name(f.db))?;
@@ -151,7 +151,7 @@ impl HirDisplay for Struct {
}
impl HirDisplay for Enum {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
f.write_str("enum ")?;
write!(f, "{}", self.name(f.db))?;
@@ -163,7 +163,7 @@ impl HirDisplay for Enum {
}
impl HirDisplay for Union {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
f.write_str("union ")?;
write!(f, "{}", self.name(f.db))?;
@@ -175,7 +175,7 @@ impl HirDisplay for Union {
}
impl HirDisplay for Field {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.parent.module(f.db).id, self.visibility(f.db), f)?;
write!(f, "{}: ", self.name(f.db))?;
self.ty(f.db).hir_fmt(f)
@@ -183,7 +183,7 @@ impl HirDisplay for Field {
}
impl HirDisplay for Variant {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "{}", self.name(f.db))?;
let data = self.variant_data(f.db);
match &*data {
@@ -224,13 +224,13 @@ impl HirDisplay for Variant {
}
impl HirDisplay for Type {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.ty.hir_fmt(f)
}
}
impl HirDisplay for GenericParam {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self {
GenericParam::TypeParam(it) => it.hir_fmt(f),
GenericParam::ConstParam(it) => it.hir_fmt(f),
@@ -240,7 +240,7 @@ impl HirDisplay for GenericParam {
}
impl HirDisplay for TypeOrConstParam {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self.split(f.db) {
either::Either::Left(x) => x.hir_fmt(f),
either::Either::Right(x) => x.hir_fmt(f),
@@ -249,7 +249,7 @@ impl HirDisplay for TypeOrConstParam {
}
impl HirDisplay for TypeParam {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "{}", self.name(f.db))?;
if f.omit_verbose_types() {
return Ok(());
@@ -277,19 +277,19 @@ impl HirDisplay for TypeParam {
}
impl HirDisplay for LifetimeParam {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "{}", self.name(f.db))
}
}
impl HirDisplay for ConstParam {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write!(f, "const {}: ", self.name(f.db))?;
self.ty(f.db).hir_fmt(f)
}
}
-fn write_generic_params(def: GenericDefId, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+fn write_generic_params(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let params = f.db.generic_params(def);
if params.lifetimes.is_empty()
&& params.type_or_consts.iter().all(|x| x.1.const_param().is_none())
@@ -304,7 +304,7 @@ fn write_generic_params(def: GenericDefId, f: &mut HirFormatter) -> Result<(), H
f.write_char('<')?;
let mut first = true;
- let mut delim = |f: &mut HirFormatter| {
+ let mut delim = |f: &mut HirFormatter<'_>| {
if first {
first = false;
Ok(())
@@ -343,7 +343,7 @@ fn write_generic_params(def: GenericDefId, f: &mut HirFormatter) -> Result<(), H
Ok(())
}
-fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+fn write_where_clause(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
let params = f.db.generic_params(def);
// unnamed type targets are displayed inline with the argument itself, e.g. `f: impl Y`.
@@ -365,7 +365,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), Hir
return Ok(());
}
- let write_target = |target: &WherePredicateTypeTarget, f: &mut HirFormatter| match target {
+ let write_target = |target: &WherePredicateTypeTarget, f: &mut HirFormatter<'_>| match target {
WherePredicateTypeTarget::TypeRef(ty) => ty.hir_fmt(f),
WherePredicateTypeTarget::TypeOrConstParam(id) => {
match &params.type_or_consts[*id].name() {
@@ -382,7 +382,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), Hir
if pred_idx == 0 { None } else { Some(&params.where_predicates[pred_idx - 1]) };
let new_predicate =
- |f: &mut HirFormatter| f.write_str(if pred_idx == 0 { "\n " } else { ",\n " });
+ |f: &mut HirFormatter<'_>| f.write_str(if pred_idx == 0 { "\n " } else { ",\n " });
match pred {
WherePredicate::TypeBound { target, .. } if is_unnamed_type_target(target) => {}
@@ -438,7 +438,7 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter) -> Result<(), Hir
}
impl HirDisplay for Const {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.const_data(self.id);
f.write_str("const ")?;
@@ -452,7 +452,7 @@ impl HirDisplay for Const {
}
impl HirDisplay for Static {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.static_data(self.id);
f.write_str("static ")?;
@@ -466,7 +466,7 @@ impl HirDisplay for Static {
}
impl HirDisplay for Trait {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.trait_data(self.id);
if data.is_unsafe {
@@ -484,7 +484,7 @@ impl HirDisplay for Trait {
}
impl HirDisplay for TypeAlias {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
let data = f.db.type_alias_data(self.id);
write!(f, "type {}", data.name)?;
@@ -501,7 +501,7 @@ impl HirDisplay for TypeAlias {
}
impl HirDisplay for Module {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
// FIXME: Module doesn't have visibility saved in data.
match self.name(f.db) {
Some(name) => write!(f, "mod {}", name),
@@ -515,7 +515,7 @@ impl HirDisplay for Module {
}
impl HirDisplay for Macro {
- fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
+ fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
match self.id {
hir_def::MacroId::Macro2Id(_) => f.write_str("macro"),
hir_def::MacroId::MacroRulesId(_) => f.write_str("macro_rules!"),
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 327493ccac..9ffbb3964c 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -3028,7 +3028,7 @@ impl Type {
pub fn iterate_method_candidates<T>(
&self,
db: &dyn HirDatabase,
- scope: &SemanticsScope,
+ scope: &SemanticsScope<'_>,
// FIXME this can be retrieved from `scope`, except autoimport uses this
// to specify a different set, so the method needs to be split
traits_in_scope: &FxHashSet<TraitId>,
@@ -3061,7 +3061,7 @@ impl Type {
fn iterate_method_candidates_dyn(
&self,
db: &dyn HirDatabase,
- scope: &SemanticsScope,
+ scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,
@@ -3091,7 +3091,7 @@ impl Type {
pub fn iterate_path_candidates<T>(
&self,
db: &dyn HirDatabase,
- scope: &SemanticsScope,
+ scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,
@@ -3119,7 +3119,7 @@ impl Type {
fn iterate_path_candidates_dyn(
&self,
db: &dyn HirDatabase,
- scope: &SemanticsScope,
+ scope: &SemanticsScope<'_>,
traits_in_scope: &FxHashSet<TraitId>,
with_local_impls: Option<Module>,
name: Option<&Name>,
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 744f3865aa..edcb2fc6a7 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -124,7 +124,7 @@ impl<DB> fmt::Debug for Semantics<'_, DB> {
}
impl<'db, DB: HirDatabase> Semantics<'db, DB> {
- pub fn new(db: &DB) -> Semantics<DB> {
+ pub fn new(db: &DB) -> Semantics<'_, DB> {
let impl_ = SemanticsImpl::new(db);
Semantics { db, imp: impl_ }
}
@@ -1056,7 +1056,7 @@ impl<'db> SemanticsImpl<'db> {
.unwrap_or_default()
}
- fn with_ctx<F: FnOnce(&mut SourceToDefCtx) -> T, T>(&self, f: F) -> T {
+ fn with_ctx<F: FnOnce(&mut SourceToDefCtx<'_, '_>) -> T, T>(&self, f: F) -> T {
let mut cache = self.s2d_cache.borrow_mut();
let mut ctx = SourceToDefCtx { db: self.db, cache: &mut *cache };
f(&mut ctx)
@@ -1280,7 +1280,7 @@ impl<'db> SemanticsImpl<'db> {
}
fn macro_call_to_macro_id(
- ctx: &mut SourceToDefCtx,
+ ctx: &mut SourceToDefCtx<'_, '_>,
db: &dyn AstDatabase,
macro_call_id: MacroCallId,
) -> Option<MacroId> {
@@ -1302,14 +1302,14 @@ fn macro_call_to_macro_id(
pub trait ToDef: AstNode + Clone {
type Def;
- fn to_def(sema: &SemanticsImpl, src: InFile<Self>) -> Option<Self::Def>;
+ fn to_def(sema: &SemanticsImpl<'_>, src: InFile<Self>) -> Option<Self::Def>;
}
macro_rules! to_def_impls {
($(($def:path, $ast:path, $meth:ident)),* ,) => {$(
impl ToDef for $ast {
type Def = $def;
- fn to_def(sema: &SemanticsImpl, src: InFile<Self>) -> Option<Self::Def> {
+ fn to_def(sema: &SemanticsImpl<'_>, src: InFile<Self>) -> Option<Self::Def> {
sema.with_ctx(|ctx| ctx.$meth(src)).map(<$def>::from)
}
}
diff --git a/crates/hir/src/symbols.rs b/crates/hir/src/symbols.rs
index 3b84877dd3..616a406c72 100644
--- a/crates/hir/src/symbols.rs
+++ b/crates/hir/src/symbols.rs
@@ -32,7 +32,7 @@ pub struct DeclarationLocation {
}
impl DeclarationLocation {
- pub fn syntax<DB: HirDatabase>(&self, sema: &Semantics<DB>) -> Option<SyntaxNode> {
+ pub fn syntax<DB: HirDatabase>(&self, sema: &Semantics<'_, DB>) -> Option<SyntaxNode> {
let root = sema.parse_or_expand(self.hir_file_id)?;
Some(self.ptr.to_node(&root))
}
diff --git a/crates/ide-assists/src/assist_context.rs b/crates/ide-assists/src/assist_context.rs
index ec85faaf46..f9b4266142 100644
--- a/crates/ide-assists/src/assist_context.rs
+++ b/crates/ide-assists/src/assist_context.rs
@@ -144,7 +144,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,
diff --git a/crates/ide-assists/src/handlers/add_explicit_type.rs b/crates/ide-assists/src/handlers/add_explicit_type.rs
index 3cdb8df31c..bfa9759ec8 100644
--- a/crates/ide-assists/src/handlers/add_explicit_type.rs
+++ b/crates/ide-assists/src/handlers/add_explicit_type.rs
@@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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 (ascribed_ty, expr, pat) = if let Some(let_stmt) = ctx.find_node_at_offset::<LetStmt>() {
let cursor_in_range = {
let eq_range = let_stmt.eq_token()?.text_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 a14cc45989..001f1e8bb1 100644
--- a/crates/ide-assists/src/handlers/add_label_to_loop.rs
+++ b/crates/ide-assists/src/handlers/add_label_to_loop.rs
@@ -27,7 +27,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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_kw = ctx.find_token_syntax_at_offset(T![loop])?;
let loop_expr = loop_kw.parent().and_then(ast::LoopExpr::cast)?;
if loop_expr.label().is_some() {
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 14cdc1cf86..12213c8455 100644
--- a/crates/ide-assists/src/handlers/add_lifetime_to_type.rs
+++ b/crates/ide-assists/src/handlers/add_lifetime_to_type.rs
@@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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() {
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 6e6fd96a68..9d252e411f 100644
--- a/crates/ide-assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/ide-assists/src/handlers/add_missing_impl_members.rs
@@ -44,7 +44,7 @@ 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,
@@ -85,7 +85,7 @@ pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext) -
// $0fn bar(&self) {}
// }
// ```
-pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
add_missing_impl_members_inner(
acc,
ctx,
@@ -97,7 +97,7 @@ pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext
fn add_missing_impl_members_inner(
acc: &mut Assists,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
mode: DefaultMethods,
assist_id: &'static str,
label: &'static str,
@@ -164,7 +164,7 @@ fn add_missing_impl_members_inner(
}
fn try_gen_trait_body(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
func: &ast::Fn,
trait_: &hir::Trait,
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 171b3f4432..b16f6fe03a 100644
--- a/crates/ide-assists/src/handlers/add_missing_match_arms.rs
+++ b/crates/ide-assists/src/handlers/add_missing_match_arms.rs
@@ -36,7 +36,7 @@ use crate::{
// }
// }
// ```
-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 target_range = ctx.sema.original_range(match_expr.syntax()).range;
@@ -221,7 +221,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<()> {
@@ -321,7 +321,7 @@ impl ExtendedEnum {
}
}
-fn resolve_enum_def(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<ExtendedEnum> {
+fn resolve_enum_def(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> Option<ExtendedEnum> {
sema.type_of_expr(expr)?.adjusted().autoderef(sema.db).find_map(|ty| match ty.as_adt() {
Some(Adt::Enum(e)) => Some(ExtendedEnum::Enum(e)),
_ => ty.is_bool().then(|| ExtendedEnum::Bool),
@@ -329,7 +329,7 @@ fn resolve_enum_def(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<
}
fn resolve_tuple_of_enum_def(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
expr: &ast::Expr,
) -> Option<Vec<ExtendedEnum>> {
sema.type_of_expr(expr)?
diff --git a/crates/ide-assists/src/handlers/add_return_type.rs b/crates/ide-assists/src/handlers/add_return_type.rs
index 42a5b8b672..f858d7a15c 100644
--- a/crates/ide-assists/src/handlers/add_return_type.rs
+++ b/crates/ide-assists/src/handlers/add_return_type.rs
@@ -15,7 +15,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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()))?.original();
@@ -132,7 +132,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 (fn_type, tail_expr, return_type_range, action) =
if let Some(closure) = ctx.find_node_at_offset::<ast::ClosureExpr>() {
let rpipe = closure.param_list()?.syntax().last_token()?;
diff --git a/crates/ide-assists/src/handlers/add_turbo_fish.rs b/crates/ide-assists/src/handlers/add_turbo_fish.rs
index a82dca9db0..c0bf238db7 100644
--- a/crates/ide-assists/src/handlers/add_turbo_fish.rs
+++ b/crates/ide-assists/src/handlers/add_turbo_fish.rs
@@ -24,7 +24,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 ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| {
let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?;
if arg_list.args().next().is_some() {
diff --git a/crates/ide-assists/src/handlers/apply_demorgan.rs b/crates/ide-assists/src/handlers/apply_demorgan.rs
index fd3ae5f78c..2853d1d1be 100644
--- a/crates/ide-assists/src/handlers/apply_demorgan.rs
+++ b/crates/ide-assists/src/handlers/apply_demorgan.rs
@@ -22,7 +22,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin
// 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 expr = ctx.find_node_at_offset::<ast::BinExpr>()?;
let op = expr.op_kind()?;
let op_range = expr.op_token()?.text_range();
diff --git a/crates/ide-assists/src/handlers/auto_import.rs b/crates/ide-assists/src/handlers/auto_import.rs
index 802449f858..c086d9f1cd 100644
--- a/crates/ide-assists/src/handlers/auto_import.rs
+++ b/crates/ide-assists/src/handlers/auto_import.rs
@@ -87,7 +87,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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 (import_assets, syntax_under_caret) = find_importable_node(ctx)?;
let mut proposed_imports =
import_assets.search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind);
@@ -142,7 +142,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
Some(())
}
-pub(super) fn find_importable_node(ctx: &AssistContext) -> Option<(ImportAssets, SyntaxElement)> {
+pub(super) fn find_importable_node(ctx: &AssistContext<'_>) -> Option<(ImportAssets, SyntaxElement)> {
if let Some(path_under_caret) = ctx.find_node_at_offset_with_descend::<ast::Path>() {
ImportAssets::for_exact_path(&path_under_caret, &ctx.sema)
.zip(Some(path_under_caret.syntax().clone().into()))
@@ -177,7 +177,7 @@ fn group_label(import_candidate: &ImportCandidate) -> GroupLabel {
/// Determine how relevant a given import is in the current context. Higher scores are more
/// relevant.
fn relevance_score(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
import: &LocatedImport,
current_module: Option<&Module>,
) -> i32 {
diff --git a/crates/ide-assists/src/handlers/change_visibility.rs b/crates/ide-assists/src/handlers/change_visibility.rs
index 5f15e923ad..2b1d8f6f01 100644
--- a/crates/ide-assists/src/handlers/change_visibility.rs
+++ b/crates/ide-assists/src/handlers/change_visibility.rs
@@ -20,14 +20,14 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
// ```
// 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 f9ec9326b6..db96ad3304 100644
--- a/crates/ide-assists/src/handlers/convert_bool_then.rs
+++ b/crates/ide-assists/src/handlers/convert_bool_then.rs
@@ -37,7 +37,7 @@ 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()) {
@@ -149,7 +149,7 @@ 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()?;
@@ -219,7 +219,7 @@ pub(crate) fn convert_bool_then_to_if(acc: &mut Assists, ctx: &AssistContext) ->
}
fn option_variants(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
expr: &SyntaxNode,
) -> Option<(hir::Variant, hir::Variant)> {
let fam = FamousDefs(sema, sema.scope(expr)?.krate());
@@ -237,7 +237,7 @@ fn option_variants(
/// Traverses the expression checking if it contains `return` or `?` expressions or if any tail is not a `Some(expr)` expression.
/// If any of these conditions are met it is impossible to rewrite this as a `bool::then` call.
fn is_invalid_body(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
some_variant: hir::Variant,
expr: &ast::Expr,
) -> bool {
@@ -272,7 +272,7 @@ fn is_invalid_body(
}
fn block_is_none_variant(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
block: &ast::BlockExpr,
none_variant: hir::Variant,
) -> bool {
diff --git a/crates/ide-assists/src/handlers/convert_comment_block.rs b/crates/ide-assists/src/handlers/convert_comment_block.rs
index 3261f56525..f171dd81a8 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, AssistKind, 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_integer_literal.rs b/crates/ide-assists/src/handlers/convert_integer_literal.rs
index a8a819cfcc..9060696cdc 100644
--- a/crates/ide-assists/src/handlers/convert_integer_literal.rs
+++ b/crates/ide-assists/src/handlers/convert_integer_literal.rs
@@ -13,7 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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<()> {
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/convert_into_to_from.rs b/crates/ide-assists/src/handlers/convert_into_to_from.rs
index 869f76951d..30f6dd41a1 100644
--- a/crates/ide-assists/src/handlers/convert_into_to_from.rs
+++ b/crates/ide-assists/src/handlers/convert_into_to_from.rs
@@ -31,7 +31,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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 82a67fb51d..e42a52c4db 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
@@ -32,7 +32,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// }
// }
// ```
-pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let method = ctx.find_node_at_offset::<ast::MethodCallExpr>()?;
let closure = match method.arg_list()?.args().next()? {
@@ -91,7 +91,7 @@ pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContex
// });
// }
// ```
-pub(crate) fn convert_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn convert_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let for_loop = ctx.find_node_at_offset::<ast::ForExpr>()?;
let iterable = for_loop.iterable()?;
let pat = for_loop.pat()?;
@@ -136,7 +136,7 @@ pub(crate) fn convert_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistCont
/// returning an Iterator called iter or iter_mut (depending on the type of reference) then return
/// the expression behind the reference and the method name
fn is_ref_and_impls_iter_method(
- sema: &hir::Semantics<ide_db::RootDatabase>,
+ sema: &hir::Semantics<'_, ide_db::RootDatabase>,
iterable: &ast::Expr,
) -> Option<(ast::Expr, hir::Name)> {
let ref_expr = match iterable {
@@ -173,7 +173,7 @@ fn is_ref_and_impls_iter_method(
}
/// Whether iterable implements core::Iterator
-fn impls_core_iter(sema: &hir::Semantics<ide_db::RootDatabase>, iterable: &ast::Expr) -> bool {
+fn impls_core_iter(sema: &hir::Semantics<'_, ide_db::RootDatabase>, iterable: &ast::Expr) -> bool {
(|| {
let it_typ = sema.type_of_expr(iterable)?.adjusted();
@@ -188,7 +188,7 @@ fn impls_core_iter(sema: &hir::Semantics<ide_db::RootDatabase>, iterable: &ast::
}
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 2363aa7cbd..00095de257 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
@@ -9,7 +9,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
fn binders_in_pat(
acc: &mut Vec<(Name, bool)>,
pat: &Pat,
- sem: &Semantics<RootDatabase>,
+ sem: &Semantics<'_, RootDatabase>,
) -> Option<()> {
use Pat::*;
match pat {
@@ -115,7 +115,7 @@ fn binders_to_str(binders: &[(Name, bool)], addmut: bool) -> String {
// };
// }
// ```
-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<()> {
// should focus on else token to trigger
let else_token = ctx.find_token_syntax_at_offset(T![else])?;
let let_stmt = LetStmt::cast(else_token.parent()?.parent()?)?;
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 445567b7f9..cb75619ced 100644
--- a/crates/ide-assists/src/handlers/convert_to_guarded_return.rs
+++ b/crates/ide-assists/src/handlers/convert_to_guarded_return.rs
@@ -40,7 +40,7 @@ use crate::{
// bar();
// }
// ```
-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<()> {
let if_expr: ast::IfExpr = ctx.find_node_at_offset()?;
if if_expr.else_branch().is_some() {
return None;
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 8093ba2560..4ab8e93a29 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
@@ -48,7 +48,7 @@ use crate::{assist_context::AssistBuilder, AssistContext, AssistId, AssistKind,
// ```
pub(crate) fn convert_tuple_struct_to_named_struct(
acc: &mut Assists,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
) -> Option<()> {
let strukt = ctx
.find_node_at_offset::<ast::Struct>()
@@ -79,7 +79,7 @@ pub(crate) fn convert_tuple_struct_to_named_struct(
}
fn edit_struct_def(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
edit: &mut AssistBuilder,
strukt: &Either<ast::Struct, ast::Variant>,
tuple_fields: ast::TupleFieldList,
@@ -121,7 +121,7 @@ fn edit_struct_def(
}
fn edit_struct_references(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
edit: &mut AssistBuilder,
strukt: Either<hir::Struct, hir::Variant>,
names: &[ast::Name],
@@ -202,7 +202,7 @@ fn edit_struct_references(
}
fn edit_field_references(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
edit: &mut AssistBuilder,
fields: impl Iterator<Item = ast::TupleField>,
names: &[ast::Name],
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 739097067d..c34b684112 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_tuple_binding.rs b/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
index c36cb3ff10..c1f57532bb 100644
--- a/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
+++ b/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
@@ -27,7 +27,7 @@ use crate::assist_context::{AssistBuilder, AssistContext, Assists};
// 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)
}
@@ -51,7 +51,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>()?;
@@ -82,7 +82,7 @@ pub(crate) fn destructure_tuple_binding_impl(
Some(())
}
-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,
@@ -126,7 +126,7 @@ fn collect_data(ident_pat: IdentPat, ctx: &AssistContext) -> Option<TupleData> {
}
fn generate_name(
- _ctx: &AssistContext,
+ _ctx: &AssistContext<'_>,
index: usize,
_tuple_name: &str,
_ident_pat: &IdentPat,
@@ -150,7 +150,7 @@ struct TupleData {
usages: Option<UsageSearchResult>,
}
fn edit_tuple_assignment(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
data: &TupleData,
in_sub_pattern: bool,
@@ -196,7 +196,7 @@ fn edit_tuple_assignment(
fn edit_tuple_usages(
data: &TupleData,
builder: &mut AssistBuilder,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
in_sub_pattern: bool,
) {
if let Some(usages) = data.usages.as_ref() {
@@ -210,7 +210,7 @@ fn edit_tuple_usages(
}
}
fn edit_tuple_usage(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
usage: &FileReference,
data: &TupleData,
@@ -238,7 +238,7 @@ fn edit_tuple_usage(
}
fn edit_tuple_field_usage(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
data: &TupleData,
index: TupleIndex,
@@ -321,7 +321,7 @@ impl RefData {
}
}
}
-fn handle_ref_field_usage(ctx: &AssistContext, field_expr: &FieldExpr) -> RefData {
+fn handle_ref_field_usage(ctx: &AssistContext<'_>, field_expr: &FieldExpr) -> RefData {
let s = field_expr.syntax();
let mut ref_data =
RefData { range: s.text_range(), needs_deref: true, needs_parentheses: true };
@@ -368,8 +368,8 @@ fn handle_ref_field_usage(ctx: &AssistContext, field_expr: &FieldExpr) -> RefDat
// 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
@@ -426,7 +426,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)
}
@@ -1191,10 +1191,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)
}
@@ -1256,7 +1256,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/expand_glob_import.rs b/crates/ide-assists/src/handlers/expand_glob_import.rs
index b5a5694d01..943c1d90e6 100644
--- a/crates/ide-assists/src/handlers/expand_glob_import.rs
+++ b/crates/ide-assists/src/handlers/expand_glob_import.rs
@@ -40,7 +40,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 (parent, mod_path) = find_parent_and_path(&star)?;
@@ -112,7 +112,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()
}
@@ -139,7 +139,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()
@@ -168,7 +168,7 @@ impl Refs {
}
}
-fn find_refs_in_mod(ctx: &AssistContext, module: Module, visible_from: Module) -> Option<Refs> {
+fn find_refs_in_mod(ctx: &AssistContext<'_>, module: Module, visible_from: Module) -> Option<Refs> {
if !is_mod_visible_from(ctx, module, visible_from) {
return None;
}
@@ -178,7 +178,7 @@ fn find_refs_in_mod(ctx: &AssistContext, module: Module, visible_from: Module) -
Some(Refs(refs))
}
-fn is_mod_visible_from(ctx: &AssistContext, module: Module, 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())
@@ -202,7 +202,7 @@ fn is_mod_visible_from(ctx: &AssistContext, module: Module, from: Module) -> boo
// use foo::*$0;
// use baz::Baz;
// ↑ ---------------
-fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Definition>> {
+fn find_imported_defs(ctx: &AssistContext<'_>, star: SyntaxToken) -> Option<Vec<Definition>> {
let parent_use_item_syntax = star.parent_ancestors().find_map(|n| {
if ast::Use::can_cast(n.kind()) {
Some(n)
@@ -239,7 +239,7 @@ fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Defi
}
fn find_names_to_import(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
refs_in_target: Refs,
imported_defs: Vec<Definition>,
) -> Vec<Name> {
diff --git a/crates/ide-assists/src/handlers/extract_function.rs b/crates/ide-assists/src/handlers/extract_function.rs
index 94b638d4c6..af39387cdd 100644
--- a/crates/ide-assists/src/handlers/extract_function.rs
+++ b/crates/ide-assists/src/handlers/extract_function.rs
@@ -60,7 +60,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;
@@ -170,7 +170,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option
)
}
-fn make_function_name(semantics_scope: &hir::SemanticsScope) -> ast::NameRef {
+fn make_function_name(semantics_scope: &hir::SemanticsScope<'_>) -> ast::NameRef {
let mut names_in_scope = vec![];
semantics_scope.process_all_names(&mut |name, _| names_in_scope.push(name.to_string()));
@@ -366,7 +366,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)
@@ -381,7 +381,7 @@ impl LocalUsages {
}
impl Function {
- fn return_type(&self, ctx: &AssistContext) -> FunType {
+ fn return_type(&self, ctx: &AssistContext<'_>) -> FunType {
match &self.ret_ty {
RetType::Expr(ty) if ty.is_unit() => FunType::Unit,
RetType::Expr(ty) => FunType::Single(ty.clone()),
@@ -396,7 +396,7 @@ impl Function {
}
}
- 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()?;
@@ -421,7 +421,7 @@ impl Param {
}
}
- fn to_arg(&self, ctx: &AssistContext) -> ast::Expr {
+ fn to_arg(&self, ctx: &AssistContext<'_>) -> ast::Expr {
let var = path_expr_from_local(ctx, self.var);
match self.kind() {
ParamKind::Value | ParamKind::MutValue => var,
@@ -430,7 +430,7 @@ impl Param {
}
}
- fn to_param(&self, ctx: &AssistContext, module: hir::Module) -> ast::Param {
+ fn to_param(&self, ctx: &AssistContext<'_>, module: hir::Module) -> ast::Param {
let var = self.var.name(ctx.db()).to_string();
let var_name = make::name(&var);
let pat = match self.kind() {
@@ -452,7 +452,7 @@ impl Param {
}
impl TryKind {
- fn of_ty(ty: hir::Type, ctx: &AssistContext) -> Option<TryKind> {
+ fn of_ty(ty: hir::Type, ctx: &AssistContext<'_>) -> Option<TryKind> {
if ty.is_unknown() {
// We favour Result for `expr?`
return Some(TryKind::Result { ty });
@@ -485,7 +485,7 @@ impl FlowKind {
}
}
- fn expr_ty(&self, ctx: &AssistContext) -> Option<hir::Type> {
+ fn expr_ty(&self, ctx: &AssistContext<'_>) -> Option<hir::Type> {
match self {
FlowKind::Return(Some(expr)) | FlowKind::Break(_, Some(expr)) => {
ctx.sema.type_of_expr(expr).map(TypeInfo::adjusted)
@@ -691,7 +691,7 @@ impl FunctionBody {
/// whether it contains an await expression.
fn analyze(
&self,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
) -> (FxIndexSet<Local>, Option<ast::SelfParam>) {
let mut self_param = None;
let mut res = FxIndexSet::default();
@@ -741,7 +741,7 @@ impl FunctionBody {
(res, self_param)
}
- fn analyze_container(&self, sema: &Semantics<RootDatabase>) -> Option<ContainerInfo> {
+ fn analyze_container(&self, sema: &Semantics<'_, RootDatabase>) -> Option<ContainerInfo> {
let mut ancestors = self.parent()?.ancestors();
let infer_expr_opt = |expr| sema.type_of_expr(&expr?).map(TypeInfo::adjusted);
let mut parent_loop = None;
@@ -837,7 +837,7 @@ impl FunctionBody {
})
}
- fn return_ty(&self, ctx: &AssistContext) -> Option<RetType> {
+ fn return_ty(&self, ctx: &AssistContext<'_>) -> Option<RetType> {
match self.tail_expr() {
Some(expr) => ctx.sema.type_of_expr(&expr).map(TypeInfo::original).map(RetType::Expr),
None => Some(RetType::Stmt),
@@ -847,7 +847,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();
@@ -860,7 +860,7 @@ impl FunctionBody {
/// Analyses the function body for external control flow.
fn external_control_flow(
&self,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
container_info: &ContainerInfo,
) -> Option<ControlFlow> {
let mut ret_expr = None;
@@ -950,7 +950,7 @@ impl FunctionBody {
/// Computes additional info that affects param type and mutability
fn extracted_function_params(
&self,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
container_info: &ContainerInfo,
locals: impl Iterator<Item = Local>,
) -> Vec<Param> {
@@ -1042,7 +1042,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, usages: &LocalUsages, body: &FunctionBody) -> bool {
+fn has_exclusive_usages(ctx: &AssistContext<'_>, usages: &LocalUsages, body: &FunctionBody) -> bool {
usages
.iter()
.filter(|reference| body.contains_range(reference.range))
@@ -1053,7 +1053,7 @@ fn has_exclusive_usages(ctx: &AssistContext, usages: &LocalUsages, body: &Functi
fn reference_is_exclusive(
reference: &FileReference,
node: &dyn HasTokenAtOffset,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
) -> bool {
// we directly modify variable with set: `n = 0`, `n += 1`
if reference.category == Some(ReferenceCategory::Write) {
@@ -1070,7 +1070,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;
@@ -1172,7 +1172,7 @@ fn path_element_of_reference(
/// list local variables defined inside `body`
fn locals_defined_in_body(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
body: &FunctionBody,
) -> FxIndexSet<Local> {
// FIXME: this doesn't work well with macros
@@ -1190,7 +1190,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,
@@ -1215,7 +1215,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: &hir::InFile<Either<ast::IdentPat, ast::SelfParam>>,
) -> bool {
@@ -1260,7 +1260,7 @@ fn node_to_insert_after(body: &FunctionBody, anchor: Anchor) -> Option<SyntaxNod
last_ancestor
}
-fn make_call(ctx: &AssistContext, fun: &Function, indent: IndentLevel) -> String {
+fn make_call(ctx: &AssistContext<'_>, fun: &Function, indent: IndentLevel) -> String {
let ret_ty = fun.return_type(ctx);
let args = make::arg_list(fun.params.iter().map(|param| param.to_arg(ctx)));
@@ -1429,13 +1429,13 @@ impl FlowHandler {
}
}
-fn path_expr_from_local(ctx: &AssistContext, var: Local) -> ast::Expr {
+fn path_expr_from_local(ctx: &AssistContext<'_>, var: Local) -> ast::Expr {
let name = var.name(ctx.db()).to_string();
make::expr_path(make::ext::ident_path(&name))
}
fn format_function(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
module: hir::Module,
fun: &Function,
old_indent: IndentLevel,
@@ -1490,7 +1490,7 @@ fn format_function(
}
fn make_generic_params_and_where_clause(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
fun: &Function,
) -> (Option<ast::GenericParamList>, Option<ast::WhereClause>) {
let used_type_params = fun.type_params(ctx);
@@ -1502,7 +1502,7 @@ fn make_generic_params_and_where_clause(
}
fn make_generic_param_list(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
fun: &Function,
used_type_params: &[TypeParam],
) -> Option<ast::GenericParamList> {
@@ -1525,7 +1525,7 @@ fn make_generic_param_list(
}
fn param_is_required(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
param: &ast::GenericParam,
used_type_params: &[TypeParam],
) -> bool {
@@ -1539,7 +1539,7 @@ fn param_is_required(
}
fn make_where_clause(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
fun: &Function,
used_type_params: &[TypeParam],
) -> Option<ast::WhereClause> {
@@ -1562,7 +1562,7 @@ fn make_where_clause(
}
fn pred_is_required(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
pred: &ast::WherePred,
used_type_params: &[TypeParam],
) -> bool {
@@ -1572,7 +1572,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,
@@ -1586,7 +1586,7 @@ fn resolved_type_param(ctx: &AssistContext, pred: &ast::WherePred) -> Option<Typ
impl Function {
/// Collect all the `TypeParam`s used in the `body` and `params`.
- fn type_params(&self, ctx: &AssistContext) -> Vec<TypeParam> {
+ fn type_params(&self, ctx: &AssistContext<'_>) -> 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),
@@ -1596,13 +1596,13 @@ impl Function {
type_params_in_descendant_paths.chain(type_params_in_params).collect()
}
- fn make_param_list(&self, ctx: &AssistContext, module: hir::Module) -> ast::ParamList {
+ fn make_param_list(&self, ctx: &AssistContext<'_>, module: hir::Module) -> ast::ParamList {
let self_param = self.self_param.clone();
let params = self.params.iter().map(|param| param.to_param(ctx, module));
make::param_list(self_param, params)
}
- fn make_ret_ty(&self, ctx: &AssistContext, module: hir::Module) -> Option<ast::RetType> {
+ fn make_ret_ty(&self, ctx: &AssistContext<'_>, module: hir::Module) -> Option<ast::RetType> {
let fun_ty = self.return_type(ctx);
let handler = if self.mods.is_in_tail {
FlowHandler::None
@@ -1649,7 +1649,7 @@ impl Function {
}
impl FunType {
- fn make_ty(&self, ctx: &AssistContext, module: hir::Module) -> ast::Type {
+ fn make_ty(&self, ctx: &AssistContext<'_>, module: hir::Module) -> ast::Type {
match self {
FunType::Unit => make::ty_unit(),
FunType::Single(ty) => make_ty(ty, ctx, module),
@@ -1672,7 +1672,7 @@ impl FunType {
}
fn make_body(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
old_indent: IndentLevel,
new_indent: IndentLevel,
fun: &Function,
@@ -1821,17 +1821,17 @@ fn with_tail_expr(block: ast::BlockExpr, tail_expr: ast::Expr) -> ast::BlockExpr
make::block_expr(stmts, 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()).ok().unwrap_or_else(|| "_".to_string())
}
-fn make_ty(ty: &hir::Type, ctx: &AssistContext, module: hir::Module) -> ast::Type {
+fn make_ty(ty: &hir::Type, ctx: &AssistContext<'_>, module: hir::Module) -> ast::Type {
let ty_str = format_type(ty, ctx, module);
make::ty(&ty_str)
}
fn rewrite_body_segment(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
params: &[Param],
handler: &FlowHandler,
syntax: &SyntaxNode,
@@ -1842,7 +1842,7 @@ fn rewrite_body_segment(
}
/// change all usages to account for added `&`/`&mut` for some params
-fn fix_param_usages(ctx: &AssistContext, params: &[Param], syntax: &SyntaxNode) -> SyntaxNode {
+fn fix_param_usages(ctx: &AssistContext<'_>, params: &[Param], syntax: &SyntaxNode) -> SyntaxNode {
let mut usages_for_param: Vec<(&Param, Vec<ast::Expr>)> = Vec::new();
let tm = TreeMutator::new(syntax);
diff --git a/crates/ide-assists/src/handlers/extract_module.rs b/crates/ide-assists/src/handlers/extract_module.rs
index 154856df54..b3c4d306ac 100644
--- a/crates/ide-assists/src/handlers/extract_module.rs
+++ b/crates/ide-assists/src/handlers/extract_module.rs
@@ -53,7 +53,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;
}
@@ -234,7 +234,7 @@ fn extract_target(node: &SyntaxNode, selection_range: TextRange) -> Option<Modul
impl Module {
fn get_usages_and_record_fields(
&self,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
) -> (HashMap<FileId, Vec<(TextRange, String)>>, Vec<SyntaxNode>) {
let mut adt_fields = Vec::new();
let mut refs: HashMap<FileId, Vec<(TextRange, String)>> = HashMap::new();
@@ -318,7 +318,7 @@ impl Module {
fn expand_and_group_usages_file_wise(
&self,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
node_def: Definition,
refs_in_files: &mut HashMap<FileId, Vec<(TextRange, String)>>,
) {
@@ -396,7 +396,7 @@ impl Module {
fn resolve_imports(
&mut self,
curr_parent_module: Option<ast::Module>,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
) -> Vec<TextRange> {
let mut import_paths_to_be_removed: Vec<TextRange> = vec![];
let mut node_set: HashSet<String> = HashSet::new();
@@ -471,7 +471,7 @@ impl Module {
def: Definition,
node_syntax: &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();
@@ -684,7 +684,7 @@ fn check_intersection_and_push(
fn does_source_exists_outside_sel_in_same_mod(
def: Definition,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
curr_parent_module: &Option<ast::Module>,
selection_range: TextRange,
curr_file_id: FileId,
@@ -904,7 +904,7 @@ fn add_change_vis(vis: Option<ast::Visibility>, node_or_token_opt: Option<syntax
fn compare_hir_and_ast_module(
ast_module: &ast::Module,
hir_module: hir::Module,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
) -> Option<()> {
let hir_mod_name = hir_module.name(ctx.db())?;
let ast_mod_name = ast_module.name()?;
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 ebfd65ae79..a93648f2d3 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
@@ -37,7 +37,7 @@ use crate::{assist_context::AssistBuilder, AssistContext, AssistId, AssistKind,
// ```
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)?;
@@ -373,7 +373,7 @@ fn apply_references(
}
fn process_references(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
visited_modules: &mut FxHashSet<Module>,
enum_module_def: &ModuleDef,
@@ -407,7 +407,7 @@ fn process_references(
}
fn reference_to_node(
- sema: &hir::Semantics<RootDatabase>,
+ sema: &hir::Semantics<'_, RootDatabase>,
reference: FileReference,
) -> Option<(ast::PathSegment, SyntaxNode, hir::Module)> {
let segment =
diff --git a/crates/ide-assists/src/handlers/extract_type_alias.rs b/crates/ide-assists/src/handlers/extract_type_alias.rs
index f664aa6dbf..af584cdb43 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, AssistKind, 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 500db158e6..3596b6f823 100644
--- a/crates/ide-assists/src/handlers/extract_variable.rs
+++ b/crates/ide-assists/src/handlers/extract_variable.rs
@@ -27,7 +27,7 @@ use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists};
// 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<()> {
if ctx.has_empty_selection() {
return None;
}
@@ -164,7 +164,7 @@ fn valid_target_expr(node: SyntaxNode) -> Option<ast::Expr> {
}
}
-fn get_receiver_type(ctx: &AssistContext, expression: &ast::Expr) -> Option<hir::Type> {
+fn get_receiver_type(ctx: &AssistContext<'_>, expression: &ast::Expr) -> Option<hir::Type> {
let receiver = get_receiver(expression.clone())?;
Some(ctx.sema.type_of_expr(&receiver)?.original())
}
diff --git a/crates/ide-assists/src/handlers/fix_visibility.rs b/crates/ide-assists/src/handlers/fix_visibility.rs
index b895208f41..b33846f546 100644
--- a/crates/ide-assists/src/handlers/fix_visibility.rs
+++ b/crates/ide-assists/src/handlers/fix_visibility.rs
@@ -30,12 +30,12 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, 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)
.or_else(|| add_vis_to_referenced_record_field(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 path_res = ctx.sema.resolve_path(&path)?;
let def = match path_res {
@@ -82,7 +82,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O
})
}
-fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let record_field: ast::RecordExprField = ctx.find_node_at_offset()?;
let (record_field_def, _, _) = ctx.sema.resolve_record_field(&record_field)?;
diff --git a/crates/ide-assists/src/handlers/flip_binexpr.rs b/crates/ide-assists/src/handlers/flip_binexpr.rs
index 19e85b27f9..2ea6f58fa0 100644
--- a/crates/ide-assists/src/handlers/flip_binexpr.rs
+++ b/crates/ide-assists/src/handlers/flip_binexpr.rs
@@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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()?.syntax().clone();
let rhs = expr.rhs()?.syntax().clone();
diff --git a/crates/ide-assists/src/handlers/flip_comma.rs b/crates/ide-assists/src/handlers/flip_comma.rs
index 8f3fcaf6fb..f40f2713ad 100644
--- a/crates/ide-assists/src/handlers/flip_comma.rs
+++ b/crates/ide-assists/src/handlers/flip_comma.rs
@@ -17,7 +17,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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_trait_bound.rs b/crates/ide-assists/src/handlers/flip_trait_bound.rs
index a868aa43d6..e3ae4970b6 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, AssistKind, 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<()> {
// We want to replicate the behavior of `flip_binexpr` by only suggesting
// the assist when the cursor is on a `+`
let plus = ctx.find_token_syntax_at_offset(T![+])?;
diff --git a/crates/ide-assists/src/handlers/generate_constant.rs b/crates/ide-assists/src/handlers/generate_constant.rs
index 8932a91ebe..eaa6de73eb 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 4d47437f7c..5e9995a986 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, AssistKind, 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 119bb6e07b..cbd33de19e 100644
--- a/crates/ide-assists/src/handlers/generate_default_from_new.rs
+++ b/crates/ide-assists/src/handlers/generate_default_from_new.rs
@@ -40,7 +40,7 @@ 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()?;
@@ -122,7 +122,7 @@ fn generate_trait_impl_text_from_impl(impl_: &ast::Impl, trait_text: &str, code:
buf
}
-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 120acde8e5..85b193663a 100644
--- a/crates/ide-assists/src/handlers/generate_delegate_methods.rs
+++ b/crates/ide-assists/src/handlers/generate_delegate_methods.rs
@@ -42,7 +42,7 @@ use syntax::ast::edit::AstNodeEdit;
// }
// }
// ```
-pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let strukt_name = strukt.name()?;
let current_module = ctx.sema.scope(strukt.syntax())?.module();
diff --git a/crates/ide-assists/src/handlers/generate_deref.rs b/crates/ide-assists/src/handlers/generate_deref.rs
index c102eb1ab3..b9637ee8d7 100644
--- a/crates/ide-assists/src/handlers/generate_deref.rs
+++ b/crates/ide-assists/src/handlers/generate_deref.rs
@@ -39,11 +39,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>()?;
@@ -80,7 +80,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 28483f795e..339245b94e 100644
--- a/crates/ide-assists/src/handlers/generate_derive.rs
+++ b/crates/ide-assists/src/handlers/generate_derive.rs
@@ -24,7 +24,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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 node_start = derive_insertion_offset(&nominal)?;
diff --git a/crates/ide-assists/src/handlers/generate_documentation_template.rs b/crates/ide-assists/src/handlers/generate_documentation_template.rs
index d22d8c831f..c91141f8eb 100644
--- a/crates/ide-assists/src/handlers/generate_documentation_template.rs
+++ b/crates/ide-assists/src/handlers/generate_documentation_template.rs
@@ -42,7 +42,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)?;
@@ -94,7 +94,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 =
@@ -126,7 +126,7 @@ pub(crate) fn generate_doc_example(acc: &mut Assists, ctx: &AssistContext) -> Op
)
}
-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;
@@ -176,7 +176,7 @@ fn make_example_for_fn(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<String
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 {
@@ -270,7 +270,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
@@ -279,7 +279,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()) {
@@ -294,7 +294,7 @@ fn all_parent_mods_public(hir_func: &hir::Function, ctx: &AssistContext) -> bool
}
/// 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())
}
@@ -351,7 +351,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()))
@@ -360,7 +360,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()))
@@ -462,7 +462,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) -> Option<String> {
+fn build_path(ast_func: &ast::Fn, ctx: &AssistContext<'_>) -> 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()))
@@ -480,7 +480,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 28e0b433a6..52d27d8a7d 100644
--- a/crates/ide-assists/src/handlers/generate_enum_is_method.rs
+++ b/crates/ide-assists/src/handlers/generate_enum_is_method.rs
@@ -37,7 +37,7 @@ 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 variant_name = variant.name()?;
let parent_enum = ast::Adt::Enum(variant.parent_enum());
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 fe7a3cd535..e7646421c7 100644
--- a/crates/ide-assists/src/handlers/generate_enum_projection_method.rs
+++ b/crates/ide-assists/src/handlers/generate_enum_projection_method.rs
@@ -36,7 +36,7 @@ use crate::{
// }
// }
// ```
-pub(crate) fn generate_enum_try_into_method(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn generate_enum_try_into_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
generate_enum_projection_method(
acc,
ctx,
@@ -80,7 +80,7 @@ pub(crate) fn generate_enum_try_into_method(acc: &mut Assists, ctx: &AssistConte
// }
// }
// ```
-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,
@@ -108,7 +108,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 b57076d999..4461fbd5ac 100644
--- a/crates/ide-assists/src/handlers/generate_enum_variant.rs
+++ b/crates/ide-assists/src/handlers/generate_enum_variant.rs
@@ -31,7 +31,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_expr: ast::PathExpr = ctx.find_node_at_offset()?;
let path = path_expr.path()?;
@@ -58,7 +58,7 @@ pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext) -> O
fn add_variant_to_accumulator(
acc: &mut Assists,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
target: syntax::TextRange,
adt: hir::Enum,
name_ref: &ast::NameRef,
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 f7be323824..157ad3b74e 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
@@ -20,7 +20,7 @@ use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind
// }
// }
// ```
-pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
let variant_name = variant.name()?;
let enum_ = ast::Adt::Enum(variant.parent_enum());
diff --git a/crates/ide-assists/src/handlers/generate_function.rs b/crates/ide-assists/src/handlers/generate_function.rs
index 061a481344..d564a05408 100644
--- a/crates/ide-assists/src/handlers/generate_function.rs
+++ b/crates/ide-assists/src/handlers/generate_function.rs
@@ -46,11 +46,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()?;
@@ -113,7 +113,7 @@ fn gen_fn(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
)
}
-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;
@@ -149,7 +149,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,
insert_offset: TextSize,
@@ -172,7 +172,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)> {
@@ -229,7 +229,7 @@ impl FunctionBuilder {
/// Prepares a generated function that matches `call`.
/// The function is generated in `target_module` or next to `call`
fn from_call(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
call: &ast::CallExpr,
fn_name: &str,
target_module: Option<hir::Module>,
@@ -261,7 +261,7 @@ impl FunctionBuilder {
}
fn from_method_call(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
call: &ast::MethodCallExpr,
name: &ast::NameRef,
target_module: Module,
@@ -344,7 +344,7 @@ impl FunctionBuilder {
/// * If we could infer the return type, don't focus it (and thus focus the function body) so the
/// user can change the `todo!` function body.
fn make_return_type(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
call: &ast::Expr,
target_module: Module,
) -> (Option<ast::RetType>, bool) {
@@ -367,7 +367,7 @@ fn make_return_type(
}
fn get_fn_target(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
target_module: &Option<Module>,
call: CallExpr,
) -> Option<(GeneratedFunctionTarget, FileId, TextSize)> {
@@ -385,7 +385,7 @@ fn get_fn_target(
}
fn get_method_target(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
target_module: &Module,
impl_: &Option<ast::Impl>,
) -> Option<(GeneratedFunctionTarget, TextSize)> {
@@ -423,7 +423,7 @@ impl GeneratedFunctionTarget {
/// Computes the type variables and arguments required for the generated function
fn fn_args(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
target_module: hir::Module,
call: ast::CallableExpr,
) -> Option<(Option<ast::GenericParamList>, ast::ParamList)> {
@@ -482,7 +482,7 @@ fn deduplicate_arg_names(arg_names: &mut Vec<String>) {
}
}
-fn fn_arg_name(sema: &Semantics<RootDatabase>, arg_expr: &ast::Expr) -> String {
+fn fn_arg_name(sema: &Semantics<'_, RootDatabase>, arg_expr: &ast::Expr) -> String {
let name = (|| match arg_expr {
ast::Expr::CastExpr(cast_expr) => Some(fn_arg_name(sema, &cast_expr.expr()?)),
expr => {
@@ -510,9 +510,9 @@ fn fn_arg_name(sema: &Semantics<RootDatabase>, arg_expr: &ast::Expr) -> String {
}
}
-fn fn_arg_type(ctx: &AssistContext, target_module: hir::Module, fn_arg: &ast::Expr) -> String {
+fn fn_arg_type(ctx: &AssistContext<'_>, target_module: hir::Module, fn_arg: &ast::Expr) -> String {
fn maybe_displayed_type(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
target_module: hir::Module,
fn_arg: &ast::Expr,
) -> Option<String> {
@@ -593,7 +593,7 @@ fn next_space_for_fn_in_impl(impl_: &ast::Impl) -> Option<GeneratedFunctionTarge
}
}
-fn module_is_descendant(module: &hir::Module, ans: &hir::Module, ctx: &AssistContext) -> bool {
+fn module_is_descendant(module: &hir::Module, ans: &hir::Module, ctx: &AssistContext<'_>) -> bool {
if module == ans {
return true;
}
diff --git a/crates/ide-assists/src/handlers/generate_getter.rs b/crates/ide-assists/src/handlers/generate_getter.rs
index 3702f543aa..76fcef0cad 100644
--- a/crates/ide-assists/src/handlers/generate_getter.rs
+++ b/crates/ide-assists/src/handlers/generate_getter.rs
@@ -43,7 +43,7 @@ use crate::{
// }
// }
// ```
-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)
}
@@ -68,13 +68,13 @@ pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext) -> Option<
// }
// }
// ```
-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)
}
pub(crate) fn generate_getter_impl(
acc: &mut Assists,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
mutable: bool,
) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
diff --git a/crates/ide-assists/src/handlers/generate_impl.rs b/crates/ide-assists/src/handlers/generate_impl.rs
index 58fea103f8..68287a20bf 100644
--- a/crates/ide-assists/src/handlers/generate_impl.rs
+++ b/crates/ide-assists/src/handlers/generate_impl.rs
@@ -21,7 +21,7 @@ use crate::{utils::generate_impl_text, AssistContext, AssistId, AssistKind, Assi
// $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();
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 062b12a50b..9ce525ca37 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,7 @@ 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 +86,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_new.rs b/crates/ide-assists/src/handlers/generate_new.rs
index 5f4715bb53..f275382595 100644
--- a/crates/ide-assists/src/handlers/generate_new.rs
+++ b/crates/ide-assists/src/handlers/generate_new.rs
@@ -29,7 +29,7 @@ use crate::{
// fn $0new(data: T) -> Self { Self { data } }
// }
// ```
-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>()?;
// We want to only apply this to non-union structs with named fields
diff --git a/crates/ide-assists/src/handlers/generate_setter.rs b/crates/ide-assists/src/handlers/generate_setter.rs
index 62576a854f..2a7ad6ce36 100644
--- a/crates/ide-assists/src/handlers/generate_setter.rs
+++ b/crates/ide-assists/src/handlers/generate_setter.rs
@@ -27,7 +27,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<()> {
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field = ctx.find_node_at_offset::<ast::RecordField>()?;
diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs
index c857adf876..658a1aadf5 100644
--- a/crates/ide-assists/src/handlers/inline_call.rs
+++ b/crates/ide-assists/src/handlers/inline_call.rs
@@ -59,7 +59,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 name = ctx.find_node_at_offset::<ast::Name>()?;
let ast_func = name.syntax().parent().and_then(ast::Fn::cast)?;
@@ -174,7 +174,7 @@ pub(crate) fn inline_into_callers(acc: &mut Assists, ctx: &AssistContext) -> Opt
// };
// }
// ```
-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())?;
let (function, label) = match &call_info.node {
@@ -294,7 +294,7 @@ fn get_fn_params(
}
fn inline(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
function_def_file_id: FileId,
function: hir::Function,
fn_body: &ast::BlockExpr,
diff --git a/crates/ide-assists/src/handlers/inline_local_variable.rs b/crates/ide-assists/src/handlers/inline_local_variable.rs
index 3d9242ad71..7259d67819 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 } =
@@ -149,7 +149,7 @@ struct InlineData {
}
fn inline_let(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
let_stmt: ast::LetStmt,
range: TextRange,
file_id: FileId,
@@ -184,7 +184,7 @@ fn inline_let(
}
fn inline_usage(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
path_expr: ast::PathExpr,
range: TextRange,
file_id: FileId,
diff --git a/crates/ide-assists/src/handlers/inline_type_alias.rs b/crates/ide-assists/src/handlers/inline_type_alias.rs
index d4d840f223..054663a06a 100644
--- a/crates/ide-assists/src/handlers/inline_type_alias.rs
+++ b/crates/ide-assists/src/handlers/inline_type_alias.rs
@@ -35,7 +35,7 @@ use crate::{
// 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<()> {
enum Replacement {
Generic { lifetime_map: LifetimeMap, const_and_type_map: ConstAndTypeMap },
Plain,
@@ -252,7 +252,7 @@ fn create_replacement(
updated_concrete_type.to_string()
}
-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/introduce_named_generic.rs b/crates/ide-assists/src/handlers/introduce_named_generic.rs
index 636b05dca9..062c816aef 100644
--- a/crates/ide-assists/src/handlers/introduce_named_generic.rs
+++ b/crates/ide-assists/src/handlers/introduce_named_generic.rs
@@ -16,7 +16,7 @@ use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists};
// ```
// fn foo<B: Bar>(bar: B) {}
// ```
-pub(crate) fn introduce_named_generic(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn introduce_named_generic(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let impl_trait_type = ctx.find_node_at_offset::<ast::ImplTraitType>()?;
let param = impl_trait_type.syntax().parent().and_then(ast::Param::cast)?;
let fn_ = param.syntax().ancestors().find_map(ast::Fn::cast)?;
diff --git a/crates/ide-assists/src/handlers/introduce_named_lifetime.rs b/crates/ide-assists/src/handlers/introduce_named_lifetime.rs
index fa7635d123..ce91dd2370 100644
--- a/crates/ide-assists/src/handlers/introduce_named_lifetime.rs
+++ b/crates/ide-assists/src/handlers/introduce_named_lifetime.rs
@@ -33,7 +33,7 @@ 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/invert_if.rs b/crates/ide-assists/src/handlers/invert_if.rs
index 6eed59c9ea..547158e297 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])?;
let expr = ast::IfExpr::cast(if_keyword.parent()?)?;
let if_range = if_keyword.text_range();
diff --git a/crates/ide-assists/src/handlers/merge_imports.rs b/crates/ide-assists/src/handlers/merge_imports.rs
index 946e66f1f5..7e102ceba8 100644
--- a/crates/ide-assists/src/handlers/merge_imports.rs
+++ b/crates/ide-assists/src/handlers/merge_imports.rs
@@ -22,7 +22,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
let tree: ast::UseTree = ctx.find_node_at_offset()?;
diff --git a/crates/ide-assists/src/handlers/merge_match_arms.rs b/crates/ide-assists/src/handlers/merge_match_arms.rs
index c87bd7f152..c24015b1c5 100644
--- a/crates/ide-assists/src/handlers/merge_match_arms.rs
+++ b/crates/ide-assists/src/handlers/merge_match_arms.rs
@@ -32,7 +32,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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_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() {
@@ -97,7 +97,7 @@ fn contains_placeholder(a: &ast::MatchArm) -> bool {
fn are_same_types(
current_arm_types: &HashMap<String, Option<TypeInfo>>,
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 {
@@ -112,14 +112,14 @@ fn are_same_types(
}
fn get_arm_types(
- context: &AssistContext,
+ context: &AssistContext<'_>,
arm: &ast::MatchArm,
) -> HashMap<String, Option<TypeInfo>> {
let mut mapping: HashMap<String, Option<TypeInfo>> = HashMap::new();
fn recurse(
map: &mut HashMap<String, Option<TypeInfo>>,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
pat: &Option<ast::Pat>,
) {
if let Some(local_pat) = pat {
diff --git a/crates/ide-assists/src/handlers/move_bounds.rs b/crates/ide-assists/src/handlers/move_bounds.rs
index 425dba1a75..7fa1a0d2ca 100644
--- a/crates/ide-assists/src/handlers/move_bounds.rs
+++ b/crates/ide-assists/src/handlers/move_bounds.rs
@@ -20,7 +20,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// f(x)
// }
// ```
-pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
let mut type_params = type_param_list.type_or_const_params();
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 b49c2e5da5..a6c85a2b18 100644
--- a/crates/ide-assists/src/handlers/move_from_mod_rs.rs
+++ b/crates/ide-assists/src/handlers/move_from_mod_rs.rs
@@ -23,7 +23,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.to_module_def(ctx.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 f5e8b60ad6..778a31f99d 100644
--- a/crates/ide-assists/src/handlers/move_guard.rs
+++ b/crates/ide-assists/src/handlers/move_guard.rs
@@ -32,7 +32,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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() {
@@ -91,7 +91,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) -> Option<()> {
+pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?;
let match_pat = match_arm.pat()?;
let arm_body = match_arm.expr()?;
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 759494dcf0..7468318a59 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, AssistKind, 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 887960881a..a909ce8b26 100644
--- a/crates/ide-assists/src/handlers/move_to_mod_rs.rs
+++ b/crates/ide-assists/src/handlers/move_to_mod_rs.rs
@@ -23,7 +23,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.to_module_def(ctx.file_id())?;
// Enable this assist if the user select all "meaningful" content in the source file
diff --git a/crates/ide-assists/src/handlers/number_representation.rs b/crates/ide-assists/src/handlers/number_representation.rs
index f77471d80c..424db7437a 100644
--- a/crates/ide-assists/src/handlers/number_representation.rs
+++ b/crates/ide-assists/src/handlers/number_representation.rs
@@ -15,7 +15,7 @@ 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 65c14406f9..cbbea6c1e6 100644
--- a/crates/ide-assists/src/handlers/promote_local_to_const.rs
+++ b/crates/ide-assists/src/handlers/promote_local_to_const.rs
@@ -44,7 +44,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() {
@@ -95,7 +95,7 @@ pub(crate) fn promote_local_to_const(acc: &mut Assists, ctx: &AssistContext) ->
)
}
-fn is_body_const(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> bool {
+fn is_body_const(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> bool {
let mut is_const = true;
preorder_expr(expr, &mut |ev| {
let expr = match ev {
diff --git a/crates/ide-assists/src/handlers/pull_assignment_up.rs b/crates/ide-assists/src/handlers/pull_assignment_up.rs
index d142397c24..4cfe6c99b2 100644
--- a/crates/ide-assists/src/handlers/pull_assignment_up.rs
+++ b/crates/ide-assists/src/handlers/pull_assignment_up.rs
@@ -35,7 +35,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()?;
@@ -151,7 +151,7 @@ impl<'a> AssignmentsCollector<'a> {
}
fn is_equivalent(
- sema: &hir::Semantics<ide_db::RootDatabase>,
+ sema: &hir::Semantics<'_, ide_db::RootDatabase>,
expr0: &ast::Expr,
expr1: &ast::Expr,
) -> bool {
diff --git a/crates/ide-assists/src/handlers/qualify_method_call.rs b/crates/ide-assists/src/handlers/qualify_method_call.rs
index 61cb2f0479..121f8b4a13 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 8d2293d224..0c2e9da386 100644
--- a/crates/ide-assists/src/handlers/qualify_path.rs
+++ b/crates/ide-assists/src/handlers/qualify_path.rs
@@ -35,7 +35,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) = find_importable_node(ctx)?;
let mut proposed_imports = import_assets.search_for_relative_paths(&ctx.sema);
if proposed_imports.is_empty() {
diff --git a/crates/ide-assists/src/handlers/raw_string.rs b/crates/ide-assists/src/handlers/raw_string.rs
index 41f768c317..dbe8cb7bf0 100644
--- a/crates/ide-assists/src/handlers/raw_string.rs
+++ b/crates/ide-assists/src/handlers/raw_string.rs
@@ -19,7 +19,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// 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::String>()?;
if token.is_raw() {
return None;
@@ -61,7 +61,7 @@ pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext) -> Option<
// "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::String>()?;
if !token.is_raw() {
return None;
@@ -103,7 +103,7 @@ pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext) -> Optio
// 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::String>()?;
if !token.is_raw() {
return None;
@@ -131,7 +131,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::String>()?;
if !token.is_raw() {
return None;
diff --git a/crates/ide-assists/src/handlers/remove_dbg.rs b/crates/ide-assists/src/handlers/remove_dbg.rs
index be91eacbe7..afaa7c933c 100644
--- a/crates/ide-assists/src/handlers/remove_dbg.rs
+++ b/crates/ide-assists/src/handlers/remove_dbg.rs
@@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// 92;
// }
// ```
-pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let macro_call = ctx.find_node_at_offset::<ast::MacroCall>()?;
let tt = macro_call.token_tree()?;
let r_delim = NodeOrToken::Token(tt.right_delimiter_token()?);
diff --git a/crates/ide-assists/src/handlers/remove_mut.rs b/crates/ide-assists/src/handlers/remove_mut.rs
index 30d36dacd2..0b299e8349 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, AssistKind, 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 delete_from = mut_token.text_range().start();
let delete_to = match mut_token.next_token() {
diff --git a/crates/ide-assists/src/handlers/remove_unused_param.rs b/crates/ide-assists/src/handlers/remove_unused_param.rs
index 928a5a386e..59ea94ea1f 100644
--- a/crates/ide-assists/src/handlers/remove_unused_param.rs
+++ b/crates/ide-assists/src/handlers/remove_unused_param.rs
@@ -30,7 +30,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,
@@ -87,7 +87,7 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext) -> Opt
}
fn process_usages(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
builder: &mut AssistBuilder,
file_id: FileId,
references: Vec<FileReference>,
diff --git a/crates/ide-assists/src/handlers/reorder_fields.rs b/crates/ide-assists/src/handlers/reorder_fields.rs
index 35c4cb6d64..62e396d1dc 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, AssistKind, 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 record = ctx
.find_node_at_offset::<ast::RecordExpr>()
.map(Either::Left)
@@ -86,7 +86,7 @@ fn replace<T: AstNode + PartialEq>(
});
}
-fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> {
+fn compute_fields_ranks(path: &ast::Path, 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,
_ => return None,
diff --git a/crates/ide-assists/src/handlers/reorder_impl_items.rs b/crates/ide-assists/src/handlers/reorder_impl_items.rs
index 2bda3a1817..970bbaa0e7 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, AssistKind, 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()?;
let assoc_items = items.assoc_items().collect::<Vec<_>>();
@@ -93,7 +93,7 @@ pub(crate) fn reorder_impl_items(acc: &mut Assists, ctx: &AssistContext) -> Opti
)
}
-fn compute_item_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> {
+fn compute_item_ranks(path: &ast::Path, ctx: &AssistContext<'_>) -> Option<FxHashMap<String, usize>> {
let td = trait_definition(path, &ctx.sema)?;
Some(
@@ -106,7 +106,7 @@ fn compute_item_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap
)
}
-fn trait_definition(path: &ast::Path, sema: &Semantics<RootDatabase>) -> Option<hir::Trait> {
+fn trait_definition(path: &ast::Path, sema: &Semantics<'_, RootDatabase>) -> Option<hir::Trait> {
match sema.resolve_path(path)? {
PathResolution::Def(hir::ModuleDef::Trait(trait_)) => Some(trait_),
_ => 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 03e41b4340..bd50208da5 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
@@ -42,7 +42,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()?;
@@ -113,7 +113,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,
@@ -170,7 +170,7 @@ fn add_assist(
}
fn impl_def_from_trait(
- sema: &hir::Semantics<ide_db::RootDatabase>,
+ sema: &hir::Semantics<'_, ide_db::RootDatabase>,
adt: &ast::Adt,
annotated_name: &ast::Name,
trait_: Option<hir::Trait>,
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 2b68b2dc03..484c27387d 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,7 @@ 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(),
@@ -140,7 +140,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext)
}
fn make_else_arm(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
else_block: Option<ast::BlockExpr>,
conditionals: &[(Either<ast::Pat, ast::Expr>, ast::BlockExpr)],
) -> ast::MatchArm {
@@ -197,7 +197,7 @@ 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 mut arms = match_expr.match_arm_list()?.arms();
@@ -248,7 +248,7 @@ pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext)
/// Pick the pattern for the if let condition and return the expressions for the `then` body and `else` body in that order.
fn pick_pattern_and_expr_order(
- sema: &hir::Semantics<RootDatabase>,
+ sema: &hir::Semantics<'_, RootDatabase>,
pat: ast::Pat,
pat2: ast::Pat,
expr: ast::Expr,
@@ -281,7 +281,7 @@ fn is_empty_expr(expr: &ast::Expr) -> bool {
}
}
-fn binds_name(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool {
+fn binds_name(sema: &hir::Semantics<'_, RootDatabase>, pat: &ast::Pat) -> bool {
let binds_name_v = |pat| binds_name(sema, &pat);
match pat {
ast::Pat::IdentPat(pat) => !matches!(
@@ -303,7 +303,7 @@ fn binds_name(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool {
}
}
-fn is_sad_pat(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool {
+fn is_sad_pat(sema: &hir::Semantics<'_, RootDatabase>, pat: &ast::Pat) -> bool {
sema.type_of_pat(pat)
.and_then(|ty| TryEnum::from_ty(sema, &ty.adjusted()))
.map_or(false, |it| does_pat_match_variant(pat, &it.sad_pattern()))
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 a5fa8a110d..c2be4593b9 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
@@ -36,7 +36,7 @@ use crate::{AssistContext, AssistId, AssistKind, 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_qualified_name_with_use.rs b/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs
index 4800d54956..2419fa11c1 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
@@ -27,7 +27,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ```
pub(crate) fn replace_qualified_name_with_use(
acc: &mut Assists,
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
) -> Option<()> {
let path: ast::Path = ctx.find_node_at_offset()?;
// We don't want to mess with use statements
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 a53f865a5e..decb5fb62a 100644
--- a/crates/ide-assists/src/handlers/replace_string_with_char.rs
+++ b/crates/ide-assists/src/handlers/replace_string_with_char.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// 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()?;
let target = token.syntax().text_range();
@@ -63,7 +63,7 @@ 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_try_expr_with_match.rs b/crates/ide-assists/src/handlers/replace_try_expr_with_match.rs
index a102736124..b825998cb7 100644
--- a/crates/ide-assists/src/handlers/replace_try_expr_with_match.rs
+++ b/crates/ide-assists/src/handlers/replace_try_expr_with_match.rs
@@ -34,7 +34,7 @@ use crate::assist_context::{AssistContext, Assists};
// };
// }
// ```
-pub(crate) fn replace_try_expr_with_match(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn replace_try_expr_with_match(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let qm_kw = ctx.find_token_syntax_at_offset(T![?])?;
let qm_kw_parent = qm_kw.parent().and_then(ast::TryExpr::cast)?;
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 dc3c860d7e..6112e09455 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 f784448471..a93704b394 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::{utils::get_methods, AssistContext, AssistId, AssistKind, Assists};
// 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;
diff --git a/crates/ide-assists/src/handlers/split_import.rs b/crates/ide-assists/src/handlers/split_import.rs
index ac67874b31..775ededecb 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, AssistKind, 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/toggle_ignore.rs b/crates/ide-assists/src/handlers/toggle_ignore.rs
index feaa24c1fe..b7d57f02be 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::{utils::test_related_attribute, AssistContext, AssistId, AssistKind,
// 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(&func)?;
diff --git a/crates/ide-assists/src/handlers/unmerge_use.rs b/crates/ide-assists/src/handlers/unmerge_use.rs
index 7d73632c79..3ce028e930 100644
--- a/crates/ide-assists/src/handlers/unmerge_use.rs
+++ b/crates/ide-assists/src/handlers/unmerge_use.rs
@@ -21,7 +21,7 @@ use crate::{
// use std::fmt::{Debug};
// use std::fmt::Display;
// ```
-pub(crate) fn unmerge_use(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn unmerge_use(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let tree: ast::UseTree = ctx.find_node_at_offset::<ast::UseTree>()?.clone_for_update();
let tree_list = tree.syntax().parent().and_then(ast::UseTreeList::cast)?;
diff --git a/crates/ide-assists/src/handlers/unnecessary_async.rs b/crates/ide-assists/src/handlers/unnecessary_async.rs
index d90fee7809..d5cd2d5513 100644
--- a/crates/ide-assists/src/handlers/unnecessary_async.rs
+++ b/crates/ide-assists/src/handlers/unnecessary_async.rs
@@ -26,7 +26,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 is not on the prototype. This is so that the check does not pollute
@@ -89,7 +89,7 @@ pub(crate) fn unnecessary_async(acc: &mut Assists, ctx: &AssistContext) -> Optio
}
fn find_all_references(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
def: &Definition,
) -> impl Iterator<Item = (FileId, FileReference)> {
def.usages(&ctx.sema).all().into_iter().flat_map(|(file_id, references)| {
@@ -99,7 +99,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/unwrap_block.rs b/crates/ide-assists/src/handlers/unwrap_block.rs
index 45336d704d..7969a49182 100644
--- a/crates/ide-assists/src/handlers/unwrap_block.rs
+++ b/crates/ide-assists/src/handlers/unwrap_block.rs
@@ -25,7 +25,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// println!("foo");
// }
// ```
-pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let assist_id = AssistId("unwrap_block", AssistKind::RefactorRewrite);
let assist_label = "Unwrap block";
diff --git a/crates/ide-assists/src/handlers/unwrap_result_return_type.rs b/crates/ide-assists/src/handlers/unwrap_result_return_type.rs
index ff79c5b82a..9ef4ae047e 100644
--- a/crates/ide-assists/src/handlers/unwrap_result_return_type.rs
+++ b/crates/ide-assists/src/handlers/unwrap_result_return_type.rs
@@ -22,7 +22,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ```
// fn foo() -> i32 { 42i32 }
// ```
-pub(crate) fn unwrap_result_return_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn unwrap_result_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 = match_ast! {
diff --git a/crates/ide-assists/src/handlers/wrap_return_type_in_result.rs b/crates/ide-assists/src/handlers/wrap_return_type_in_result.rs
index 251b41c84a..83446387db 100644
--- a/crates/ide-assists/src/handlers/wrap_return_type_in_result.rs
+++ b/crates/ide-assists/src/handlers/wrap_return_type_in_result.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
// ```
// fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }
// ```
-pub(crate) fn wrap_return_type_in_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
+pub(crate) fn wrap_return_type_in_result(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
let parent = ret_type.syntax().parent()?;
let body = match_ast! {
diff --git a/crates/ide-assists/src/lib.rs b/crates/ide-assists/src/lib.rs
index 1a844d9613..fe87aa15fc 100644
--- a/crates/ide-assists/src/lib.rs
+++ b/crates/ide-assists/src/lib.rs
@@ -104,7 +104,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_explicit_type;
mod add_label_to_loop;
diff --git a/crates/ide-assists/src/tests.rs b/crates/ide-assists/src/tests.rs
index a8d5f85ba6..249a56b4ae 100644
--- a/crates/ide-assists/src/tests.rs
+++ b/crates/ide-assists/src/tests.rs
@@ -113,7 +113,7 @@ enum ExpectedResult<'a> {
}
#[track_caller]
-fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label: Option<&str>) {
+fn check(handler: Handler, before: &str, expected: ExpectedResult<'_>, assist_label: Option<&str>) {
let (mut db, file_with_caret_id, range_or_offset) = RootDatabase::with_range_or_offset(before);
db.set_enable_proc_attr_macros(true);
let text_without_caret = db.file_text(file_with_caret_id).to_string();
diff --git a/crates/ide-assists/src/utils.rs b/crates/ide-assists/src/utils.rs
index 1231cf64a0..3e61d0741d 100644
--- a/crates/ide-assists/src/utils.rs
+++ b/crates/ide-assists/src/utils.rs
@@ -90,7 +90,7 @@ pub enum DefaultMethods {
}
pub fn filter_assoc_items(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
items: &[hir::AssocItem],
default_methods: DefaultMethods,
) -> Vec<ast::AssocItem> {
@@ -127,11 +127,11 @@ pub fn filter_assoc_items(
}
pub fn add_trait_assoc_items_to_impl(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
items: Vec<ast::AssocItem>,
trait_: hir::Trait,
impl_: ast::Impl,
- target_scope: hir::SemanticsScope,
+ target_scope: hir::SemanticsScope<'_>,
) -> (ast::Impl, ast::AssocItem) {
let source_scope = sema.scope_for_def(trait_);
@@ -183,7 +183,7 @@ impl<'a> Cursor<'a> {
}
}
-pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor) -> String {
+pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor<'_>) -> String {
assert!(cursor.node().ancestors().any(|it| it == *node));
let range = cursor.node().text_range() - node.text_range().start();
let range: ops::Range<usize> = range.into();
@@ -334,7 +334,7 @@ fn calc_depth(pat: &ast::Pat, depth: usize) -> usize {
// viable (e.g. we process proc macros, etc)
// FIXME: this partially overlaps with `find_impl_block_*`
pub(crate) fn find_struct_impl(
- ctx: &AssistContext,
+ ctx: &AssistContext<'_>,
adt: &ast::Adt,
name: &str,
) -> Option<Option<ast::Impl>> {
@@ -576,7 +576,7 @@ impl ReferenceConversion {
pub(crate) fn convert_reference_type(
ty: hir::Type,
db: &RootDatabase,
- famous_defs: &FamousDefs,
+ famous_defs: &FamousDefs<'_, '_>,
) -> Option<ReferenceConversion> {
handle_copy(&ty, db)
.or_else(|| handle_as_ref_str(&ty, db, famous_defs))
@@ -594,7 +594,7 @@ fn handle_copy(ty: &hir::Type, db: &dyn HirDatabase) -> Option<ReferenceConversi
fn handle_as_ref_str(
ty: &hir::Type,
db: &dyn HirDatabase,
- famous_defs: &FamousDefs,
+ famous_defs: &FamousDefs<'_, '_>,
) -> Option<ReferenceConversionType> {
let str_type = hir::BuiltinType::str().ty(db);
@@ -605,7 +605,7 @@ fn handle_as_ref_str(
fn handle_as_ref_slice(
ty: &hir::Type,
db: &dyn HirDatabase,
- famous_defs: &FamousDefs,
+ famous_defs: &FamousDefs<'_, '_>,
) -> Option<ReferenceConversionType> {
let type_argument = ty.type_arguments().next()?;
let slice_type = hir::Type::new_slice(type_argument);
@@ -617,7 +617,7 @@ fn handle_as_ref_slice(
fn handle_dereferenced(
ty: &hir::Type,
db: &dyn HirDatabase,
- famous_defs: &FamousDefs,
+ famous_defs: &FamousDefs<'_, '_>,
) -> Option<ReferenceConversionType> {
let type_argument = ty.type_arguments().next()?;
@@ -628,7 +628,7 @@ fn handle_dereferenced(
fn handle_option_as_ref(
ty: &hir::Type,
db: &dyn HirDatabase,
- famous_defs: &FamousDefs,
+ famous_defs: &FamousDefs<'_, '_>,
) -> Option<ReferenceConversionType> {
if ty.as_adt() == famous_defs.core_option_Option()?.ty(db).as_adt() {
Some(ReferenceConversionType::Option)
@@ -640,7 +640,7 @@ fn handle_option_as_ref(
fn handle_result_as_ref(
ty: &hir::Type,
db: &dyn HirDatabase,
- famous_defs: &FamousDefs,
+ famous_defs: &FamousDefs<'_, '_>,
) -> Option<ReferenceConversionType> {
if ty.as_adt() == famous_defs.core_result_Result()?.ty(db).as_adt() {
Some(ReferenceConversionType::Result)
diff --git a/crates/ide-completion/src/completions.rs b/crates/ide-completion/src/completions.rs
index 7b90307988..b1cabbb99d 100644
--- a/crates/ide-completion/src/completions.rs
+++ b/crates/ide-completion/src/completions.rs
@@ -85,12 +85,12 @@ impl Completions {
items.into_iter().for_each(|item| self.add(item.into()))
}
- 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(), keyword);
item.add_to(self);
}
- 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 {
@@ -98,7 +98,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 {
@@ -108,7 +108,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 {
@@ -120,7 +120,7 @@ impl Completions {
pub(crate) fn add_keyword_snippet_expr(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
incomplete_let: bool,
kw: &str,
snippet: &str,
@@ -144,7 +144,7 @@ impl Completions {
item.add_to(self);
}
- pub(crate) fn add_keyword_snippet(&mut self, ctx: &CompletionContext, kw: &str, snippet: &str) {
+ pub(crate) fn add_keyword_snippet(&mut self, ctx: &CompletionContext<'_>, kw: &str, snippet: &str) {
let mut item = CompletionItem::new(CompletionItemKind::Keyword, ctx.source_range(), kw);
match ctx.config.snippet_cap {
@@ -156,7 +156,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| match res {
@@ -169,7 +169,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,
@@ -192,7 +192,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,
@@ -215,7 +215,7 @@ impl Completions {
pub(crate) fn add_enum_variants(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
e: hir::Enum,
) {
@@ -226,7 +226,7 @@ impl Completions {
pub(crate) fn add_module(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
module: hir::Module,
local_name: hir::Name,
@@ -241,7 +241,7 @@ impl Completions {
pub(crate) fn add_macro(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
mac: hir::Macro,
local_name: hir::Name,
@@ -264,7 +264,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>,
@@ -287,7 +287,7 @@ impl Completions {
pub(crate) fn add_method(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
dot_access: &DotAccess,
func: hir::Function,
receiver: Option<hir::Name>,
@@ -312,7 +312,7 @@ impl Completions {
pub(crate) fn add_method_with_import(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
dot_access: &DotAccess,
func: hir::Function,
import: LocatedImport,
@@ -336,7 +336,7 @@ impl Completions {
);
}
- 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,
@@ -348,7 +348,7 @@ impl Completions {
));
}
- pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) {
+ pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext<'_>, type_alias: hir::TypeAlias) {
let is_private_editable = match ctx.is_visible(&type_alias) {
Visible::Yes => false,
Visible::Editable => true,
@@ -362,7 +362,7 @@ impl Completions {
pub(crate) fn add_type_alias_with_eq(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
type_alias: hir::TypeAlias,
) {
self.add_opt(render_type_alias_with_eq(RenderContext::new(ctx), type_alias));
@@ -370,7 +370,7 @@ impl Completions {
pub(crate) fn add_qualified_enum_variant(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
variant: hir::Variant,
path: hir::ModPath,
@@ -384,7 +384,7 @@ impl Completions {
pub(crate) fn add_enum_variant(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
variant: hir::Variant,
local_name: Option<hir::Name>,
@@ -404,7 +404,7 @@ impl Completions {
pub(crate) fn add_field(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
dot_access: &DotAccess,
receiver: Option<hir::Name>,
field: hir::Field,
@@ -427,7 +427,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>,
@@ -442,7 +442,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>,
@@ -453,7 +453,7 @@ impl Completions {
pub(crate) fn add_tuple_field(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
receiver: Option<hir::Name>,
field: usize,
ty: &hir::Type,
@@ -462,18 +462,18 @@ 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(), name.to_smol_str())
.add_to(self)
}
- 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(), name.to_smol_str()).add_to(self)
}
pub(crate) fn add_variant_pat(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
pattern_ctx: &PatternContext,
variant: hir::Variant,
local_name: Option<hir::Name>,
@@ -489,7 +489,7 @@ impl Completions {
pub(crate) fn add_qualified_variant_pat(
&mut self,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
pattern_ctx: &PatternContext,
variant: hir::Variant,
path: hir::ModPath,
@@ -500,7 +500,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>,
@@ -513,10 +513,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::Variant, hir::ModPath),
+ cb: impl Fn(&mut Completions, &CompletionContext<'_>, hir::Variant, hir::ModPath),
) {
let variants = enum_.variants(ctx.db);
@@ -545,7 +545,7 @@ fn enum_variants_with_paths(
pub(super) fn complete_name(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
NameContext { name, kind }: &NameContext,
) {
match kind {
@@ -586,7 +586,7 @@ pub(super) fn complete_name(
pub(super) fn complete_name_ref(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
NameRefContext { nameref, kind }: &NameRefContext,
) {
match kind {
@@ -661,7 +661,7 @@ pub(super) fn complete_name_ref(
}
}
-fn complete_patterns(acc: &mut Completions, ctx: &CompletionContext, pattern_ctx: &PatternContext) {
+fn complete_patterns(acc: &mut Completions, ctx: &CompletionContext<'_>, pattern_ctx: &PatternContext) {
flyimport::import_on_the_fly_pat(acc, ctx, pattern_ctx);
fn_param::complete_fn_param(acc, ctx, pattern_ctx);
pattern::complete_pattern(acc, ctx, pattern_ctx);
diff --git a/crates/ide-completion/src/completions/attribute.rs b/crates/ide-completion/src/completions/attribute.rs
index cbf40e9134..1d8a8c5f20 100644
--- a/crates/ide-completion/src/completions/attribute.rs
+++ b/crates/ide-completion/src/completions/attribute.rs
@@ -32,7 +32,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::Attr,
) -> Option<()> {
@@ -73,7 +73,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 }: &AttrCtx,
) {
diff --git a/crates/ide-completion/src/completions/attribute/cfg.rs b/crates/ide-completion/src/completions/attribute/cfg.rs
index b0a9fc8d43..311060143b 100644
--- a/crates/ide-completion/src/completions/attribute/cfg.rs
+++ b/crates/ide-completion/src/completions/attribute/cfg.rs
@@ -8,7 +8,7 @@ use syntax::SyntaxKind;
use crate::{completions::Completions, context::CompletionContext, CompletionItem};
-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);
completion.insert_text(format!(r#""{}""#, item));
diff --git a/crates/ide-completion/src/completions/attribute/derive.rs b/crates/ide-completion/src/completions/attribute/derive.rs
index b3cc1826a6..14538fef60 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/lint.rs b/crates/ide-completion/src/completions/attribute/lint.rs
index 5c04810318..967f6ddd9a 100644
--- a/crates/ide-completion/src/completions/attribute/lint.rs
+++ b/crates/ide-completion/src/completions/attribute/lint.rs
@@ -6,7 +6,7 @@ use crate::{context::CompletionContext, item::CompletionItem, Completions};
pub(super) fn complete_lint(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
is_qualified: bool,
existing_lints: &[ast::Path],
lints_completions: &[Lint],
diff --git a/crates/ide-completion/src/completions/attribute/repr.rs b/crates/ide-completion/src/completions/attribute/repr.rs
index 1dcec5f493..cdd629824a 100644
--- a/crates/ide-completion/src/completions/attribute/repr.rs
+++ b/crates/ide-completion/src/completions/attribute/repr.rs
@@ -5,7 +5,7 @@ use syntax::ast;
use crate::{context::CompletionContext, item::CompletionItem, Completions};
-pub(super) fn complete_repr(acc: &mut Completions, ctx: &CompletionContext, input: ast::TokenTree) {
+pub(super) fn complete_repr(acc: &mut Completions, ctx: &CompletionContext<'_>, input: ast::TokenTree) {
if let Some(existing_reprs) = super::parse_comma_sep_expr(input) {
for &ReprCompletion { label, snippet, lookup, collides } in REPR_COMPLETIONS {
let repr_already_annotated = existing_reprs
diff --git a/crates/ide-completion/src/completions/dot.rs b/crates/ide-completion/src/completions/dot.rs
index 727ec6e608..4f80031541 100644
--- a/crates/ide-completion/src/completions/dot.rs
+++ b/crates/ide-completion/src/completions/dot.rs
@@ -8,7 +8,7 @@ use crate::{
};
/// Complete dot accesses, i.e. fields or methods.
-pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext, dot_access: &DotAccess) {
+pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext<'_>, dot_access: &DotAccess) {
let receiver_ty = match dot_access {
DotAccess { receiver_ty: Some(receiver_ty), .. } => &receiver_ty.original,
_ => return,
@@ -38,7 +38,7 @@ pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext, dot_a
pub(crate) fn complete_undotted_self(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
expr_ctx: &ExprCtx,
) {
@@ -96,7 +96,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),
@@ -113,7 +113,7 @@ fn complete_fields(
}
fn complete_methods(
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
receiver: &hir::Type,
mut f: impl FnMut(hir::Function),
) {
diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs
index df0556ba45..d4544dd1d1 100644
--- a/crates/ide-completion/src/completions/expr.rs
+++ b/crates/ide-completion/src/completions/expr.rs
@@ -9,7 +9,7 @@ use crate::{
pub(crate) fn complete_expr_path(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx @ PathCompletionCtx { qualified, .. }: &PathCompletionCtx,
&ExprCtx {
in_block_expr,
diff --git a/crates/ide-completion/src/completions/extern_abi.rs b/crates/ide-completion/src/completions/extern_abi.rs
index 3007b3c319..4e89ef6960 100644
--- a/crates/ide-completion/src/completions/extern_abi.rs
+++ b/crates/ide-completion/src/completions/extern_abi.rs
@@ -42,7 +42,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().map_or(false, |it| ast::Abi::can_cast(it.kind())) {
diff --git a/crates/ide-completion/src/completions/field.rs b/crates/ide-completion/src/completions/field.rs
index 738c24574c..0e84d0a53e 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() {
@@ -30,7 +30,7 @@ pub(crate) fn complete_field_list_tuple_variant(
}
}
-pub(crate) fn complete_field_list_record_variant(acc: &mut Completions, ctx: &CompletionContext) {
+pub(crate) fn complete_field_list_record_variant(acc: &mut Completions, ctx: &CompletionContext<'_>) {
if ctx.qualifier_ctx.vis_node.is_none() {
let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet);
add_keyword("pub(crate)", "pub(crate)");
diff --git a/crates/ide-completion/src/completions/flyimport.rs b/crates/ide-completion/src/completions/flyimport.rs
index 6dbcfb0a5d..f04cc15d7f 100644
--- a/crates/ide-completion/src/completions/flyimport.rs
+++ b/crates/ide-completion/src/completions/flyimport.rs
@@ -113,7 +113,7 @@ use super::Completions;
// capability enabled.
pub(crate) fn import_on_the_fly_path(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
) -> Option<()> {
if !ctx.config.enable_imports_on_the_fly {
@@ -152,7 +152,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 {
@@ -177,7 +177,7 @@ pub(crate) fn import_on_the_fly_pat(
pub(crate) fn import_on_the_fly_dot(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
dot_access: &DotAccess,
) -> Option<()> {
if !ctx.config.enable_imports_on_the_fly {
@@ -205,7 +205,7 @@ pub(crate) fn import_on_the_fly_dot(
fn import_on_the_fly(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx @ PathCompletionCtx { kind, .. }: &PathCompletionCtx,
import_assets: ImportAssets,
position: SyntaxNode,
@@ -285,7 +285,7 @@ fn import_on_the_fly(
fn import_on_the_fly_pat_(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
pattern_ctx: &PatternContext,
import_assets: ImportAssets,
position: SyntaxNode,
@@ -329,7 +329,7 @@ fn import_on_the_fly_pat_(
fn import_on_the_fly_method(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
dot_access: &DotAccess,
import_assets: ImportAssets,
position: SyntaxNode,
@@ -362,7 +362,7 @@ fn import_on_the_fly_method(
Some(())
}
-fn import_name(ctx: &CompletionContext) -> String {
+fn import_name(ctx: &CompletionContext<'_>) -> String {
let token_kind = ctx.token.kind();
if matches!(token_kind, T![.] | T![::]) {
String::new()
@@ -372,7 +372,7 @@ fn import_name(ctx: &CompletionContext) -> String {
}
fn import_assets_for_path(
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
potential_import_name: &str,
qualifier: Option<ast::Path>,
) -> Option<ImportAssets> {
diff --git a/crates/ide-completion/src/completions/fn_param.rs b/crates/ide-completion/src/completions/fn_param.rs
index cc6c17450b..f0ecc595af 100644
--- a/crates/ide-completion/src/completions/fn_param.rs
+++ b/crates/ide-completion/src/completions/fn_param.rs
@@ -21,7 +21,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, .. }, impl_) = match pattern_ctx {
@@ -59,7 +59,7 @@ pub(crate) fn complete_fn_param(
}
fn fill_fn_params(
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
function: &ast::Fn,
param_list: &ast::ParamList,
impl_: &Option<ast::Impl>,
@@ -113,7 +113,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),
) {
@@ -170,7 +170,7 @@ fn should_add_self_completions(
}
}
-fn comma_wrapper(ctx: &CompletionContext) -> Option<(impl Fn(&str) -> String, TextRange)> {
+fn comma_wrapper(ctx: &CompletionContext<'_>) -> Option<(impl Fn(&str) -> String, TextRange)> {
let param = ctx.token.parent_ancestors().find(|node| node.kind() == SyntaxKind::PARAM)?;
let next_token_kind = {
diff --git a/crates/ide-completion/src/completions/format_string.rs b/crates/ide-completion/src/completions/format_string.rs
index f7a75b2dd5..038bdb4279 100644
--- a/crates/ide-completion/src/completions/format_string.rs
+++ b/crates/ide-completion/src/completions/format_string.rs
@@ -9,7 +9,7 @@ use crate::{context::CompletionContext, CompletionItem, CompletionItemKind, Comp
/// 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 43b4899390..4e4c9fba6c 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: &ExprCtx,
) {
@@ -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,
) {
@@ -70,7 +70,7 @@ 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 49b8537029..e9256803cc 100644
--- a/crates/ide-completion/src/completions/item_list/trait_impl.rs
+++ b/crates/ide-completion/src/completions/item_list/trait_impl.rs
@@ -57,7 +57,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)
@@ -65,7 +65,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)
@@ -73,7 +73,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)
@@ -81,7 +81,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<()> {
@@ -104,7 +104,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>,
@@ -128,7 +128,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,
@@ -154,7 +154,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,
@@ -204,7 +204,7 @@ fn add_function_impl(
/// 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> {
@@ -228,7 +228,7 @@ fn get_transformed_assoc_item(
fn add_type_alias_impl(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
replacement_range: TextRange,
type_alias: hir::TypeAlias,
) {
@@ -252,7 +252,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,
@@ -340,7 +340,7 @@ fn function_declaration(node: &ast::Fn, needs_whitespace: bool) -> String {
syntax.trim_end().to_owned()
}
-fn replacement_range(ctx: &CompletionContext, item: &SyntaxNode) -> TextRange {
+fn replacement_range(ctx: &CompletionContext<'_>, item: &SyntaxNode) -> TextRange {
let first_child = item
.children_with_tokens()
.find(|child| {
diff --git a/crates/ide-completion/src/completions/keyword.rs b/crates/ide-completion/src/completions/keyword.rs
index 7d8d3a9636..0089958ff1 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 76e1c2e510..3b79def639 100644
--- a/crates/ide-completion/src/completions/lifetime.rs
+++ b/crates/ide-completion/src/completions/lifetime.rs
@@ -18,7 +18,7 @@ use crate::{
/// Completes lifetimes.
pub(crate) fn complete_lifetime(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
lifetime_ctx: &LifetimeContext,
) {
let (lp, lifetime) = match lifetime_ctx {
@@ -54,7 +54,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/mod_.rs b/crates/ide-completion/src/completions/mod_.rs
index 6f67c38dfd..9c975b9295 100644
--- a/crates/ide-completion/src/completions/mod_.rs
+++ b/crates/ide-completion/src/completions/mod_.rs
@@ -14,7 +14,7 @@ use crate::{context::CompletionContext, CompletionItem, Completions};
/// 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 8d7fbc6627..17dfe432b3 100644
--- a/crates/ide-completion/src/completions/pattern.rs
+++ b/crates/ide-completion/src/completions/pattern.rs
@@ -11,7 +11,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,
) {
match pattern_ctx.parent_pat.as_ref() {
@@ -107,7 +107,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 b09f4634c6..9a891cea2d 100644
--- a/crates/ide-completion/src/completions/postfix.rs
+++ b/crates/ide-completion/src/completions/postfix.rs
@@ -20,7 +20,7 @@ use crate::{
pub(crate) fn complete_postfix(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
dot_access: &DotAccess,
) {
if !ctx.config.enable_postfix_completions {
@@ -221,7 +221,7 @@ fn include_references(initial_element: &ast::Expr) -> ast::Expr {
}
fn build_postfix_snippet_builder<'ctx>(
- ctx: &'ctx CompletionContext,
+ ctx: &'ctx CompletionContext<'_>,
cap: SnippetCap,
receiver: &'ctx ast::Expr,
) -> Option<impl Fn(&str, &str, &str) -> Builder + 'ctx> {
@@ -236,7 +236,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, &str) -> Builder + 'ctx {
@@ -262,7 +262,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, &str) -> 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 16f902489b..6b94347e0a 100644
--- a/crates/ide-completion/src/completions/postfix/format_like.rs
+++ b/crates/ide-completion/src/completions/postfix/format_like.rs
@@ -38,7 +38,7 @@ static KINDS: &[(&str, &str)] = &[
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/record.rs b/crates/ide-completion/src/completions/record.rs
index 9f5922c5b0..1c9042390d 100644
--- a/crates/ide-completion/src/completions/record.rs
+++ b/crates/ide-completion/src/completions/record.rs
@@ -10,7 +10,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 {
@@ -20,7 +20,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,
) {
@@ -59,7 +59,7 @@ pub(crate) fn complete_record_expr_fields(
// FIXME: This should probably be part of complete_path_expr
pub(crate) fn complete_record_expr_func_update(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
expr_ctx: &ExprCtx,
) {
@@ -81,7 +81,7 @@ pub(crate) fn complete_record_expr_func_update(
fn add_default_update(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
ty: Option<hir::TypeInfo>,
missing_fields: &[(hir::Field, hir::Type)],
) {
@@ -105,7 +105,7 @@ 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 a530f4262e..66adb42863 100644
--- a/crates/ide-completion/src/completions/snippet.rs
+++ b/crates/ide-completion/src/completions/snippet.rs
@@ -11,7 +11,7 @@ use crate::{
pub(crate) fn complete_expr_snippet(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
&ExprCtx { in_block_expr, .. }: &ExprCtx,
) {
@@ -51,7 +51,7 @@ macro_rules! $1 {
pub(crate) fn complete_item_snippet(
acc: &mut Completions,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
path_ctx: &PathCompletionCtx,
kind: &ItemListKind,
) {
@@ -118,7 +118,7 @@ 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);
item.insert_snippet(cap, snippet);
item
@@ -126,7 +126,7 @@ fn snippet(ctx: &CompletionContext, cap: SnippetCap, label: &str, snippet: &str)
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 0469d34951..87a998dfcc 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,
) {
@@ -208,7 +208,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 d4827771ad..bb2ecc9fdd 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 39028eca41..ca8303906a 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 7c53db9bf2..6a2079b126 100644
--- a/crates/ide-completion/src/context.rs
+++ b/crates/ide-completion/src/context.rs
@@ -388,7 +388,7 @@ impl<'a> CompletionContext<'a> {
}
}
- pub(crate) fn famous_defs(&self) -> FamousDefs {
+ pub(crate) fn famous_defs(&self) -> FamousDefs<'_, '_> {
FamousDefs(&self.sema, self.krate)
}
diff --git a/crates/ide-completion/src/context/analysis.rs b/crates/ide-completion/src/context/analysis.rs
index fabbbe867e..0c8b569b66 100644
--- a/crates/ide-completion/src/context/analysis.rs
+++ b/crates/ide-completion/src/context/analysis.rs
@@ -410,7 +410,7 @@ impl<'a> CompletionContext<'a> {
}
fn classify_lifetime(
- _sema: &Semantics<RootDatabase>,
+ _sema: &Semantics<'_, RootDatabase>,
original_file: &SyntaxNode,
lifetime: ast::Lifetime,
) -> Option<LifetimeContext> {
@@ -437,7 +437,7 @@ impl<'a> CompletionContext<'a> {
}
fn classify_name(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
original_file: &SyntaxNode,
name: ast::Name,
) -> Option<NameContext> {
@@ -477,7 +477,7 @@ impl<'a> CompletionContext<'a> {
}
fn classify_name_ref(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
original_file: &SyntaxNode,
name_ref: ast::NameRef,
parent: SyntaxNode,
@@ -987,7 +987,7 @@ impl<'a> CompletionContext<'a> {
}
fn pattern_context_for(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
original_file: &SyntaxNode,
pat: ast::Pat,
) -> PatternContext {
@@ -1047,7 +1047,7 @@ fn pattern_context_for(
}
fn fetch_immediate_impl(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
original_file: &SyntaxNode,
node: &SyntaxNode,
) -> Option<ast::Impl> {
@@ -1085,7 +1085,7 @@ fn find_node_in_file<N: AstNode>(syntax: &SyntaxNode, node: &N) -> Option<N> {
/// for the offset introduced by the fake ident.
/// This is wrong if `node` comes before the insertion point! Use `find_node_in_file` instead.
fn find_node_in_file_compensated<N: AstNode>(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
in_file: &SyntaxNode,
node: &N,
) -> Option<N> {
@@ -1093,7 +1093,7 @@ fn find_node_in_file_compensated<N: AstNode>(
}
fn ancestors_in_file_compensated<'sema>(
- sema: &'sema Semantics<RootDatabase>,
+ sema: &'sema Semantics<'_, RootDatabase>,
in_file: &SyntaxNode,
node: &SyntaxNode,
) -> Option<impl Iterator<Item = SyntaxNode> + 'sema> {
@@ -1117,7 +1117,7 @@ fn ancestors_in_file_compensated<'sema>(
/// for the offset introduced by the fake ident..
/// This is wrong if `node` comes before the insertion point! Use `find_node_in_file` instead.
fn find_opt_node_in_file_compensated<N: AstNode>(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
node: Option<N>,
) -> Option<N> {
diff --git a/crates/ide-completion/src/item.rs b/crates/ide-completion/src/item.rs
index 2b10dccb80..27482ea489 100644
--- a/crates/ide-completion/src/item.rs
+++ b/crates/ide-completion/src/item.rs
@@ -76,7 +76,7 @@ pub struct CompletionItem {
// We use custom debug for CompletionItem to make snapshot tests more readable.
impl fmt::Debug for CompletionItem {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut s = f.debug_struct("CompletionItem");
s.field("label", &self.label()).field("source_range", &self.source_range());
if self.text_edit().len() == 1 {
@@ -433,7 +433,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 19e46889a5..f3de4a94ca 100644
--- a/crates/ide-completion/src/render.rs
+++ b/crates/ide-completion/src/render.rs
@@ -158,7 +158,7 @@ pub(crate) fn render_tuple_field(
item.build()
}
-pub(crate) fn render_type_inference(ty_string: String, ctx: &CompletionContext) -> CompletionItem {
+pub(crate) fn render_type_inference(ty_string: String, ctx: &CompletionContext<'_>) -> CompletionItem {
let mut builder =
CompletionItem::new(CompletionItemKind::InferredType, ctx.source_range(), ty_string);
builder.set_relevance(CompletionRelevance { is_definite: true, ..Default::default() });
@@ -206,7 +206,7 @@ pub(crate) fn render_resolution_with_import_pat(
fn scope_def_to_name(
resolution: ScopeDef,
- ctx: &RenderContext,
+ ctx: &RenderContext<'_>,
import_edit: &LocatedImport,
) -> Option<hir::Name> {
Some(match resolution {
@@ -400,7 +400,7 @@ fn scope_def_is_deprecated(ctx: &RenderContext<'_>, resolution: ScopeDef) -> boo
}
fn compute_type_match(
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
completion_ty: &hir::Type,
) -> Option<CompletionRelevanceTypeMatch> {
let expected_type = ctx.expected_type.as_ref()?;
@@ -420,12 +420,12 @@ fn compute_type_match(
}
}
-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().map_or(false, |name| name.text() == completion_name)
}
fn compute_ref_match(
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
completion_ty: &hir::Type,
) -> Option<hir::Mutability> {
let expected_type = ctx.expected_type.as_ref()?;
diff --git a/crates/ide-completion/src/render/function.rs b/crates/ide-completion/src/render/function.rs
index 4a8a5d5c77..241de0a183 100644
--- a/crates/ide-completion/src/render/function.rs
+++ b/crates/ide-completion/src/render/function.rs
@@ -44,7 +44,7 @@ fn render(
ctx @ RenderContext { completion, .. }: RenderContext<'_>,
local_name: Option<hir::Name>,
func: hir::Function,
- func_kind: FuncKind,
+ func_kind: FuncKind<'_>,
) -> Builder {
let db = completion.db;
@@ -150,7 +150,7 @@ fn render(
pub(super) fn add_call_parens<'b>(
builder: &'b mut Builder,
- ctx: &CompletionContext,
+ ctx: &CompletionContext<'_>,
cap: SnippetCap,
name: SmolStr,
escaped_name: SmolStr,
@@ -211,7 +211,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() {
if name.as_text().as_deref() == Some(arg) {
@@ -278,7 +278,7 @@ fn params_display(db: &dyn HirDatabase, func: hir::Function) -> String {
fn params(
ctx: &CompletionContext<'_>,
func: hir::Function,
- func_kind: &FuncKind,
+ func_kind: &FuncKind<'_>,
has_dot_receiver: bool,
) -> Option<(Option<hir::SelfParam>, Vec<hir::Param>)> {
if ctx.config.callable.is_none() {
diff --git a/crates/ide-completion/src/render/literal.rs b/crates/ide-completion/src/render/literal.rs
index df80fb2fa6..91a253f8fc 100644
--- a/crates/ide-completion/src/render/literal.rs
+++ b/crates/ide-completion/src/render/literal.rs
@@ -138,7 +138,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),
diff --git a/crates/ide-completion/src/render/union_literal.rs b/crates/ide-completion/src/render/union_literal.rs
index fc35381256..9c9540a9bd 100644
--- a/crates/ide-completion/src/render/union_literal.rs
+++ b/crates/ide-completion/src/render/union_literal.rs
@@ -13,7 +13,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 440b9d14ca..003a0c11ed 100644
--- a/crates/ide-completion/src/render/variant.rs
+++ b/crates/ide-completion/src/render/variant.rs
@@ -68,7 +68,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 40c72b5351..dc1039fa62 100644
--- a/crates/ide-completion/src/snippet.rs
+++ b/crates/ide-completion/src/snippet.rs
@@ -154,7 +154,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)
}
@@ -167,7 +167,7 @@ impl Snippet {
}
}
-fn import_edits(ctx: &CompletionContext, requires: &[GreenNode]) -> Option<Vec<LocatedImport>> {
+fn import_edits(ctx: &CompletionContext<'_>, requires: &[GreenNode]) -> Option<Vec<LocatedImport>> {
let resolve = |import: &GreenNode| {
let path = ast::Path::cast(SyntaxNode::new_root(import.clone()))?;
let item = match ctx.scope.speculative_resolve(&path)? {
diff --git a/crates/ide-db/src/active_parameter.rs b/crates/ide-db/src/active_parameter.rs
index 788a5ed17e..7303ef8b7b 100644
--- a/crates/ide-db/src/active_parameter.rs
+++ b/crates/ide-db/src/active_parameter.rs
@@ -17,7 +17,7 @@ pub struct ActiveParameter {
impl ActiveParameter {
/// Returns information about the call argument this token is part of.
- pub fn at_token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Self> {
+ pub fn at_token(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Self> {
let (signature, active_parameter) = callable_for_token(sema, token)?;
let idx = active_parameter?;
@@ -40,7 +40,7 @@ impl ActiveParameter {
/// Returns a [`hir::Callable`] this token is a part of and its argument index of said callable.
pub fn callable_for_token(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<(hir::Callable, Option<usize>)> {
// Find the calling expression and its NameRef
@@ -54,7 +54,7 @@ pub fn callable_for_token(
}
pub fn callable_for_node(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
calling_node: &ast::CallableExpr,
token: &SyntaxToken,
) -> Option<(hir::Callable, Option<usize>)> {
diff --git a/crates/ide-db/src/defs.rs b/crates/ide-db/src/defs.rs
index 540cc70dd5..26f63a2bd1 100644
--- a/crates/ide-db/src/defs.rs
+++ b/crates/ide-db/src/defs.rs
@@ -130,7 +130,7 @@ pub enum IdentClass {
}
impl IdentClass {
- pub fn classify_node(sema: &Semantics<RootDatabase>, node: &SyntaxNode) -> Option<IdentClass> {
+ pub fn classify_node(sema: &Semantics<'_, RootDatabase>, node: &SyntaxNode) -> Option<IdentClass> {
match_ast! {
match node {
ast::Name(name) => NameClass::classify(sema, &name).map(IdentClass::NameClass),
@@ -146,7 +146,7 @@ impl IdentClass {
}
pub fn classify_token(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
token: &SyntaxToken,
) -> Option<IdentClass> {
let parent = token.parent()?;
@@ -154,7 +154,7 @@ impl IdentClass {
}
pub fn classify_lifetime(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
lifetime: &ast::Lifetime,
) -> Option<IdentClass> {
NameRefClass::classify_lifetime(sema, lifetime)
@@ -218,7 +218,7 @@ impl NameClass {
Some(res)
}
- pub fn classify(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> {
+ pub fn classify(sema: &Semantics<'_, RootDatabase>, name: &ast::Name) -> Option<NameClass> {
let _p = profile::span("classify_name");
let parent = name.syntax().parent()?;
@@ -238,7 +238,7 @@ impl NameClass {
};
return Some(NameClass::Definition(definition));
- fn classify_item(sema: &Semantics<RootDatabase>, item: ast::Item) -> Option<Definition> {
+ fn classify_item(sema: &Semantics<'_, RootDatabase>, item: ast::Item) -> Option<Definition> {
let definition = match item {
ast::Item::MacroRules(it) => {
Definition::Macro(sema.to_def(&ast::Macro::MacroRules(it))?)
@@ -266,7 +266,7 @@ impl NameClass {
}
fn classify_ident_pat(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
ident_pat: ast::IdentPat,
) -> Option<NameClass> {
if let Some(def) = sema.resolve_bind_pat_to_const(&ident_pat) {
@@ -289,7 +289,7 @@ impl NameClass {
}
fn classify_rename(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
rename: ast::Rename,
) -> Option<Definition> {
if let Some(use_tree) = rename.syntax().parent().and_then(ast::UseTree::cast) {
@@ -305,7 +305,7 @@ impl NameClass {
}
pub fn classify_lifetime(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
lifetime: &ast::Lifetime,
) -> Option<NameClass> {
let _p = profile::span("classify_lifetime").detail(|| lifetime.to_string());
@@ -338,7 +338,7 @@ impl NameRefClass {
// Note: we don't have unit-tests for this rather important function.
// It is primarily exercised via goto definition tests in `ide`.
pub fn classify(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
name_ref: &ast::NameRef,
) -> Option<NameRefClass> {
let _p = profile::span("classify_name_ref").detail(|| name_ref.to_string());
@@ -418,7 +418,7 @@ impl NameRefClass {
}
pub fn classify_lifetime(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
lifetime: &ast::Lifetime,
) -> Option<NameRefClass> {
let _p = profile::span("classify_lifetime_ref").detail(|| lifetime.to_string());
diff --git a/crates/ide-db/src/helpers.rs b/crates/ide-db/src/helpers.rs
index d4fda397d6..6e56efe344 100644
--- a/crates/ide-db/src/helpers.rs
+++ b/crates/ide-db/src/helpers.rs
@@ -56,7 +56,7 @@ pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path {
/// Iterates all `ModuleDef`s and `Impl` blocks of the given file.
pub fn visit_file_defs(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
file_id: FileId,
cb: &mut dyn FnMut(Definition),
) {
diff --git a/crates/ide-db/src/imports/import_assets.rs b/crates/ide-db/src/imports/import_assets.rs
index 81467ab07a..8378e323ed 100644
--- a/crates/ide-db/src/imports/import_assets.rs
+++ b/crates/ide-db/src/imports/import_assets.rs
@@ -99,7 +99,7 @@ pub struct ImportAssets {
impl ImportAssets {
pub fn for_method_call(
method_call: &ast::MethodCallExpr,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
) -> Option<Self> {
let candidate_node = method_call.syntax().clone();
Some(Self {
@@ -111,7 +111,7 @@ impl ImportAssets {
pub fn for_exact_path(
fully_qualified_path: &ast::Path,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
) -> Option<Self> {
let candidate_node = fully_qualified_path.syntax().clone();
if let Some(use_tree) = candidate_node.ancestors().find_map(ast::UseTree::cast) {
@@ -129,7 +129,7 @@ impl ImportAssets {
})
}
- pub fn for_ident_pat(sema: &Semantics<RootDatabase>, pat: &ast::IdentPat) -> Option<Self> {
+ pub fn for_ident_pat(sema: &Semantics<'_, RootDatabase>, pat: &ast::IdentPat) -> Option<Self> {
if !pat.is_simple_ident() {
return None;
}
@@ -146,7 +146,7 @@ impl ImportAssets {
module_with_candidate: Module,
qualifier: Option<ast::Path>,
fuzzy_name: String,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
candidate_node: SyntaxNode,
) -> Option<Self> {
Some(Self {
@@ -210,7 +210,7 @@ impl ImportAssets {
pub fn search_for_imports(
&self,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
prefix_kind: PrefixKind,
) -> Vec<LocatedImport> {
let _p = profile::span("import_assets::search_for_imports");
@@ -218,7 +218,7 @@ impl ImportAssets {
}
/// This may return non-absolute paths if a part of the returned path is already imported into scope.
- pub fn search_for_relative_paths(&self, sema: &Semantics<RootDatabase>) -> Vec<LocatedImport> {
+ pub fn search_for_relative_paths(&self, sema: &Semantics<'_, RootDatabase>) -> Vec<LocatedImport> {
let _p = profile::span("import_assets::search_for_relative_paths");
self.search_for(sema, None)
}
@@ -237,7 +237,7 @@ impl ImportAssets {
fn search_for(
&self,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
prefixed: Option<PrefixKind>,
) -> Vec<LocatedImport> {
let _p = profile::span("import_assets::search_for");
@@ -276,7 +276,7 @@ impl ImportAssets {
.collect()
}
- fn scope_definitions(&self, sema: &Semantics<RootDatabase>) -> FxHashSet<ScopeDef> {
+ fn scope_definitions(&self, sema: &Semantics<'_, RootDatabase>) -> FxHashSet<ScopeDef> {
let _p = profile::span("import_assets::scope_definitions");
let mut scope_definitions = FxHashSet::default();
if let Some(scope) = sema.scope(&self.candidate_node) {
@@ -289,7 +289,7 @@ impl ImportAssets {
}
fn path_applicable_imports(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
current_crate: Crate,
path_candidate: &PathImportCandidate,
mod_path: impl Fn(ItemInNs) -> Option<ModPath> + Copy,
@@ -456,9 +456,9 @@ fn module_with_segment_name(
}
fn trait_applicable_items(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
current_crate: Crate,
- scope: &SemanticsScope,
+ scope: &SemanticsScope<'_>,
trait_candidate: &TraitImportCandidate,
trait_assoc_item: bool,
mod_path: impl Fn(ItemInNs) -> Option<ModPath>,
@@ -571,7 +571,7 @@ fn get_mod_path(
impl ImportCandidate {
fn for_method_call(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
method_call: &ast::MethodCallExpr,
) -> Option<Self> {
match sema.resolve_method_call(method_call) {
@@ -585,7 +585,7 @@ impl ImportCandidate {
}
}
- fn for_regular_path(sema: &Semantics<RootDatabase>, path: &ast::Path) -> Option<Self> {
+ fn for_regular_path(sema: &Semantics<'_, RootDatabase>, path: &ast::Path) -> Option<Self> {
if sema.resolve_path(path).is_some() {
return None;
}
@@ -596,7 +596,7 @@ impl ImportCandidate {
)
}
- fn for_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<Self> {
+ fn for_name(sema: &Semantics<'_, RootDatabase>, name: &ast::Name) -> Option<Self> {
if sema
.scope(name.syntax())?
.speculative_resolve(&ast::make::ext::ident_path(&name.text()))
@@ -613,14 +613,14 @@ impl ImportCandidate {
fn for_fuzzy_path(
qualifier: Option<ast::Path>,
fuzzy_name: String,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
) -> Option<Self> {
path_import_candidate(sema, qualifier, NameToImport::Fuzzy(fuzzy_name))
}
}
fn path_import_candidate(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
qualifier: Option<ast::Path>,
name: NameToImport,
) -> Option<ImportCandidate> {
diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs
index e2630d686b..26648b4d76 100644
--- a/crates/ide-db/src/lib.rs
+++ b/crates/ide-db/src/lib.rs
@@ -115,7 +115,7 @@ impl FileLoader for RootDatabase {
fn file_text(&self, file_id: FileId) -> Arc<String> {
FileLoaderDelegate(self).file_text(file_id)
}
- fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
+ fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
diff --git a/crates/ide-db/src/path_transform.rs b/crates/ide-db/src/path_transform.rs
index 61b2c3f3b8..d78b8758d6 100644
--- a/crates/ide-db/src/path_transform.rs
+++ b/crates/ide-db/src/path_transform.rs
@@ -255,7 +255,7 @@ fn get_type_args_from_arg_list(generic_arg_list: ast::GenericArgList) -> Option<
}
fn find_trait_for_assoc_item(
- scope: &SemanticsScope,
+ scope: &SemanticsScope<'_>,
type_param: hir::TypeParam,
assoc_item: ast::NameRef,
) -> Option<hir::Trait> {
diff --git a/crates/ide-db/src/rename.rs b/crates/ide-db/src/rename.rs
index c2e7142f52..435a99aa0f 100644
--- a/crates/ide-db/src/rename.rs
+++ b/crates/ide-db/src/rename.rs
@@ -66,7 +66,7 @@ macro_rules! _bail {
pub use _bail as bail;
impl Definition {
- pub fn rename(&self, sema: &Semantics<RootDatabase>, new_name: &str) -> Result<SourceChange> {
+ pub fn rename(&self, sema: &Semantics<'_, RootDatabase>, new_name: &str) -> Result<SourceChange> {
match *self {
Definition::Module(module) => rename_mod(sema, module, new_name),
Definition::BuiltinType(_) => {
@@ -80,7 +80,7 @@ impl Definition {
/// Textual range of the identifier which will change when renaming this
/// `Definition`. Note that some definitions, like buitin types, can't be
/// renamed.
- pub fn range_for_rename(self, sema: &Semantics<RootDatabase>) -> Option<FileRange> {
+ pub fn range_for_rename(self, sema: &Semantics<'_, RootDatabase>) -> Option<FileRange> {
let res = match self {
Definition::Macro(mac) => {
let src = mac.source(sema.db)?;
@@ -155,7 +155,7 @@ impl Definition {
};
return res;
- fn name_range<D>(def: D, sema: &Semantics<RootDatabase>) -> Option<FileRange>
+ fn name_range<D>(def: D, sema: &Semantics<'_, RootDatabase>) -> Option<FileRange>
where
D: HasSource,
D::Ast: ast::HasName,
@@ -168,7 +168,7 @@ impl Definition {
}
fn rename_mod(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
module: hir::Module,
new_name: &str,
) -> Result<SourceChange> {
@@ -248,7 +248,7 @@ fn rename_mod(
}
fn rename_reference(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
def: Definition,
new_name: &str,
) -> Result<SourceChange> {
@@ -448,7 +448,7 @@ fn source_edit_from_name_ref(
}
fn source_edit_from_def(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
def: Definition,
new_name: &str,
) -> Result<(FileId, TextEdit)> {
diff --git a/crates/ide-db/src/search.rs b/crates/ide-db/src/search.rs
index f02e096350..c75364084e 100644
--- a/crates/ide-db/src/search.rs
+++ b/crates/ide-db/src/search.rs
@@ -305,7 +305,7 @@ impl Definition {
}
}
- pub fn usages<'a>(self, sema: &'a Semantics<RootDatabase>) -> FindUsages<'a> {
+ pub fn usages<'a>(self, sema: &'a Semantics<'_, RootDatabase>) -> FindUsages<'a> {
FindUsages {
local_repr: match self {
Definition::Local(local) => Some(local.representative(sema.db)),
@@ -424,7 +424,7 @@ impl<'a> FindUsages<'a> {
}
fn scope_files<'a>(
- sema: &'a Semantics<RootDatabase>,
+ sema: &'a Semantics<'_, RootDatabase>,
scope: &'a SearchScope,
) -> impl Iterator<Item = (Arc<String>, FileId, TextRange)> + 'a {
scope.entries.iter().map(|(&file_id, &search_range)| {
@@ -740,7 +740,7 @@ impl<'a> FindUsages<'a> {
}
}
-fn def_to_ty(sema: &Semantics<RootDatabase>, def: &Definition) -> Option<hir::Type> {
+fn def_to_ty(sema: &Semantics<'_, RootDatabase>, def: &Definition) -> Option<hir::Type> {
match def {
Definition::Adt(adt) => Some(adt.ty(sema.db)),
Definition::TypeAlias(it) => Some(it.ty(sema.db)),
diff --git a/crates/ide-db/src/symbol_index.rs b/crates/ide-db/src/symbol_index.rs
index 33e2001934..bfb0031277 100644
--- a/crates/ide-db/src/symbol_index.rs
+++ b/crates/ide-db/src/symbol_index.rs
@@ -224,7 +224,7 @@ pub struct SymbolIndex {
}
impl fmt::Debug for SymbolIndex {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SymbolIndex").field("n_symbols", &self.symbols.len()).finish()
}
}
diff --git a/crates/ide-db/src/syntax_helpers/node_ext.rs b/crates/ide-db/src/syntax_helpers/node_ext.rs
index f011a4a48a..84bde4d44d 100644
--- a/crates/ide-db/src/syntax_helpers/node_ext.rs
+++ b/crates/ide-db/src/syntax_helpers/node_ext.rs
@@ -399,7 +399,7 @@ impl TreeWithDepthIterator {
}
}
-impl<'a> Iterator for TreeWithDepthIterator {
+impl Iterator for TreeWithDepthIterator {
type Item = (ast::Expr, u32);
fn next(&mut self) -> Option<Self::Item> {
diff --git a/crates/ide-db/src/tests/sourcegen_lints.rs b/crates/ide-db/src/tests/sourcegen_lints.rs
index b7db1dd8db..5042f6d815 100644
--- a/crates/ide-db/src/tests/sourcegen_lints.rs
+++ b/crates/ide-db/src/tests/sourcegen_lints.rs
@@ -264,7 +264,7 @@ fn push_lint_completion(buf: &mut String, label: &str, description: &str) {
);
}
-fn push_lint_group<'a>(buf: &mut String, label: &str, description: &str, children: &[String]) {
+fn push_lint_group(buf: &mut String, label: &str, description: &str, children: &[String]) {
buf.push_str(
r###" LintGroup {
lint:
diff --git a/crates/ide-db/src/traits.rs b/crates/ide-db/src/traits.rs
index b607cdfee3..6a7ea7c19f 100644
--- a/crates/ide-db/src/traits.rs
+++ b/crates/ide-db/src/traits.rs
@@ -7,7 +7,7 @@ use syntax::{ast, AstNode};
/// Given the `impl` block, attempts to find the trait this `impl` corresponds to.
pub fn resolve_target_trait(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
impl_def: &ast::Impl,
) -> Option<hir::Trait> {
let ast_path =
@@ -22,7 +22,7 @@ pub fn resolve_target_trait(
/// Given the `impl` block, returns the list of associated items (e.g. functions or types) that are
/// missing in this `impl` block.
pub fn get_missing_assoc_items(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
impl_def: &ast::Impl,
) -> Vec<hir::AssocItem> {
let imp = match sema.to_def(impl_def) {
diff --git a/crates/ide-db/src/ty_filter.rs b/crates/ide-db/src/ty_filter.rs
index 2c6b00b134..46f47f258b 100644
--- a/crates/ide-db/src/ty_filter.rs
+++ b/crates/ide-db/src/ty_filter.rs
@@ -20,7 +20,7 @@ impl TryEnum {
const ALL: [TryEnum; 2] = [TryEnum::Option, TryEnum::Result];
/// Returns `Some(..)` if the provided type is an enum that implements `std::ops::Try`.
- pub fn from_ty(sema: &Semantics<RootDatabase>, ty: &hir::Type) -> Option<TryEnum> {
+ pub fn from_ty(sema: &Semantics<'_, RootDatabase>, ty: &hir::Type) -> Option<TryEnum> {
let enum_ = match ty.as_adt() {
Some(hir::Adt::Enum(it)) => it,
_ => return None,
diff --git a/crates/ide-diagnostics/src/handlers/no_such_field.rs b/crates/ide-diagnostics/src/handlers/no_such_field.rs
index 667a550d1f..e032c578f0 100644
--- a/crates/ide-diagnostics/src/handlers/no_such_field.rs
+++ b/crates/ide-diagnostics/src/handlers/no_such_field.rs
@@ -30,7 +30,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField) -> Option<Vec<Assis
}
fn missing_record_expr_field_fixes(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
usage_file_id: FileId,
record_expr_field: &ast::RecordExprField,
) -> Option<Vec<Assist>> {
diff --git a/crates/ide-diagnostics/src/handlers/unlinked_file.rs b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
index 9d46e2b078..80bd055c78 100644
--- a/crates/ide-diagnostics/src/handlers/unlinked_file.rs
+++ b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
@@ -18,7 +18,7 @@ use crate::{fix, Assist, Diagnostic, DiagnosticsContext, Severity};
//
// 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, acc: &mut Vec<Diagnostic>, file_id: FileId) {
+pub(crate) fn unlinked_file(ctx: &DiagnosticsContext<'_>, acc: &mut Vec<Diagnostic>, file_id: FileId) {
// Limit diagnostic to the first few characters in the file. This matches how VS Code
// renders it with the full span, but on other editors, and is less invasive.
let range = ctx.sema.db.parse(file_id).syntax_node().text_range();
@@ -32,7 +32,7 @@ pub(crate) fn unlinked_file(ctx: &DiagnosticsContext, acc: &mut Vec<Diagnostic>,
);
}
-fn fixes(ctx: &DiagnosticsContext, file_id: FileId) -> Option<Vec<Assist>> {
+fn fixes(ctx: &DiagnosticsContext<'_>, file_id: FileId) -> Option<Vec<Assist>> {
// If there's an existing module that could add `mod` or `pub mod` items to include the unlinked file,
// suggest that as a fix.
diff --git a/crates/ide-ssr/src/from_comment.rs b/crates/ide-ssr/src/from_comment.rs
index c50e74d93a..2c9c25b96c 100644
--- a/crates/ide-ssr/src/from_comment.rs
+++ b/crates/ide-ssr/src/from_comment.rs
@@ -15,7 +15,7 @@ use crate::MatchFinder;
/// Attempts to build an SSR MatchFinder from a comment at the given file
/// range. If successful, returns the MatchFinder and a TextRange covering
/// comment.
-pub fn ssr_from_comment(db: &RootDatabase, frange: FileRange) -> Option<(MatchFinder, TextRange)> {
+pub fn ssr_from_comment(db: &RootDatabase, frange: FileRange) -> Option<(MatchFinder<'_>, TextRange)> {
let comment = {
let file = db.parse(frange.file_id);
file.tree().syntax().token_at_offset(frange.range.start()).find_map(ast::Comment::cast)
diff --git a/crates/ide-ssr/src/matching.rs b/crates/ide-ssr/src/matching.rs
index ba2a99c5d4..e3a837ddcd 100644
--- a/crates/ide-ssr/src/matching.rs
+++ b/crates/ide-ssr/src/matching.rs
@@ -89,7 +89,7 @@ pub(crate) fn get_match(
rule: &ResolvedRule,
code: &SyntaxNode,
restrict_range: &Option<FileRange>,
- sema: &Semantics<ide_db::RootDatabase>,
+ sema: &Semantics<'_, ide_db::RootDatabase>,
) -> Result<Match, MatchFailed> {
record_match_fails_reasons_scope(debug_active, || {
Matcher::try_match(rule, code, restrict_range, sema)
@@ -165,7 +165,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
fn attempt_match_node(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern: &SyntaxNode,
code: &SyntaxNode,
) -> Result<(), MatchFailed> {
@@ -218,7 +218,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
fn attempt_match_node_children(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern: &SyntaxNode,
code: &SyntaxNode,
) -> Result<(), MatchFailed> {
@@ -231,7 +231,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
fn attempt_match_sequences(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern_it: PatternIterator,
mut code_it: SyntaxElementChildren,
) -> Result<(), MatchFailed> {
@@ -260,7 +260,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
fn attempt_match_token(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern: &mut Peekable<PatternIterator>,
code: &syntax::SyntaxToken,
) -> Result<(), MatchFailed> {
@@ -332,7 +332,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
/// differently.
fn attempt_match_path(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern: &SyntaxNode,
code: &SyntaxNode,
) -> Result<(), MatchFailed> {
@@ -372,7 +372,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
fn attempt_match_opt<T: AstNode>(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern: Option<T>,
code: Option<T>,
) -> Result<(), MatchFailed> {
@@ -390,7 +390,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
/// them.
fn attempt_match_record_field_list(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern: &SyntaxNode,
code: &SyntaxNode,
) -> Result<(), MatchFailed> {
@@ -440,7 +440,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
/// expanded the macro.
fn attempt_match_token_tree(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern: &SyntaxNode,
code: &syntax::SyntaxNode,
) -> Result<(), MatchFailed> {
@@ -521,7 +521,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
fn attempt_match_ufcs_to_method_call(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern_ufcs: &UfcsCallInfo,
code: &ast::MethodCallExpr,
) -> Result<(), MatchFailed> {
@@ -581,7 +581,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
fn attempt_match_ufcs_to_ufcs(
&self,
- phase: &mut Phase,
+ phase: &mut Phase<'_>,
pattern_ufcs: &UfcsCallInfo,
code: &ast::CallExpr,
) -> Result<(), MatchFailed> {
@@ -640,7 +640,7 @@ impl Match {
fn render_template_paths(
&mut self,
template: &ResolvedPattern,
- sema: &Semantics<ide_db::RootDatabase>,
+ sema: &Semantics<'_, ide_db::RootDatabase>,
) -> Result<(), MatchFailed> {
let module = sema
.scope(&self.matched_node)
diff --git a/crates/ide-ssr/src/nester.rs b/crates/ide-ssr/src/nester.rs
index 0c1b2685b2..c6a765070e 100644
--- a/crates/ide-ssr/src/nester.rs
+++ b/crates/ide-ssr/src/nester.rs
@@ -14,7 +14,7 @@ use crate::{Match, SsrMatches};
pub(crate) fn nest_and_remove_collisions(
mut matches: Vec<Match>,
- sema: &hir::Semantics<ide_db::RootDatabase>,
+ sema: &hir::Semantics<'_, ide_db::RootDatabase>,
) -> SsrMatches {
// We sort the matches by depth then by rule index. Sorting by depth means that by the time we
// see a match, any parent matches or conflicting matches will have already been seen. Sorting
@@ -37,7 +37,7 @@ impl MatchCollector {
/// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If
/// it is entirely within the a placeholder of an existing match, then it is added as a child
/// match of the existing match.
- fn add_match(&mut self, m: Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
+ fn add_match(&mut self, m: Match, sema: &hir::Semantics<'_, ide_db::RootDatabase>) {
let matched_node = m.matched_node.clone();
if let Some(existing) = self.matches_by_node.get_mut(&matched_node) {
try_add_sub_match(m, existing, sema);
@@ -54,7 +54,7 @@ impl MatchCollector {
}
/// Attempts to add `m` as a sub-match of `existing`.
-fn try_add_sub_match(m: Match, existing: &mut Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
+fn try_add_sub_match(m: Match, existing: &mut Match, sema: &hir::Semantics<'_, ide_db::RootDatabase>) {
for p in existing.placeholder_values.values_mut() {
// Note, no need to check if p.range.file is equal to m.range.file, since we
// already know we're within `existing`.
diff --git a/crates/ide-ssr/src/resolving.rs b/crates/ide-ssr/src/resolving.rs
index f3b1af8e77..4731f14f4e 100644
--- a/crates/ide-ssr/src/resolving.rs
+++ b/crates/ide-ssr/src/resolving.rs
@@ -42,7 +42,7 @@ pub(crate) struct UfcsCallInfo {
impl ResolvedRule {
pub(crate) fn new(
rule: parsing::ParsedRule,
- resolution_scope: &ResolutionScope,
+ resolution_scope: &ResolutionScope<'_>,
index: usize,
) -> Result<ResolvedRule, SsrError> {
let resolver =
diff --git a/crates/ide-ssr/src/tests.rs b/crates/ide-ssr/src/tests.rs
index e86190564c..1ecb7aa9aa 100644
--- a/crates/ide-ssr/src/tests.rs
+++ b/crates/ide-ssr/src/tests.rs
@@ -113,7 +113,7 @@ fn assert_ssr_transforms(rules: &[&str], input: &str, expected: Expect) {
expected.assert_eq(&actual);
}
-fn print_match_debug_info(match_finder: &MatchFinder, file_id: FileId, snippet: &str) {
+fn print_match_debug_info(match_finder: &MatchFinder<'_>, file_id: FileId, snippet: &str) {
let debug_info = match_finder.debug_where_text_equal(file_id, snippet);
println!(
"Match debug info: {} nodes had text exactly equal to '{}'",
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index 0f2ab6d695..fed327f52b 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -75,7 +75,7 @@ pub(crate) fn rewrite_links(db: &RootDatabase, markdown: &str, definition: Defin
pub(crate) fn remove_links(markdown: &str) -> String {
let mut drop_link = false;
- let mut cb = |_: BrokenLink| {
+ let mut cb = |_: BrokenLink<'_>| {
let empty = InlineStr::try_from("").unwrap();
Some((CowStr::Inlined(empty), CowStr::Inlined(empty)))
};
@@ -196,7 +196,7 @@ pub(crate) fn resolve_doc_path_for_def(
}
pub(crate) fn doc_attributes(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
node: &SyntaxNode,
) -> Option<(hir::AttrsWithOwner, Definition)> {
match_ast! {
@@ -241,7 +241,7 @@ pub(crate) fn token_as_doc_comment(doc_token: &SyntaxToken) -> Option<DocComment
impl DocCommentToken {
pub(crate) fn get_definition_with_descend_at<T>(
self,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
offset: TextSize,
// Definition, CommentOwner, range of intra doc link in original file
mut cb: impl FnMut(Definition, SyntaxNode, TextRange) -> Option<T>,
@@ -360,7 +360,7 @@ fn map_links<'e>(
) -> impl Iterator<Item = Event<'e>> {
let mut in_link = false;
// holds the origin link target on start event and the rewritten one on end event
- let mut end_link_target: Option<CowStr> = None;
+ let mut end_link_target: Option<CowStr<'_>> = None;
// normally link's type is determined by the type of link tag in the end event,
// however in some cases we want to change the link type, for example,
// `Shortcut` type parsed from Start/End tags doesn't make sense for url links
diff --git a/crates/ide/src/doc_links/tests.rs b/crates/ide/src/doc_links/tests.rs
index 2cba5081c1..c6bfb6b9d0 100644
--- a/crates/ide/src/doc_links/tests.rs
+++ b/crates/ide/src/doc_links/tests.rs
@@ -52,7 +52,7 @@ fn check_doc_links(ra_fixture: &str) {
}
fn def_under_cursor(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
position: &FilePosition,
) -> (Definition, hir::Documentation) {
let (docs, def) = sema
@@ -70,7 +70,7 @@ fn def_under_cursor(
}
fn node_to_def(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
node: &SyntaxNode,
) -> Option<Option<(Option<hir::Documentation>, Definition)>> {
Some(match_ast! {
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs
index fd0a29f64f..136d3dec80 100644
--- a/crates/ide/src/expand_macro.rs
+++ b/crates/ide/src/expand_macro.rs
@@ -100,23 +100,23 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
}
fn expand_macro_recur(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
macro_call: &ast::MacroCall,
) -> Option<SyntaxNode> {
let expanded = sema.expand(macro_call)?.clone_for_update();
expand(sema, expanded, ast::MacroCall::cast, expand_macro_recur)
}
-fn expand_attr_macro_recur(sema: &Semantics<RootDatabase>, item: &ast::Item) -> Option<SyntaxNode> {
+fn expand_attr_macro_recur(sema: &Semantics<'_, RootDatabase>, item: &ast::Item) -> Option<SyntaxNode> {
let expanded = sema.expand_attr_macro(item)?.clone_for_update();
expand(sema, expanded, ast::Item::cast, expand_attr_macro_recur)
}
fn expand<T: AstNode>(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
expanded: SyntaxNode,
f: impl FnMut(SyntaxNode) -> Option<T>,
- exp: impl Fn(&Semantics<RootDatabase>, &T) -> Option<SyntaxNode>,
+ exp: impl Fn(&Semantics<'_, RootDatabase>, &T) -> Option<SyntaxNode>,
) -> Option<SyntaxNode> {
let children = expanded.descendants().filter_map(f);
let mut replacements = Vec::new();
diff --git a/crates/ide/src/extend_selection.rs b/crates/ide/src/extend_selection.rs
index 6111bdb94a..45f1fd7484 100644
--- a/crates/ide/src/extend_selection.rs
+++ b/crates/ide/src/extend_selection.rs
@@ -33,7 +33,7 @@ pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRang
}
fn try_extend_selection(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
root: &SyntaxNode,
frange: FileRange,
) -> Option<TextRange> {
@@ -120,7 +120,7 @@ fn try_extend_selection(
}
fn extend_tokens_from_range(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
macro_call: ast::MacroCall,
original_range: TextRange,
) -> Option<TextRange> {
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index e10789fd47..d9c97751c9 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -79,7 +79,7 @@ pub(crate) fn goto_definition(
}
fn try_lookup_include_path(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
tt: ast::TokenTree,
token: SyntaxToken,
file_id: FileId,
@@ -112,7 +112,7 @@ fn try_lookup_include_path(
/// impl A for S { type a = i32; } // <-- on this associate type, will get the location of a in the trait
/// ```
fn try_filter_trait_item_definition(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
def: &Definition,
) -> Option<Vec<NavigationTarget>> {
let db = sema.db;
diff --git a/crates/ide/src/goto_implementation.rs b/crates/ide/src/goto_implementation.rs
index 1d2909fa28..b29ee44e5b 100644
--- a/crates/ide/src/goto_implementation.rs
+++ b/crates/ide/src/goto_implementation.rs
@@ -86,11 +86,11 @@ pub(crate) fn goto_implementation(
Some(RangeInfo { range, info: navs })
}
-fn impls_for_ty(sema: &Semantics<RootDatabase>, ty: hir::Type) -> Vec<NavigationTarget> {
+fn impls_for_ty(sema: &Semantics<'_, RootDatabase>, ty: hir::Type) -> Vec<NavigationTarget> {
Impl::all_for_type(sema.db, ty).into_iter().filter_map(|imp| imp.try_to_nav(sema.db)).collect()
}
-fn impls_for_trait(sema: &Semantics<RootDatabase>, trait_: hir::Trait) -> Vec<NavigationTarget> {
+fn impls_for_trait(sema: &Semantics<'_, RootDatabase>, trait_: hir::Trait) -> Vec<NavigationTarget> {
Impl::all_for_trait(sema.db, trait_)
.into_iter()
.filter_map(|imp| imp.try_to_nav(sema.db))
@@ -98,7 +98,7 @@ fn impls_for_trait(sema: &Semantics<RootDatabase>, trait_: hir::Trait) -> Vec<Na
}
fn impls_for_trait_item(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
trait_: hir::Trait,
fun_name: hir::Name,
) -> Vec<NavigationTarget> {
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index 9b4bfc4107..f2d7029eab 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -44,7 +44,7 @@ pub struct HighlightRelatedConfig {
//
// Note: `?` and `->` do not currently trigger this behavior in the VSCode editor.
pub(crate) fn highlight_related(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: HighlightRelatedConfig,
FilePosition { offset, file_id }: FilePosition,
) -> Option<Vec<HighlightedRange>> {
@@ -76,7 +76,7 @@ pub(crate) fn highlight_related(
}
fn highlight_references(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
node: &SyntaxNode,
token: SyntaxToken,
file_id: FileId,
@@ -136,11 +136,11 @@ fn highlight_references(
}
fn highlight_exit_points(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<Vec<HighlightedRange>> {
fn hl(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
body: Option<ast::Expr>,
) -> Option<Vec<HighlightedRange>> {
let mut highlights = Vec::new();
@@ -330,7 +330,7 @@ fn cover_range(r0: Option<TextRange>, r1: Option<TextRange>) -> Option<TextRange
}
}
-fn find_defs(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> FxHashSet<Definition> {
+fn find_defs(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> FxHashSet<Definition> {
sema.descend_into_macros(token)
.into_iter()
.filter_map(|token| IdentClass::classify_token(sema, &token).map(IdentClass::definitions))
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 592fff322e..d8867cf783 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -163,7 +163,7 @@ pub(crate) fn hover(
}
pub(crate) fn hover_for_definition(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
file_id: FileId,
definition: Definition,
node: &SyntaxNode,
@@ -189,7 +189,7 @@ pub(crate) fn hover_for_definition(
fn hover_ranged(
file: &SyntaxNode,
range: syntax::TextRange,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
) -> Option<RangeInfo<HoverResult>> {
// FIXME: make this work in attributes
@@ -222,7 +222,7 @@ fn hover_ranged(
}
fn hover_type_fallback(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
token: &SyntaxToken,
original_token: &SyntaxToken,
@@ -281,7 +281,7 @@ fn show_fn_references_action(db: &RootDatabase, def: Definition) -> Option<Hover
}
fn runnable_action(
- sema: &hir::Semantics<RootDatabase>,
+ sema: &hir::Semantics<'_, RootDatabase>,
def: Definition,
file_id: FileId,
) -> Option<HoverAction> {
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index 1cb67c6657..925aaa61cd 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -26,7 +26,7 @@ use crate::{
};
pub(super) fn type_info(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
expr_or_pat: &Either<ast::Expr, ast::Pat>,
) -> Option<HoverResult> {
@@ -71,7 +71,7 @@ pub(super) fn type_info(
}
pub(super) fn try_expr(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
try_expr: &ast::TryExpr,
) -> Option<HoverResult> {
@@ -162,7 +162,7 @@ pub(super) fn try_expr(
}
pub(super) fn deref_expr(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
deref_expr: &ast::PrefixExpr,
) -> Option<HoverResult> {
@@ -226,7 +226,7 @@ pub(super) fn deref_expr(
}
pub(super) fn keyword(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
token: &SyntaxToken,
) -> Option<HoverResult> {
@@ -335,7 +335,7 @@ pub(super) fn path(db: &RootDatabase, module: hir::Module, item_name: Option<Str
pub(super) fn definition(
db: &RootDatabase,
def: Definition,
- famous_defs: Option<&FamousDefs>,
+ famous_defs: Option<&FamousDefs<'_, '_>>,
config: &HoverConfig,
) -> Option<Markup> {
let mod_path = definition_mod_path(db, &def);
@@ -460,7 +460,7 @@ fn markup(docs: Option<String>, desc: String, mod_path: Option<String>) -> Optio
Some(buf.into())
}
-fn builtin(famous_defs: &FamousDefs, builtin: hir::BuiltinType) -> Option<Markup> {
+fn builtin(famous_defs: &FamousDefs<'_, '_>, builtin: hir::BuiltinType) -> Option<Markup> {
// std exposes prim_{} modules with docstrings on the root to document the builtins
let primitive_mod = format!("prim_{}", builtin.name());
let doc_owner = find_std_module(famous_defs, &primitive_mod)?;
@@ -468,7 +468,7 @@ fn builtin(famous_defs: &FamousDefs, builtin: hir::BuiltinType) -> Option<Markup
markup(Some(docs.into()), builtin.name().to_string(), None)
}
-fn find_std_module(famous_defs: &FamousDefs, name: &str) -> Option<hir::Module> {
+fn find_std_module(famous_defs: &FamousDefs<'_, '_>, name: &str) -> Option<hir::Module> {
let db = famous_defs.0.db;
let std_crate = famous_defs.std()?;
let std_root_module = std_crate.root_module(db);
@@ -513,7 +513,7 @@ impl KeywordHint {
}
fn keyword_hints(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
token: &SyntaxToken,
parent: syntax::SyntaxNode,
) -> KeywordHint {
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 2c3009abe9..5aae669aa4 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -138,7 +138,7 @@ pub(crate) fn inlay_hints(
fn hints(
hints: &mut Vec<InlayHint>,
- famous_defs @ FamousDefs(sema, _): &FamousDefs,
+ famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: FileId,
node: SyntaxNode,
@@ -185,7 +185,7 @@ fn hints(
fn closing_brace_hints(
acc: &mut Vec<InlayHint>,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
file_id: FileId,
node: SyntaxNode,
@@ -502,8 +502,8 @@ fn fn_lifetime_fn_hints(
fn closure_ret_hints(
acc: &mut Vec<InlayHint>,
- sema: &Semantics<RootDatabase>,
- famous_defs: &FamousDefs,
+ sema: &Semantics<'_, RootDatabase>,
+ famous_defs: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: FileId,
closure: ast::ClosureExpr,
@@ -543,7 +543,7 @@ fn closure_ret_hints(
fn reborrow_hints(
acc: &mut Vec<InlayHint>,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
expr: &ast::Expr,
) -> Option<()> {
@@ -570,8 +570,8 @@ fn reborrow_hints(
fn chaining_hints(
acc: &mut Vec<InlayHint>,
- sema: &Semantics<RootDatabase>,
- famous_defs: &FamousDefs,
+ sema: &Semantics<'_, RootDatabase>,
+ famous_defs: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: FileId,
expr: &ast::Expr,
@@ -632,7 +632,7 @@ fn chaining_hints(
fn param_name_hints(
acc: &mut Vec<InlayHint>,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
expr: ast::Expr,
) -> Option<()> {
@@ -685,7 +685,7 @@ fn param_name_hints(
fn binding_mode_hints(
acc: &mut Vec<InlayHint>,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
pat: &ast::Pat,
) -> Option<()> {
@@ -732,7 +732,7 @@ fn binding_mode_hints(
fn bind_pat_hints(
acc: &mut Vec<InlayHint>,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
file_id: FileId,
pat: &ast::IdentPat,
@@ -783,7 +783,7 @@ fn bind_pat_hints(
}
fn is_named_constructor(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
pat: &ast::IdentPat,
ty_name: &str,
) -> Option<()> {
@@ -837,8 +837,8 @@ fn is_named_constructor(
/// Checks if the type is an Iterator from std::iter and replaces its hint with an `impl Iterator<Item = Ty>`.
fn hint_iterator(
- sema: &Semantics<RootDatabase>,
- famous_defs: &FamousDefs,
+ sema: &Semantics<'_, RootDatabase>,
+ famous_defs: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
ty: &hir::Type,
) -> Option<String> {
@@ -899,7 +899,7 @@ fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &hir
}
fn should_not_display_type_hint(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
bind_pat: &ast::IdentPat,
pat_ty: &hir::Type,
@@ -959,7 +959,7 @@ fn closure_has_block_body(closure: &ast::ClosureExpr) -> bool {
}
fn should_hide_param_name_hint(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
callable: &hir::Callable,
param_name: &str,
argument: &ast::Expr,
@@ -1048,7 +1048,7 @@ fn is_param_name_suffix_of_fn_name(
}
fn is_adt_constructor_similar_to_param_name(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
argument: &ast::Expr,
param_name: &str,
) -> bool {
@@ -1116,7 +1116,7 @@ fn is_obvious_param(param_name: &str) -> bool {
}
fn get_callable(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
expr: &ast::Expr,
) -> Option<(hir::Callable, ast::ArgList)> {
match expr {
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index 8a00d6f144..1a6beec188 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -50,7 +50,7 @@ pub struct Declaration {
//
// image::https://user-images.githubusercontent.com/48062697/113020670-b7c34f00-917a-11eb-8003-370ac5f2b3cb.gif[]
pub(crate) fn find_all_refs(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
position: FilePosition,
search_scope: Option<SearchScope>,
) -> Option<Vec<ReferenceSearchResult>> {
@@ -112,7 +112,7 @@ pub(crate) fn find_all_refs(
}
pub(crate) fn find_defs<'a>(
- sema: &'a Semantics<RootDatabase>,
+ sema: &'a Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
offset: TextSize,
) -> Option<impl Iterator<Item = Definition> + 'a> {
@@ -178,7 +178,7 @@ pub(crate) fn decl_mutability(def: &Definition, syntax: &SyntaxNode, range: Text
fn retain_adt_literal_usages(
usages: &mut UsageSearchResult,
def: Definition,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
) {
let refs = usages.references.values_mut();
match def {
@@ -242,7 +242,7 @@ fn name_for_constructor_search(syntax: &SyntaxNode, position: FilePosition) -> O
}
fn is_enum_lit_name_ref(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
enum_: hir::Enum,
name_ref: &ast::NameRef,
) -> bool {
diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs
index 23d6f8d8e4..9f64ddea20 100644
--- a/crates/ide/src/rename.rs
+++ b/crates/ide/src/rename.rs
@@ -120,7 +120,7 @@ pub(crate) fn will_rename_file(
}
fn find_definitions(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
position: FilePosition,
) -> RenameResult<impl Iterator<Item = (ast::NameLike, Definition)>> {
@@ -201,7 +201,7 @@ fn find_definitions(
}
}
-fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameResult<SourceChange> {
+fn rename_to_self(sema: &Semantics<'_, RootDatabase>, local: hir::Local) -> RenameResult<SourceChange> {
if never!(local.is_self(sema.db)) {
bail!("rename_to_self invoked on self");
}
@@ -269,7 +269,7 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
}
fn rename_self_to_param(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
local: hir::Local,
self_param: hir::SelfParam,
new_name: &str,
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 8c2219860b..b2869d44ac 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -35,7 +35,7 @@ pub enum TestId {
}
impl fmt::Display for TestId {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TestId::Name(name) => name.fmt(f),
TestId::Path(path) => path.fmt(f),
@@ -219,7 +219,7 @@ pub(crate) fn related_tests(
}
fn find_related_tests(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
position: FilePosition,
search_scope: Option<SearchScope>,
@@ -259,7 +259,7 @@ fn find_related_tests(
}
fn find_related_tests_in_module(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
fn_def: &ast::Fn,
parent_module: &hir::Module,
@@ -282,7 +282,7 @@ fn find_related_tests_in_module(
find_related_tests(sema, syntax, fn_pos, Some(mod_scope), tests)
}
-fn as_test_runnable(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<Runnable> {
+fn as_test_runnable(sema: &Semantics<'_, RootDatabase>, fn_def: &ast::Fn) -> Option<Runnable> {
if test_related_attribute(fn_def).is_some() {
let function = sema.to_def(fn_def)?;
runnable_fn(sema, function)
@@ -291,7 +291,7 @@ fn as_test_runnable(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<
}
}
-fn parent_test_module(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<hir::Module> {
+fn parent_test_module(sema: &Semantics<'_, RootDatabase>, fn_def: &ast::Fn) -> Option<hir::Module> {
fn_def.syntax().ancestors().find_map(|node| {
let module = ast::Module::cast(node)?;
let module = sema.to_def(&module)?;
@@ -304,7 +304,7 @@ fn parent_test_module(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Optio
})
}
-pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) -> Option<Runnable> {
+pub(crate) fn runnable_fn(sema: &Semantics<'_, RootDatabase>, def: hir::Function) -> Option<Runnable> {
let func = def.source(sema.db)?;
let name = def.name(sema.db).to_smol_str();
@@ -340,7 +340,7 @@ pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) ->
Some(Runnable { use_name_in_title: false, nav, kind, cfg })
}
-pub(crate) fn runnable_mod(sema: &Semantics<RootDatabase>, def: hir::Module) -> Option<Runnable> {
+pub(crate) fn runnable_mod(sema: &Semantics<'_, RootDatabase>, def: hir::Module) -> Option<Runnable> {
if !has_test_function_or_multiple_test_submodules(sema, &def) {
return None;
}
@@ -353,7 +353,7 @@ pub(crate) fn runnable_mod(sema: &Semantics<RootDatabase>, def: hir::Module) ->
Some(Runnable { use_name_in_title: false, nav, kind: RunnableKind::TestMod { path }, cfg })
}
-pub(crate) fn runnable_impl(sema: &Semantics<RootDatabase>, def: &hir::Impl) -> Option<Runnable> {
+pub(crate) fn runnable_impl(sema: &Semantics<'_, RootDatabase>, def: &hir::Impl) -> Option<Runnable> {
let attrs = def.attrs(sema.db);
if !has_runnable_doc_test(&attrs) {
return None;
@@ -375,7 +375,7 @@ pub(crate) fn runnable_impl(sema: &Semantics<RootDatabase>, def: &hir::Impl) ->
/// Creates a test mod runnable for outline modules at the top of their definition.
fn runnable_mod_outline_definition(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
def: hir::Module,
) -> Option<Runnable> {
if !has_test_function_or_multiple_test_submodules(sema, &def) {
@@ -509,7 +509,7 @@ fn has_runnable_doc_test(attrs: &hir::Attrs) -> bool {
// We could create runnables for modules with number_of_test_submodules > 0,
// but that bloats the runnables for no real benefit, since all tests can be run by the submodule already
fn has_test_function_or_multiple_test_submodules(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
module: &hir::Module,
) -> bool {
let mut number_of_test_submodules = 0;
diff --git a/crates/ide/src/signature_help.rs b/crates/ide/src/signature_help.rs
index 871c995122..ba287d13ae 100644
--- a/crates/ide/src/signature_help.rs
+++ b/crates/ide/src/signature_help.rs
@@ -94,7 +94,7 @@ pub(crate) fn signature_help(db: &RootDatabase, position: FilePosition) -> Optio
}
fn signature_help_for_call(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<SignatureHelp> {
// Find the calling expression and its NameRef
@@ -198,7 +198,7 @@ fn signature_help_for_call(
}
fn signature_help_for_generics(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<SignatureHelp> {
let parent = token.parent()?;
diff --git a/crates/ide/src/static_index.rs b/crates/ide/src/static_index.rs
index 95a9635a06..d74b640415 100644
--- a/crates/ide/src/static_index.rs
+++ b/crates/ide/src/static_index.rs
@@ -173,7 +173,7 @@ impl StaticIndex<'_> {
self.files.push(result);
}
- pub fn compute(analysis: &Analysis) -> StaticIndex {
+ pub fn compute(analysis: &Analysis) -> StaticIndex<'_> {
let db = &*analysis.db;
let work = all_modules(db).into_iter().filter(|module| {
let file_id = module.definition_source(db).file_id.original_file(db);
@@ -202,7 +202,7 @@ impl StaticIndex<'_> {
}
}
-fn get_definition(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Definition> {
+fn get_definition(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Definition> {
for token in sema.descend_into_macros(token) {
let def = IdentClass::classify_token(sema, &token).map(IdentClass::definitions);
if let Some(&[x]) = def.as_deref() {
diff --git a/crates/ide/src/status.rs b/crates/ide/src/status.rs
index ea2b7906e9..3191870eb5 100644
--- a/crates/ide/src/status.rs
+++ b/crates/ide/src/status.rs
@@ -75,7 +75,7 @@ struct FilesStats {
}
impl fmt::Display for FilesStats {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{} of files", self.size)
}
}
@@ -101,7 +101,7 @@ pub(crate) struct SyntaxTreeStats {
}
impl fmt::Display for SyntaxTreeStats {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{} trees, {} preserved", self.total, self.retained)
}
}
@@ -143,7 +143,7 @@ struct LibrarySymbolsStats {
}
impl fmt::Display for LibrarySymbolsStats {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{} of index symbols ({})", self.size, self.total)
}
}
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index b2f6d18553..9fb6a30263 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -196,7 +196,7 @@ pub(crate) fn highlight(
fn traverse(
hl: &mut Highlights,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
file_id: FileId,
root: &SyntaxNode,
krate: hir::Crate,
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index 788cbe9272..42adca4958 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -16,7 +16,7 @@ use crate::{
Highlight, HlMod, HlTag,
};
-pub(super) fn token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Highlight> {
+pub(super) fn token(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Highlight> {
if let Some(comment) = ast::Comment::cast(token.clone()) {
let h = HlTag::Comment;
return Some(match comment.kind().doc {
@@ -46,7 +46,7 @@ pub(super) fn token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Optio
}
pub(super) fn name_like(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
bindings_shadow_count: &mut FxHashMap<hir::Name, u32>,
syntactic_name_ref_highlighting: bool,
@@ -79,7 +79,7 @@ pub(super) fn name_like(
Some((highlight, binding_hash))
}
-fn punctuation(sema: &Semantics<RootDatabase>, token: SyntaxToken, kind: SyntaxKind) -> Highlight {
+fn punctuation(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken, kind: SyntaxKind) -> Highlight {
let parent = token.parent();
let parent_kind = parent.as_ref().map_or(EOF, SyntaxNode::kind);
match (kind, parent_kind) {
@@ -151,7 +151,7 @@ fn punctuation(sema: &Semantics<RootDatabase>, token: SyntaxToken, kind: SyntaxK
}
fn keyword(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
kind: SyntaxKind,
) -> Option<Highlight> {
@@ -190,7 +190,7 @@ fn keyword(
}
fn highlight_name_ref(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
bindings_shadow_count: &mut FxHashMap<hir::Name, u32>,
binding_hash: &mut Option<u64>,
@@ -274,7 +274,7 @@ fn highlight_name_ref(
}
fn highlight_name(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
bindings_shadow_count: &mut FxHashMap<hir::Name, u32>,
binding_hash: &mut Option<u64>,
krate: hir::Crate,
@@ -321,7 +321,7 @@ fn calc_binding_hash(name: &hir::Name, shadow_count: u32) -> u64 {
hash((name, shadow_count))
}
-fn highlight_def(sema: &Semantics<RootDatabase>, krate: hir::Crate, def: Definition) -> Highlight {
+fn highlight_def(sema: &Semantics<'_, RootDatabase>, krate: hir::Crate, def: Definition) -> Highlight {
let db = sema.db;
let mut h = match def {
Definition::Macro(m) => Highlight::new(HlTag::Symbol(m.kind(sema.db).into())),
@@ -486,7 +486,7 @@ fn highlight_def(sema: &Semantics<RootDatabase>, krate: hir::Crate, def: Definit
}
fn highlight_method_call_by_name_ref(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
name_ref: &ast::NameRef,
) -> Option<Highlight> {
@@ -495,7 +495,7 @@ fn highlight_method_call_by_name_ref(
}
fn highlight_method_call(
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
method_call: &ast::MethodCallExpr,
) -> Option<Highlight> {
@@ -584,7 +584,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
fn highlight_name_ref_by_syntax(
name: ast::NameRef,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
) -> Highlight {
let default = HlTag::UnresolvedReference;
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs
index 8ac3c2da50..94d573a30b 100644
--- a/crates/ide/src/syntax_highlighting/inject.rs
+++ b/crates/ide/src/syntax_highlighting/inject.rs
@@ -20,7 +20,7 @@ use crate::{
pub(super) fn ra_fixture(
hl: &mut Highlights,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
literal: &ast::String,
expanded: &ast::String,
) -> Option<()> {
@@ -84,7 +84,7 @@ const RUSTDOC_FENCES: [&str; 2] = ["```", "~~~"];
/// Injection of syntax highlighting of doctests.
pub(super) fn doc_comment(
hl: &mut Highlights,
- sema: &Semantics<RootDatabase>,
+ sema: &Semantics<'_, RootDatabase>,
InFile { file_id: src_file_id, value: node }: InFile<&SyntaxNode>,
) {
let (attributes, def) = match doc_attributes(sema, node) {
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index 3b857ad794..5020e9abaf 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -522,7 +522,7 @@ fn match_loop_inner<'t>(
fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
let mut src = TtIter::new(src);
- let mut stack: SmallVec<[TtIter; 1]> = SmallVec::new();
+ let mut stack: SmallVec<[TtIter<'_>; 1]> = SmallVec::new();
let mut res = Match::default();
let mut error_recover_item = None;
@@ -656,7 +656,7 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
}
}
-fn match_leaf(lhs: &tt::Leaf, src: &mut TtIter) -> Result<(), ExpandError> {
+fn match_leaf(lhs: &tt::Leaf, src: &mut TtIter<'_>) -> Result<(), ExpandError> {
let rhs = src
.expect_leaf()
.map_err(|()| ExpandError::binding_error(format!("expected leaf: `{lhs}`")))?;
@@ -677,7 +677,7 @@ fn match_leaf(lhs: &tt::Leaf, src: &mut TtIter) -> Result<(), ExpandError> {
}
}
-fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragment>> {
+fn match_meta_var(kind: &str, input: &mut TtIter<'_>) -> ExpandResult<Option<Fragment>> {
let fragment = match kind {
"path" => parser::PrefixEntryPoint::Path,
"ty" => parser::PrefixEntryPoint::Ty,
diff --git a/crates/mbe/src/expander/transcriber.rs b/crates/mbe/src/expander/transcriber.rs
index 93d29b6ffe..7bcc84740f 100644
--- a/crates/mbe/src/expander/transcriber.rs
+++ b/crates/mbe/src/expander/transcriber.rs
@@ -75,7 +75,7 @@ struct ExpandCtx<'a> {
}
fn expand_subtree(
- ctx: &mut ExpandCtx,
+ ctx: &mut ExpandCtx<'_>,
template: &MetaTemplate,
delimiter: Option<Delimiter>,
arena: &mut Vec<tt::TokenTree>,
@@ -127,7 +127,7 @@ fn expand_subtree(
ExpandResult { value: tt::Subtree { delimiter, token_trees: tts }, err }
}
-fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr, id: tt::TokenId) -> ExpandResult<Fragment> {
+fn expand_var(ctx: &mut ExpandCtx<'_>, v: &SmolStr, id: tt::TokenId) -> ExpandResult<Fragment> {
// We already handle $crate case in mbe parser
debug_assert!(v != "crate");
@@ -163,7 +163,7 @@ fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr, id: tt::TokenId) -> ExpandResult
}
fn expand_repeat(
- ctx: &mut ExpandCtx,
+ ctx: &mut ExpandCtx<'_>,
template: &MetaTemplate,
kind: RepeatKind,
separator: &Option<Separator>,
diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs
index 4f09049fdf..79da84f4a0 100644
--- a/crates/mbe/src/lib.rs
+++ b/crates/mbe/src/lib.rs
@@ -268,7 +268,7 @@ impl DeclarativeMacro {
}
impl Rule {
- fn parse(src: &mut TtIter, expect_arrow: bool) -> Result<Self, ParseError> {
+ fn parse(src: &mut TtIter<'_>, expect_arrow: bool) -> Result<Self, ParseError> {
let lhs = src.expect_subtree().map_err(|()| ParseError::expected("expected subtree"))?;
if expect_arrow {
src.expect_char('=').map_err(|()| ParseError::expected("expected `=`"))?;
diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs
index df3872b3e6..acb4be5846 100644
--- a/crates/mbe/src/parser.rs
+++ b/crates/mbe/src/parser.rs
@@ -194,7 +194,7 @@ fn is_boolean_literal(lit: &tt::Literal) -> bool {
matches!(lit.text.as_str(), "true" | "false")
}
-fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), ParseError> {
+fn parse_repeat(src: &mut TtIter<'_>) -> Result<(Option<Separator>, RepeatKind), ParseError> {
let mut separator = Separator::Puncts(SmallVec::new());
for tt in src {
let tt = match tt {
@@ -231,7 +231,7 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), Par
Err(ParseError::InvalidRepeat)
}
-fn parse_metavar_expr(src: &mut TtIter) -> Result<Op, ()> {
+fn parse_metavar_expr(src: &mut TtIter<'_>) -> Result<Op, ()> {
let func = src.expect_ident()?;
let args = src.expect_subtree()?;
diff --git a/crates/mbe/src/to_parser_input.rs b/crates/mbe/src/to_parser_input.rs
index 6faa147218..783c3ca4a8 100644
--- a/crates/mbe/src/to_parser_input.rs
+++ b/crates/mbe/src/to_parser_input.rs
@@ -4,7 +4,7 @@
use syntax::{SyntaxKind, SyntaxKind::*, T};
use tt::buffer::TokenBuffer;
-pub(crate) fn to_parser_input(buffer: &TokenBuffer) -> parser::Input {
+pub(crate) fn to_parser_input(buffer: &TokenBuffer<'_>) -> parser::Input {
let mut res = parser::Input::default();
let mut current = buffer.begin();
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index 4efbf9a606..b746832961 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -50,36 +50,36 @@ pub(crate) mod entry {
pub(crate) mod prefix {
use super::*;
- pub(crate) fn vis(p: &mut Parser) {
+ pub(crate) fn vis(p: &mut Parser<'_>) {
let _ = opt_visibility(p, false);
}
- pub(crate) fn block(p: &mut Parser) {
+ pub(crate) fn block(p: &mut Parser<'_>) {
expressions::block_expr(p);
}
- pub(crate) fn stmt(p: &mut Parser) {
+ pub(crate) fn stmt(p: &mut Parser<'_>) {
expressions::stmt(p, expressions::Semicolon::Forbidden);
}
- pub(crate) fn pat(p: &mut Parser) {
+ pub(crate) fn pat(p: &mut Parser<'_>) {
patterns::pattern_single(p);
}
- pub(crate) fn ty(p: &mut Parser) {
+ pub(crate) fn ty(p: &mut Parser<'_>) {
types::type_(p);
}
- pub(crate) fn expr(p: &mut Parser) {
+ pub(crate) fn expr(p: &mut Parser<'_>) {
let _ = expressions::expr(p);
}
- pub(crate) fn path(p: &mut Parser) {
+ pub(crate) fn path(p: &mut Parser<'_>) {
let _ = paths::type_path(p);
}
- pub(crate) fn item(p: &mut Parser) {
+ pub(crate) fn item(p: &mut Parser<'_>) {
items::item_or_macro(p, true);
}
// Parse a meta item , which excluded [], e.g : #[ MetaItem ]
- pub(crate) fn meta_item(p: &mut Parser) {
+ pub(crate) fn meta_item(p: &mut Parser<'_>) {
attributes::meta(p);
}
}
@@ -87,14 +87,14 @@ pub(crate) mod entry {
pub(crate) mod top {
use super::*;
- pub(crate) fn source_file(p: &mut Parser) {
+ pub(crate) fn source_file(p: &mut Parser<'_>) {
let m = p.start();
p.eat(SHEBANG);
items::mod_contents(p, false);
m.complete(p, SOURCE_FILE);
}
- pub(crate) fn macro_stmts(p: &mut Parser) {
+ pub(crate) fn macro_stmts(p: &mut Parser<'_>) {
let m = p.start();
while !p.at(EOF) {
@@ -104,13 +104,13 @@ pub(crate) mod entry {
m.complete(p, MACRO_STMTS);
}
- pub(crate) fn macro_items(p: &mut Parser) {
+ pub(crate) fn macro_items(p: &mut Parser<'_>) {
let m = p.start();
items::mod_contents(p, false);
m.complete(p, MACRO_ITEMS);
}
- pub(crate) fn pattern(p: &mut Parser) {
+ pub(crate) fn pattern(p: &mut Parser<'_>) {
let m = p.start();
patterns::pattern_top(p);
if p.at(EOF) {
@@ -123,7 +123,7 @@ pub(crate) mod entry {
m.complete(p, ERROR);
}
- pub(crate) fn type_(p: &mut Parser) {
+ pub(crate) fn type_(p: &mut Parser<'_>) {
let m = p.start();
types::type_(p);
if p.at(EOF) {
@@ -136,7 +136,7 @@ pub(crate) mod entry {
m.complete(p, ERROR);
}
- pub(crate) fn expr(p: &mut Parser) {
+ pub(crate) fn expr(p: &mut Parser<'_>) {
let m = p.start();
expressions::expr(p);
if p.at(EOF) {
@@ -149,7 +149,7 @@ pub(crate) mod entry {
m.complete(p, ERROR);
}
- pub(crate) fn meta_item(p: &mut Parser) {
+ pub(crate) fn meta_item(p: &mut Parser<'_>) {
let m = p.start();
attributes::meta(p);
if p.at(EOF) {
@@ -168,7 +168,7 @@ pub(crate) fn reparser(
node: SyntaxKind,
first_child: Option<SyntaxKind>,
parent: Option<SyntaxKind>,
-) -> Option<fn(&mut Parser)> {
+) -> Option<fn(&mut Parser<'_>)> {
let res = match node {
BLOCK_EXPR => expressions::block_expr,
RECORD_FIELD_LIST => items::record_field_list,
@@ -200,7 +200,7 @@ impl BlockLike {
}
}
-fn opt_visibility(p: &mut Parser, in_tuple_field: bool) -> bool {
+fn opt_visibility(p: &mut Parser<'_>, in_tuple_field: bool) -> bool {
match p.current() {
T![pub] => {
let m = p.start();
@@ -262,7 +262,7 @@ fn opt_visibility(p: &mut Parser, in_tuple_field: bool) -> bool {
}
}
-fn opt_rename(p: &mut Parser) {
+fn opt_rename(p: &mut Parser<'_>) {
if p.at(T![as]) {
let m = p.start();
p.bump(T![as]);
@@ -273,7 +273,7 @@ fn opt_rename(p: &mut Parser) {
}
}
-fn abi(p: &mut Parser) {
+fn abi(p: &mut Parser<'_>) {
assert!(p.at(T![extern]));
let abi = p.start();
p.bump(T![extern]);
@@ -281,7 +281,7 @@ fn abi(p: &mut Parser) {
abi.complete(p, ABI);
}
-fn opt_ret_type(p: &mut Parser) -> bool {
+fn opt_ret_type(p: &mut Parser<'_>) -> bool {
if p.at(T![->]) {
let m = p.start();
p.bump(T![->]);
@@ -293,7 +293,7 @@ fn opt_ret_type(p: &mut Parser) -> bool {
}
}
-fn name_r(p: &mut Parser, recovery: TokenSet) {
+fn name_r(p: &mut Parser<'_>, recovery: TokenSet) {
if p.at(IDENT) {
let m = p.start();
p.bump(IDENT);
@@ -303,11 +303,11 @@ fn name_r(p: &mut Parser, recovery: TokenSet) {
}
}
-fn name(p: &mut Parser) {
+fn name(p: &mut Parser<'_>) {
name_r(p, TokenSet::EMPTY);
}
-fn name_ref(p: &mut Parser) {
+fn name_ref(p: &mut Parser<'_>) {
if p.at(IDENT) {
let m = p.start();
p.bump(IDENT);
@@ -317,21 +317,21 @@ fn name_ref(p: &mut Parser) {
}
}
-fn name_ref_or_index(p: &mut Parser) {
+fn name_ref_or_index(p: &mut Parser<'_>) {
assert!(p.at(IDENT) || p.at(INT_NUMBER));
let m = p.start();
p.bump_any();
m.complete(p, NAME_REF);
}
-fn lifetime(p: &mut Parser) {
+fn lifetime(p: &mut Parser<'_>) {
assert!(p.at(LIFETIME_IDENT));
let m = p.start();
p.bump(LIFETIME_IDENT);
m.complete(p, LIFETIME);
}
-fn error_block(p: &mut Parser, message: &str) {
+fn error_block(p: &mut Parser<'_>, message: &str) {
assert!(p.at(T!['{']));
let m = p.start();
p.error(message);
diff --git a/crates/parser/src/grammar/attributes.rs b/crates/parser/src/grammar/attributes.rs
index 1efffca515..0cf6a16f86 100644
--- a/crates/parser/src/grammar/attributes.rs
+++ b/crates/parser/src/grammar/attributes.rs
@@ -1,18 +1,18 @@
use super::*;
-pub(super) fn inner_attrs(p: &mut Parser) {
+pub(super) fn inner_attrs(p: &mut Parser<'_>) {
while p.at(T![#]) && p.nth(1) == T![!] {
attr(p, true);
}
}
-pub(super) fn outer_attrs(p: &mut Parser) {
+pub(super) fn outer_attrs(p: &mut Parser<'_>) {
while p.at(T![#]) {
attr(p, false);
}
}
-fn attr(p: &mut Parser, inner: bool) {
+fn attr(p: &mut Parser<'_>, inner: bool) {
assert!(p.at(T![#]));
let attr = p.start();
@@ -34,7 +34,7 @@ fn attr(p: &mut Parser, inner: bool) {
attr.complete(p, ATTR);
}
-pub(super) fn meta(p: &mut Parser) {
+pub(super) fn meta(p: &mut Parser<'_>) {
let meta = p.start();
paths::use_path(p);
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs
index b063c73a9d..8887f3330b 100644
--- a/crates/parser/src/grammar/expressions.rs
+++ b/crates/parser/src/grammar/expressions.rs
@@ -14,17 +14,17 @@ pub(super) enum Semicolon {
const EXPR_FIRST: TokenSet = LHS_FIRST;
-pub(super) fn expr(p: &mut Parser) -> bool {
+pub(super) fn expr(p: &mut Parser<'_>) -> bool {
let r = Restrictions { forbid_structs: false, prefer_stmt: false };
expr_bp(p, None, r, 1).is_some()
}
-pub(super) fn expr_stmt(p: &mut Parser, m: Option<Marker>) -> Option<(CompletedMarker, BlockLike)> {
+pub(super) fn expr_stmt(p: &mut Parser<'_>, m: Option<Marker>) -> Option<(CompletedMarker, BlockLike)> {
let r = Restrictions { forbid_structs: false, prefer_stmt: true };
expr_bp(p, m, r, 1)
}
-fn expr_no_struct(p: &mut Parser) {
+fn expr_no_struct(p: &mut Parser<'_>) {
let r = Restrictions { forbid_structs: true, prefer_stmt: false };
expr_bp(p, None, r, 1);
}
@@ -33,12 +33,12 @@ fn expr_no_struct(p: &mut Parser) {
/// It needs to be parsed with lower precedence than `&&`, so that
/// `if let true = true && false` is parsed as `if (let true = true) && (true)`
/// and not `if let true = (true && true)`.
-fn expr_let(p: &mut Parser) {
+fn expr_let(p: &mut Parser<'_>) {
let r = Restrictions { forbid_structs: true, prefer_stmt: false };
expr_bp(p, None, r, 5);
}
-pub(super) fn stmt(p: &mut Parser, semicolon: Semicolon) {
+pub(super) fn stmt(p: &mut Parser<'_>, semicolon: Semicolon) {
if p.eat(T![;]) {
return;
}
@@ -101,7 +101,7 @@ pub(super) fn stmt(p: &mut Parser, semicolon: Semicolon) {
// test let_stmt
// fn f() { let x: i32 = 92; }
- fn let_stmt(p: &mut Parser, m: Marker, with_semi: Semicolon) {
+ fn let_stmt(p: &mut Parser<'_>, m: Marker, with_semi: Semicolon) {
p.bump(T![let]);
patterns::pattern(p);
if p.at(T![:]) {
@@ -138,7 +138,7 @@ pub(super) fn stmt(p: &mut Parser, semicolon: Semicolon) {
}
}
-pub(super) fn expr_block_contents(p: &mut Parser) {
+pub(super) fn expr_block_contents(p: &mut Parser<'_>) {
attributes::inner_attrs(p);
while !p.at(EOF) && !p.at(T!['}']) {
@@ -170,7 +170,7 @@ struct Restrictions {
///
/// See <https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html>
#[rustfmt::skip]
-fn current_op(p: &Parser) -> (u8, SyntaxKind) {
+fn current_op(p: &Parser<'_>) -> (u8, SyntaxKind) {
const NOT_AN_OP: (u8, SyntaxKind) = (0, T![@]);
match p.current() {
T![|] if p.at(T![||]) => (3, T![||]),
@@ -214,7 +214,7 @@ fn current_op(p: &Parser) -> (u8, SyntaxKind) {
// Parses expression with binding power of at least bp.
fn expr_bp(
- p: &mut Parser,
+ p: &mut Parser<'_>,
m: Option<Marker>,
mut r: Restrictions,
bp: u8,
@@ -287,7 +287,7 @@ fn expr_bp(
const LHS_FIRST: TokenSet =
atom::ATOM_EXPR_FIRST.union(TokenSet::new(&[T![&], T![*], T![!], T![.], T![-]]));
-fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
+fn lhs(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
let m;
let kind = match p.current() {
// test ref_expr
@@ -356,7 +356,7 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)>
}
fn postfix_expr(
- p: &mut Parser,
+ p: &mut Parser<'_>,
mut lhs: CompletedMarker,
// Calls are disallowed if the type is a block and we prefer statements because the call cannot be disambiguated from a tuple
// E.g. `while true {break}();` is parsed as
@@ -392,7 +392,7 @@ fn postfix_expr(
return (lhs, block_like);
fn postfix_dot_expr(
- p: &mut Parser,
+ p: &mut Parser<'_>,
lhs: CompletedMarker,
) -> Result<CompletedMarker, CompletedMarker> {
assert!(p.at(T![.]));
@@ -428,7 +428,7 @@ fn postfix_expr(
// let _ = f(<Foo>::func());
// f(<Foo as Trait>::func());
// }
-fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
+fn call_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T!['(']));
let m = lhs.precede(p);
arg_list(p);
@@ -439,7 +439,7 @@ fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
// fn foo() {
// x[1][2];
// }
-fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
+fn index_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T!['[']));
let m = lhs.precede(p);
p.bump(T!['[']);
@@ -453,7 +453,7 @@ fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
// x.foo();
// y.bar::<T>(1, 2,);
// }
-fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
+fn method_call_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![.]) && p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth_at(2, T![::])));
let m = lhs.precede(p);
p.bump_any();
@@ -471,7 +471,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
// x.0.bar;
// x.0();
// }
-fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
+fn field_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![.]));
let m = lhs.precede(p);
p.bump(T![.]);
@@ -490,7 +490,7 @@ fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
// fn foo() {
// x?;
// }
-fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
+fn try_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![?]));
let m = lhs.precede(p);
p.bump(T![?]);
@@ -504,7 +504,7 @@ fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
// 79 as i16 - 1;
// 0x36 as u8 <= 0x37;
// }
-fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
+fn cast_expr(p: &mut Parser<'_>, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![as]));
let m = lhs.precede(p);
p.bump(T![as]);
@@ -514,7 +514,7 @@ fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
m.complete(p, CAST_EXPR)
}
-fn arg_list(p: &mut Parser) {
+fn arg_list(p: &mut Parser<'_>) {
assert!(p.at(T!['(']));
let m = p.start();
p.bump(T!['(']);
@@ -541,7 +541,7 @@ fn arg_list(p: &mut Parser) {
// let _ = ::a::<b>;
// let _ = format!();
// }
-fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
+fn path_expr(p: &mut Parser<'_>, r: Restrictions) -> (CompletedMarker, BlockLike) {
assert!(paths::is_path_start(p));
let m = p.start();
paths::expr_path(p);
@@ -565,7 +565,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
// S { x, y: 32, ..Default::default() };
// TupleStruct { 0: 1 };
// }
-pub(crate) fn record_expr_field_list(p: &mut Parser) {
+pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs
index 10e5d897e0..30aadb1f9d 100644
--- a/crates/parser/src/grammar/expressions/atom.rs
+++ b/crates/parser/src/grammar/expressions/atom.rs
@@ -24,7 +24,7 @@ pub(crate) const LITERAL_FIRST: TokenSet = TokenSet::new(&[
BYTE_STRING,
]);
-pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
+pub(crate) fn literal(p: &mut Parser<'_>) -> Option<CompletedMarker> {
if !p.at_ts(LITERAL_FIRST) {
return None;
}
@@ -60,7 +60,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
const EXPR_RECOVERY_SET: TokenSet = TokenSet::new(&[T![let]]);
-pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
+pub(super) fn atom_expr(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
if let Some(m) = literal(p) {
return Some((m, BlockLike::NotBlock));
}
@@ -169,7 +169,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
// (1);
// (1,);
// }
-fn tuple_expr(p: &mut Parser) -> CompletedMarker {
+fn tuple_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T!['(']));
let m = p.start();
p.expect(T!['(']);
@@ -201,7 +201,7 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker {
// [1, 2,];
// [1; 2];
// }
-fn array_expr(p: &mut Parser) -> CompletedMarker {
+fn array_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T!['[']));
let m = p.start();
@@ -248,7 +248,7 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
// for<'a> || {};
// for<'a> move || {};
// }
-fn closure_expr(p: &mut Parser) -> CompletedMarker {
+fn closure_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(match p.current() {
T![static] | T![async] | T![move] | T![|] => true,
T![for] => p.nth(1) == T![<],
@@ -290,7 +290,7 @@ fn closure_expr(p: &mut Parser) -> CompletedMarker {
// if S {};
// if { true } { } else { };
// }
-fn if_expr(p: &mut Parser) -> CompletedMarker {
+fn if_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![if]));
let m = p.start();
p.bump(T![if]);
@@ -313,7 +313,7 @@ fn if_expr(p: &mut Parser) -> CompletedMarker {
// 'b: while true {}
// 'c: for x in () {}
// }
-fn label(p: &mut Parser) {
+fn label(p: &mut Parser<'_>) {
assert!(p.at(LIFETIME_IDENT) && p.nth(1) == T![:]);
let m = p.start();
lifetime(p);
@@ -325,7 +325,7 @@ fn label(p: &mut Parser) {
// fn foo() {
// loop {};
// }
-fn loop_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
+fn loop_expr(p: &mut Parser<'_>, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![loop]));
let m = m.unwrap_or_else(|| p.start());
p.bump(T![loop]);
@@ -339,7 +339,7 @@ fn loop_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
// while let Some(x) = it.next() {};
// while { true } {};
// }
-fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
+fn while_expr(p: &mut Parser<'_>, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![while]));
let m = m.unwrap_or_else(|| p.start());
p.bump(T![while]);
@@ -352,7 +352,7 @@ fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
// fn foo() {
// for x in [] {};
// }
-fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
+fn for_expr(p: &mut Parser<'_>, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![for]));
let m = m.unwrap_or_else(|| p.start());
p.bump(T![for]);
@@ -368,7 +368,7 @@ fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
// if let Some(_) = None && true {}
// while 1 == 5 && (let None = None) {}
// }
-fn let_expr(p: &mut Parser) -> CompletedMarker {
+fn let_expr(p: &mut Parser<'_>) -> CompletedMarker {
let m = p.start();
p.bump(T![let]);
patterns::pattern_top(p);
@@ -384,7 +384,7 @@ fn let_expr(p: &mut Parser) -> CompletedMarker {
// match { } { _ => () };
// match { S {} } {};
// }
-fn match_expr(p: &mut Parser) -> CompletedMarker {
+fn match_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![match]));
let m = p.start();
p.bump(T![match]);
@@ -397,7 +397,7 @@ fn match_expr(p: &mut Parser) -> CompletedMarker {
m.complete(p, MATCH_EXPR)
}
-pub(crate) fn match_arm_list(p: &mut Parser) {
+pub(crate) fn match_arm_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.eat(T!['{']);
@@ -434,7 +434,7 @@ pub(crate) fn match_arm_list(p: &mut Parser) {
// | X => (),
// };
// }
-fn match_arm(p: &mut Parser) {
+fn match_arm(p: &mut Parser<'_>) {
let m = p.start();
// test match_arms_outer_attributes
// fn foo() {
@@ -482,7 +482,7 @@ fn match_arm(p: &mut Parser) {
// _ if let foo = bar => (),
// }
// }
-fn match_guard(p: &mut Parser) -> CompletedMarker {
+fn match_guard(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![if]));
let m = p.start();
p.bump(T![if]);
@@ -495,7 +495,7 @@ fn match_guard(p: &mut Parser) -> CompletedMarker {
// fn b() { let _ = 1; }
// fn c() { 1; 2; }
// fn d() { 1; 2 }
-pub(crate) fn block_expr(p: &mut Parser) {
+pub(crate) fn block_expr(p: &mut Parser<'_>) {
if !p.at(T!['{']) {
p.error("expected a block");
return;
@@ -505,7 +505,7 @@ pub(crate) fn block_expr(p: &mut Parser) {
m.complete(p, BLOCK_EXPR);
}
-fn stmt_list(p: &mut Parser) -> CompletedMarker {
+fn stmt_list(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
@@ -519,7 +519,7 @@ fn stmt_list(p: &mut Parser) -> CompletedMarker {
// return;
// return 92;
// }
-fn return_expr(p: &mut Parser) -> CompletedMarker {
+fn return_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![return]));
let m = p.start();
p.bump(T![return]);
@@ -533,7 +533,7 @@ fn return_expr(p: &mut Parser) -> CompletedMarker {
// yield;
// yield 1;
// }
-fn yield_expr(p: &mut Parser) -> CompletedMarker {
+fn yield_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![yield]));
let m = p.start();
p.bump(T![yield]);
@@ -550,7 +550,7 @@ fn yield_expr(p: &mut Parser) -> CompletedMarker {
// continue 'l;
// }
// }
-fn continue_expr(p: &mut Parser) -> CompletedMarker {
+fn continue_expr(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![continue]));
let m = p.start();
p.bump(T![continue]);
@@ -569,7 +569,7 @@ fn continue_expr(p: &mut Parser) -> CompletedMarker {
// break 'l 92;
// }
// }
-fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
+fn break_expr(p: &mut Parser<'_>, r: Restrictions) -> CompletedMarker {
assert!(p.at(T![break]));
let m = p.start();
p.bump(T![break]);
@@ -593,7 +593,7 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
// fn foo() {
// let _ = try {};
// }
-fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
+fn try_block_expr(p: &mut Parser<'_>, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![try]));
let m = m.unwrap_or_else(|| p.start());
// Special-case `try!` as macro.
@@ -629,7 +629,7 @@ fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
// let y = (box 1i32, box 2i32);
// let z = Foo(box 1i32, box 2i32);
// }
-fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
+fn box_expr(p: &mut Parser<'_>, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![box]));
let m = m.unwrap_or_else(|| p.start());
p.bump(T![box]);
diff --git a/crates/parser/src/grammar/generic_args.rs b/crates/parser/src/grammar/generic_args.rs
index 862d3b259f..c438943a00 100644
--- a/crates/parser/src/grammar/generic_args.rs
+++ b/crates/parser/src/grammar/generic_args.rs
@@ -1,6 +1,6 @@
use super::*;
-pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
+pub(super) fn opt_generic_arg_list(p: &mut Parser<'_>, colon_colon_required: bool) {
let m;
if p.at(T![::]) && p.nth(2) == T![<] {
m = p.start();
@@ -25,7 +25,7 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
// test generic_arg
// type T = S<i32>;
-fn generic_arg(p: &mut Parser) {
+fn generic_arg(p: &mut Parser<'_>) {
match p.current() {
LIFETIME_IDENT => lifetime_arg(p),
T!['{'] | T![true] | T![false] | T![-] => const_arg(p),
@@ -74,13 +74,13 @@ fn generic_arg(p: &mut Parser) {
// test lifetime_arg
// type T = S<'static>;
-fn lifetime_arg(p: &mut Parser) {
+fn lifetime_arg(p: &mut Parser<'_>) {
let m = p.start();
lifetime(p);
m.complete(p, LIFETIME_ARG);
}
-pub(super) fn const_arg_expr(p: &mut Parser) {
+pub(super) fn const_arg_expr(p: &mut Parser<'_>) {
// The tests in here are really for `const_arg`, which wraps the content
// CONST_ARG.
match p.current() {
@@ -118,13 +118,13 @@ pub(super) fn const_arg_expr(p: &mut Parser) {
// test const_arg
// type T = S<92>;
-pub(super) fn const_arg(p: &mut Parser) {
+pub(super) fn const_arg(p: &mut Parser<'_>) {
let m = p.start();
const_arg_expr(p);
m.complete(p, CONST_ARG);
}
-fn type_arg(p: &mut Parser) {
+fn type_arg(p: &mut Parser<'_>) {
let m = p.start();
types::type_(p);
m.complete(p, TYPE_ARG);
diff --git a/crates/parser/src/grammar/generic_params.rs b/crates/parser/src/grammar/generic_params.rs
index 78a75fad1c..6db28ef132 100644
--- a/crates/parser/src/grammar/generic_params.rs
+++ b/crates/parser/src/grammar/generic_params.rs
@@ -1,6 +1,6 @@
use super::*;
-pub(super) fn opt_generic_param_list(p: &mut Parser) {
+pub(super) fn opt_generic_param_list(p: &mut Parser<'_>) {
if p.at(T![<]) {
generic_param_list(p);
}
@@ -8,7 +8,7 @@ pub(super) fn opt_generic_param_list(p: &mut Parser) {
// test generic_param_list
// fn f<T: Clone>() {}
-fn generic_param_list(p: &mut Parser) {
+fn generic_param_list(p: &mut Parser<'_>) {
assert!(p.at(T![<]));
let m = p.start();
p.bump(T![<]);
@@ -23,7 +23,7 @@ fn generic_param_list(p: &mut Parser) {
m.complete(p, GENERIC_PARAM_LIST);
}
-fn generic_param(p: &mut Parser) {
+fn generic_param(p: &mut Parser<'_>) {
let m = p.start();
// test generic_param_attribute
// fn foo<#[lt_attr] 'a, #[t_attr] T>() {}
@@ -41,7 +41,7 @@ fn generic_param(p: &mut Parser) {
// test lifetime_param
// fn f<'a: 'b>() {}
-fn lifetime_param(p: &mut Parser, m: Marker) {
+fn lifetime_param(p: &mut Parser<'_>, m: Marker) {
assert!(p.at(LIFETIME_IDENT));
lifetime(p);
if p.at(T![:]) {
@@ -52,7 +52,7 @@ fn lifetime_param(p: &mut Parser, m: Marker) {
// test type_param
// fn f<T: Clone>() {}
-fn type_param(p: &mut Parser, m: Marker) {
+fn type_param(p: &mut Parser<'_>, m: Marker) {
assert!(p.at(IDENT));
name(p);
if p.at(T![:]) {
@@ -69,7 +69,7 @@ fn type_param(p: &mut Parser, m: Marker) {
// test const_param
// struct S<const N: u32>;
-fn const_param(p: &mut Parser, m: Marker) {
+fn const_param(p: &mut Parser<'_>, m: Marker) {
p.bump(T![const]);
name(p);
if p.at(T![:]) {
@@ -94,7 +94,7 @@ fn const_param(p: &mut Parser, m: Marker) {
m.complete(p, CONST_PARAM);
}
-fn lifetime_bounds(p: &mut Parser) {
+fn lifetime_bounds(p: &mut Parser<'_>) {
assert!(p.at(T![:]));
p.bump(T![:]);
while p.at(LIFETIME_IDENT) {
@@ -107,18 +107,18 @@ fn lifetime_bounds(p: &mut Parser) {
// test type_param_bounds
// struct S<T: 'a + ?Sized + (Copy) + ~const Drop>;
-pub(super) fn bounds(p: &mut Parser) {
+pub(super) fn bounds(p: &mut Parser<'_>) {
assert!(p.at(T![:]));
p.bump(T![:]);
bounds_without_colon(p);
}
-pub(super) fn bounds_without_colon(p: &mut Parser) {
+pub(super) fn bounds_without_colon(p: &mut Parser<'_>) {
let m = p.start();
bounds_without_colon_m(p, m);
}
-pub(super) fn bounds_without_colon_m(p: &mut Parser, marker: Marker) -> CompletedMarker {
+pub(super) fn bounds_without_colon_m(p: &mut Parser<'_>, marker: Marker) -> CompletedMarker {
while type_bound(p) {
if !p.eat(T![+]) {
break;
@@ -127,7 +127,7 @@ pub(super) fn bounds_without_colon_m(p: &mut Parser, marker: Marker) -> Complete
marker.complete(p, TYPE_BOUND_LIST)
}
-fn type_bound(p: &mut Parser) -> bool {
+fn type_bound(p: &mut Parser<'_>) -> bool {
let m = p.start();
let has_paren = p.eat(T!['(']);
match p.current() {
@@ -172,7 +172,7 @@ fn type_bound(p: &mut Parser) -> bool {
// Iterator::Item: 'a,
// <T as Iterator>::Item: 'a
// {}
-pub(super) fn opt_where_clause(p: &mut Parser) {
+pub(super) fn opt_where_clause(p: &mut Parser<'_>) {
if !p.at(T![where]) {
return;
}
@@ -196,7 +196,7 @@ pub(super) fn opt_where_clause(p: &mut Parser) {
m.complete(p, WHERE_CLAUSE);
- fn is_where_predicate(p: &mut Parser) -> bool {
+ fn is_where_predicate(p: &mut Parser<'_>) -> bool {
match p.current() {
LIFETIME_IDENT => true,
T![impl] => false,
@@ -205,7 +205,7 @@ pub(super) fn opt_where_clause(p: &mut Parser) {
}
}
-fn where_predicate(p: &mut Parser) {
+fn where_predicate(p: &mut Parser<'_>) {
let m = p.start();
match p.current() {
LIFETIME_IDENT => {
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index 7bfd9ef8c8..5e0951bf8b 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -17,7 +17,7 @@ use super::*;
// foo::bar!();
// super::baz! {}
// struct S;
-pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
+pub(super) fn mod_contents(p: &mut Parser<'_>, stop_on_r_curly: bool) {
attributes::inner_attrs(p);
while !p.at(EOF) && !(p.at(T!['}']) && stop_on_r_curly) {
item_or_macro(p, stop_on_r_curly);
@@ -41,7 +41,7 @@ pub(super) const ITEM_RECOVERY_SET: TokenSet = TokenSet::new(&[
T![;],
]);
-pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
+pub(super) fn item_or_macro(p: &mut Parser<'_>, stop_on_r_curly: bool) {
let m = p.start();
attributes::outer_attrs(p);
@@ -84,7 +84,7 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
}
/// Try to parse an item, completing `m` in case of success.
-pub(super) fn opt_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
+pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
// test_err pub_expr
// fn foo() { pub 92; }
let has_visibility = opt_visibility(p, false);
@@ -214,7 +214,7 @@ pub(super) fn opt_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
Ok(())
}
-fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
+fn opt_item_without_modifiers(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
let la = p.nth(1);
match p.current() {
T![extern] if la == T![crate] => extern_crate(p, m),
@@ -239,7 +239,7 @@ fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
// test extern_crate
// extern crate foo;
-fn extern_crate(p: &mut Parser, m: Marker) {
+fn extern_crate(p: &mut Parser<'_>, m: Marker) {
p.bump(T![extern]);
p.bump(T![crate]);
@@ -262,7 +262,7 @@ fn extern_crate(p: &mut Parser, m: Marker) {
// test mod_item
// mod a;
-pub(crate) fn mod_item(p: &mut Parser, m: Marker) {
+pub(crate) fn mod_item(p: &mut Parser<'_>, m: Marker) {
p.bump(T![mod]);
name(p);
if p.at(T!['{']) {
@@ -277,7 +277,7 @@ pub(crate) fn mod_item(p: &mut Parser, m: Marker) {
// test type_alias
// type Foo = Bar;
-fn type_alias(p: &mut Parser, m: Marker) {
+fn type_alias(p: &mut Parser<'_>, m: Marker) {
p.bump(T![type]);
name(p);
@@ -305,7 +305,7 @@ fn type_alias(p: &mut Parser, m: Marker) {
m.complete(p, TYPE_ALIAS);
}
-pub(crate) fn item_list(p: &mut Parser) {
+pub(crate) fn item_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
@@ -314,7 +314,7 @@ pub(crate) fn item_list(p: &mut Parser) {
m.complete(p, ITEM_LIST);
}
-pub(crate) fn extern_item_list(p: &mut Parser) {
+pub(crate) fn extern_item_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
@@ -323,7 +323,7 @@ pub(crate) fn extern_item_list(p: &mut Parser) {
m.complete(p, EXTERN_ITEM_LIST);
}
-fn macro_rules(p: &mut Parser, m: Marker) {
+fn macro_rules(p: &mut Parser<'_>, m: Marker) {
assert!(p.at_contextual_kw(T![macro_rules]));
p.bump_remap(T![macro_rules]);
p.expect(T![!]);
@@ -358,7 +358,7 @@ fn macro_rules(p: &mut Parser, m: Marker) {
// test macro_def
// macro m($i:ident) {}
-fn macro_def(p: &mut Parser, m: Marker) {
+fn macro_def(p: &mut Parser<'_>, m: Marker) {
p.expect(T![macro]);
name_r(p, ITEM_RECOVERY_SET);
if p.at(T!['{']) {
@@ -382,7 +382,7 @@ fn macro_def(p: &mut Parser, m: Marker) {
// test fn
// fn foo() {}
-fn fn_(p: &mut Parser, m: Marker) {
+fn fn_(p: &mut Parser<'_>, m: Marker) {
p.bump(T![fn]);
name_r(p, ITEM_RECOVERY_SET);
@@ -414,13 +414,13 @@ fn fn_(p: &mut Parser, m: Marker) {
m.complete(p, FN);
}
-fn macro_call(p: &mut Parser) -> BlockLike {
+fn macro_call(p: &mut Parser<'_>) -> BlockLike {
assert!(paths::is_use_path_start(p));
paths::use_path(p);
macro_call_after_excl(p)
}
-pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
+pub(super) fn macro_call_after_excl(p: &mut Parser<'_>) -> BlockLike {
p.expect(T![!]);
match p.current() {
@@ -439,7 +439,7 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
}
}
-pub(crate) fn token_tree(p: &mut Parser) {
+pub(crate) fn token_tree(p: &mut Parser<'_>) {
let closing_paren_kind = match p.current() {
T!['{'] => T!['}'],
T!['('] => T![')'],
diff --git a/crates/parser/src/grammar/items/adt.rs b/crates/parser/src/grammar/items/adt.rs
index 83b7ff0578..e7d30516b9 100644
--- a/crates/parser/src/grammar/items/adt.rs
+++ b/crates/parser/src/grammar/items/adt.rs
@@ -2,20 +2,20 @@ use super::*;
// test struct_item
// struct S {}
-pub(super) fn strukt(p: &mut Parser, m: Marker) {
+pub(super) fn strukt(p: &mut Parser<'_>, m: Marker) {
p.bump(T![struct]);
struct_or_union(p, m, true);
}
// test union_item
// struct U { i: i32, f: f32 }
-pub(super) fn union(p: &mut Parser, m: Marker) {
+pub(super) fn union(p: &mut Parser<'_>, m: Marker) {
assert!(p.at_contextual_kw(T![union]));
p.bump_remap(T![union]);
struct_or_union(p, m, false);
}
-fn struct_or_union(p: &mut Parser, m: Marker, is_struct: bool) {
+fn struct_or_union(p: &mut Parser<'_>, m: Marker, is_struct: bool) {
name_r(p, ITEM_RECOVERY_SET);
generic_params::opt_generic_param_list(p);
match p.current() {
@@ -50,7 +50,7 @@ fn struct_or_union(p: &mut Parser, m: Marker, is_struct: bool) {
m.complete(p, if is_struct { STRUCT } else { UNION });
}
-pub(super) fn enum_(p: &mut Parser, m: Marker) {
+pub(super) fn enum_(p: &mut Parser<'_>, m: Marker) {
p.bump(T![enum]);
name_r(p, ITEM_RECOVERY_SET);
generic_params::opt_generic_param_list(p);
@@ -63,7 +63,7 @@ pub(super) fn enum_(p: &mut Parser, m: Marker) {
m.complete(p, ENUM);
}
-pub(crate) fn variant_list(p: &mut Parser) {
+pub(crate) fn variant_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
@@ -80,7 +80,7 @@ pub(crate) fn variant_list(p: &mut Parser) {
p.expect(T!['}']);
m.complete(p, VARIANT_LIST);
- fn variant(p: &mut Parser) {
+ fn variant(p: &mut Parser<'_>) {
let m = p.start();
attributes::outer_attrs(p);
if p.at(IDENT) {
@@ -106,7 +106,7 @@ pub(crate) fn variant_list(p: &mut Parser) {
// test record_field_list
// struct S { a: i32, b: f32 }
-pub(crate) fn record_field_list(p: &mut Parser) {
+pub(crate) fn record_field_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
@@ -123,7 +123,7 @@ pub(crate) fn record_field_list(p: &mut Parser) {
p.expect(T!['}']);
m.complete(p, RECORD_FIELD_LIST);
- fn record_field(p: &mut Parser) {
+ fn record_field(p: &mut Parser<'_>) {
let m = p.start();
// test record_field_attrs
// struct S { #[attr] f: f32 }
@@ -141,7 +141,7 @@ pub(crate) fn record_field_list(p: &mut Parser) {
}
}
-fn tuple_field_list(p: &mut Parser) {
+fn tuple_field_list(p: &mut Parser<'_>) {
assert!(p.at(T!['(']));
let m = p.start();
p.bump(T!['(']);
diff --git a/crates/parser/src/grammar/items/consts.rs b/crates/parser/src/grammar/items/consts.rs
index 98064cd98a..9549ec9b40 100644
--- a/crates/parser/src/grammar/items/consts.rs
+++ b/crates/parser/src/grammar/items/consts.rs
@@ -2,17 +2,17 @@ use super::*;
// test const_item
// const C: u32 = 92;
-pub(super) fn konst(p: &mut Parser, m: Marker) {
+pub(super) fn konst(p: &mut Parser<'_>, m: Marker) {
p.bump(T![const]);
const_or_static(p, m, true);
}
-pub(super) fn static_(p: &mut Parser, m: Marker) {
+pub(super) fn static_(p: &mut Parser<'_>, m: Marker) {
p.bump(T![static]);
const_or_static(p, m, false);
}
-fn const_or_static(p: &mut Parser, m: Marker, is_const: bool) {
+fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) {
p.eat(T![mut]);
if is_const && p.eat(T![_]) {
diff --git a/crates/parser/src/grammar/items/traits.rs b/crates/parser/src/grammar/items/traits.rs
index d6bb3b9b62..c982e2d564 100644
--- a/crates/parser/src/grammar/items/traits.rs
+++ b/crates/parser/src/grammar/items/traits.rs
@@ -2,7 +2,7 @@ use super::*;
// test trait_item
// trait T { fn new() -> Self; }
-pub(super) fn trait_(p: &mut Parser, m: Marker) {
+pub(super) fn trait_(p: &mut Parser<'_>, m: Marker) {
p.bump(T![trait]);
name_r(p, ITEM_RECOVERY_SET);
@@ -44,7 +44,7 @@ pub(super) fn trait_(p: &mut Parser, m: Marker) {
// test impl_item
// impl S {}
-pub(super) fn impl_(p: &mut Parser, m: Marker) {
+pub(super) fn impl_(p: &mut Parser<'_>, m: Marker) {
p.bump(T![impl]);
if p.at(T![<]) && not_a_qualified_path(p) {
generic_params::opt_generic_param_list(p);
@@ -80,7 +80,7 @@ pub(super) fn impl_(p: &mut Parser, m: Marker) {
// fn foo() {}
// fn bar(&self) {}
// }
-pub(crate) fn assoc_item_list(p: &mut Parser) {
+pub(crate) fn assoc_item_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
@@ -102,7 +102,7 @@ pub(crate) fn assoc_item_list(p: &mut Parser) {
// test impl_type_params
// impl<const N: u32> Bar<N> {}
-fn not_a_qualified_path(p: &Parser) -> bool {
+fn not_a_qualified_path(p: &Parser<'_>) -> bool {
// There's an ambiguity between generic parameters and qualified paths in impls.
// If we see `<` it may start both, so we have to inspect some following tokens.
// The following combinations can only start generics,
@@ -131,7 +131,7 @@ fn not_a_qualified_path(p: &Parser) -> bool {
// impl Trait1 for T {}
// impl impl NotType {}
// impl Trait2 for impl NotType {}
-pub(crate) fn impl_type(p: &mut Parser) {
+pub(crate) fn impl_type(p: &mut Parser<'_>) {
if p.at(T![impl]) {
p.error("expected trait or type");
return;
diff --git a/crates/parser/src/grammar/items/use_item.rs b/crates/parser/src/grammar/items/use_item.rs
index ffb147b1fd..69880b7946 100644
--- a/crates/parser/src/grammar/items/use_item.rs
+++ b/crates/parser/src/grammar/items/use_item.rs
@@ -2,7 +2,7 @@ use super::*;
// test use_item
// use std::collections;
-pub(super) fn use_(p: &mut Parser, m: Marker) {
+pub(super) fn use_(p: &mut Parser<'_>, m: Marker) {
p.bump(T![use]);
use_tree(p, true);
p.expect(T![;]);
@@ -11,7 +11,7 @@ pub(super) fn use_(p: &mut Parser, m: Marker) {
// test use_tree
// use outer::tree::{inner::tree};
-fn use_tree(p: &mut Parser, top_level: bool) {
+fn use_tree(p: &mut Parser<'_>, top_level: bool) {
let m = p.start();
match p.current() {
// test use_tree_star
@@ -78,7 +78,7 @@ fn use_tree(p: &mut Parser, top_level: bool) {
// test use_tree_list
// use {a, b, c};
-pub(crate) fn use_tree_list(p: &mut Parser) {
+pub(crate) fn use_tree_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
diff --git a/crates/parser/src/grammar/params.rs b/crates/parser/src/grammar/params.rs
index c2e633fdb0..20e8e95f06 100644
--- a/crates/parser/src/grammar/params.rs
+++ b/crates/parser/src/grammar/params.rs
@@ -5,21 +5,21 @@ use super::*;
// fn b(x: i32) {}
// fn c(x: i32, ) {}
// fn d(x: i32, y: ()) {}
-pub(super) fn param_list_fn_def(p: &mut Parser) {
+pub(super) fn param_list_fn_def(p: &mut Parser<'_>) {
list_(p, Flavor::FnDef);
}
// test param_list_opt_patterns
// fn foo<F: FnMut(&mut Foo<'a>)>(){}
-pub(super) fn param_list_fn_trait(p: &mut Parser) {
+pub(super) fn param_list_fn_trait(p: &mut Parser<'_>) {
list_(p, Flavor::FnTrait);
}
-pub(super) fn param_list_fn_ptr(p: &mut Parser) {
+pub(super) fn param_list_fn_ptr(p: &mut Parser<'_>) {
list_(p, Flavor::FnPointer);
}
-pub(super) fn param_list_closure(p: &mut Parser) {
+pub(super) fn param_list_closure(p: &mut Parser<'_>) {
list_(p, Flavor::Closure);
}
@@ -31,7 +31,7 @@ enum Flavor {
Closure,
}
-fn list_(p: &mut Parser, flavor: Flavor) {
+fn list_(p: &mut Parser<'_>, flavor: Flavor) {
use Flavor::*;
let (bra, ket) = match flavor {
@@ -87,7 +87,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
const PARAM_FIRST: TokenSet = patterns::PATTERN_FIRST.union(types::TYPE_FIRST);
-fn param(p: &mut Parser, m: Marker, flavor: Flavor) {
+fn param(p: &mut Parser<'_>, m: Marker, flavor: Flavor) {
match flavor {
// test param_list_vararg
// extern "C" { fn printf(format: *const i8, ..., _: u8) -> i32; }
@@ -146,7 +146,7 @@ fn param(p: &mut Parser, m: Marker, flavor: Flavor) {
m.complete(p, PARAM);
}
-fn variadic_param(p: &mut Parser) -> bool {
+fn variadic_param(p: &mut Parser<'_>) -> bool {
if p.at(T![:]) && p.nth_at(1, T![...]) {
p.bump(T![:]);
p.bump(T![...]);
@@ -164,7 +164,7 @@ fn variadic_param(p: &mut Parser) -> bool {
// fn d(&'a mut self, x: i32) {}
// fn e(mut self) {}
// }
-fn opt_self_param(p: &mut Parser, m: Marker) -> Result<(), Marker> {
+fn opt_self_param(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] {
p.eat(T![mut]);
self_as_name(p);
@@ -202,7 +202,7 @@ fn opt_self_param(p: &mut Parser, m: Marker) -> Result<(), Marker> {
Ok(())
}
-fn self_as_name(p: &mut Parser) {
+fn self_as_name(p: &mut Parser<'_>) {
let m = p.start();
p.bump(T![self]);
m.complete(p, NAME);
diff --git a/crates/parser/src/grammar/paths.rs b/crates/parser/src/grammar/paths.rs
index b4a60574e5..22c7f003f4 100644
--- a/crates/parser/src/grammar/paths.rs
+++ b/crates/parser/src/grammar/paths.rs
@@ -3,11 +3,11 @@ use super::*;
pub(super) const PATH_FIRST: TokenSet =
TokenSet::new(&[IDENT, T![self], T![super], T![crate], T![Self], T![:], T![<]]);
-pub(super) fn is_path_start(p: &Parser) -> bool {
+pub(super) fn is_path_start(p: &Parser<'_>) -> bool {
is_use_path_start(p) || p.at(T![<]) || p.at(T![Self])
}
-pub(super) fn is_use_path_start(p: &Parser) -> bool {
+pub(super) fn is_use_path_start(p: &Parser<'_>) -> bool {
match p.current() {
IDENT | T![self] | T![super] | T![crate] => true,
T![:] if p.at(T![::]) => true,
@@ -15,19 +15,19 @@ pub(super) fn is_use_path_start(p: &Parser) -> bool {
}
}
-pub(super) fn use_path(p: &mut Parser) {
+pub(super) fn use_path(p: &mut Parser<'_>) {
path(p, Mode::Use);
}
-pub(crate) fn type_path(p: &mut Parser) {
+pub(crate) fn type_path(p: &mut Parser<'_>) {
path(p, Mode::Type);
}
-pub(super) fn expr_path(p: &mut Parser) {
+pub(super) fn expr_path(p: &mut Parser<'_>) {
path(p, Mode::Expr);
}
-pub(crate) fn type_path_for_qualifier(p: &mut Parser, qual: CompletedMarker) -> CompletedMarker {
+pub(crate) fn type_path_for_qualifier(p: &mut Parser<'_>, qual: CompletedMarker) -> CompletedMarker {
path_for_qualifier(p, Mode::Type, qual)
}
@@ -38,14 +38,14 @@ enum Mode {
Expr,
}
-fn path(p: &mut Parser, mode: Mode) {
+fn path(p: &mut Parser<'_>, mode: Mode) {
let path = p.start();
path_segment(p, mode, true);
let qual = path.complete(p, PATH);
path_for_qualifier(p, mode, qual);
}
-fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) -> CompletedMarker {
+fn path_for_qualifier(p: &mut Parser<'_>, mode: Mode, mut qual: CompletedMarker) -> CompletedMarker {
loop {
let use_tree = matches!(p.nth(2), T![*] | T!['{']);
if p.at(T![::]) && !use_tree {
@@ -60,7 +60,7 @@ fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) ->
}
}
-fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
+fn path_segment(p: &mut Parser<'_>, mode: Mode, first: bool) {
let m = p.start();
// test qual_paths
// type X = <A as B>::Output;
@@ -107,7 +107,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
m.complete(p, PATH_SEGMENT);
}
-fn opt_path_type_args(p: &mut Parser, mode: Mode) {
+fn opt_path_type_args(p: &mut Parser<'_>, mode: Mode) {
match mode {
Mode::Use => {}
Mode::Type => {
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index 1f622b32e5..4cbf103061 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -13,22 +13,22 @@ pub(super) const PATTERN_FIRST: TokenSet =
T![.],
]));
-pub(crate) fn pattern(p: &mut Parser) {
+pub(crate) fn pattern(p: &mut Parser<'_>) {
pattern_r(p, PAT_RECOVERY_SET);
}
/// Parses a pattern list separated by pipes `|`.
-pub(super) fn pattern_top(p: &mut Parser) {
+pub(super) fn pattern_top(p: &mut Parser<'_>) {
pattern_top_r(p, PAT_RECOVERY_SET);
}
-pub(crate) fn pattern_single(p: &mut Parser) {
+pub(crate) fn pattern_single(p: &mut Parser<'_>) {
pattern_single_r(p, PAT_RECOVERY_SET);
}
/// Parses a pattern list separated by pipes `|`
/// using the given `recovery_set`.
-pub(super) fn pattern_top_r(p: &mut Parser, recovery_set: TokenSet) {
+pub(super) fn pattern_top_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
p.eat(T![|]);
pattern_r(p, recovery_set);
}
@@ -45,7 +45,7 @@ pub(super) fn pattern_top_r(p: &mut Parser, recovery_set: TokenSet) {
// [_ | _,] => (),
// }
// }
-fn pattern_r(p: &mut Parser, recovery_set: TokenSet) {
+fn pattern_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
let m = p.start();
pattern_single_r(p, recovery_set);
@@ -59,7 +59,7 @@ fn pattern_r(p: &mut Parser, recovery_set: TokenSet) {
m.complete(p, OR_PAT);
}
-fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
+fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {
if let Some(lhs) = atom_pat(p, recovery_set) {
// test range_pat
// fn main() {
@@ -106,7 +106,7 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
const PAT_RECOVERY_SET: TokenSet =
TokenSet::new(&[T![let], T![if], T![while], T![loop], T![match], T![')'], T![,], T![=]]);
-fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
+fn atom_pat(p: &mut Parser<'_>, recovery_set: TokenSet) -> Option<CompletedMarker> {
let m = match p.current() {
T![box] => box_pat(p),
T![ref] | T![mut] => ident_pat(p, true),
@@ -139,7 +139,7 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
Some(m)
}
-fn is_literal_pat_start(p: &Parser) -> bool {
+fn is_literal_pat_start(p: &Parser<'_>) -> bool {
p.at(T![-]) && (p.nth(1) == INT_NUMBER || p.nth(1) == FLOAT_NUMBER)
|| p.at_ts(expressions::LITERAL_FIRST)
}
@@ -153,7 +153,7 @@ fn is_literal_pat_start(p: &Parser) -> bool {
// "hello" => (),
// }
// }
-fn literal_pat(p: &mut Parser) -> CompletedMarker {
+fn literal_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(is_literal_pat_start(p));
let m = p.start();
if p.at(T![-]) {
@@ -170,7 +170,7 @@ fn literal_pat(p: &mut Parser) -> CompletedMarker {
// let Bar { .. } = ();
// let Bar(..) = ();
// }
-fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker {
+fn path_or_macro_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(paths::is_path_start(p));
let m = p.start();
paths::expr_path(p);
@@ -203,7 +203,7 @@ fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker {
// let S(_,) = ();
// let S(_, .. , x) = ();
// }
-fn tuple_pat_fields(p: &mut Parser) {
+fn tuple_pat_fields(p: &mut Parser<'_>) {
assert!(p.at(T!['(']));
p.bump(T!['(']);
pat_list(p, T![')']);
@@ -216,7 +216,7 @@ fn tuple_pat_fields(p: &mut Parser) {
// let S { x: 1 } = ();
// let S { #[cfg(any())] x: 1 } = ();
// }
-fn record_pat_field(p: &mut Parser) {
+fn record_pat_field(p: &mut Parser<'_>) {
match p.current() {
IDENT | INT_NUMBER if p.nth(1) == T![:] => {
name_ref_or_index(p);
@@ -244,7 +244,7 @@ fn record_pat_field(p: &mut Parser) {
// let S { h: _, } = ();
// let S { #[cfg(any())] .. } = ();
// }
-fn record_pat_field_list(p: &mut Parser) {
+fn record_pat_field_list(p: &mut Parser<'_>) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump(T!['{']);
@@ -277,7 +277,7 @@ fn record_pat_field_list(p: &mut Parser) {
// test placeholder_pat
// fn main() { let _ = (); }
-fn wildcard_pat(p: &mut Parser) -> CompletedMarker {
+fn wildcard_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![_]));
let m = p.start();
p.bump(T![_]);
@@ -310,7 +310,7 @@ fn wildcard_pat(p: &mut Parser) -> CompletedMarker {
// let [head, .., mid, tail @ ..] = ();
// let [head, .., mid, .., cons] = ();
// }
-fn rest_pat(p: &mut Parser) -> CompletedMarker {
+fn rest_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![..]));
let m = p.start();
p.bump(T![..]);
@@ -322,7 +322,7 @@ fn rest_pat(p: &mut Parser) -> CompletedMarker {
// let &a = ();
// let &mut b = ();
// }
-fn ref_pat(p: &mut Parser) -> CompletedMarker {
+fn ref_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![&]));
let m = p.start();
p.bump(T![&]);
@@ -338,7 +338,7 @@ fn ref_pat(p: &mut Parser) -> CompletedMarker {
// let (..) = ();
// let () = ();
// }
-fn tuple_pat(p: &mut Parser) -> CompletedMarker {
+fn tuple_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T!['(']));
let m = p.start();
p.bump(T!['(']);
@@ -368,7 +368,7 @@ fn tuple_pat(p: &mut Parser) -> CompletedMarker {
// fn main() {
// let [a, b, ..] = [];
// }
-fn slice_pat(p: &mut Parser) -> CompletedMarker {
+fn slice_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T!['[']));
let m = p.start();
p.bump(T!['[']);
@@ -377,7 +377,7 @@ fn slice_pat(p: &mut Parser) -> CompletedMarker {
m.complete(p, SLICE_PAT)
}
-fn pat_list(p: &mut Parser, ket: SyntaxKind) {
+fn pat_list(p: &mut Parser<'_>, ket: SyntaxKind) {
while !p.at(EOF) && !p.at(ket) {
if !p.at_ts(PATTERN_FIRST) {
p.error("expected a pattern");
@@ -400,7 +400,7 @@ fn pat_list(p: &mut Parser, ket: SyntaxKind) {
// let e @ _ = ();
// let ref mut f @ g @ _ = ();
// }
-fn ident_pat(p: &mut Parser, with_at: bool) -> CompletedMarker {
+fn ident_pat(p: &mut Parser<'_>, with_at: bool) -> CompletedMarker {
assert!(matches!(p.current(), T![ref] | T![mut] | IDENT));
let m = p.start();
p.eat(T![ref]);
@@ -418,7 +418,7 @@ fn ident_pat(p: &mut Parser, with_at: bool) -> CompletedMarker {
// let box Outer { box i, j: box Inner(box &x) } = ();
// let box ref mut i = ();
// }
-fn box_pat(p: &mut Parser) -> CompletedMarker {
+fn box_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![box]));
let m = p.start();
p.bump(T![box]);
@@ -431,7 +431,7 @@ fn box_pat(p: &mut Parser) -> CompletedMarker {
// let const { 15 } = ();
// let const { foo(); bar() } = ();
// }
-fn const_block_pat(p: &mut Parser) -> CompletedMarker {
+fn const_block_pat(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(T![const]));
let m = p.start();
p.bump(T![const]);
diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs
index 46db487d02..5c6e18fee8 100644
--- a/crates/parser/src/grammar/types.rs
+++ b/crates/parser/src/grammar/types.rs
@@ -25,15 +25,15 @@ const TYPE_RECOVERY_SET: TokenSet = TokenSet::new(&[
T![pub],
]);
-pub(crate) fn type_(p: &mut Parser) {
+pub(crate) fn type_(p: &mut Parser<'_>) {
type_with_bounds_cond(p, true);
}
-pub(super) fn type_no_bounds(p: &mut Parser) {
+pub(super) fn type_no_bounds(p: &mut Parser<'_>) {
type_with_bounds_cond(p, false);
}
-fn type_with_bounds_cond(p: &mut Parser, allow_bounds: bool) {
+fn type_with_bounds_cond(p: &mut Parser<'_>, allow_bounds: bool) {
match p.current() {
T!['('] => paren_or_tuple_type(p),
T![!] => never_type(p),
@@ -54,7 +54,7 @@ fn type_with_bounds_cond(p: &mut Parser, allow_bounds: bool) {
}
}
-pub(super) fn ascription(p: &mut Parser) {
+pub(super) fn ascription(p: &mut Parser<'_>) {
assert!(p.at(T![:]));
p.bump(T![:]);
if p.at(T![=]) {
@@ -66,7 +66,7 @@ pub(super) fn ascription(p: &mut Parser) {
type_(p);
}
-fn paren_or_tuple_type(p: &mut Parser) {
+fn paren_or_tuple_type(p: &mut Parser<'_>) {
assert!(p.at(T!['(']));
let m = p.start();
p.bump(T!['(']);
@@ -101,14 +101,14 @@ fn paren_or_tuple_type(p: &mut Parser) {
// test never_type
// type Never = !;
-fn never_type(p: &mut Parser) {
+fn never_type(p: &mut Parser<'_>) {
assert!(p.at(T![!]));
let m = p.start();
p.bump(T![!]);
m.complete(p, NEVER_TYPE);
}
-fn ptr_type(p: &mut Parser) {
+fn ptr_type(p: &mut Parser<'_>) {
assert!(p.at(T![*]));
let m = p.start();
p.bump(T![*]);
@@ -132,7 +132,7 @@ fn ptr_type(p: &mut Parser) {
m.complete(p, PTR_TYPE);
}
-fn array_or_slice_type(p: &mut Parser) {
+fn array_or_slice_type(p: &mut Parser<'_>) {
assert!(p.at(T!['[']));
let m = p.start();
p.bump(T!['[']);
@@ -168,7 +168,7 @@ fn array_or_slice_type(p: &mut Parser) {
// type A = &();
// type B = &'static ();
// type C = &mut ();
-fn ref_type(p: &mut Parser) {
+fn ref_type(p: &mut Parser<'_>) {
assert!(p.at(T![&]));
let m = p.start();
p.bump(T![&]);
@@ -182,7 +182,7 @@ fn ref_type(p: &mut Parser) {
// test placeholder_type
// type Placeholder = _;
-fn infer_type(p: &mut Parser) {
+fn infer_type(p: &mut Parser<'_>) {
assert!(p.at(T![_]));
let m = p.start();
p.bump(T![_]);
@@ -194,7 +194,7 @@ fn infer_type(p: &mut Parser) {
// type B = unsafe fn();
// type C = unsafe extern "C" fn();
// type D = extern "C" fn ( u8 , ... ) -> u8;
-fn fn_ptr_type(p: &mut Parser) {
+fn fn_ptr_type(p: &mut Parser<'_>) {
let m = p.start();
p.eat(T![unsafe]);
if p.at(T![extern]) {
@@ -218,7 +218,7 @@ fn fn_ptr_type(p: &mut Parser) {
m.complete(p, FN_PTR_TYPE);
}
-pub(super) fn for_binder(p: &mut Parser) {
+pub(super) fn for_binder(p: &mut Parser<'_>) {
assert!(p.at(T![for]));
p.bump(T![for]);
if p.at(T![<]) {
@@ -232,7 +232,7 @@ pub(super) fn for_binder(p: &mut Parser) {
// type A = for<'a> fn() -> ();
// type B = for<'a> unsafe extern "C" fn(&'a ()) -> ();
// type Obj = for<'a> PartialEq<&'a i32>;
-pub(super) fn for_type(p: &mut Parser, allow_bounds: bool) {
+pub(super) fn for_type(p: &mut Parser<'_>, allow_bounds: bool) {
assert!(p.at(T![for]));
let m = p.start();
for_binder(p);
@@ -256,7 +256,7 @@ pub(super) fn for_type(p: &mut Parser, allow_bounds: bool) {
// test impl_trait_type
// type A = impl Iterator<Item=Foo<'a>> + 'a;
-fn impl_trait_type(p: &mut Parser) {
+fn impl_trait_type(p: &mut Parser<'_>) {
assert!(p.at(T![impl]));
let m = p.start();
p.bump(T![impl]);
@@ -266,7 +266,7 @@ fn impl_trait_type(p: &mut Parser) {
// test dyn_trait_type
// type A = dyn Iterator<Item=Foo<'a>> + 'a;
-fn dyn_trait_type(p: &mut Parser) {
+fn dyn_trait_type(p: &mut Parser<'_>) {
assert!(p.at(T![dyn]));
let m = p.start();
p.bump(T![dyn]);
@@ -279,14 +279,14 @@ fn dyn_trait_type(p: &mut Parser) {
// type B = ::Foo;
// type C = self::Foo;
// type D = super::Foo;
-pub(super) fn path_type(p: &mut Parser) {
+pub(super) fn path_type(p: &mut Parser<'_>) {
path_type_(p, true);
}
// test macro_call_type
// type A = foo!();
// type B = crate::foo!();
-fn path_or_macro_type_(p: &mut Parser, allow_bounds: bool) {
+fn path_or_macro_type_(p: &mut Parser<'_>, allow_bounds: bool) {
assert!(paths::is_path_start(p));
let r = p.start();
let m = p.start();
@@ -309,7 +309,7 @@ fn path_or_macro_type_(p: &mut Parser, allow_bounds: bool) {
}
}
-pub(super) fn path_type_(p: &mut Parser, allow_bounds: bool) {
+pub(super) fn path_type_(p: &mut Parser<'_>, allow_bounds: bool) {
assert!(paths::is_path_start(p));
let m = p.start();
paths::type_path(p);
@@ -325,7 +325,7 @@ pub(super) fn path_type_(p: &mut Parser, allow_bounds: bool) {
/// This turns a parsed PATH_TYPE or FOR_TYPE optionally into a DYN_TRAIT_TYPE
/// with a TYPE_BOUND_LIST
-fn opt_type_bounds_as_dyn_trait_type(p: &mut Parser, type_marker: CompletedMarker) {
+fn opt_type_bounds_as_dyn_trait_type(p: &mut Parser<'_>, type_marker: CompletedMarker) {
assert!(matches!(
type_marker.kind(),
SyntaxKind::PATH_TYPE | SyntaxKind::FOR_TYPE | SyntaxKind::MACRO_TYPE
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 203f59407a..87be479277 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -79,7 +79,7 @@ pub enum TopEntryPoint {
impl TopEntryPoint {
pub fn parse(&self, input: &Input) -> Output {
- let entry_point: fn(&'_ mut parser::Parser) = match self {
+ let entry_point: fn(&'_ mut parser::Parser<'_>) = match self {
TopEntryPoint::SourceFile => grammar::entry::top::source_file,
TopEntryPoint::MacroStmts => grammar::entry::top::macro_stmts,
TopEntryPoint::MacroItems => grammar::entry::top::macro_items,
@@ -136,7 +136,7 @@ pub enum PrefixEntryPoint {
impl PrefixEntryPoint {
pub fn parse(&self, input: &Input) -> Output {
- let entry_point: fn(&'_ mut parser::Parser) = match self {
+ let entry_point: fn(&'_ mut parser::Parser<'_>) = match self {
PrefixEntryPoint::Vis => grammar::entry::prefix::vis,
PrefixEntryPoint::Block => grammar::entry::prefix::block,
PrefixEntryPoint::Stmt => grammar::entry::prefix::stmt,
@@ -155,7 +155,7 @@ impl PrefixEntryPoint {
}
/// A parsing function for a specific braced-block.
-pub struct Reparser(fn(&mut parser::Parser));
+pub struct Reparser(fn(&mut parser::Parser<'_>));
impl Reparser {
/// If the node is a braced block, return the corresponding `Reparser`.
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index d4aecf9b44..48d8350e07 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -259,7 +259,7 @@ impl Marker {
/// Finishes the syntax tree node and assigns `kind` to it,
/// and mark the create a `CompletedMarker` for possible future
/// operation like `.precede()` to deal with forward_parent.
- pub(crate) fn complete(mut self, p: &mut Parser, kind: SyntaxKind) -> CompletedMarker {
+ pub(crate) fn complete(mut self, p: &mut Parser<'_>, kind: SyntaxKind) -> CompletedMarker {
self.bomb.defuse();
let idx = self.pos as usize;
match &mut p.events[idx] {
@@ -274,7 +274,7 @@ impl Marker {
/// Abandons the syntax tree node. All its children
/// are attached to its parent instead.
- pub(crate) fn abandon(mut self, p: &mut Parser) {
+ pub(crate) fn abandon(mut self, p: &mut Parser<'_>) {
self.bomb.defuse();
let idx = self.pos as usize;
if idx == p.events.len() - 1 {
@@ -309,7 +309,7 @@ impl CompletedMarker {
/// Append a new `START` events as `[START, FINISH, NEWSTART]`,
/// then mark `NEWSTART` as `START`'s parent with saving its relative
/// distance to `NEWSTART` into forward_parent(=2 in this case);
- pub(crate) fn precede(self, p: &mut Parser) -> Marker {
+ pub(crate) fn precede(self, p: &mut Parser<'_>) -> Marker {
let new_pos = p.start();
let idx = self.pos as usize;
match &mut p.events[idx] {
@@ -322,7 +322,7 @@ impl CompletedMarker {
}
/// Extends this completed marker *to the left* up to `m`.
- pub(crate) fn extend_to(self, p: &mut Parser, mut m: Marker) -> CompletedMarker {
+ pub(crate) fn extend_to(self, p: &mut Parser<'_>, mut m: Marker) -> CompletedMarker {
m.bomb.defuse();
let idx = m.pos as usize;
match &mut p.events[idx] {
diff --git a/crates/parser/src/shortcuts.rs b/crates/parser/src/shortcuts.rs
index b038d44fe0..4b805faddc 100644
--- a/crates/parser/src/shortcuts.rs
+++ b/crates/parser/src/shortcuts.rs
@@ -54,7 +54,7 @@ impl<'a> LexedStr<'a> {
pub fn intersperse_trivia(
&self,
output: &crate::Output,
- sink: &mut dyn FnMut(StrStep),
+ sink: &mut dyn FnMut(StrStep<'_>),
) -> bool {
let mut builder = Builder { lexed: self, pos: 0, state: State::PendingEnter, sink };
diff --git a/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs b/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs
index dd3fd8b642..41e2e45703 100644
--- a/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs
+++ b/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs
@@ -25,7 +25,7 @@ impl From<proc_macro::bridge::PanicMessage> for PanicMessage {
impl Abi {
pub unsafe fn from_lib(lib: &Library, symbol_name: String) -> Result<Abi, libloading::Error> {
- let macros: libloading::Symbol<&&[proc_macro::bridge::client::ProcMacro]> =
+ let macros: libloading::Symbol<'_, &&[proc_macro::bridge::client::ProcMacro]> =
lib.get(symbol_name.as_bytes())?;
Ok(Self { exported_macros: macros.to_vec() })
}
diff --git a/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs b/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs
index 590712fe69..c253b10994 100644
--- a/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs
+++ b/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs
@@ -27,7 +27,7 @@ impl From<proc_macro::bridge::PanicMessage> for PanicMessage {
impl Abi {
pub unsafe fn from_lib(lib: &Library, symbol_name: String) -> Result<Abi, libloading::Error> {
- let macros: libloading::Symbol<&&[proc_macro::bridge::client::ProcMacro]> =
+ let macros: libloading::Symbol<'_, &&[proc_macro::bridge::client::ProcMacro]> =
lib.get(symbol_name.as_bytes())?;
Ok(Self { exported_macros: macros.to_vec() })
}
diff --git a/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs b/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs
index a5c9a1a976..0ba4bbbef0 100644
--- a/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs
+++ b/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs
@@ -27,7 +27,7 @@ impl From<proc_macro::bridge::PanicMessage> for PanicMessage {
impl Abi {
pub unsafe fn from_lib(lib: &Library, symbol_name: String) -> Result<Abi, libloading::Error> {
- let macros: libloading::Symbol<&&[proc_macro::bridge::client::ProcMacro]> =
+ let macros: libloading::Symbol<'_, &&[proc_macro::bridge::client::ProcMacro]> =
lib.get(symbol_name.as_bytes())?;
Ok(Self { exported_macros: macros.to_vec() })
}
diff --git a/crates/profile/src/memory_usage.rs b/crates/profile/src/memory_usage.rs
index 885fe1f1aa..ee882b4cb4 100644
--- a/crates/profile/src/memory_usage.rs
+++ b/crates/profile/src/memory_usage.rs
@@ -11,7 +11,7 @@ pub struct MemoryUsage {
}
impl fmt::Display for MemoryUsage {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.allocated.fmt(f)
}
}
@@ -97,7 +97,7 @@ impl Bytes {
}
impl fmt::Display for Bytes {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let bytes = self.0;
let mut value = bytes;
let mut suffix = "b";
diff --git a/crates/rust-analyzer/src/bin/logger.rs b/crates/rust-analyzer/src/bin/logger.rs
index db00029da2..0b69f75bc0 100644
--- a/crates/rust-analyzer/src/bin/logger.rs
+++ b/crates/rust-analyzer/src/bin/logger.rs
@@ -109,7 +109,7 @@ where
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
- mut writer: Writer,
+ mut writer: Writer<'_>,
event: &Event<'_>,
) -> fmt::Result {
// Write level and target
diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs
index 2415abc1d8..4fa88c3c6d 100644
--- a/crates/rust-analyzer/tests/slow-tests/support.rs
+++ b/crates/rust-analyzer/tests/slow-tests/support.rs
@@ -26,7 +26,7 @@ pub(crate) struct Project<'a> {
}
impl<'a> Project<'a> {
- pub(crate) fn with_fixture(fixture: &str) -> Project {
+ pub(crate) fn with_fixture(fixture: &str) -> Project<'_> {
Project {
fixture,
tmp_dir: None,
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index 2a41d0a701..b143df1f83 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -432,7 +432,7 @@ impl NameLike {
_ => None,
}
}
- pub fn text(&self) -> TokenText {
+ pub fn text(&self) -> TokenText<'_> {
match self {
NameLike::NameRef(name_ref) => name_ref.text(),
NameLike::Name(name) => name.text(),
diff --git a/crates/syntax/src/syntax_error.rs b/crates/syntax/src/syntax_error.rs
index 940b7f0a24..dc6130bd64 100644
--- a/crates/syntax/src/syntax_error.rs
+++ b/crates/syntax/src/syntax_error.rs
@@ -38,7 +38,7 @@ impl SyntaxError {
}
impl fmt::Display for SyntaxError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
diff --git a/crates/syntax/src/tests/ast_src.rs b/crates/syntax/src/tests/ast_src.rs
index 2f6932a1ad..cf5be1c30f 100644
--- a/crates/syntax/src/tests/ast_src.rs
+++ b/crates/syntax/src/tests/ast_src.rs
@@ -9,7 +9,7 @@ pub(crate) struct KindsSrc<'a> {
pub(crate) nodes: &'a [&'a str],
}
-pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
+pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc {
punct: &[
(";", "SEMICOLON"),
(",", "COMMA"),
diff --git a/crates/syntax/src/token_text.rs b/crates/syntax/src/token_text.rs
index c8ba638c52..913b24d42b 100644
--- a/crates/syntax/src/token_text.rs
+++ b/crates/syntax/src/token_text.rs
@@ -42,7 +42,7 @@ impl AsRef<str> for TokenText<'_> {
}
impl From<TokenText<'_>> for String {
- fn from(token_text: TokenText) -> Self {
+ fn from(token_text: TokenText<'_>) -> Self {
token_text.as_str().into()
}
}
@@ -53,7 +53,7 @@ impl PartialEq<&'_ str> for TokenText<'_> {
}
}
impl PartialEq<TokenText<'_>> for &'_ str {
- fn eq(&self, other: &TokenText) -> bool {
+ fn eq(&self, other: &TokenText<'_>) -> bool {
other == self
}
}
@@ -63,12 +63,12 @@ impl PartialEq<String> for TokenText<'_> {
}
}
impl PartialEq<TokenText<'_>> for String {
- fn eq(&self, other: &TokenText) -> bool {
+ fn eq(&self, other: &TokenText<'_>) -> bool {
other == self
}
}
impl PartialEq for TokenText<'_> {
- fn eq(&self, other: &TokenText) -> bool {
+ fn eq(&self, other: &TokenText<'_>) -> bool {
self.as_str() == other.as_str()
}
}
diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs
index 160cf60f9f..dedfbd7afe 100644
--- a/crates/test-utils/src/lib.rs
+++ b/crates/test-utils/src/lib.rs
@@ -407,7 +407,7 @@ pub fn project_root() -> PathBuf {
PathBuf::from(dir).parent().unwrap().parent().unwrap().to_owned()
}
-pub fn format_diff(chunks: Vec<dissimilar::Chunk>) -> String {
+pub fn format_diff(chunks: Vec<dissimilar::Chunk<'_>>) -> String {
let mut buf = String::new();
for chunk in chunks {
let formatted = match chunk {
diff --git a/crates/tt/src/buffer.rs b/crates/tt/src/buffer.rs
index 1fa61c41dd..69226bd4c4 100644
--- a/crates/tt/src/buffer.rs
+++ b/crates/tt/src/buffer.rs
@@ -109,7 +109,7 @@ impl<'t> TokenBuffer<'t> {
Cursor::create(self, EntryPtr(EntryId(0), 0))
}
- fn entry(&self, ptr: &EntryPtr) -> Option<&Entry> {
+ fn entry(&self, ptr: &EntryPtr) -> Option<&Entry<'_>> {
let id = ptr.0;
self.buffers[id.0].get(ptr.1)
}
@@ -141,7 +141,7 @@ pub struct Cursor<'a> {
}
impl<'a> PartialEq for Cursor<'a> {
- fn eq(&self, other: &Cursor) -> bool {
+ fn eq(&self, other: &Cursor<'_>) -> bool {
self.ptr == other.ptr && std::ptr::eq(self.buffer, other.buffer)
}
}
@@ -198,7 +198,7 @@ impl<'a> Cursor<'a> {
}
}
- fn create(buffer: &'a TokenBuffer, ptr: EntryPtr) -> Cursor<'a> {
+ fn create(buffer: &'a TokenBuffer<'_>, ptr: EntryPtr) -> Cursor<'a> {
Cursor { buffer, ptr }
}
diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs
index 845ebfa4da..a54861de95 100644
--- a/crates/tt/src/lib.rs
+++ b/crates/tt/src/lib.rs
@@ -156,7 +156,7 @@ impl fmt::Debug for Subtree {
}
impl fmt::Display for TokenTree {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TokenTree::Leaf(it) => fmt::Display::fmt(it, f),
TokenTree::Subtree(it) => fmt::Display::fmt(it, f),
@@ -165,7 +165,7 @@ impl fmt::Display for TokenTree {
}
impl fmt::Display for Subtree {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (l, r) = match self.delimiter_kind() {
Some(DelimiterKind::Parenthesis) => ("(", ")"),
Some(DelimiterKind::Brace) => ("{", "}"),
@@ -193,7 +193,7 @@ impl fmt::Display for Subtree {
}
impl fmt::Display for Leaf {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Leaf::Ident(it) => fmt::Display::fmt(it, f),
Leaf::Literal(it) => fmt::Display::fmt(it, f),
@@ -203,19 +203,19 @@ impl fmt::Display for Leaf {
}
impl fmt::Display for Ident {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.text, f)
}
}
impl fmt::Display for Literal {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.text, f)
}
}
impl fmt::Display for Punct {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.char, f)
}
}
diff --git a/lib/la-arena/src/lib.rs b/lib/la-arena/src/lib.rs
index ce6eebd31e..dadee43b10 100644
--- a/lib/la-arena/src/lib.rs
+++ b/lib/la-arena/src/lib.rs
@@ -31,13 +31,13 @@ impl From<u32> for RawIdx {
}
impl fmt::Debug for RawIdx {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl fmt::Display for RawIdx {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
@@ -192,7 +192,7 @@ pub struct Arena<T> {
}
impl<T: fmt::Debug> fmt::Debug for Arena<T> {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Arena").field("len", &self.len()).field("data", &self.data).finish()
}
}