Skip to content

Commit

Permalink
from_over_into: Check HIR tree first.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Jul 5, 2024
1 parent 278e837 commit 3fcac2c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions clippy_lints/src/from_over_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ impl_lint_pass!(FromOverInto => [FROM_OVER_INTO]);

impl<'tcx> LateLintPass<'tcx> for FromOverInto {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
if !self.msrv.meets(msrvs::RE_REBALANCING_COHERENCE) || !span_is_local(item.span) {
return;
}

if let ItemKind::Impl(Impl {
of_trait: Some(hir_trait_ref),
self_ty,
Expand All @@ -77,6 +73,8 @@ impl<'tcx> LateLintPass<'tcx> for FromOverInto {
&& let Some(into_trait_seg) = hir_trait_ref.path.segments.last()
// `impl Into<target_ty> for self_ty`
&& let Some(GenericArgs { args: [GenericArg::Type(target_ty)], .. }) = into_trait_seg.args
&& self.msrv.meets(msrvs::RE_REBALANCING_COHERENCE)
&& span_is_local(item.span)
&& let Some(middle_trait_ref) = cx.tcx.impl_trait_ref(item.owner_id)
.map(ty::EarlyBinder::instantiate_identity)
&& cx.tcx.is_diagnostic_item(sym::Into, middle_trait_ref.def_id)
Expand Down

0 comments on commit 3fcac2c

Please sign in to comment.