@@ -81,8 +81,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
81
81
{
82
82
let mut violations = vec ! [ ] ;
83
83
84
- if self . supertraits_reference_self ( trait_def_id) {
85
- violations. push ( ObjectSafetyViolation :: SupertraitSelf ) ;
84
+ for def_id in traits:: supertrait_def_ids ( self , trait_def_id) {
85
+ if self . predicates_reference_self ( def_id, true ) {
86
+ violations. push ( ObjectSafetyViolation :: SupertraitSelf ) ;
87
+ }
86
88
}
87
89
88
90
debug ! ( "astconv_object_safety_violations(trait_def_id={:?}) = {:?}" ,
@@ -115,7 +117,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
115
117
if self . trait_has_sized_self ( trait_def_id) {
116
118
violations. push ( ObjectSafetyViolation :: SizedSelf ) ;
117
119
}
118
- if self . supertraits_reference_self ( trait_def_id) {
120
+ if self . predicates_reference_self ( trait_def_id, false ) {
119
121
violations. push ( ObjectSafetyViolation :: SupertraitSelf ) ;
120
122
}
121
123
@@ -126,12 +128,20 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
126
128
violations
127
129
}
128
130
129
- 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
+ {
130
136
let trait_ref = ty:: Binder ( ty:: TraitRef {
131
137
def_id : trait_def_id,
132
138
substs : Substs :: identity_for_item ( self , trait_def_id)
133
139
} ) ;
134
- 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
+ } ;
135
145
predicates
136
146
. predicates
137
147
. into_iter ( )
0 commit comments