Skip to content

Commit 3567ea5

Browse files
committed
clippy: fold by value
1 parent 27a1572 commit 3567ea5

9 files changed

+15
-15
lines changed

clippy_lints/src/eval_order_dependence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
141141
match typ.kind() {
142142
ty::FnDef(..) | ty::FnPtr(_) => {
143143
let sig = typ.fn_sig(self.cx.tcx);
144-
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind() {
144+
if let ty::Never = self.cx.tcx.erase_late_bound_regions(sig).output().kind() {
145145
self.report_diverging_sub_expr(e);
146146
}
147147
},

clippy_lints/src/methods/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
16151615

16161616
let method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
16171617
let method_sig = cx.tcx.fn_sig(method_def_id);
1618-
let method_sig = cx.tcx.erase_late_bound_regions(&method_sig);
1618+
let method_sig = cx.tcx.erase_late_bound_regions(method_sig);
16191619

16201620
let first_arg_ty = &method_sig.inputs().iter().next();
16211621

@@ -2681,7 +2681,7 @@ fn lint_map_flatten<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map
26812681
ty::Closure(_, substs) => substs.as_closure().sig(),
26822682
_ => map_closure_ty.fn_sig(cx.tcx),
26832683
};
2684-
let map_closure_return_ty = cx.tcx.erase_late_bound_regions(&map_closure_sig.output());
2684+
let map_closure_return_ty = cx.tcx.erase_late_bound_regions(map_closure_sig.output());
26852685
is_type_diagnostic_item(cx, map_closure_return_ty, sym::option_type)
26862686
},
26872687
_ => false,

clippy_lints/src/mut_key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, item_hir_id: hir::HirId, decl: &hir::
9292
check_ty(
9393
cx,
9494
decl.output.span(),
95-
cx.tcx.erase_late_bound_regions(&fn_sig.output()),
95+
cx.tcx.erase_late_bound_regions(fn_sig.output()),
9696
);
9797
}
9898

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
141141
};
142142

143143
let fn_sig = cx.tcx.fn_sig(fn_def_id);
144-
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
144+
let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig);
145145

146146
for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() {
147147
// All spans generated from a proc-macro invocation are the same...

clippy_lints/src/pass_by_ref_or_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'tcx> PassByRefOrValue {
115115
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
116116

117117
let fn_sig = cx.tcx.fn_sig(fn_def_id);
118-
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
118+
let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig);
119119

120120
let fn_body = cx.enclosing_body.map(|id| cx.tcx.hir().body(id));
121121

clippy_lints/src/transmute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
491491
Applicability::Unspecified,
492492
);
493493
} else {
494-
if (cx.tcx.erase_regions(&from_ty) != cx.tcx.erase_regions(&to_ty))
494+
if (cx.tcx.erase_regions(from_ty) != cx.tcx.erase_regions(to_ty))
495495
&& !const_context {
496496
span_lint_and_then(
497497
cx,

clippy_lints/src/unit_return_expecting_ord.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
4343
for (pred, _) in generics.predicates {
4444
if_chain! {
4545
if let PredicateAtom::Trait(poly_trait_pred, _) = pred.skip_binders();
46-
let trait_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(poly_trait_pred));
46+
let trait_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(poly_trait_pred));
4747
if let Some(trait_def_id) = trait_id;
4848
if trait_def_id == trait_pred.trait_ref.def_id;
4949
then {
@@ -61,7 +61,7 @@ fn get_projection_pred<'tcx>(
6161
) -> Option<ProjectionPredicate<'tcx>> {
6262
generics.predicates.iter().find_map(|(proj_pred, _)| {
6363
if let ty::PredicateAtom::Projection(proj_pred) = proj_pred.skip_binders() {
64-
let projection_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(proj_pred));
64+
let projection_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(proj_pred));
6565
if projection_pred.projection_ty.substs == pred.trait_ref.substs {
6666
return Some(projection_pred);
6767
}
@@ -81,7 +81,7 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve
8181
get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().partial_ord_trait());
8282
// Trying to call erase_late_bound_regions on fn_sig.inputs() gives the following error
8383
// The trait `rustc::ty::TypeFoldable<'_>` is not implemented for `&[&rustc::ty::TyS<'_>]`
84-
let inputs_output = cx.tcx.erase_late_bound_regions(&fn_sig.inputs_and_output());
84+
let inputs_output = cx.tcx.erase_late_bound_regions(fn_sig.inputs_and_output());
8585
inputs_output
8686
.iter()
8787
.rev()
@@ -112,7 +112,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa
112112
if let ExprKind::Closure(_, _fn_decl, body_id, span, _) = arg.kind;
113113
if let ty::Closure(_def_id, substs) = &cx.typeck_results().node_type(arg.hir_id).kind();
114114
let ret_ty = substs.as_closure().sig().output();
115-
let ty = cx.tcx.erase_late_bound_regions(&ret_ty);
115+
let ty = cx.tcx.erase_late_bound_regions(ret_ty);
116116
if ty.is_unit();
117117
then {
118118
if_chain! {

clippy_lints/src/use_self.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn check_trait_method_impl_decl<'tcx>(
123123
.expect("impl method matches a trait method");
124124

125125
let trait_method_sig = cx.tcx.fn_sig(trait_method.def_id);
126-
let trait_method_sig = cx.tcx.erase_late_bound_regions(&trait_method_sig);
126+
let trait_method_sig = cx.tcx.erase_late_bound_regions(trait_method_sig);
127127

128128
let output_hir_ty = if let FnRetTy::Return(ty) = &impl_decl.output {
129129
Some(&**ty)

clippy_lints/src/utils/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub fn implements_trait<'tcx>(
363363
if ty.has_infer_types() {
364364
return false;
365365
}
366-
let ty = cx.tcx.erase_regions(&ty);
366+
let ty = cx.tcx.erase_regions(ty);
367367
let ty_params = cx.tcx.mk_substs(ty_params.iter());
368368
cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env))
369369
}
@@ -887,7 +887,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
887887
pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId) -> Ty<'tcx> {
888888
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
889889
let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
890-
cx.tcx.erase_late_bound_regions(&ret_ty)
890+
cx.tcx.erase_late_bound_regions(ret_ty)
891891
}
892892

893893
/// 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>(
12201220
pub fn is_normalizable<'tcx>(cx: &LateContext<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
12211221
cx.tcx.infer_ctxt().enter(|infcx| {
12221222
let cause = rustc_middle::traits::ObligationCause::dummy();
1223-
infcx.at(&cause, param_env).normalize(&ty).is_ok()
1223+
infcx.at(&cause, param_env).normalize(ty).is_ok()
12241224
})
12251225
}
12261226

0 commit comments

Comments
 (0)