Skip to content

Commit 7537031

Browse files
committed
clippy::redundant_closure
1 parent 705f7e6 commit 7537031

File tree

12 files changed

+17
-17
lines changed

12 files changed

+17
-17
lines changed

crates/hir_def/src/attr.rs

Lines changed: 2 additions & 2 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
}

crates/hir_ty/src/chalk_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pub(crate) fn trait_datum_query(
431431
};
432432
let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars);
433433
let associated_ty_ids =
434-
trait_data.associated_types().map(|type_alias| to_assoc_type_id(type_alias)).collect();
434+
trait_data.associated_types().map(to_assoc_type_id).collect();
435435
let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses };
436436
let well_known =
437437
lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name));

crates/hir_ty/src/consteval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn usize_const(value: Option<u64>) -> Const {
4949
ConstData {
5050
ty: TyKind::Scalar(chalk_ir::Scalar::Uint(chalk_ir::UintTy::Usize)).intern(&Interner),
5151
value: ConstValue::Concrete(chalk_ir::ConcreteConst {
52-
interned: value.map(|value| ConstScalar::Usize(value)).unwrap_or(ConstScalar::Unknown),
52+
interned: value.map(ConstScalar::Usize).unwrap_or(ConstScalar::Unknown),
5353
}),
5454
}
5555
.intern(&Interner)

crates/hir_ty/src/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<'a> TyLoweringContext<'a> {
784784
let trait_ref = match bound {
785785
TypeBound::Path(path) => {
786786
bindings = self.lower_trait_ref_from_path(path, Some(self_ty));
787-
bindings.clone().map(WhereClause::Implemented).map(|b| crate::wrap_empty_binders(b))
787+
bindings.clone().map(WhereClause::Implemented).map(crate::wrap_empty_binders)
788788
}
789789
TypeBound::Lifetime(_) => None,
790790
TypeBound::Error => None,

crates/hir_ty/src/method_resolution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl TyFingerprint {
6060
TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt),
6161
TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability),
6262
TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id),
63-
TyKind::Dyn(_) => ty.dyn_trait().map(|trait_| TyFingerprint::Dyn(trait_))?,
63+
TyKind::Dyn(_) => ty.dyn_trait().map(TyFingerprint::Dyn)?,
6464
_ => return None,
6565
};
6666
Some(fp)
@@ -77,7 +77,7 @@ impl TyFingerprint {
7777
TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt),
7878
TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability),
7979
TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id),
80-
TyKind::Dyn(_) => ty.dyn_trait().map(|trait_| TyFingerprint::Dyn(trait_))?,
80+
TyKind::Dyn(_) => ty.dyn_trait().map(TyFingerprint::Dyn)?,
8181
TyKind::Ref(_, _, ty) => return TyFingerprint::for_trait_impl(ty),
8282
TyKind::Tuple(_, subst) => {
8383
let first_ty = subst.interned().get(0).map(|arg| arg.assert_ty_ref(&Interner));

crates/ide/src/hover.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ fn runnable_action(
288288
) -> Option<HoverAction> {
289289
match def {
290290
Definition::ModuleDef(it) => match it {
291-
ModuleDef::Module(it) => runnable_mod(sema, it).map(|it| HoverAction::Runnable(it)),
291+
ModuleDef::Module(it) => runnable_mod(sema, it).map(HoverAction::Runnable),
292292
ModuleDef::Function(func) => {
293293
let src = func.source(sema.db)?;
294294
if src.file_id != file_id.into() {

crates/ide/src/references/rename.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ fn text_edit_from_self_param(self_param: &ast::SelfParam, new_name: &str) -> Opt
426426
None
427427
}
428428

429-
let impl_def = self_param.syntax().ancestors().find_map(|it| ast::Impl::cast(it))?;
429+
let impl_def = self_param.syntax().ancestors().find_map(ast::Impl::cast)?;
430430
let type_name = target_type_name(&impl_def)?;
431431

432432
let mut replacement_text = String::from(new_name);

crates/ide_assists/src/handlers/apply_demorgan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<(
7878
terms.sort_by_key(|t| t.syntax().text_range().start());
7979
let mut terms = VecDeque::from(terms);
8080

81-
let paren_expr = expr.syntax().parent().and_then(|parent| ast::ParenExpr::cast(parent));
81+
let paren_expr = expr.syntax().parent().and_then(ast::ParenExpr::cast);
8282

8383
let neg_expr = paren_expr
8484
.clone()
8585
.and_then(|paren_expr| paren_expr.syntax().parent())
86-
.and_then(|parent| ast::PrefixExpr::cast(parent))
86+
.and_then(ast::PrefixExpr::cast)
8787
.and_then(|prefix_expr| {
8888
if prefix_expr.op_kind().unwrap() == ast::PrefixOp::Not {
8989
Some(prefix_expr)

crates/ide_assists/src/handlers/fill_match_arms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl ExtendedEnum {
202202
fn variants(self, db: &RootDatabase) -> Vec<ExtendedVariant> {
203203
match self {
204204
ExtendedEnum::Enum(e) => {
205-
e.variants(db).into_iter().map(|x| ExtendedVariant::Variant(x)).collect::<Vec<_>>()
205+
e.variants(db).into_iter().map(ExtendedVariant::Variant).collect::<Vec<_>>()
206206
}
207207
ExtendedEnum::Bool => {
208208
Vec::<ExtendedVariant>::from([ExtendedVariant::True, ExtendedVariant::False])

crates/ide_completion/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<'a> CompletionContext<'a> {
380380
(|| {
381381
let expr_field = self.token.prev_sibling_or_token()?
382382
.into_node()
383-
.and_then(|node| ast::RecordExprField::cast(node))?;
383+
.and_then(ast::RecordExprField::cast)?;
384384
let (_, _, ty) = self.sema.resolve_record_field(&expr_field)?;
385385
Some((
386386
Some(ty),

0 commit comments

Comments
 (0)