@@ -540,11 +540,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
540540 }
541541 DefKind :: Impl { of_trait } => {
542542 if of_trait && let Some ( impl_trait_header) = tcx. impl_trait_header ( def_id) {
543- check_impl_items_against_trait (
544- tcx,
545- def_id,
546- impl_trait_header. instantiate_identity ( ) ,
547- ) ;
543+ check_impl_items_against_trait ( tcx, def_id, impl_trait_header) ;
548544 check_on_unimplemented ( tcx, def_id) ;
549545 }
550546 }
@@ -735,10 +731,11 @@ fn check_impl_items_against_trait<'tcx>(
735731 impl_id : LocalDefId ,
736732 impl_trait_header : ty:: ImplTraitHeader < ' tcx > ,
737733) {
734+ let trait_ref = impl_trait_header. trait_ref . instantiate_identity ( ) ;
738735 // If the trait reference itself is erroneous (so the compilation is going
739736 // to fail), skip checking the items here -- the `impl_item` table in `tcx`
740737 // isn't populated for such impls.
741- if impl_trait_header . references_error ( ) {
738+ if trait_ref . references_error ( ) {
742739 return ;
743740 }
744741
@@ -762,7 +759,7 @@ fn check_impl_items_against_trait<'tcx>(
762759 }
763760 }
764761
765- let trait_def = tcx. trait_def ( impl_trait_header . trait_ref . def_id ) ;
762+ let trait_def = tcx. trait_def ( trait_ref. def_id ) ;
766763
767764 for & impl_item in impl_item_refs {
768765 let ty_impl_item = tcx. associated_item ( impl_item) ;
@@ -781,10 +778,10 @@ fn check_impl_items_against_trait<'tcx>(
781778 ) ) ;
782779 }
783780 ty:: AssocKind :: Fn => {
784- compare_impl_method ( tcx, ty_impl_item, ty_trait_item, impl_trait_header . trait_ref ) ;
781+ compare_impl_method ( tcx, ty_impl_item, ty_trait_item, trait_ref) ;
785782 }
786783 ty:: AssocKind :: Type => {
787- compare_impl_ty ( tcx, ty_impl_item, ty_trait_item, impl_trait_header . trait_ref ) ;
784+ compare_impl_ty ( tcx, ty_impl_item, ty_trait_item, trait_ref) ;
788785 }
789786 }
790787
@@ -804,7 +801,7 @@ fn check_impl_items_against_trait<'tcx>(
804801 let mut must_implement_one_of: Option < & [ Ident ] > =
805802 trait_def. must_implement_one_of . as_deref ( ) ;
806803
807- for & trait_item_id in tcx. associated_item_def_ids ( impl_trait_header . trait_ref . def_id ) {
804+ for & trait_item_id in tcx. associated_item_def_ids ( trait_ref. def_id ) {
808805 let leaf_def = ancestors. leaf_def ( tcx, trait_item_id) ;
809806
810807 let is_implemented = leaf_def
@@ -882,7 +879,7 @@ fn check_impl_items_against_trait<'tcx>(
882879
883880 if let Some ( missing_items) = must_implement_one_of {
884881 let attr_span = tcx
885- . get_attr ( impl_trait_header . trait_ref . def_id , sym:: rustc_must_implement_one_of)
882+ . get_attr ( trait_ref. def_id , sym:: rustc_must_implement_one_of)
886883 . map ( |attr| attr. span ) ;
887884
888885 missing_items_must_implement_one_of_err (
0 commit comments