@@ -34,6 +34,7 @@ use ty;
34
34
use ty:: subst:: { Subst , Substs } ;
35
35
use ty:: util:: { IntTypeExt , Discr } ;
36
36
use ty:: walk:: TypeWalker ;
37
+ use util:: captures:: Captures ;
37
38
use util:: nodemap:: { NodeSet , DefIdMap , FxHashMap } ;
38
39
39
40
use serialize:: { self , Encodable , Encoder } ;
@@ -1942,8 +1943,10 @@ impl<'a, 'gcx, 'tcx> AdtDef {
1942
1943
}
1943
1944
1944
1945
#[ inline]
1945
- pub fn discriminants ( & ' a self , tcx : TyCtxt < ' a , ' gcx , ' tcx > )
1946
- -> impl Iterator < Item =Discr < ' tcx > > + ' a {
1946
+ pub fn discriminants (
1947
+ & ' a self ,
1948
+ tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
1949
+ ) -> impl Iterator < Item =Discr < ' tcx > > + Captures < ' gcx > + ' a {
1947
1950
let repr_type = self . repr . discr_type ( ) ;
1948
1951
let initial = repr_type. initial_discriminant ( tcx. global_tcx ( ) ) ;
1949
1952
let mut prev_discr = None :: < Discr < ' tcx > > ;
@@ -2290,7 +2293,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2290
2293
/// Returns an iterator of the def-ids for all body-owners in this
2291
2294
/// crate. If you would prefer to iterate over the bodies
2292
2295
/// themselves, you can do `self.hir.krate().body_ids.iter()`.
2293
- pub fn body_owners ( self ) -> impl Iterator < Item = DefId > + ' a {
2296
+ pub fn body_owners (
2297
+ self ,
2298
+ ) -> impl Iterator < Item = DefId > + Captures < ' tcx > + Captures < ' gcx > + ' a {
2294
2299
self . hir . krate ( )
2295
2300
. body_ids
2296
2301
. iter ( )
@@ -2394,11 +2399,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2394
2399
}
2395
2400
}
2396
2401
2397
- #[ inline] // FIXME(#35870) Avoid closures being unexported due to impl Trait.
2398
- pub fn associated_items ( self , def_id : DefId )
2399
- -> impl Iterator < Item = ty:: AssociatedItem > + ' a {
2402
+ pub fn associated_items (
2403
+ self ,
2404
+ def_id : DefId ,
2405
+ ) -> impl Iterator < Item = ty:: AssociatedItem > + ' a {
2400
2406
let def_ids = self . associated_item_def_ids ( def_id) ;
2401
- ( 0 ..def_ids. len ( ) ) . map ( move |i| self . associated_item ( def_ids[ i] ) )
2407
+ Box :: new ( ( 0 ..def_ids. len ( ) ) . map ( move |i| self . associated_item ( def_ids[ i] ) ) )
2408
+ as Box < dyn Iterator < Item = ty:: AssociatedItem > + ' a >
2402
2409
}
2403
2410
2404
2411
/// Returns true if the impls are the same polarity and are implementing
0 commit comments