Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ed12887

Browse files
committed
remove needless borrows
1 parent 7705167 commit ed12887

File tree

53 files changed

+87
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+87
-87
lines changed

crates/hir-def/src/data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl<'a> AssocItemCollector<'a> {
542542
if !attrs.is_cfg_enabled(self.expander.cfg_options()) {
543543
self.inactive_diagnostics.push(DefDiagnostic::unconfigured_code(
544544
self.module_id.local_id,
545-
InFile::new(self.expander.current_file_id(), item.ast_id(&item_tree).upcast()),
545+
InFile::new(self.expander.current_file_id(), item.ast_id(item_tree).upcast()),
546546
attrs.cfg().unwrap(),
547547
self.expander.cfg_options().clone(),
548548
));
@@ -551,7 +551,7 @@ impl<'a> AssocItemCollector<'a> {
551551

552552
'attrs: for attr in &*attrs {
553553
let ast_id =
554-
AstId::new(self.expander.current_file_id(), item.ast_id(&item_tree).upcast());
554+
AstId::new(self.expander.current_file_id(), item.ast_id(item_tree).upcast());
555555
let ast_id_with_path = AstIdWithPath { path: (*attr.path).clone(), ast_id };
556556

557557
if let Ok(ResolvedAttr::Macro(call_id)) = self.def_map.resolve_attr_macro(

crates/hir-def/src/find_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn find_path_for_module(
176176

177177
// - if relative paths are fine, check if we are searching for a parent
178178
if prefixed.filter(PrefixKind::is_absolute).is_none() {
179-
if let modpath @ Some(_) = find_self_super(&def_map, module_id, from) {
179+
if let modpath @ Some(_) = find_self_super(def_map, module_id, from) {
180180
return modpath;
181181
}
182182
}

crates/hir-def/src/nameres/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ impl DefCollector<'_> {
10941094
ast_id,
10951095
*expand_to,
10961096
self.def_map.krate,
1097-
&resolver_def_id,
1097+
resolver_def_id,
10981098
&mut |_err| (),
10991099
);
11001100
if let Ok(Ok(call_id)) = call_id {
@@ -1110,7 +1110,7 @@ impl DefCollector<'_> {
11101110
*derive_attr,
11111111
*derive_pos as u32,
11121112
self.def_map.krate,
1113-
&resolver,
1113+
resolver,
11141114
);
11151115

11161116
if let Ok((macro_id, def_id, call_id)) = id {

crates/hir-expand/src/builtin_attr_macro.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ pub fn pseudo_derive_attr_expansion(
115115
};
116116

117117
let mut token_trees = Vec::new();
118-
for tt in (&args.token_trees)
118+
for tt in args
119+
.token_trees
119120
.split(|tt| matches!(tt, tt::TokenTree::Leaf(tt::Leaf::Punct(tt::Punct { char: ',', .. }))))
120121
{
121122
token_trees.push(mk_leaf('#'));

crates/hir-expand/src/name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'a> UnescapedName<'a> {
6262
it.clone()
6363
}
6464
}
65-
Repr::TupleField(it) => SmolStr::new(&it.to_string()),
65+
Repr::TupleField(it) => SmolStr::new(it.to_string()),
6666
}
6767
}
6868
}
@@ -139,7 +139,7 @@ impl Name {
139139
pub fn to_smol_str(&self) -> SmolStr {
140140
match &self.0 {
141141
Repr::Text(it) => it.clone(),
142-
Repr::TupleField(it) => SmolStr::new(&it.to_string()),
142+
Repr::TupleField(it) => SmolStr::new(it.to_string()),
143143
}
144144
}
145145

crates/hir-ty/src/consteval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ pub(crate) fn path_to_const(
404404
args_lazy: impl FnOnce() -> Generics,
405405
debruijn: DebruijnIndex,
406406
) -> Option<Const> {
407-
match resolver.resolve_path_in_value_ns_fully(db.upcast(), &path) {
407+
match resolver.resolve_path_in_value_ns_fully(db.upcast(), path) {
408408
Some(ValueNs::GenericParam(p)) => {
409409
let ty = db.const_param_ty(p);
410410
let args = args_lazy();

crates/hir-ty/src/infer/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ impl<'a> InferenceContext<'a> {
13351335
ty,
13361336
c,
13371337
ParamLoweringMode::Placeholder,
1338-
|| generics(this.db.upcast(), (&this.resolver).generic_def().unwrap()),
1338+
|| generics(this.db.upcast(), this.resolver.generic_def().unwrap()),
13391339
DebruijnIndex::INNERMOST,
13401340
)
13411341
},

crates/hir-ty/src/infer/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'a> InferenceContext<'a> {
153153
) -> Ty {
154154
let mut expected = self.resolve_ty_shallow(expected);
155155

156-
if is_non_ref_pat(&self.body, pat) {
156+
if is_non_ref_pat(self.body, pat) {
157157
let mut pat_adjustments = Vec::new();
158158
while let Some((inner, _lifetime, mutability)) = expected.as_reference() {
159159
pat_adjustments.push(expected.clone());

crates/hir-ty/src/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub fn layout_of_ty(db: &dyn HirDatabase, ty: &Ty, krate: CrateId) -> Result<Lay
241241

242242
fn layout_of_unit(cx: &LayoutCx<'_>, dl: &TargetDataLayout) -> Result<Layout, LayoutError> {
243243
cx.univariant::<RustcEnumVariantIdx, &&Layout>(
244-
&dl,
244+
dl,
245245
&[],
246246
&ReprOptions::default(),
247247
StructKind::AlwaysSized,

crates/hir-ty/src/layout/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use super::layout_of_ty;
1212
fn eval_goal(ra_fixture: &str, minicore: &str) -> Result<Layout, LayoutError> {
1313
// using unstable cargo features failed, fall back to using plain rustc
1414
let mut cmd = std::process::Command::new("rustc");
15-
cmd.args(&["-Z", "unstable-options", "--print", "target-spec-json"])
16-
.env("RUSTC_BOOTSTRAP", "1");
15+
cmd.args(["-Z", "unstable-options", "--print", "target-spec-json"]).env("RUSTC_BOOTSTRAP", "1");
1716
let output = cmd.output().unwrap();
1817
assert!(output.status.success(), "{}", output.status);
1918
let stdout = String::from_utf8(output.stdout).unwrap();

crates/hir-ty/src/lower.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ impl<'a> TyLoweringContext<'a> {
780780
|_, c, ty| {
781781
const_or_path_to_chalk(
782782
self.db,
783-
&self.resolver,
783+
self.resolver,
784784
ty,
785785
c,
786786
self.type_param_mode,
@@ -1852,7 +1852,7 @@ pub(crate) fn return_type_impl_traits(
18521852
let ctx_ret = TyLoweringContext::new(db, &resolver)
18531853
.with_impl_trait_mode(ImplTraitLoweringMode::Opaque)
18541854
.with_type_param_mode(ParamLoweringMode::Variable);
1855-
let _ret = (&ctx_ret).lower_ty(&data.ret_type);
1855+
let _ret = ctx_ret.lower_ty(&data.ret_type);
18561856
let generics = generics(db.upcast(), def.into());
18571857
let return_type_impl_traits =
18581858
ReturnTypeImplTraits { impl_traits: ctx_ret.opaque_type_data.into_inner() };

crates/hir-ty/src/method_resolution.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ fn iterate_method_candidates_by_receiver(
926926
while let Some((self_ty, _)) = autoderef.next() {
927927
iterate_inherent_methods(
928928
&self_ty,
929-
&mut autoderef.table,
929+
autoderef.table,
930930
name,
931931
Some(&receiver_ty),
932932
Some(receiver_adjustments.clone()),
@@ -941,7 +941,7 @@ fn iterate_method_candidates_by_receiver(
941941
while let Some((self_ty, _)) = autoderef.next() {
942942
iterate_trait_method_candidates(
943943
&self_ty,
944-
&mut autoderef.table,
944+
autoderef.table,
945945
traits_in_scope,
946946
name,
947947
Some(&receiver_ty),
@@ -1246,7 +1246,7 @@ fn is_valid_candidate(
12461246
let expected_self_ty = TyBuilder::impl_self_ty(db, impl_id)
12471247
.fill_with_inference_vars(table)
12481248
.build();
1249-
table.unify(&expected_self_ty, &self_ty)
1249+
table.unify(&expected_self_ty, self_ty)
12501250
});
12511251
if !self_ty_matches {
12521252
cov_mark::hit!(const_candidate_self_type_mismatch);

crates/hir/src/semantics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ impl<'db> SemanticsImpl<'db> {
12521252

12531253
fn to_def<T: ToDef>(&self, src: &T) -> Option<T::Def> {
12541254
let src = self.find_file(src.syntax()).with_value(src).cloned();
1255-
T::to_def(&self, src)
1255+
T::to_def(self, src)
12561256
}
12571257

12581258
fn to_module_def(&self, file: FileId) -> impl Iterator<Item = Module> {

crates/hir/src/source_analyzer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl SourceAnalyzer {
228228
db: &dyn HirDatabase,
229229
pat: &ast::Pat,
230230
) -> Option<SmallVec<[Type; 1]>> {
231-
let pat_id = self.pat_id(&pat)?;
231+
let pat_id = self.pat_id(pat)?;
232232
let infer = self.infer.as_ref()?;
233233
Some(
234234
infer
@@ -824,7 +824,7 @@ impl SourceAnalyzer {
824824
}
825825

826826
fn ty_of_expr(&self, db: &dyn HirDatabase, expr: &ast::Expr) -> Option<&Ty> {
827-
self.infer.as_ref()?.type_of_expr.get(self.expr_id(db, &expr)?)
827+
self.infer.as_ref()?.type_of_expr.get(self.expr_id(db, expr)?)
828828
}
829829
}
830830

crates/ide-assists/src/handlers/add_return_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ pub(crate) fn add_return_type(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt
3535
match builder_edit_pos {
3636
InsertOrReplace::Insert(insert_pos, needs_whitespace) => {
3737
let preceeding_whitespace = if needs_whitespace { " " } else { "" };
38-
builder.insert(insert_pos, &format!("{preceeding_whitespace}-> {ty} "))
38+
builder.insert(insert_pos, format!("{preceeding_whitespace}-> {ty} "))
3939
}
4040
InsertOrReplace::Replace(text_range) => {
41-
builder.replace(text_range, &format!("-> {ty}"))
41+
builder.replace(text_range, format!("-> {ty}"))
4242
}
4343
}
4444
if let FnType::Closure { wrap_expr: true } = fn_type {
4545
cov_mark::hit!(wrap_closure_non_block_expr);
4646
// `|x| x` becomes `|x| -> T x` which is invalid, so wrap it in a block
47-
builder.replace(tail_expr.syntax().text_range(), &format!("{{{tail_expr}}}"));
47+
builder.replace(tail_expr.syntax().text_range(), format!("{{{tail_expr}}}"));
4848
}
4949
},
5050
)

crates/ide-assists/src/handlers/auto_import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn relevance_score(
203203
// get the distance between the imported path and the current module
204204
// (prefer items that are more local)
205205
Some((item_module, current_module)) => {
206-
score -= module_distance_hueristic(db, &current_module, &item_module) as i32;
206+
score -= module_distance_hueristic(db, current_module, &item_module) as i32;
207207
}
208208

209209
// could not find relevant modules, so just use the length of the path as an estimate

crates/ide-assists/src/handlers/generate_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn make_tuple_field_list(
180180
) -> Option<ast::FieldList> {
181181
let args = call_expr.arg_list()?.args();
182182
let tuple_fields = args.map(|arg| {
183-
let ty = expr_ty(ctx, arg, &scope).unwrap_or_else(make::ty_placeholder);
183+
let ty = expr_ty(ctx, arg, scope).unwrap_or_else(make::ty_placeholder);
184184
make::tuple_field(None, ty)
185185
});
186186
Some(make::tuple_field_list(tuple_fields).into())

crates/ide-assists/src/handlers/generate_getter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub(crate) fn generate_getter_impl(
176176
// for separating it from other assoc items, that needs
177177
// to be handled spearately
178178
let mut getter_buf =
179-
generate_getter_from_info(ctx, &getter_info, &record_field_info);
179+
generate_getter_from_info(ctx, &getter_info, record_field_info);
180180

181181
// Insert `$0` only for last getter we generate
182182
if i == record_fields_count - 1 {

crates/ide-assists/src/handlers/generate_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
7070
)?;
7171

7272
let expr = use_trivial_constructor(
73-
&ctx.sema.db,
73+
ctx.sema.db,
7474
ide_db::helpers::mod_path_to_ast(&type_path),
7575
&ty,
7676
)?;

crates/ide-assists/src/handlers/inline_type_alias.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub(crate) fn inline_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
138138
replacement = Replacement::Plain;
139139
}
140140
_ => {
141-
let alias = get_type_alias(&ctx, &alias_instance)?;
141+
let alias = get_type_alias(ctx, &alias_instance)?;
142142
concrete_type = alias.ty()?;
143143
replacement = inline(&alias, &alias_instance)?;
144144
}
@@ -158,7 +158,7 @@ impl Replacement {
158158
fn to_text(&self, concrete_type: &ast::Type) -> String {
159159
match self {
160160
Replacement::Generic { lifetime_map, const_and_type_map } => {
161-
create_replacement(&lifetime_map, &const_and_type_map, &concrete_type)
161+
create_replacement(lifetime_map, const_and_type_map, concrete_type)
162162
}
163163
Replacement::Plain => concrete_type.to_string(),
164164
}
@@ -240,7 +240,7 @@ impl ConstAndTypeMap {
240240
) -> Option<Self> {
241241
let mut inner = HashMap::new();
242242
let instance_generics = generic_args_to_const_and_type_generics(instance_args);
243-
let alias_generics = generic_param_list_to_const_and_type_generics(&alias_generics);
243+
let alias_generics = generic_param_list_to_const_and_type_generics(alias_generics);
244244

245245
if instance_generics.len() > alias_generics.len() {
246246
cov_mark::hit!(too_many_generic_args);

crates/ide-assists/src/handlers/unnecessary_async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn find_all_references(
107107
/// If no await expression is found, returns None.
108108
fn find_await_expression(ctx: &AssistContext<'_>, nameref: &NameRef) -> Option<ast::AwaitExpr> {
109109
// From the nameref, walk up the tree to the await expression.
110-
let await_expr = if let Some(path) = full_path_of_name_ref(&nameref) {
110+
let await_expr = if let Some(path) = full_path_of_name_ref(nameref) {
111111
// Function calls.
112112
path.syntax()
113113
.parent()

crates/ide-completion/src/completions/dot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ pub(crate) fn complete_dot(
3232
complete_fields(
3333
acc,
3434
ctx,
35-
&receiver_ty,
35+
receiver_ty,
3636
|acc, field, ty| acc.add_field(ctx, dot_access, None, field, &ty),
3737
|acc, field, ty| acc.add_tuple_field(ctx, None, field, &ty),
3838
);
3939
}
40-
complete_methods(ctx, &receiver_ty, |func| acc.add_method(ctx, dot_access, func, None, None));
40+
complete_methods(ctx, receiver_ty, |func| acc.add_method(ctx, dot_access, func, None, None));
4141
}
4242

4343
pub(crate) fn complete_undotted_self(

crates/ide-completion/src/completions/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) fn complete_expr_path(
6464
acc.add_enum_variants(ctx, path_ctx, e);
6565
}
6666

67-
ctx.iterate_path_candidates(&ty, |item| {
67+
ctx.iterate_path_candidates(ty, |item| {
6868
add_assoc_item(acc, item);
6969
});
7070

crates/ide-completion/src/completions/format_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) fn format_string(
1313
original: &ast::String,
1414
expanded: &ast::String,
1515
) {
16-
if !is_format_string(&expanded) {
16+
if !is_format_string(expanded) {
1717
return;
1818
}
1919
let cursor = ctx.position.offset;

crates/ide-completion/src/completions/type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn complete_type_path(
5858
trait_.items(ctx.sema.db).into_iter().for_each(|item| add_assoc_item(acc, item))
5959
}
6060
Qualified::TypeAnchor { ty: Some(ty), trait_: None } => {
61-
ctx.iterate_path_candidates(&ty, |item| {
61+
ctx.iterate_path_candidates(ty, |item| {
6262
add_assoc_item(acc, item);
6363
});
6464

crates/ide-completion/src/context/analysis.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ fn analyze(
226226
find_node_at_offset(&file_with_fake_ident, offset)
227227
{
228228
let parent = name_ref.syntax().parent()?;
229-
let (mut nameref_ctx, _) = classify_name_ref(&sema, &original_file, name_ref, parent)?;
229+
let (mut nameref_ctx, _) = classify_name_ref(sema, &original_file, name_ref, parent)?;
230230
if let NameRefKind::Path(path_ctx) = &mut nameref_ctx.kind {
231231
path_ctx.kind = PathKind::Derive {
232232
existing_derives: sema
@@ -277,7 +277,7 @@ fn analyze(
277277
return Some((analysis, (None, None), QualifierCtx::default()));
278278
}
279279
};
280-
let expected = expected_type_and_name(sema, &self_token, &name_like);
280+
let expected = expected_type_and_name(sema, self_token, &name_like);
281281
let mut qual_ctx = QualifierCtx::default();
282282
let analysis = match name_like {
283283
ast::NameLike::Lifetime(lifetime) => {
@@ -374,7 +374,7 @@ fn expected_type_and_name(
374374
ast::ArgList(_) => {
375375
cov_mark::hit!(expected_type_fn_param);
376376
ActiveParameter::at_token(
377-
&sema,
377+
sema,
378378
token.clone(),
379379
).map(|ap| {
380380
let name = ap.ident().map(NameOrNameRef::Name);
@@ -507,7 +507,7 @@ fn classify_lifetime(
507507
_ => LifetimeKind::Lifetime,
508508
}
509509
};
510-
let lifetime = find_node_at_offset(&original_file, lifetime.syntax().text_range().start());
510+
let lifetime = find_node_at_offset(original_file, lifetime.syntax().text_range().start());
511511

512512
Some(LifetimeContext { lifetime, kind })
513513
}
@@ -548,7 +548,7 @@ fn classify_name(
548548
_ => return None,
549549
}
550550
};
551-
let name = find_node_at_offset(&original_file, name.syntax().text_range().start());
551+
let name = find_node_at_offset(original_file, name.syntax().text_range().start());
552552
Some(NameContext { name, kind })
553553
}
554554

@@ -558,7 +558,7 @@ fn classify_name_ref(
558558
name_ref: ast::NameRef,
559559
parent: SyntaxNode,
560560
) -> Option<(NameRefContext, QualifierCtx)> {
561-
let nameref = find_node_at_offset(&original_file, name_ref.syntax().text_range().start());
561+
let nameref = find_node_at_offset(original_file, name_ref.syntax().text_range().start());
562562

563563
let make_res = |kind| (NameRefContext { nameref: nameref.clone(), kind }, Default::default());
564564

crates/ide-completion/src/render/union_literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub(crate) fn render_union_literal(
6868

6969
item.set_documentation(ctx.docs(un))
7070
.set_deprecated(ctx.is_deprecated(un))
71-
.detail(&detail)
71+
.detail(detail)
7272
.set_relevance(ctx.completion_relevance());
7373

7474
match ctx.snippet_cap() {

crates/ide-diagnostics/src/handlers/missing_fields.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
128128
)?;
129129

130130
use_trivial_constructor(
131-
&ctx.sema.db,
131+
ctx.sema.db,
132132
ide_db::helpers::mod_path_to_ast(&type_path),
133-
&ty,
133+
ty,
134134
)
135135
})();
136136

0 commit comments

Comments
 (0)