@@ -540,11 +540,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
540
540
}
541
541
DefKind :: Impl { of_trait } => {
542
542
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) ;
548
544
check_on_unimplemented ( tcx, def_id) ;
549
545
}
550
546
}
@@ -735,10 +731,11 @@ fn check_impl_items_against_trait<'tcx>(
735
731
impl_id : LocalDefId ,
736
732
impl_trait_header : ty:: ImplTraitHeader < ' tcx > ,
737
733
) {
734
+ let trait_ref = impl_trait_header. trait_ref . instantiate_identity ( ) ;
738
735
// If the trait reference itself is erroneous (so the compilation is going
739
736
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
740
737
// isn't populated for such impls.
741
- if impl_trait_header . references_error ( ) {
738
+ if trait_ref . references_error ( ) {
742
739
return ;
743
740
}
744
741
@@ -762,7 +759,7 @@ fn check_impl_items_against_trait<'tcx>(
762
759
}
763
760
}
764
761
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 ) ;
766
763
767
764
for & impl_item in impl_item_refs {
768
765
let ty_impl_item = tcx. associated_item ( impl_item) ;
@@ -781,10 +778,10 @@ fn check_impl_items_against_trait<'tcx>(
781
778
) ) ;
782
779
}
783
780
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) ;
785
782
}
786
783
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) ;
788
785
}
789
786
}
790
787
@@ -804,7 +801,7 @@ fn check_impl_items_against_trait<'tcx>(
804
801
let mut must_implement_one_of: Option < & [ Ident ] > =
805
802
trait_def. must_implement_one_of . as_deref ( ) ;
806
803
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 ) {
808
805
let leaf_def = ancestors. leaf_def ( tcx, trait_item_id) ;
809
806
810
807
let is_implemented = leaf_def
@@ -882,7 +879,7 @@ fn check_impl_items_against_trait<'tcx>(
882
879
883
880
if let Some ( missing_items) = must_implement_one_of {
884
881
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)
886
883
. map ( |attr| attr. span ) ;
887
884
888
885
missing_items_must_implement_one_of_err (
0 commit comments