@@ -110,8 +110,8 @@ pub fn elaborate_predicates<'cx, 'tcx>(
110
110
}
111
111
112
112
impl < ' cx , ' tcx > Elaborator < ' cx , ' tcx > {
113
- pub fn filter_to_traits ( self ) -> Supertraits < ' cx , ' tcx > {
114
- Supertraits { elaborator : self }
113
+ pub fn filter_to_traits ( self ) -> JustTraits < Elaborator < ' cx , ' tcx > > {
114
+ JustTraits :: new ( self )
115
115
}
116
116
117
117
fn push ( & mut self , predicate : & ty:: Predicate < ' tcx > ) {
@@ -185,11 +185,7 @@ impl<'cx, 'tcx> Iterator for Elaborator<'cx, 'tcx> {
185
185
// Supertrait iterator
186
186
///////////////////////////////////////////////////////////////////////////
187
187
188
- /// A filter around the `Elaborator` that just yields up supertrait references,
189
- /// not other kinds of predicates.
190
- pub struct Supertraits < ' cx , ' tcx : ' cx > {
191
- elaborator : Elaborator < ' cx , ' tcx > ,
192
- }
188
+ pub type Supertraits < ' cx , ' tcx > = JustTraits < Elaborator < ' cx , ' tcx > > ;
193
189
194
190
pub fn supertraits < ' cx , ' tcx > ( tcx : & ' cx ty:: ctxt < ' tcx > ,
195
191
trait_ref : ty:: PolyTraitRef < ' tcx > )
@@ -205,12 +201,28 @@ pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
205
201
elaborate_trait_refs ( tcx, bounds) . filter_to_traits ( )
206
202
}
207
203
208
- impl < ' cx , ' tcx > Iterator for Supertraits < ' cx , ' tcx > {
204
+ ///////////////////////////////////////////////////////////////////////////
205
+ // Other
206
+ ///////////////////////////////////////////////////////////////////////////
207
+
208
+ /// A filter around an iterator of predicates that makes it yield up
209
+ /// just trait references.
210
+ pub struct JustTraits < I > {
211
+ base_iterator : I
212
+ }
213
+
214
+ impl < I > JustTraits < I > {
215
+ fn new ( base : I ) -> JustTraits < I > {
216
+ JustTraits { base_iterator : base }
217
+ }
218
+ }
219
+
220
+ impl < ' tcx , I : Iterator < Item =ty:: Predicate < ' tcx > > > Iterator for JustTraits < I > {
209
221
type Item = ty:: PolyTraitRef < ' tcx > ;
210
222
211
223
fn next ( & mut self ) -> Option < ty:: PolyTraitRef < ' tcx > > {
212
224
loop {
213
- match self . elaborator . next ( ) {
225
+ match self . base_iterator . next ( ) {
214
226
None => {
215
227
return None ;
216
228
}
@@ -224,6 +236,7 @@ impl<'cx, 'tcx> Iterator for Supertraits<'cx, 'tcx> {
224
236
}
225
237
}
226
238
239
+
227
240
///////////////////////////////////////////////////////////////////////////
228
241
// Other
229
242
///////////////////////////////////////////////////////////////////////////
0 commit comments