Skip to content

Commit bf1127d

Browse files
committed
Adapt clippy.
1 parent 2e30f43 commit bf1127d

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/tools/clippy/clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
111111
.map_or(callee_ty, |id| cx.tcx.type_of(id));
112112
if check_sig(cx, closure_ty, call_ty);
113113
let substs = cx.typeck_results().node_substs(callee.hir_id);
114-
// This fixes some false positives that I don't entirely understand
115-
if substs.is_empty() || !cx.typeck_results().expr_ty(expr).has_late_bound_regions();
116114
// A type param function ref like `T::f` is not 'static, however
117115
// it is if cast like `T::f as fn()`. This seems like a rustc bug.
118116
if !substs.types().any(|t| matches!(t.kind(), ty::Param(_)));
@@ -217,7 +215,7 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure_ty: Ty<'tcx>, call_ty: Ty<'tc
217215
return false;
218216
};
219217
let closure_sig = cx.tcx.signature_unclosure(substs.as_closure().sig(), Unsafety::Normal);
220-
cx.tcx.erase_late_bound_regions(closure_sig) == cx.tcx.erase_late_bound_regions(call_sig)
218+
cx.tcx.anonymize_late_bound_regions(closure_sig) == cx.tcx.anonymize_late_bound_regions(call_sig)
221219
}
222220

223221
fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: DefId) -> String {

src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,9 @@ fn is_to_string_on_string_like<'a>(
486486
}
487487

488488
if let Some(substs) = cx.typeck_results().node_substs_opt(call_expr.hir_id)
489-
&& let [generic_arg] = substs.as_slice()
489+
&& let substs = substs.as_slice()
490+
&& let Some(generic_arg) = substs.get(0)
491+
&& substs.iter().skip(1).all(|arg| matches!(arg.unpack(), ty::GenericArgKind::Lifetime(_)))
490492
&& let GenericArgKind::Type(ty) = generic_arg.unpack()
491493
&& let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref)
492494
&& let Some(as_ref_trait_id) = cx.tcx.get_diagnostic_item(sym::AsRef)

src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,12 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
247247
&& let Some(trait_ref) = cx.tcx.impl_trait_ref(item.def_id)
248248
&& let Some(trait_item_id) = cx.tcx.associated_item(def_id).trait_item_def_id
249249
{
250+
let substs = ty::InternalSubsts::identity_for_item(cx.tcx, trait_item_id)
251+
.rebase_onto(cx.tcx, trait_ref.def_id, trait_ref.substs);
252+
let substs = cx.tcx.erase_regions(substs);
250253
(
251254
trait_item_id,
252-
FnKind::ImplTraitFn(cx.tcx.erase_regions(trait_ref.substs) as *const _ as usize),
255+
FnKind::ImplTraitFn(substs as *const _ as usize),
253256
usize::from(sig.decl.implicit_self.has_implicit_self()),
254257
)
255258
} else {

src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'tcx> PassByRefOrValue {
143143
return;
144144
}
145145

146-
let fn_sig = cx.tcx.fn_sig(def_id);
146+
let fn_sig = cx.tcx.type_of(def_id).fn_sig(cx.tcx);
147147
let fn_body = cx.enclosing_body.map(|id| cx.tcx.hir().body(id));
148148

149149
// Gather all the lifetimes found in the output type which may affect whether

0 commit comments

Comments
 (0)