@@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
8282 let mut violations = vec ! [ ] ;
8383
8484 for def_id in traits:: supertrait_def_ids ( self , trait_def_id) {
85- if self . supertraits_reference_self ( def_id) {
85+ if self . predicates_reference_self ( def_id, true ) {
8686 violations. push ( ObjectSafetyViolation :: SupertraitSelf ) ;
8787 }
8888 }
@@ -117,7 +117,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
117117 if self . trait_has_sized_self ( trait_def_id) {
118118 violations. push ( ObjectSafetyViolation :: SizedSelf ) ;
119119 }
120- if self . supertraits_reference_self ( trait_def_id) {
120+ if self . predicates_reference_self ( trait_def_id, false ) {
121121 violations. push ( ObjectSafetyViolation :: SupertraitSelf ) ;
122122 }
123123
@@ -128,12 +128,20 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
128128 violations
129129 }
130130
131- fn supertraits_reference_self ( self , trait_def_id : DefId ) -> bool {
131+ fn predicates_reference_self (
132+ self ,
133+ trait_def_id : DefId ,
134+ supertraits_only : bool ) -> bool
135+ {
132136 let trait_ref = ty:: Binder ( ty:: TraitRef {
133137 def_id : trait_def_id,
134138 substs : Substs :: identity_for_item ( self , trait_def_id)
135139 } ) ;
136- let predicates = self . item_super_predicates ( trait_def_id) ;
140+ let predicates = if supertraits_only {
141+ self . item_super_predicates ( trait_def_id)
142+ } else {
143+ self . item_predicates ( trait_def_id)
144+ } ;
137145 predicates
138146 . predicates
139147 . into_iter ( )
0 commit comments