@@ -530,11 +530,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
530530 }
531531 DefKind :: Impl { of_trait } => {
532532 if of_trait && let Some ( impl_trait_header) = tcx. impl_trait_header ( def_id) {
533- check_impl_items_against_trait (
534- tcx,
535- def_id,
536- impl_trait_header. instantiate_identity ( ) ,
537- ) ;
533+ check_impl_items_against_trait ( tcx, def_id, impl_trait_header) ;
538534 check_on_unimplemented ( tcx, def_id) ;
539535 }
540536 }
@@ -725,10 +721,11 @@ fn check_impl_items_against_trait<'tcx>(
725721 impl_id : LocalDefId ,
726722 impl_trait_header : ty:: ImplTraitHeader < ' tcx > ,
727723) {
724+ let trait_ref = impl_trait_header. trait_ref . instantiate_identity ( ) ;
728725 // If the trait reference itself is erroneous (so the compilation is going
729726 // to fail), skip checking the items here -- the `impl_item` table in `tcx`
730727 // isn't populated for such impls.
731- if impl_trait_header . references_error ( ) {
728+ if trait_ref . references_error ( ) {
732729 return ;
733730 }
734731
@@ -752,7 +749,7 @@ fn check_impl_items_against_trait<'tcx>(
752749 }
753750 }
754751
755- let trait_def = tcx. trait_def ( impl_trait_header . trait_ref . def_id ) ;
752+ let trait_def = tcx. trait_def ( trait_ref. def_id ) ;
756753
757754 for & impl_item in impl_item_refs {
758755 let ty_impl_item = tcx. associated_item ( impl_item) ;
@@ -771,10 +768,10 @@ fn check_impl_items_against_trait<'tcx>(
771768 ) ) ;
772769 }
773770 ty:: AssocKind :: Fn => {
774- compare_impl_method ( tcx, ty_impl_item, ty_trait_item, impl_trait_header . trait_ref ) ;
771+ compare_impl_method ( tcx, ty_impl_item, ty_trait_item, trait_ref) ;
775772 }
776773 ty:: AssocKind :: Type => {
777- compare_impl_ty ( tcx, ty_impl_item, ty_trait_item, impl_trait_header . trait_ref ) ;
774+ compare_impl_ty ( tcx, ty_impl_item, ty_trait_item, trait_ref) ;
778775 }
779776 }
780777
@@ -794,7 +791,7 @@ fn check_impl_items_against_trait<'tcx>(
794791 let mut must_implement_one_of: Option < & [ Ident ] > =
795792 trait_def. must_implement_one_of . as_deref ( ) ;
796793
797- for & trait_item_id in tcx. associated_item_def_ids ( impl_trait_header . trait_ref . def_id ) {
794+ for & trait_item_id in tcx. associated_item_def_ids ( trait_ref. def_id ) {
798795 let leaf_def = ancestors. leaf_def ( tcx, trait_item_id) ;
799796
800797 let is_implemented = leaf_def
@@ -872,7 +869,7 @@ fn check_impl_items_against_trait<'tcx>(
872869
873870 if let Some ( missing_items) = must_implement_one_of {
874871 let attr_span = tcx
875- . get_attr ( impl_trait_header . trait_ref . def_id , sym:: rustc_must_implement_one_of)
872+ . get_attr ( trait_ref. def_id , sym:: rustc_must_implement_one_of)
876873 . map ( |attr| attr. span ) ;
877874
878875 missing_items_must_implement_one_of_err (
0 commit comments