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

Commit 3839f9a

Browse files
committed
needless_borrow
1 parent d351cb8 commit 3839f9a

File tree

9 files changed

+14
-15
lines changed

9 files changed

+14
-15
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ field_reassign_with_default = "allow"
175175
forget_non_drop = "allow"
176176
format_collect = "allow"
177177
large_enum_variant = "allow"
178-
needless_borrow = "allow"
179178
needless_doctest_main = "allow"
180179
needless_lifetimes = "allow"
181180
needless_pass_by_value = "allow"

crates/hir-def/src/body/lower.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,8 +1844,8 @@ impl ExprCollector<'_> {
18441844
flags as u128,
18451845
Some(BuiltinUint::U32),
18461846
)));
1847-
let precision = self.make_count(&precision, argmap);
1848-
let width = self.make_count(&width, argmap);
1847+
let precision = self.make_count(precision, argmap);
1848+
let width = self.make_count(width, argmap);
18491849

18501850
let format_placeholder_new = {
18511851
let format_placeholder_new =

crates/hir-def/src/find_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn find_path_for_module(
230230
}
231231

232232
if let value @ Some(_) =
233-
find_in_prelude(ctx.db, &root_def_map, &def_map, ItemInNs::Types(module_id.into()), from)
233+
find_in_prelude(ctx.db, &root_def_map, def_map, ItemInNs::Types(module_id.into()), from)
234234
{
235235
return value.zip(Some(Stable));
236236
}

crates/hir-def/src/import_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,14 @@ impl SearchMode {
294294
pub fn check(self, query: &str, case_sensitive: bool, candidate: &str) -> bool {
295295
match self {
296296
SearchMode::Exact if case_sensitive => candidate == query,
297-
SearchMode::Exact => candidate.eq_ignore_ascii_case(&query),
297+
SearchMode::Exact => candidate.eq_ignore_ascii_case(query),
298298
SearchMode::Prefix => {
299299
query.len() <= candidate.len() && {
300300
let prefix = &candidate[..query.len() as usize];
301301
if case_sensitive {
302302
prefix == query
303303
} else {
304-
prefix.eq_ignore_ascii_case(&query)
304+
prefix.eq_ignore_ascii_case(query)
305305
}
306306
}
307307
}

crates/hir-def/src/lang_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl LangItems {
192192

193193
pub(crate) fn lang_attr(db: &dyn DefDatabase, item: AttrDefId) -> Option<LangItem> {
194194
let attrs = db.attrs(item);
195-
attrs.by_key("lang").string_value().and_then(|it| LangItem::from_str(&it))
195+
attrs.by_key("lang").string_value().and_then(|it| LangItem::from_str(it))
196196
}
197197

198198
pub(crate) fn notable_traits_in_deps(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ impl DefCollector<'_> {
14061406
}
14071407
if let errors @ [_, ..] = &*value {
14081408
let loc: MacroCallLoc = self.db.lookup_intern_macro_call(macro_call_id);
1409-
let diag = DefDiagnostic::macro_expansion_parse_error(module_id, loc.kind, &errors);
1409+
let diag = DefDiagnostic::macro_expansion_parse_error(module_id, loc.kind, errors);
14101410
self.def_map.diagnostics.push(diag);
14111411
}
14121412

@@ -2287,7 +2287,7 @@ impl ModCollector<'_, '_> {
22872287
&MacroCall { ref path, ast_id, expand_to, call_site }: &MacroCall,
22882288
container: ItemContainerId,
22892289
) {
2290-
let ast_id = AstIdWithPath::new(self.file_id(), ast_id, ModPath::clone(&path));
2290+
let ast_id = AstIdWithPath::new(self.file_id(), ast_id, ModPath::clone(path));
22912291
let db = self.def_collector.db;
22922292

22932293
// FIXME: Immediately expanding in "Case 1" is insufficient since "Case 2" may also define

crates/hir-def/src/path.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Path {
154154

155155
pub fn mod_path(&self) -> Option<&ModPath> {
156156
match self {
157-
Path::Normal { mod_path, .. } => Some(&mod_path),
157+
Path::Normal { mod_path, .. } => Some(mod_path),
158158
Path::LangItem(..) => None,
159159
}
160160
}
@@ -219,13 +219,13 @@ impl<'a> PathSegments<'a> {
219219
}
220220
pub fn skip(&self, len: usize) -> PathSegments<'a> {
221221
PathSegments {
222-
segments: &self.segments.get(len..).unwrap_or(&[]),
222+
segments: self.segments.get(len..).unwrap_or(&[]),
223223
generic_args: self.generic_args.and_then(|it| it.get(len..)),
224224
}
225225
}
226226
pub fn take(&self, len: usize) -> PathSegments<'a> {
227227
PathSegments {
228-
segments: &self.segments.get(..len).unwrap_or(&self.segments),
228+
segments: self.segments.get(..len).unwrap_or(self.segments),
229229
generic_args: self.generic_args.map(|it| it.get(..len).unwrap_or(it)),
230230
}
231231
}

crates/hir/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ impl Adt {
14391439
resolver
14401440
.generic_params()
14411441
.and_then(|gp| {
1442-
(&gp.lifetimes)
1442+
gp.lifetimes
14431443
.iter()
14441444
// there should only be a single lifetime
14451445
// but `Arena` requires to use an iterator
@@ -4286,7 +4286,7 @@ impl Type {
42864286
) -> impl Iterator<Item = SmolStr> + 'a {
42874287
// iterate the lifetime
42884288
self.as_adt()
4289-
.and_then(|a| a.lifetime(db).map(|lt| (&lt.name).to_smol_str()))
4289+
.and_then(|a| a.lifetime(db).map(|lt| lt.name.to_smol_str()))
42904290
.into_iter()
42914291
// add the type and const parameters
42924292
.chain(self.type_and_const_arguments(db))

crates/ide-ssr/src/matching.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ impl Iterator for PatternIterator {
764764
type Item = SyntaxElement;
765765

766766
fn next(&mut self) -> Option<SyntaxElement> {
767-
(&mut self.iter).find(|element| !element.kind().is_trivia())
767+
self.iter.find(|element| !element.kind().is_trivia())
768768
}
769769
}
770770

0 commit comments

Comments
 (0)