From 75370312fbfe072947ffdc568eebc9cb4c6108e4 Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:29:36 +0530 Subject: clippy::redundant_closure --- crates/hir_def/src/attr.rs | 4 ++-- crates/hir_ty/src/chalk_db.rs | 2 +- crates/hir_ty/src/consteval.rs | 2 +- crates/hir_ty/src/lower.rs | 2 +- crates/hir_ty/src/method_resolution.rs | 4 ++-- crates/ide/src/hover.rs | 2 +- crates/ide/src/references/rename.rs | 2 +- crates/ide_assists/src/handlers/apply_demorgan.rs | 4 ++-- crates/ide_assists/src/handlers/fill_match_arms.rs | 2 +- crates/ide_completion/src/context.rs | 2 +- crates/ide_completion/src/patterns.rs | 6 +++--- crates/rust-analyzer/src/handlers.rs | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) (limited to 'crates') diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 2b21cf927..d07adb084 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -583,13 +583,13 @@ impl AttrSourceMap { .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 4e042bf42..1dab19000 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 e3ceb3d62..6f0bf8f8c 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 0b8f21e5d..a8a9f5ca1 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -784,7 +784,7 @@ impl<'a> TyLoweringContext<'a> { 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 8c00a6369..f3d390961 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -60,7 +60,7 @@ impl TyFingerprint { 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 @@ impl TyFingerprint { 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 4ba4f61d8..c08516805 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 02b171bda..50cc1f963 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs @@ -426,7 +426,7 @@ fn text_edit_from_self_param(self_param: &ast::SelfParam, new_name: &str) -> Opt 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 5c936a510..c93959e66 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 c8bc923f5..5a43bdd6f 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 e4abe2742..4c3929a26 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -380,7 +380,7 @@ impl<'a> CompletionContext<'a> { (|| { 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 c567ac63d..72e67e3c4 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 59339d401..a81e398c4 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, -- cgit v1.2.3