@@ -757,7 +757,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
757757 struct IllegalSelfTypeVisitor < ' tcx > {
758758 tcx : TyCtxt < ' tcx > ,
759759 trait_def_id : DefId ,
760- supertraits : Option < Vec < ty :: PolyTraitRef < ' tcx > > > ,
760+ supertraits : Option < Vec < DefId > > ,
761761 }
762762
763763 impl < ' tcx > TypeVisitor < ' tcx > for IllegalSelfTypeVisitor < ' tcx > {
@@ -778,8 +778,10 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
778778 // Compute supertraits of current trait lazily.
779779 if self . supertraits . is_none ( ) {
780780 let trait_ref =
781- ty:: Binder :: bind ( ty:: TraitRef :: identity ( self . tcx , self . trait_def_id ) ) ;
782- self . supertraits = Some ( traits:: supertraits ( self . tcx , trait_ref) . collect ( ) ) ;
781+ ty:: Binder :: dummy ( ty:: TraitRef :: identity ( self . tcx , self . trait_def_id ) ) ;
782+ self . supertraits = Some (
783+ traits:: supertraits ( self . tcx , trait_ref) . map ( |t| t. def_id ( ) ) . collect ( ) ,
784+ ) ;
783785 }
784786
785787 // Determine whether the trait reference `Foo as
@@ -790,9 +792,11 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
790792 // direct equality here because all of these types
791793 // are part of the formal parameter listing, and
792794 // hence there should be no inference variables.
793- let projection_trait_ref = ty:: Binder :: bind ( data. trait_ref ( self . tcx ) ) ;
794- let is_supertrait_of_current_trait =
795- self . supertraits . as_ref ( ) . unwrap ( ) . contains ( & projection_trait_ref) ;
795+ let is_supertrait_of_current_trait = self
796+ . supertraits
797+ . as_ref ( )
798+ . unwrap ( )
799+ . contains ( & data. trait_ref ( self . tcx ) . def_id ) ;
796800
797801 if is_supertrait_of_current_trait {
798802 ControlFlow :: CONTINUE // do not walk contained types, do not report error, do collect $200
0 commit comments