@@ -6,7 +6,7 @@ use rustc_errors::Applicability;
66use rustc_hir:: def_id:: DefId ;
77use rustc_hir:: { Block , Body , Expr , ExprKind , ImplItem , ImplItemKind , Item , ItemKind , LangItem , UnOp } ;
88use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
9- use rustc_middle:: ty:: { EarlyBinder , TyCtxt , TypeckResults } ;
9+ use rustc_middle:: ty:: { TyCtxt , TypeckResults } ;
1010use rustc_session:: impl_lint_pass;
1111use rustc_span:: sym;
1212use rustc_span:: symbol:: kw;
@@ -173,10 +173,11 @@ impl LateLintPass<'_> for NonCanonicalImpls {
173173 }
174174 } ) ;
175175
176+ let trait_impl = cx. tcx . impl_trait_ref ( item. owner_id ) . skip_binder ( ) ;
177+
176178 match trait_ {
177179 Trait :: Clone => {
178180 if let Some ( copy_trait) = self . copy_trait
179- && let Some ( trait_impl) = cx. tcx . impl_trait_ref ( item. owner_id ) . map ( EarlyBinder :: skip_binder)
180181 && implements_trait ( cx, trait_impl. self_ty ( ) , copy_trait, & [ ] )
181182 {
182183 for ( assoc, _, block) in assoc_fns {
@@ -185,10 +186,9 @@ impl LateLintPass<'_> for NonCanonicalImpls {
185186 }
186187 } ,
187188 Trait :: PartialOrd => {
188- if let Some ( trait_impl) = cx. tcx . impl_trait_ref ( item. owner_id ) . map ( EarlyBinder :: skip_binder)
189- // If `Self` and `Rhs` are not the same type, then a corresponding `Ord` impl is not possible,
190- // since it doesn't have an `Rhs`
191- && let [ lhs, rhs] = trait_impl. args . as_slice ( )
189+ // If `Self` and `Rhs` are not the same type, then a corresponding `Ord` impl is not possible,
190+ // since it doesn't have an `Rhs`
191+ if let [ lhs, rhs] = trait_impl. args . as_slice ( )
192192 && lhs == rhs
193193 && let Some ( ord_trait) = self . ord_trait
194194 && implements_trait ( cx, trait_impl. self_ty ( ) , ord_trait, & [ ] )
0 commit comments