From 3567ea546f9bdfb71ed107cff176df08b2da985f Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Sat, 24 Oct 2020 02:21:27 +0200 Subject: [PATCH] clippy: fold by value --- clippy_lints/src/eval_order_dependence.rs | 2 +- clippy_lints/src/methods/mod.rs | 4 ++-- clippy_lints/src/mut_key.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/pass_by_ref_or_value.rs | 2 +- clippy_lints/src/transmute.rs | 2 +- clippy_lints/src/unit_return_expecting_ord.rs | 8 ++++---- clippy_lints/src/use_self.rs | 2 +- clippy_lints/src/utils/mod.rs | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 4240147f498..bc2b2904698 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { match typ.kind() { ty::FnDef(..) | ty::FnPtr(_) => { let sig = typ.fn_sig(self.cx.tcx); - if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind() { + if let ty::Never = self.cx.tcx.erase_late_bound_regions(sig).output().kind() { self.report_diverging_sub_expr(e); } }, diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 7186656f4e1..30f4c0c56d2 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1615,7 +1615,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods { let method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id); let method_sig = cx.tcx.fn_sig(method_def_id); - let method_sig = cx.tcx.erase_late_bound_regions(&method_sig); + let method_sig = cx.tcx.erase_late_bound_regions(method_sig); let first_arg_ty = &method_sig.inputs().iter().next(); @@ -2681,7 +2681,7 @@ fn lint_map_flatten<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map ty::Closure(_, substs) => substs.as_closure().sig(), _ => map_closure_ty.fn_sig(cx.tcx), }; - let map_closure_return_ty = cx.tcx.erase_late_bound_regions(&map_closure_sig.output()); + let map_closure_return_ty = cx.tcx.erase_late_bound_regions(map_closure_sig.output()); is_type_diagnostic_item(cx, map_closure_return_ty, sym::option_type) }, _ => false, diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 4525b12689f..9cceecc785a 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -92,7 +92,7 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, item_hir_id: hir::HirId, decl: &hir:: check_ty( cx, decl.output.span(), - cx.tcx.erase_late_bound_regions(&fn_sig.output()), + cx.tcx.erase_late_bound_regions(fn_sig.output()), ); } diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 1d0e230c6a7..532c0266946 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { }; let fn_sig = cx.tcx.fn_sig(fn_def_id); - let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig); + let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig); for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() { // All spans generated from a proc-macro invocation are the same... diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 030650c3256..f03facc235e 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -115,7 +115,7 @@ impl<'tcx> PassByRefOrValue { let fn_def_id = cx.tcx.hir().local_def_id(hir_id); let fn_sig = cx.tcx.fn_sig(fn_def_id); - let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig); + let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig); let fn_body = cx.enclosing_body.map(|id| cx.tcx.hir().body(id)); diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index 47c650ac27d..b0909f73177 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -491,7 +491,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { Applicability::Unspecified, ); } else { - if (cx.tcx.erase_regions(&from_ty) != cx.tcx.erase_regions(&to_ty)) + if (cx.tcx.erase_regions(from_ty) != cx.tcx.erase_regions(to_ty)) && !const_context { span_lint_and_then( cx, diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index 0d5a5017331..ade5fff5ffc 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -43,7 +43,7 @@ fn get_trait_predicates_for_trait_id<'tcx>( for (pred, _) in generics.predicates { if_chain! { if let PredicateAtom::Trait(poly_trait_pred, _) = pred.skip_binders(); - let trait_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(poly_trait_pred)); + let trait_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(poly_trait_pred)); if let Some(trait_def_id) = trait_id; if trait_def_id == trait_pred.trait_ref.def_id; then { @@ -61,7 +61,7 @@ fn get_projection_pred<'tcx>( ) -> Option> { generics.predicates.iter().find_map(|(proj_pred, _)| { if let ty::PredicateAtom::Projection(proj_pred) = proj_pred.skip_binders() { - let projection_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(proj_pred)); + let projection_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(proj_pred)); if projection_pred.projection_ty.substs == pred.trait_ref.substs { return Some(projection_pred); } @@ -81,7 +81,7 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().partial_ord_trait()); // Trying to call erase_late_bound_regions on fn_sig.inputs() gives the following error // The trait `rustc::ty::TypeFoldable<'_>` is not implemented for `&[&rustc::ty::TyS<'_>]` - let inputs_output = cx.tcx.erase_late_bound_regions(&fn_sig.inputs_and_output()); + let inputs_output = cx.tcx.erase_late_bound_regions(fn_sig.inputs_and_output()); inputs_output .iter() .rev() @@ -112,7 +112,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa if let ExprKind::Closure(_, _fn_decl, body_id, span, _) = arg.kind; if let ty::Closure(_def_id, substs) = &cx.typeck_results().node_type(arg.hir_id).kind(); let ret_ty = substs.as_closure().sig().output(); - let ty = cx.tcx.erase_late_bound_regions(&ret_ty); + let ty = cx.tcx.erase_late_bound_regions(ret_ty); if ty.is_unit(); then { if_chain! { diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 427a1b65773..5ac4797680b 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -123,7 +123,7 @@ fn check_trait_method_impl_decl<'tcx>( .expect("impl method matches a trait method"); let trait_method_sig = cx.tcx.fn_sig(trait_method.def_id); - let trait_method_sig = cx.tcx.erase_late_bound_regions(&trait_method_sig); + let trait_method_sig = cx.tcx.erase_late_bound_regions(trait_method_sig); let output_hir_ty = if let FnRetTy::Return(ty) = &impl_decl.output { Some(&**ty) diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 0d43fd0392e..b027bfebacb 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -363,7 +363,7 @@ pub fn implements_trait<'tcx>( if ty.has_infer_types() { return false; } - let ty = cx.tcx.erase_regions(&ty); + let ty = cx.tcx.erase_regions(ty); let ty_params = cx.tcx.mk_substs(ty_params.iter()); cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env)) } @@ -887,7 +887,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option { pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId) -> Ty<'tcx> { let fn_def_id = cx.tcx.hir().local_def_id(fn_item); let ret_ty = cx.tcx.fn_sig(fn_def_id).output(); - cx.tcx.erase_late_bound_regions(&ret_ty) + cx.tcx.erase_late_bound_regions(ret_ty) } /// Walks into `ty` and returns `true` if any inner type is the same as `other_ty` @@ -1220,7 +1220,7 @@ pub fn match_function_call<'tcx>( pub fn is_normalizable<'tcx>(cx: &LateContext<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool { cx.tcx.infer_ctxt().enter(|infcx| { let cause = rustc_middle::traits::ObligationCause::dummy(); - infcx.at(&cause, param_env).normalize(&ty).is_ok() + infcx.at(&cause, param_env).normalize(ty).is_ok() }) }