Skip to content

Commit adbee62

Browse files
bors[bot]maan2003
andauthored
Merge #9242
9242: Clippy r=matklad a=Maan2003 Best viewed commit wise Co-authored-by: Maan2003 <manmeetmann2003@gmail.com>
2 parents f107b0f + 5ac6804 commit adbee62

File tree

134 files changed

+372
-402
lines changed

Some content is hidden

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

134 files changed

+372
-402
lines changed

crates/base_db/src/fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl From<Fixture> for FileMeta {
190190
edition: f
191191
.edition
192192
.as_ref()
193-
.map_or(Edition::Edition2018, |v| Edition::from_str(&v).unwrap()),
193+
.map_or(Edition::Edition2018, |v| Edition::from_str(v).unwrap()),
194194
env: f.env.into_iter().collect(),
195195
introduce_new_source_root: f.introduce_new_source_root,
196196
}

crates/hir/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ impl Module {
452452
}
453453

454454
pub fn visibility_of(self, db: &dyn HirDatabase, def: &ModuleDef) -> Option<Visibility> {
455-
self.id.def_map(db.upcast())[self.id.local_id].scope.visibility_of(def.clone().into())
455+
self.id.def_map(db.upcast())[self.id.local_id].scope.visibility_of((*def).into())
456456
}
457457

