@@ -474,8 +474,12 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
474
474
}
475
475
DefKind :: Fn => { } // entirely within check_item_body
476
476
DefKind :: Impl { of_trait } => {
477
- if of_trait && let Some ( impl_trait_ref) = tcx. impl_trait_ref ( def_id) {
478
- check_impl_items_against_trait ( tcx, def_id, impl_trait_ref. instantiate_identity ( ) ) ;
477
+ if of_trait && let Some ( impl_trait_header) = tcx. impl_trait_header ( def_id) {
478
+ check_impl_items_against_trait (
479
+ tcx,
480
+ def_id,
481
+ impl_trait_header. instantiate_identity ( ) ,
482
+ ) ;
479
483
check_on_unimplemented ( tcx, def_id) ;
480
484
}
481
485
}
@@ -666,19 +670,19 @@ pub(super) fn check_specialization_validity<'tcx>(
666
670
fn check_impl_items_against_trait < ' tcx > (
667
671
tcx : TyCtxt < ' tcx > ,
668
672
impl_id : LocalDefId ,
669
- impl_trait_ref : ty:: TraitRef < ' tcx > ,
673
+ impl_trait_header : ty:: ImplTraitHeader < ' tcx > ,
670
674
) {
671
675
// If the trait reference itself is erroneous (so the compilation is going
672
676
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
673
677
// isn't populated for such impls.
674
- if impl_trait_ref . references_error ( ) {
678
+ if impl_trait_header . references_error ( ) {
675
679
return ;
676
680
}
677
681
678
682
let impl_item_refs = tcx. associated_item_def_ids ( impl_id) ;
679
683
680
684
// Negative impls are not expected to have any items
681
- match tcx . impl_polarity ( impl_id ) {
685
+ match impl_trait_header . polarity {
682
686
ty:: ImplPolarity :: Reservation | ty:: ImplPolarity :: Positive => { }
683
687
ty:: ImplPolarity :: Negative => {
684
688
if let [ first_item_ref, ..] = impl_item_refs {
@@ -695,7 +699,7 @@ fn check_impl_items_against_trait<'tcx>(
695
699
}
696
700
}
697
701
698
- let trait_def = tcx. trait_def ( impl_trait_ref . def_id ) ;
702
+ let trait_def = tcx. trait_def ( impl_trait_header . trait_ref . def_id ) ;
699
703
700
704
for & impl_item in impl_item_refs {
701
705
let ty_impl_item = tcx. associated_item ( impl_item) ;
@@ -714,10 +718,10 @@ fn check_impl_items_against_trait<'tcx>(
714
718
) ) ;
715
719
}
716
720
ty:: AssocKind :: Fn => {
717
- compare_impl_method ( tcx, ty_impl_item, ty_trait_item, impl_trait_ref ) ;
721
+ compare_impl_method ( tcx, ty_impl_item, ty_trait_item, impl_trait_header . trait_ref ) ;
718
722
}
719
723
ty:: AssocKind :: Type => {
720
- compare_impl_ty ( tcx, ty_impl_item, ty_trait_item, impl_trait_ref ) ;
724
+ compare_impl_ty ( tcx, ty_impl_item, ty_trait_item, impl_trait_header . trait_ref ) ;
721
725
}
722
726
}
723
727
@@ -737,7 +741,7 @@ fn check_impl_items_against_trait<'tcx>(
737
741
let mut must_implement_one_of: Option < & [ Ident ] > =
738
742
trait_def. must_implement_one_of . as_deref ( ) ;
739
743
740
- for & trait_item_id in tcx. associated_item_def_ids ( impl_trait_ref . def_id ) {
744
+ for & trait_item_id in tcx. associated_item_def_ids ( impl_trait_header . trait_ref . def_id ) {
741
745
let leaf_def = ancestors. leaf_def ( tcx, trait_item_id) ;
742
746
743
747
let is_implemented = leaf_def
@@ -815,7 +819,7 @@ fn check_impl_items_against_trait<'tcx>(
815
819
816
820
if let Some ( missing_items) = must_implement_one_of {
817
821
let attr_span = tcx
818
- . get_attr ( impl_trait_ref . def_id , sym:: rustc_must_implement_one_of)
822
+ . get_attr ( impl_trait_header . trait_ref . def_id , sym:: rustc_must_implement_one_of)
819
823
. map ( |attr| attr. span ) ;
820
824
821
825
missing_items_must_implement_one_of_err (
0 commit comments