Unnamed repository; edit this file 'description' to name the repository.
fix clippy::needless_borrow
Matthias Krüger 2022-03-12
parent ff7e057 · commit 7912e33
-rw-r--r--crates/hir/src/semantics.rs2
-rw-r--r--crates/hir/src/source_analyzer.rs2
-rw-r--r--crates/hir_def/src/attr.rs2
-rw-r--r--crates/hir_def/src/generics.rs2
-rw-r--r--crates/hir_def/src/item_tree/pretty.rs4
-rw-r--r--crates/hir_def/src/macro_expansion_tests.rs4
-rw-r--r--crates/hir_def/src/type_ref.rs2
-rw-r--r--crates/hir_expand/src/db.rs6
-rw-r--r--crates/hir_expand/src/eager.rs2
-rw-r--r--crates/hir_ty/src/consteval.rs2
-rw-r--r--crates/hir_ty/src/method_resolution.rs8
-rw-r--r--crates/ide/src/hover.rs2
-rw-r--r--crates/ide/src/hover/render.rs2
-rw-r--r--crates/ide_assists/src/handlers/add_missing_match_arms.rs2
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs2
-rw-r--r--crates/ide_assists/src/handlers/extract_module.rs20
-rw-r--r--crates/ide_assists/src/handlers/extract_variable.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_documentation_template.rs6
-rw-r--r--crates/ide_assists/src/handlers/inline_call.rs8
-rw-r--r--crates/ide_assists/src/handlers/merge_match_arms.rs6
-rw-r--r--crates/ide_assists/src/handlers/qualify_method_call.rs2
-rw-r--r--crates/ide_assists/src/utils/gen_trait_fn_body.rs6
-rw-r--r--crates/ide_completion/src/completions/attribute/cfg.rs2
-rw-r--r--crates/ide_completion/src/completions/fn_param.rs4
-rw-r--r--crates/ide_completion/src/completions/postfix.rs4
-rw-r--r--crates/ide_completion/src/completions/qualified_path.rs2
-rw-r--r--crates/ide_completion/src/completions/snippet.rs2
-rw-r--r--crates/ide_db/src/defs.rs4
-rw-r--r--crates/ide_db/src/imports/merge_imports.rs4
-rw-r--r--crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs2
-rw-r--r--crates/ide_db/src/tests/sourcegen_lints.rs10
-rw-r--r--crates/mbe/src/syntax_bridge.rs8
-rw-r--r--crates/proc_macro_api/src/msg.rs7
-rw-r--r--crates/proc_macro_srv/src/dylib.rs2
-rw-r--r--crates/rust-analyzer/src/diagnostics/to_proto.rs4
-rw-r--r--crates/rust-analyzer/src/dispatch.rs2
36 files changed, 74 insertions, 77 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 45544559ea..236487d8e5 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -398,7 +398,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
}
pub fn scope_at_offset(&self, node: &SyntaxNode, offset: TextSize) -> SemanticsScope<'db> {
- self.imp.scope_at_offset(&node, offset)
+ self.imp.scope_at_offset(node, offset)
}
pub fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db> {
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 1789fc319a..499817b6b8 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -603,7 +603,7 @@ fn resolve_hir_path_(
// within the trait's associated types.
if let (Some(unresolved), &TypeNs::TraitId(trait_id)) = (&unresolved, &ty) {
if let Some(type_alias_id) =
- db.trait_data(trait_id).associated_type_by_name(&unresolved.name)
+ db.trait_data(trait_id).associated_type_by_name(unresolved.name)
{
return Some(PathResolution::Def(ModuleDefId::from(type_alias_id).into()));
}
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index d080182554..81054f83b0 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -667,7 +667,7 @@ impl DocsRangeMap {
let InFile { file_id, value: source } = self.source_map.source_of_id(idx);
match source {
Either::Left(attr) => {
- let string = get_doc_string_in_attr(&attr)?;
+ let string = get_doc_string_in_attr(attr)?;
let text_range = string.open_quote_text_range()?;
let range = TextRange::at(
text_range.end() + original_line_src_range.start() + relative_range.start(),
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs
index 60d79f1473..6d7b98f3b1 100644
--- a/crates/hir_def/src/generics.rs
+++ b/crates/hir_def/src/generics.rs
@@ -72,7 +72,7 @@ impl TypeOrConstParamData {
pub fn type_param(&self) -> Option<&TypeParamData> {
match self {
- TypeOrConstParamData::TypeParamData(x) => Some(&x),
+ TypeOrConstParamData::TypeParamData(x) => Some(x),
TypeOrConstParamData::ConstParamData(_) => None,
}
}
diff --git a/crates/hir_def/src/item_tree/pretty.rs b/crates/hir_def/src/item_tree/pretty.rs
index ca164148a1..34bea5bd45 100644
--- a/crates/hir_def/src/item_tree/pretty.rs
+++ b/crates/hir_def/src/item_tree/pretty.rs
@@ -500,7 +500,7 @@ impl<'a> Printer<'a> {
if i != 0 {
w!(self, ", ");
}
- self.print_type_ref(&typeref);
+ self.print_type_ref(typeref);
}
if *varargs {
if !args.is_empty() {
@@ -509,7 +509,7 @@ impl<'a> Printer<'a> {
w!(self, "...");
}
w!(self, ") -> ");
- self.print_type_ref(&return_type);
+ self.print_type_ref(return_type);
}
TypeRef::Macro(_ast_id) => {
w!(self, "<macro>");
diff --git a/crates/hir_def/src/macro_expansion_tests.rs b/crates/hir_def/src/macro_expansion_tests.rs
index 7e0598f4a0..489a3c67e5 100644
--- a/crates/hir_def/src/macro_expansion_tests.rs
+++ b/crates/hir_def/src/macro_expansion_tests.rs
@@ -191,7 +191,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
if let Some((tree, map, _)) = arg.as_deref() {
let tt_range = call.token_tree().unwrap().syntax().text_range();
let mut ranges = Vec::new();
- extract_id_ranges(&mut ranges, &map, &tree);
+ extract_id_ranges(&mut ranges, map, tree);
for (range, id) in ranges {
let idx = (tt_range.start() + range.end()).into();
text_edits.push((idx..idx, format!("#{}", id.0)));
@@ -269,7 +269,7 @@ fn reindent(indent: IndentLevel, pp: String) -> String {
let mut res = lines.next().unwrap().to_string();
for line in lines {
if line.trim().is_empty() {
- res.push_str(&line)
+ res.push_str(line)
} else {
format_to!(res, "{}{}", indent, line)
}
diff --git a/crates/hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs
index ee8ef6caa3..027c410cdf 100644
--- a/crates/hir_def/src/type_ref.rs
+++ b/crates/hir_def/src/type_ref.rs
@@ -245,7 +245,7 @@ impl TypeRef {
f(type_ref);
match type_ref {
TypeRef::Fn(params, _) => {
- params.iter().for_each(|(_, param_type)| go(&param_type, f))
+ params.iter().for_each(|(_, param_type)| go(param_type, f))
}
TypeRef::Tuple(types) => types.iter().for_each(|t| go(t, f)),
TypeRef::RawPtr(type_ref, _)
diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs
index 9fe414de26..ac07daa0ab 100644
--- a/crates/hir_expand/src/db.rs
+++ b/crates/hir_expand/src/db.rs
@@ -149,11 +149,11 @@ pub fn expand_speculative(
let token_range = token_to_map.text_range();
// Build the subtree and token mapping for the speculative args
- let censor = censor_for_macro_input(&loc, &speculative_args);
- let mut fixups = fixup::fixup_syntax(&speculative_args);
+ let censor = censor_for_macro_input(&loc, speculative_args);
+ let mut fixups = fixup::fixup_syntax(speculative_args);
fixups.replace.extend(censor.into_iter().map(|node| (node, Vec::new())));
let (mut tt, spec_args_tmap, _) = mbe::syntax_node_to_token_tree_with_modifications(
- &speculative_args,
+ speculative_args,
fixups.token_map,
fixups.next_id,
fixups.replace,
diff --git a/crates/hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs
index 1de0d5a77d..a24c24cfb0 100644
--- a/crates/hir_expand/src/eager.rs
+++ b/crates/hir_expand/src/eager.rs
@@ -207,7 +207,7 @@ fn eager_macro_recur(
// Collect replacement
for child in children {
- let def = match child.path().and_then(|path| ModPath::from_src(db, path, &hygiene)) {
+ let def = match child.path().and_then(|path| ModPath::from_src(db, path, hygiene)) {
Some(path) => macro_resolver(path.clone()).ok_or_else(|| UnresolvedMacro { path })?,
None => {
diagnostic_sink(ExpandError::Other("malformed macro invocation".into()));
diff --git a/crates/hir_ty/src/consteval.rs b/crates/hir_ty/src/consteval.rs
index 68e6e0582e..0139c5d589 100644
--- a/crates/hir_ty/src/consteval.rs
+++ b/crates/hir_ty/src/consteval.rs
@@ -293,7 +293,7 @@ pub fn eval_const(expr: &Expr, ctx: &mut ConstEvalCtx<'_>) -> Result<ComputedExp
pub fn eval_usize(expr: Idx<Expr>, mut ctx: ConstEvalCtx<'_>) -> Option<u64> {
let expr = &ctx.exprs[expr];
- if let Ok(ce) = eval_const(&expr, &mut ctx) {
+ if let Ok(ce) = eval_const(expr, &mut ctx) {
match ce {
ComputedExpr::Literal(Literal::Int(x, _)) => return x.try_into().ok(),
ComputedExpr::Literal(Literal::Uint(x, _)) => return x.try_into().ok(),
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index 44ece57a8e..fdf884a76d 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -693,7 +693,7 @@ fn iterate_method_candidates_with_autoref(
iterate_method_candidates_by_receiver(
receiver_ty,
first_adjustment.clone(),
- &rest,
+ rest,
db,
env.clone(),
traits_in_scope,
@@ -973,7 +973,7 @@ fn iterate_inherent_methods(
// already happens in `is_valid_candidate` above; if not, we
// check it here
if receiver_ty.is_none()
- && inherent_impl_substs(db, env.clone(), impl_def, &self_ty).is_none()
+ && inherent_impl_substs(db, env.clone(), impl_def, self_ty).is_none()
{
cov_mark::hit!(impl_self_type_match_without_receiver);
continue;
@@ -1152,7 +1152,7 @@ pub fn implements_trait(
env: Arc<TraitEnvironment>,
trait_: TraitId,
) -> bool {
- let goal = generic_implements_goal(db, env.clone(), trait_, &ty);
+ let goal = generic_implements_goal(db, env.clone(), trait_, ty);
let solution = db.trait_solve(env.krate, goal.cast(Interner));
solution.is_some()
@@ -1164,7 +1164,7 @@ pub fn implements_trait_unique(
env: Arc<TraitEnvironment>,
trait_: TraitId,
) -> bool {
- let goal = generic_implements_goal(db, env.clone(), trait_, &ty);
+ let goal = generic_implements_goal(db, env.clone(), trait_, ty);
let solution = db.trait_solve(env.krate, goal.cast(Interner));
matches!(solution, Some(crate::Solution::Unique(_)))
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 4a762ad1f8..ec0435aad0 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -145,7 +145,7 @@ pub(crate) fn hover(
if result.is_none() {
// fallbacks, show keywords or types
- let res = descended.iter().find_map(|token| render::keyword(sema, config, &token));
+ let res = descended.iter().find_map(|token| render::keyword(sema, config, token));
if let Some(res) = res {
return Some(RangeInfo::new(original_token.text_range(), res));
}
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index 2e141600e8..b2b74ccce3 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -103,7 +103,7 @@ pub(super) fn try_expr(
let adts = inner_ty.as_adt().zip(body_ty.as_adt());
if let Some((hir::Adt::Enum(inner), hir::Adt::Enum(body))) = adts {
- let famous_defs = FamousDefs(sema, sema.scope(&try_expr.syntax()).krate());
+ let famous_defs = FamousDefs(sema, sema.scope(try_expr.syntax()).krate());
// special case for two options, there is no value in showing them
if let Some(option_enum) = famous_defs.core_option_Option() {
if inner == option_enum && body == option_enum {
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 9b6a1ad169..2070cca142 100644
--- a/crates/ide_assists/src/handlers/add_missing_match_arms.rs
+++ b/crates/ide_assists/src/handlers/add_missing_match_arms.rs
@@ -41,7 +41,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
let match_arm_list = match_expr.match_arm_list()?;
let target_range = ctx.sema.original_range(match_expr.syntax()).range;
- if let None = cursor_at_trivial_match_arm_list(&ctx, &match_expr, &match_arm_list) {
+ if let None = cursor_at_trivial_match_arm_list(ctx, &match_expr, &match_arm_list) {
let arm_list_range = ctx.sema.original_range(match_arm_list.syntax()).range;
let cursor_in_range = arm_list_range.contains_range(ctx.selection_trimmed());
if cursor_in_range {
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index 5f86957ba2..4cc4860ed5 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -1448,7 +1448,7 @@ fn make_body(
.filter(|it| text_range.contains_range(it.text_range()))
.map(|it| match &it {
syntax::NodeOrToken::Node(n) => syntax::NodeOrToken::Node(
- rewrite_body_segment(ctx, &fun.params, &handler, &n),
+ rewrite_body_segment(ctx, &fun.params, &handler, n),
),
_ => it,
})
diff --git a/crates/ide_assists/src/handlers/extract_module.rs b/crates/ide_assists/src/handlers/extract_module.rs
index 9e1481b2f6..d8dda784c5 100644
--- a/crates/ide_assists/src/handlers/extract_module.rs
+++ b/crates/ide_assists/src/handlers/extract_module.rs
@@ -103,7 +103,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
//for change_visibility and usages for first point mentioned above in the process
let (usages_to_be_processed, record_fields) = module.get_usages_and_record_fields(ctx);
- let import_paths_to_be_removed = module.resolve_imports(curr_parent_module, &ctx);
+ let import_paths_to_be_removed = module.resolve_imports(curr_parent_module, ctx);
module.body_items = module.change_visibility(record_fields)?;
if module.body_items.len() == 0 {
return None;
@@ -203,7 +203,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
builder.delete(node_to_be_removed.text_range());
// Remove preceding indentation from node
- if let Some(range) = indent_range_before_given_node(&node_to_be_removed) {
+ if let Some(range) = indent_range_before_given_node(node_to_be_removed) {
builder.delete(range);
}
@@ -700,7 +700,7 @@ fn does_source_exists_outside_sel_in_same_mod(
if let Some(ast_module) = &curr_parent_module {
if let Some(hir_module) = x.parent(ctx.db()) {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, hir_module, ctx).is_some();
+ compare_hir_and_ast_module(ast_module, hir_module, ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
@@ -725,7 +725,7 @@ fn does_source_exists_outside_sel_in_same_mod(
let have_same_parent;
if let Some(ast_module) = &curr_parent_module {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, x.module(ctx.db()), ctx).is_some();
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
@@ -742,7 +742,7 @@ fn does_source_exists_outside_sel_in_same_mod(
let have_same_parent;
if let Some(ast_module) = &curr_parent_module {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, x.module(ctx.db()), ctx).is_some();
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
@@ -759,7 +759,7 @@ fn does_source_exists_outside_sel_in_same_mod(
let have_same_parent;
if let Some(ast_module) = &curr_parent_module {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, x.module(ctx.db()), ctx).is_some();
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
@@ -776,7 +776,7 @@ fn does_source_exists_outside_sel_in_same_mod(
let have_same_parent;
if let Some(ast_module) = &curr_parent_module {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, x.module(ctx.db()), ctx).is_some();
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
@@ -793,7 +793,7 @@ fn does_source_exists_outside_sel_in_same_mod(
let have_same_parent;
if let Some(ast_module) = &curr_parent_module {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, x.module(ctx.db()), ctx).is_some();
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
@@ -810,7 +810,7 @@ fn does_source_exists_outside_sel_in_same_mod(
let have_same_parent;
if let Some(ast_module) = &curr_parent_module {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, x.module(ctx.db()), ctx).is_some();
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
@@ -827,7 +827,7 @@ fn does_source_exists_outside_sel_in_same_mod(
let have_same_parent;
if let Some(ast_module) = &curr_parent_module {
have_same_parent =
- compare_hir_and_ast_module(&ast_module, x.module(ctx.db()), ctx).is_some();
+ compare_hir_and_ast_module(ast_module, x.module(ctx.db()), ctx).is_some();
} else {
let source_file_id = source.file_id.original_file(ctx.db());
have_same_parent = source_file_id == curr_file_id;
diff --git a/crates/ide_assists/src/handlers/extract_variable.rs b/crates/ide_assists/src/handlers/extract_variable.rs
index aaed2b67fe..ecf9feb0e5 100644
--- a/crates/ide_assists/src/handlers/extract_variable.rs
+++ b/crates/ide_assists/src/handlers/extract_variable.rs
@@ -52,7 +52,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
}
}
- let reference_modifier = match get_receiver_type(&ctx, &to_extract) {
+ let reference_modifier = match get_receiver_type(ctx, &to_extract) {
Some(receiver_type) if receiver_type.is_mutable_reference() => "&mut ",
Some(receiver_type) if receiver_type.is_reference() => "&",
_ => "",
diff --git a/crates/ide_assists/src/handlers/generate_documentation_template.rs b/crates/ide_assists/src/handlers/generate_documentation_template.rs
index bb7c8b1010..15a07492ec 100644
--- a/crates/ide_assists/src/handlers/generate_documentation_template.rs
+++ b/crates/ide_assists/src/handlers/generate_documentation_template.rs
@@ -52,7 +52,7 @@ pub(crate) fn generate_documentation_template(
let parent_syntax = ast_func.syntax();
let text_range = parent_syntax.text_range();
- let indent_level = IndentLevel::from_node(&parent_syntax);
+ let indent_level = IndentLevel::from_node(parent_syntax);
acc.add(
AssistId("generate_documentation_template", AssistKind::Generate),
@@ -202,7 +202,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> {
- let krate = ctx.sema.scope(&ast_func.syntax()).module()?.krate();
+ let krate = ctx.sema.scope(ast_func.syntax()).module()?.krate();
Some(krate.display_name(ctx.db())?.to_string())
}
@@ -338,7 +338,7 @@ fn function_call(
is_unsafe: bool,
) -> Option<String> {
let name = ast_func.name()?;
- let arguments = arguments_from_params(&param_list);
+ let arguments = arguments_from_params(param_list);
let function_call = if param_list.self_param().is_some() {
format!("{}.{}({})", self_name?, name, arguments)
} else if let Some(implementation) = self_partial_type(ast_func) {
diff --git a/crates/ide_assists/src/handlers/inline_call.rs b/crates/ide_assists/src/handlers/inline_call.rs
index 5e9f561806..1bcddeb9ac 100644
--- a/crates/ide_assists/src/handlers/inline_call.rs
+++ b/crates/ide_assists/src/handlers/inline_call.rs
@@ -305,7 +305,7 @@ fn inline(
let body = fn_body.clone_for_update();
let usages_for_locals = |local| {
Definition::Local(local)
- .usages(&sema)
+ .usages(sema)
.all()
.references
.remove(&function_def_file_id)
@@ -369,12 +369,12 @@ fn inline(
// inline single use literals
[usage] if matches!(expr, ast::Expr::Literal(_)) => {
cov_mark::hit!(inline_call_inline_literal);
- inline_direct(usage, &expr);
+ inline_direct(usage, expr);
}
// inline direct local arguments
- [_, ..] if expr_as_name_ref(&expr).is_some() => {
+ [_, ..] if expr_as_name_ref(expr).is_some() => {
cov_mark::hit!(inline_call_inline_locals);
- usages.into_iter().for_each(|usage| inline_direct(usage, &expr));
+ usages.into_iter().for_each(|usage| inline_direct(usage, expr));
}
// can't inline, emit a let statement
_ => {
diff --git a/crates/ide_assists/src/handlers/merge_match_arms.rs b/crates/ide_assists/src/handlers/merge_match_arms.rs
index 622ead81f1..83d7f0338a 100644
--- a/crates/ide_assists/src/handlers/merge_match_arms.rs
+++ b/crates/ide_assists/src/handlers/merge_match_arms.rs
@@ -40,7 +40,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option
}
let current_expr = current_arm.expr()?;
let current_text_range = current_arm.syntax().text_range();
- let current_arm_types = get_arm_types(&ctx, &current_arm);
+ let current_arm_types = get_arm_types(ctx, &current_arm);
// We check if the following match arms match this one. We could, but don't,
// compare to the previous match arm as well.
@@ -99,7 +99,7 @@ fn are_same_types(
arm: &ast::MatchArm,
ctx: &AssistContext,
) -> bool {
- let arm_types = get_arm_types(&ctx, &arm);
+ let arm_types = get_arm_types(ctx, arm);
for (other_arm_type_name, other_arm_type) in arm_types {
match (current_arm_types.get(&other_arm_type_name), other_arm_type) {
(Some(Some(current_arm_type)), Some(other_arm_type))
@@ -163,7 +163,7 @@ fn get_arm_types(
}
}
- recurse(&mut mapping, &context, &arm.pat());
+ recurse(&mut mapping, context, &arm.pat());
mapping
}
diff --git a/crates/ide_assists/src/handlers/qualify_method_call.rs b/crates/ide_assists/src/handlers/qualify_method_call.rs
index 61c16aa044..0f232caab6 100644
--- a/crates/ide_assists/src/handlers/qualify_method_call.rs
+++ b/crates/ide_assists/src/handlers/qualify_method_call.rs
@@ -44,7 +44,7 @@ pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext) -> Opt
let range = call.syntax().text_range();
let resolved_call = ctx.sema.resolve_method_call(&call)?;
- let current_module = ctx.sema.scope(&call.syntax()).module()?;
+ let current_module = ctx.sema.scope(call.syntax()).module()?;
let target_module_def = ModuleDef::from(resolved_call);
let item_in_ns = ItemInNs::from(target_module_def);
let receiver_path = current_module
diff --git a/crates/ide_assists/src/utils/gen_trait_fn_body.rs b/crates/ide_assists/src/utils/gen_trait_fn_body.rs
index 908bb136be..944346b555 100644
--- a/crates/ide_assists/src/utils/gen_trait_fn_body.rs
+++ b/crates/ide_assists/src/utils/gen_trait_fn_body.rs
@@ -406,7 +406,7 @@ fn gen_partial_eq(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
}
fn gen_record_pat_field(field_name: &str, pat_name: &str) -> ast::RecordPatField {
- let pat = make::ext::simple_ident_pat(make::name(&pat_name));
+ let pat = make::ext::simple_ident_pat(make::name(pat_name));
let name_ref = make::name_ref(field_name);
make::record_pat_field(name_ref, pat.into())
}
@@ -455,10 +455,10 @@ fn gen_partial_eq(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
let field_name = field.name()?.to_string();
let l_name = &format!("l_{}", field_name);
- l_fields.push(gen_record_pat_field(&field_name, &l_name));
+ l_fields.push(gen_record_pat_field(&field_name, l_name));
let r_name = &format!("r_{}", field_name);
- r_fields.push(gen_record_pat_field(&field_name, &r_name));
+ r_fields.push(gen_record_pat_field(&field_name, r_name));
let lhs = make::expr_path(make::ext::ident_path(l_name));
let rhs = make::expr_path(make::ext::ident_path(r_name));
diff --git a/crates/ide_completion/src/completions/attribute/cfg.rs b/crates/ide_completion/src/completions/attribute/cfg.rs
index e53bf49174..58d0a39949 100644
--- a/crates/ide_completion/src/completions/attribute/cfg.rs
+++ b/crates/ide_completion/src/completions/attribute/cfg.rs
@@ -29,7 +29,7 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
Some("target_endian") => ["little", "big"].into_iter().for_each(add_completion),
Some(name) => {
if let Some(krate) = ctx.krate {
- krate.potential_cfg(ctx.db).get_cfg_values(&name).cloned().for_each(|s| {
+ krate.potential_cfg(ctx.db).get_cfg_values(name).cloned().for_each(|s| {
let insert_text = format!(r#""{}""#, s);
let mut item =
CompletionItem::new(SymbolKind::BuiltinAttr, ctx.source_range(), s);
diff --git a/crates/ide_completion/src/completions/fn_param.rs b/crates/ide_completion/src/completions/fn_param.rs
index 961681c20c..c5bc91d73d 100644
--- a/crates/ide_completion/src/completions/fn_param.rs
+++ b/crates/ide_completion/src/completions/fn_param.rs
@@ -31,7 +31,7 @@ pub(crate) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
CompletionItem::new(CompletionItemKind::Binding, ctx.source_range(), label)
};
let mut item = match &comma_wrapper {
- Some(fmt) => mk_item(&fmt(&label)),
+ Some(fmt) => mk_item(&fmt(label)),
None => mk_item(label),
};
item.lookup_by(lookup);
@@ -40,7 +40,7 @@ pub(crate) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
match param_kind {
ParamKind::Function(function) => {
- fill_fn_params(ctx, function, &param_list, add_new_item_to_acc);
+ fill_fn_params(ctx, function, param_list, add_new_item_to_acc);
}
ParamKind::Closure(closure) => {
let stmt_list = closure.syntax().ancestors().find_map(ast::StmtList::cast)?;
diff --git a/crates/ide_completion/src/completions/postfix.rs b/crates/ide_completion/src/completions/postfix.rs
index 23d4310aa9..ead957a3f1 100644
--- a/crates/ide_completion/src/completions/postfix.rs
+++ b/crates/ide_completion/src/completions/postfix.rs
@@ -51,7 +51,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
None => return,
};
- let postfix_snippet = match build_postfix_snippet_builder(ctx, cap, &dot_receiver) {
+ let postfix_snippet = match build_postfix_snippet_builder(ctx, cap, dot_receiver) {
Some(it) => it,
None => return,
};
@@ -265,7 +265,7 @@ fn add_custom_postfix_completions(
Some(imports) => imports,
None => return,
};
- let body = snippet.postfix_snippet(&receiver_text);
+ let body = snippet.postfix_snippet(receiver_text);
let mut builder =
postfix_snippet(trigger, snippet.description.as_deref().unwrap_or_default(), &body);
builder.documentation(Documentation::new(format!("```rust\n{}\n```", body)));
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs
index 86b1f534b2..ad93be4210 100644
--- a/crates/ide_completion/src/completions/qualified_path.rs
+++ b/crates/ide_completion/src/completions/qualified_path.rs
@@ -74,7 +74,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
}
_ => {
// Add associated types on type parameters and `Self`.
- ctx.scope.assoc_type_shorthand_candidates(&resolution, |_, alias| {
+ ctx.scope.assoc_type_shorthand_candidates(resolution, |_, alias| {
acc.add_type_alias(ctx, alias);
None::<()>
});
diff --git a/crates/ide_completion/src/completions/snippet.rs b/crates/ide_completion/src/completions/snippet.rs
index e4c4899477..673ee51f78 100644
--- a/crates/ide_completion/src/completions/snippet.rs
+++ b/crates/ide_completion/src/completions/snippet.rs
@@ -112,7 +112,7 @@ fn add_custom_completions(
None => return,
};
let body = snip.snippet();
- let mut builder = snippet(ctx, cap, &trigger, &body);
+ let mut builder = snippet(ctx, cap, trigger, &body);
builder.documentation(Documentation::new(format!("```rust\n{}\n```", body)));
for import in imports.into_iter() {
builder.add_import(import);
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index d3d8ec6cbe..fc48e642f0 100644
--- a/crates/ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
@@ -150,9 +150,9 @@ impl IdentClass {
sema: &Semantics<RootDatabase>,
lifetime: &ast::Lifetime,
) -> Option<IdentClass> {
- NameRefClass::classify_lifetime(sema, &lifetime)
+ NameRefClass::classify_lifetime(sema, lifetime)
.map(IdentClass::NameRefClass)
- .or_else(|| NameClass::classify_lifetime(sema, &lifetime).map(IdentClass::NameClass))
+ .or_else(|| NameClass::classify_lifetime(sema, lifetime).map(IdentClass::NameClass))
}
pub fn definitions(self) -> ArrayVec<Definition, 2> {
diff --git a/crates/ide_db/src/imports/merge_imports.rs b/crates/ide_db/src/imports/merge_imports.rs
index 71859b7fc7..9a9097ba5e 100644
--- a/crates/ide_db/src/imports/merge_imports.rs
+++ b/crates/ide_db/src/imports/merge_imports.rs
@@ -75,7 +75,7 @@ fn try_merge_trees_mut(lhs: &ast::UseTree, rhs: &ast::UseTree, merge: MergeBehav
lhs.split_prefix(&lhs_prefix);
rhs.split_prefix(&rhs_prefix);
}
- recursive_merge(&lhs, &rhs, merge)
+ recursive_merge(lhs, rhs, merge)
}
/// Recursively merges rhs to lhs
@@ -157,7 +157,7 @@ fn recursive_merge(lhs: &ast::UseTree, rhs: &ast::UseTree, merge: MergeBehavior)
}
lhs_t.split_prefix(&lhs_prefix);
rhs_t.split_prefix(&rhs_prefix);
- recursive_merge(&lhs_t, &rhs_t, merge)?;
+ recursive_merge(lhs_t, &rhs_t, merge)?;
}
Err(_)
if merge == MergeBehavior::Module
diff --git a/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs b/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs
index d59f13b9a1..0f1dd96f6f 100644
--- a/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs
+++ b/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs
@@ -69,7 +69,7 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
if indent > 0 {
mods.push(do_indent(after, tok, indent));
}
- mods.push(do_nl(after, &tok));
+ mods.push(do_nl(after, tok));
}
R_CURLY if is_last(|it| it != L_CURLY, true) => {
indent = indent.saturating_sub(1);
diff --git a/crates/ide_db/src/tests/sourcegen_lints.rs b/crates/ide_db/src/tests/sourcegen_lints.rs
index 44f8f21795..1555bad54e 100644
--- a/crates/ide_db/src/tests/sourcegen_lints.rs
+++ b/crates/ide_db/src/tests/sourcegen_lints.rs
@@ -85,7 +85,7 @@ fn generate_lint_descriptor(buf: &mut String) {
.sorted_by(|(ident, ..), (ident2, ..)| ident.cmp(ident2))
.collect::<Vec<_>>();
for (name, description, ..) in &lints {
- push_lint_completion(buf, &name.replace("-", "_"), &description);
+ push_lint_completion(buf, &name.replace("-", "_"), description);
}
buf.push_str("];\n");
buf.push_str(r#"pub const DEFAULT_LINT_GROUPS: &[LintGroup] = &["#);
@@ -93,10 +93,10 @@ fn generate_lint_descriptor(buf: &mut String) {
if !children.is_empty() {
// HACK: warnings is emitted with a general description, not with its members
if name == &"warnings" {
- push_lint_group(buf, &name, &description, &Vec::new());
+ push_lint_group(buf, name, description, &Vec::new());
continue;
}
- push_lint_group(buf, &name.replace("-", "_"), &description, children);
+ push_lint_group(buf, &name.replace("-", "_"), description, children);
}
}
buf.push('\n');
@@ -136,14 +136,14 @@ fn generate_lint_descriptor(buf: &mut String) {
.collect::<Vec<_>>();
for (name, description, ..) in &lints_rustdoc {
- push_lint_completion(buf, &name.replace("-", "_"), &description)
+ push_lint_completion(buf, &name.replace("-", "_"), description)
}
buf.push_str("];\n");
buf.push_str(r#"pub const RUSTDOC_LINT_GROUPS: &[LintGroup] = &["#);
for (name, description, children) in &lints_rustdoc {
if !children.is_empty() {
- push_lint_group(buf, &name.replace("-", "_"), &description, children);
+ push_lint_group(buf, &name.replace("-", "_"), description, children);
}
}
buf.push('\n');
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs
index 7e12647cd8..21a0aa4284 100644
--- a/crates/mbe/src/syntax_bridge.rs
+++ b/crates/mbe/src/syntax_bridge.rs
@@ -170,9 +170,9 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
Some(it) => it,
None => break,
};
- let synth_id = token.synthetic_id(&conv);
+ let synth_id = token.synthetic_id(conv);
- let kind = token.kind(&conv);
+ let kind = token.kind(conv);
if kind == COMMENT {
if let Some(tokens) = conv.convert_doc_comment(&token) {
// FIXME: There has to be a better way to do this
@@ -227,7 +227,7 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
continue;
}
- let spacing = match conv.peek().map(|next| next.kind(&conv)) {
+ let spacing = match conv.peek().map(|next| next.kind(conv)) {
Some(kind)
if !kind.is_trivia()
&& kind.is_punct()
@@ -240,7 +240,7 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
}
_ => tt::Spacing::Alone,
};
- let char = match token.to_char(&conv) {
+ let char = match token.to_char(conv) {
Some(c) => c,
None => {
panic!("Token from lexer must be single char: token = {:#?}", token);
diff --git a/crates/proc_macro_api/src/msg.rs b/crates/proc_macro_api/src/msg.rs
index da96c81d49..f9c2b9fda3 100644
--- a/crates/proc_macro_api/src/msg.rs
+++ b/crates/proc_macro_api/src/msg.rs
@@ -74,14 +74,11 @@ pub trait Message: Serialize + DeserializeOwned {
impl Message for Request {}
impl Message for Response {}
-fn read_json<'a>(
- inp: &mut impl BufRead,
- mut buf: &'a mut String,
-) -> io::Result<Option<&'a String>> {
+fn read_json<'a>(inp: &mut impl BufRead, buf: &'a mut String) -> io::Result<Option<&'a String>> {
loop {
buf.clear();
- inp.read_line(&mut buf)?;
+ inp.read_line(buf)?;
buf.pop(); // Remove trailing '\n'
if buf.is_empty() {
diff --git a/crates/proc_macro_srv/src/dylib.rs b/crates/proc_macro_srv/src/dylib.rs
index cc0b816a53..2b6c070fec 100644
--- a/crates/proc_macro_srv/src/dylib.rs
+++ b/crates/proc_macro_srv/src/dylib.rs
@@ -121,7 +121,7 @@ impl ProcMacroLibraryLibloading {
let abs_file: &AbsPath = file.try_into().map_err(|_| {
invalid_data_err(format!("expected an absolute path, got {}", file.display()))
})?;
- let version_info = read_dylib_info(&abs_file)?;
+ let version_info = read_dylib_info(abs_file)?;
let lib = load_library(file).map_err(invalid_data_err)?;
let abi = Abi::from_lib(&lib, symbol_name, version_info)?;
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs
index 5f936ee086..dd59923cb3 100644
--- a/crates/rust-analyzer/src/diagnostics/to_proto.rs
+++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs
@@ -24,7 +24,7 @@ fn diagnostic_severity(
// HACK: special case for `warnings` rustc lint.
Some(code)
if config.warnings_as_hint.iter().any(|lint| {
- lint == "warnings" || ide_db::helpers::lint_eq_or_in_group(&code.code, &lint)
+ lint == "warnings" || ide_db::helpers::lint_eq_or_in_group(&code.code, lint)
}) =>
{
lsp_types::DiagnosticSeverity::HINT
@@ -32,7 +32,7 @@ fn diagnostic_severity(
// HACK: special case for `warnings` rustc lint.
Some(code)
if config.warnings_as_info.iter().any(|lint| {
- lint == "warnings" || ide_db::helpers::lint_eq_or_in_group(&code.code, &lint)
+ lint == "warnings" || ide_db::helpers::lint_eq_or_in_group(&code.code, lint)
}) =>
{
lsp_types::DiagnosticSeverity::INFORMATION
diff --git a/crates/rust-analyzer/src/dispatch.rs b/crates/rust-analyzer/src/dispatch.rs
index 19aa33fe97..8a7ee7e9c2 100644
--- a/crates/rust-analyzer/src/dispatch.rs
+++ b/crates/rust-analyzer/src/dispatch.rs
@@ -48,7 +48,7 @@ impl<'a> RequestDispatcher<'a> {
};
let _pctx = stdx::panic_context::enter(panic_context);
- let result = f(&mut self.global_state, params);
+ let result = f(self.global_state, params);
let response = result_to_response::<R>(id, result);
self.global_state.respond(response);