@@ -530,11 +530,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
530
530
}
531
531
DefKind :: Impl { of_trait } => {
532
532
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) ;
538
534
check_on_unimplemented ( tcx, def_id) ;
539
535
}
540
536
}
@@ -725,10 +721,11 @@ fn check_impl_items_against_trait<'tcx>(
725
721
impl_id : LocalDefId ,
726
722
impl_trait_header : ty:: ImplTraitHeader < ' tcx > ,
727
723
) {
724
+ let trait_ref = impl_trait_header. trait_ref . instantiate_identity ( ) ;
728
725
// If the trait reference itself is erroneous (so the compilation is going
729
726
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
730
727
// isn't populated for such impls.
731
- if impl_trait_header . references_error ( ) {
728
+ if trait_ref . references_error ( ) {
732
729
return ;
733
730
}
734
731
@@ -752,7 +749,7 @@ fn check_impl_items_against_trait<'tcx>(
752
749
}
753
750
}
754
751
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 ) ;
756
753
757
754
for & impl_item in impl_item_refs {
758
755
let ty_impl_item = tcx. associated_item ( impl_item) ;
@@ -771,10 +768,10 @@ fn check_impl_items_against_trait<'tcx>(
771
768
) ) ;
772
769
}
773
770
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) ;
775
772
}
776
773
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) ;
778
775
}
779
776
}
780
777
@@ -794,7 +791,7 @@ fn check_impl_items_against_trait<'tcx>(
794
791
let mut must_implement_one_of: Option < & [ Ident ] > =
795
792
trait_def. must_implement_one_of . as_deref ( ) ;
796
793
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 ) {
798
795
let leaf_def = ancestors. leaf_def ( tcx, trait_item_id) ;
799
796
800
797
let is_implemented = leaf_def
@@ -872,7 +869,7 @@ fn check_impl_items_against_trait<'tcx>(
872
869
873
870
if let Some ( missing_items) = must_implement_one_of {
874
871
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)
876
873
. map ( |attr| attr. span ) ;
877
874
878
875
missing_items_must_implement_one_of_err (
0 commit comments