diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 2b21cf92791..d07adb08462 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -583,13 +583,13 @@ fn source_of_id(&self, id: AttrId) -> InFile> { .get(id.ast_index as usize) .unwrap_or_else(|| panic!("cannot find doc comment at index {:?}", id)) .clone() - .map(|attr| Either::Right(attr)) + .map(Either::Right) } else { self.attrs .get(id.ast_index as usize) .unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", id)) .clone() - .map(|attr| Either::Left(attr)) + .map(Either::Left) } } } diff --git a/crates/hir_ty/src/chalk_db.rs b/crates/hir_ty/src/chalk_db.rs index 4e042bf4223..1dab1900054 100644 --- a/crates/hir_ty/src/chalk_db.rs +++ b/crates/hir_ty/src/chalk_db.rs @@ -431,7 +431,7 @@ pub(crate) fn trait_datum_query( }; let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); let associated_ty_ids = - trait_data.associated_types().map(|type_alias| to_assoc_type_id(type_alias)).collect(); + trait_data.associated_types().map(to_assoc_type_id).collect(); let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses }; let well_known = lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name)); diff --git a/crates/hir_ty/src/consteval.rs b/crates/hir_ty/src/consteval.rs index e3ceb3d6269..6f0bf8f8c6c 100644 --- a/crates/hir_ty/src/consteval.rs +++ b/crates/hir_ty/src/consteval.rs @@ -49,7 +49,7 @@ pub fn usize_const(value: Option) -> Const { ConstData { ty: TyKind::Scalar(chalk_ir::Scalar::Uint(chalk_ir::UintTy::Usize)).intern(&Interner), value: ConstValue::Concrete(chalk_ir::ConcreteConst { - interned: value.map(|value| ConstScalar::Usize(value)).unwrap_or(ConstScalar::Unknown), + interned: value.map(ConstScalar::Usize).unwrap_or(ConstScalar::Unknown), }), } .intern(&Interner) diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 0b8f21e5df1..a8a9f5ca124 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -784,7 +784,7 @@ pub(crate) fn lower_type_bound( let trait_ref = match bound { TypeBound::Path(path) => { bindings = self.lower_trait_ref_from_path(path, Some(self_ty)); - bindings.clone().map(WhereClause::Implemented).map(|b| crate::wrap_empty_binders(b)) + bindings.clone().map(WhereClause::Implemented).map(crate::wrap_empty_binders) } TypeBound::Lifetime(_) => None, TypeBound::Error => None, diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 8c00a636995..f3d390961a5 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -60,7 +60,7 @@ pub fn for_inherent_impl(ty: &Ty) -> Option { TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt), TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability), TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id), - TyKind::Dyn(_) => ty.dyn_trait().map(|trait_| TyFingerprint::Dyn(trait_))?, + TyKind::Dyn(_) => ty.dyn_trait().map(TyFingerprint::Dyn)?, _ => return None, }; Some(fp) @@ -77,7 +77,7 @@ pub fn for_trait_impl(ty: &Ty) -> Option { TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt), TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability), TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id), - TyKind::Dyn(_) => ty.dyn_trait().map(|trait_| TyFingerprint::Dyn(trait_))?, + TyKind::Dyn(_) => ty.dyn_trait().map(TyFingerprint::Dyn)?, TyKind::Ref(_, _, ty) => return TyFingerprint::for_trait_impl(ty), TyKind::Tuple(_, subst) => { let first_ty = subst.interned().get(0).map(|arg| arg.assert_ty_ref(&Interner)); diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 4ba4f61d855..c08516805e1 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -288,7 +288,7 @@ fn runnable_action( ) -> Option { match def { Definition::ModuleDef(it) => match it { - ModuleDef::Module(it) => runnable_mod(sema, it).map(|it| HoverAction::Runnable(it)), + ModuleDef::Module(it) => runnable_mod(sema, it).map(HoverAction::Runnable), ModuleDef::Function(func) => { let src = func.source(sema.db)?; if src.file_id != file_id.into() { diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 02b171bdaa3..50cc1f963cd 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs @@ -426,7 +426,7 @@ fn target_type_name(impl_def: &ast::Impl) -> Option { None } - let impl_def = self_param.syntax().ancestors().find_map(|it| ast::Impl::cast(it))?; + let impl_def = self_param.syntax().ancestors().find_map(ast::Impl::cast)?; let type_name = target_type_name(&impl_def)?; let mut replacement_text = String::from(new_name); diff --git a/crates/ide_assists/src/handlers/apply_demorgan.rs b/crates/ide_assists/src/handlers/apply_demorgan.rs index 5c936a510b5..c93959e669e 100644 --- a/crates/ide_assists/src/handlers/apply_demorgan.rs +++ b/crates/ide_assists/src/handlers/apply_demorgan.rs @@ -78,12 +78,12 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<( terms.sort_by_key(|t| t.syntax().text_range().start()); let mut terms = VecDeque::from(terms); - let paren_expr = expr.syntax().parent().and_then(|parent| ast::ParenExpr::cast(parent)); + let paren_expr = expr.syntax().parent().and_then(ast::ParenExpr::cast); let neg_expr = paren_expr .clone() .and_then(|paren_expr| paren_expr.syntax().parent()) - .and_then(|parent| ast::PrefixExpr::cast(parent)) + .and_then(ast::PrefixExpr::cast) .and_then(|prefix_expr| { if prefix_expr.op_kind().unwrap() == ast::PrefixOp::Not { Some(prefix_expr) diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs index c8bc923f5d6..5a43bdd6f1b 100644 --- a/crates/ide_assists/src/handlers/fill_match_arms.rs +++ b/crates/ide_assists/src/handlers/fill_match_arms.rs @@ -202,7 +202,7 @@ impl ExtendedEnum { fn variants(self, db: &RootDatabase) -> Vec { match self { ExtendedEnum::Enum(e) => { - e.variants(db).into_iter().map(|x| ExtendedVariant::Variant(x)).collect::>() + e.variants(db).into_iter().map(ExtendedVariant::Variant).collect::>() } ExtendedEnum::Bool => { Vec::::from([ExtendedVariant::True, ExtendedVariant::False]) diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index e4abe2742b6..4c3929a2668 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -380,7 +380,7 @@ fn expected_type_and_name(&self) -> (Option, Option) { (|| { let expr_field = self.token.prev_sibling_or_token()? .into_node() - .and_then(|node| ast::RecordExprField::cast(node))?; + .and_then(ast::RecordExprField::cast)?; let (_, _, ty) = self.sema.resolve_record_field(&expr_field)?; Some(( Some(ty), diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index c567ac63dc9..72e67e3c4cd 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs @@ -259,7 +259,7 @@ fn test_inside_impl_trait_block() { } pub(crate) fn previous_token(element: SyntaxElement) -> Option { - element.into_token().and_then(|it| previous_non_trivia_token(it)) + element.into_token().and_then(previous_non_trivia_token) } /// Check if the token previous to the previous one is `for`. @@ -267,8 +267,8 @@ pub(crate) fn previous_token(element: SyntaxElement) -> Option { pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool { element .into_token() - .and_then(|it| previous_non_trivia_token(it)) - .and_then(|it| previous_non_trivia_token(it)) + .and_then(previous_non_trivia_token) + .and_then(previous_non_trivia_token) .filter(|it| it.kind() == T![for]) .is_some() } diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 59339d4015e..a81e398c43a 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -781,7 +781,7 @@ pub(crate) fn handle_completion_resolve( let resolve_data = match original_completion .data .take() - .map(|data| serde_json::from_value::(data)) + .map(serde_json::from_value::) .transpose()? { Some(data) => data,