458458
pub fn diagnostics(
@@ -1112,7 +1112,7 @@ impl Function {
11121112
.collect();
11131113
sink.push(MissingFields {
11141114
file: source_ptr.file_id,
1115-
field_list_parent: AstPtr::new(&record_expr),
1115+
field_list_parent: AstPtr::new(record_expr),
11161116
field_list_parent_path: record_expr
11171117
.path()
11181118
.map(|path| AstPtr::new(&path)),
@@ -2531,13 +2531,13 @@ impl Type {
25312531
match ty.kind(&Interner) {
25322532
TyKind::Adt(_, substs) => {
25332533
cb(type_.derived(ty.clone()));
2534-
walk_substs(db, type_, &substs, cb);
2534+
walk_substs(db, type_, substs, cb);
25352535
}
25362536
TyKind::AssociatedType(_, substs) => {
25372537
if let Some(_) = ty.associated_type_parent_trait(db) {
25382538
cb(type_.derived(ty.clone()));
25392539
}
2540-
walk_substs(db, type_, &substs, cb);
2540+
walk_substs(db, type_, substs, cb);
25412541
}
25422542
TyKind::OpaqueType(_, subst) => {
25432543
if let Some(bounds) = ty.impl_trait_bounds(db) {
@@ -2577,7 +2577,7 @@ impl Type {
25772577
TyKind::FnDef(_, substs)
25782578
| TyKind::Tuple(_, substs)
25792579
| TyKind::Closure(.., substs) => {
2580-
walk_substs(db, type_, &substs, cb);
2580+
walk_substs(db, type_, substs, cb);
25812581
}
25822582
TyKind::Function(hir_ty::FnPointer { substitution, .. }) => {
25832583
walk_substs(db, type_, &substitution.0, cb);

crates/hir/src/semantics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
192192
node: &SyntaxNode,
193193
offset: TextSize,
194194
) -> Option<N> {
195-
if let Some(it) = find_node_at_offset(&node, offset) {
195+
if let Some(it) = find_node_at_offset(node, offset) {
196196
return Some(it);
197197
}
198198

@@ -744,7 +744,7 @@ impl<'db> SemanticsImpl<'db> {
744744
return None;
745745
}
746746

747-
let func = self.resolve_method_call(&method_call_expr).map(Function::from)?;
747+
let func = self.resolve_method_call(method_call_expr).map(Function::from)?;
748748
let res = match func.self_param(self.db)?.access(self.db) {
749749
Access::Shared | Access::Exclusive => true,
750750
Access::Owned => false,

crates/hir/src/source_analyzer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl SourceAnalyzer {
222222
Pat::Path(path) => path,
223223
_ => return None,
224224
};
225-
let res = resolve_hir_path(db, &self.resolver, &path)?;
225+
let res = resolve_hir_path(db, &self.resolver, path)?;
226226
match res {
227227
PathResolution::Def(def) => Some(def),
228228
_ => None,
@@ -329,7 +329,7 @@ impl SourceAnalyzer {
329329

330330
let (variant, missing_fields, _exhaustive) =
331331
record_literal_missing_fields(db, infer, expr_id, &body[expr_id])?;
332-
let res = self.missing_fields(db, krate, &substs, variant, missing_fields);
332+
let res = self.missing_fields(db, krate, substs, variant, missing_fields);
333333
Some(res)
334334
}
335335

@@ -347,7 +347,7 @@ impl SourceAnalyzer {
347347

348348
let (variant, missing_fields, _exhaustive) =
349349
record_pattern_missing_fields(db, infer, pat_id, &body[pat_id])?;
350-
let res = self.missing_fields(db, krate, &substs, variant, missing_fields);
350+
let res = self.missing_fields(db, krate, substs, variant, missing_fields);
351351
Some(res)
352352
}
353353

crates/hir_def/src/attr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,13 @@ impl AttrSourceMap {
583583
.get(id.ast_index as usize)
584584
.unwrap_or_else(|| panic!("cannot find doc comment at index {:?}", id))
585585
.clone()
586-
.map(|attr| Either::Right(attr))
586+
.map(Either::Right)
587587
} else {
588588
self.attrs
589589
.get(id.ast_index as usize)
590590
.unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", id))
591591
.clone()
592-
.map(|attr| Either::Left(attr))
592+
.map(Either::Left)
593593
}
594594
}
595595
}
@@ -606,7 +606,7 @@ pub struct DocsRangeMap {
606606
impl DocsRangeMap {
607607
pub fn map(&self, range: TextRange) -> Option<InFile<TextRange>> {
608608
let found = self.mapping.binary_search_by(|(probe, ..)| probe.ordering(range)).ok()?;
609-
let (line_docs_range, idx, original_line_src_range) = self.mapping[found].clone();
609+
let (line_docs_range, idx, original_line_src_range) = self.mapping[found];
610610
if !line_docs_range.contains_range(range) {
611611
return None;
612612
}

crates/hir_def/src/body/lower.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,18 +1000,18 @@ impl From<ast::LiteralKind> for Literal {
10001000
// FIXME: these should have actual values filled in, but unsure on perf impact
10011001
LiteralKind::IntNumber(lit) => {
10021002
if let builtin @ Some(_) = lit.suffix().and_then(BuiltinFloat::from_suffix) {
1003-
return Literal::Float(Default::default(), builtin);
1003+
Literal::Float(Default::default(), builtin)
10041004
} else if let builtin @ Some(_) =
1005-
lit.suffix().and_then(|it| BuiltinInt::from_suffix(&it))
1005+
lit.suffix().and_then(|it| BuiltinInt::from_suffix(it))
10061006
{
10071007
Literal::Int(lit.value().unwrap_or(0) as i128, builtin)
10081008
} else {
1009-
let builtin = lit.suffix().and_then(|it| BuiltinUint::from_suffix(&it));
1009+
let builtin = lit.suffix().and_then(|it| BuiltinUint::from_suffix(it));
10101010
Literal::Uint(lit.value().unwrap_or(0), builtin)
10111011
}
10121012
}
10131013
LiteralKind::FloatNumber(lit) => {
1014-
let ty = lit.suffix().and_then(|it| BuiltinFloat::from_suffix(&it));
1014+
let ty = lit.suffix().and_then(|it| BuiltinFloat::from_suffix(it));
10151015
Literal::Float(Default::default(), ty)
10161016
}
10171017
LiteralKind::ByteString(bs) => {

crates/hir_def/src/body/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
198198
}
199199
Expr::Lambda { args, body: body_expr, .. } => {
200200
let scope = scopes.new_scope(scope);
201-
scopes.add_params_bindings(body, scope, &args);
201+
scopes.add_params_bindings(body, scope, args);
202202
compute_expr_scopes(*body_expr, body, scopes, scope);
203203
}
204204
Expr::Match { expr, arms } => {

crates/hir_def/src/generics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl GenericParams {
280280
sm.type_params.insert(param_id, Either::Right(type_param.clone()));
281281

282282
let type_ref = TypeRef::Path(name.into());
283-
self.fill_bounds(&lower_ctx, &type_param, Either::Left(type_ref));
283+
self.fill_bounds(lower_ctx, &type_param, Either::Left(type_ref));
284284
}
285285
for lifetime_param in params.lifetime_params() {
286286
let name =
@@ -289,7 +289,7 @@ impl GenericParams {
289289
let param_id = self.lifetimes.alloc(param);
290290
sm.lifetime_params.insert(param_id, lifetime_param.clone());
291291
let lifetime_ref = LifetimeRef::new_name(name);
292-
self.fill_bounds(&lower_ctx, &lifetime_param, Either::Right(lifetime_ref));
292+
self.fill_bounds(lower_ctx, &lifetime_param, Either::Right(lifetime_ref));
293293
}
294294
for const_param in params.const_params() {
295295
let name = const_param.name().map_or_else(Name::missing, |it| it.as_name());

crates/hir_def/src/item_scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub struct ItemScope {
5959
pub(crate) static BUILTIN_SCOPE: Lazy<FxHashMap<Name, PerNs>> = Lazy::new(|| {
6060
BuiltinType::ALL
6161
.iter()
62-
.map(|(name, ty)| (name.clone(), PerNs::types(ty.clone().into(), Visibility::Public)))
62+
.map(|(name, ty)| (name.clone(), PerNs::types((*ty).into(), Visibility::Public)))
6363
.collect()
6464
});
6565

crates/hir_def/src/item_tree/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ fn is_intrinsic_fn_unsafe(name: &Name) -> bool {
823823
known::type_name,
824824
known::variant_count,
825825
]
826-
.contains(&name)
826+
.contains(name)
827827
}
828828

829829
fn lower_abi(abi: ast::Abi) -> Interned<str> {
@@ -855,7 +855,7 @@ impl UseTreeLowering<'_> {
855855
// E.g. `use something::{inner}` (prefix is `None`, path is `something`)
856856
// or `use something::{path::{inner::{innerer}}}` (prefix is `something::path`, path is `inner`)
857857
Some(path) => {
858-
match ModPath::from_src(self.db, path, &self.hygiene) {
858+
match ModPath::from_src(self.db, path, self.hygiene) {
859859
Some(it) => Some(it),
860860
None => return None, // FIXME: report errors somewhere
861861
}
@@ -874,7 +874,7 @@ impl UseTreeLowering<'_> {
874874
} else {
875875
let is_glob = tree.star_token().is_some();
876876
let path = match tree.path() {
877-
Some(path) => Some(ModPath::from_src(self.db, path, &self.hygiene)?),
877+
Some(path) => Some(ModPath::from_src(self.db, path, self.hygiene)?),
878878
None => None,
879879
};
880880
let alias = tree.rename().map(|a| {

0 commit comments

Comments
 (0)