1
+ use rustc_data_structures:: fx:: FxHashSet ;
1
2
use rustc_hir as hir;
2
3
use rustc_hir:: HirId ;
3
4
use rustc_middle:: ty:: { self , ParamEnv , Ty } ;
@@ -8,6 +9,7 @@ use rustc_trait_selection::traits::{ObligationCause, TraitEngine, TraitEngineExt
8
9
9
10
pub use rustc_middle:: traits:: query:: OutlivesBound ;
10
11
12
+ type Bounds < ' a , ' tcx : ' a > = impl Iterator < Item = OutlivesBound < ' tcx > > + ' a ;
11
13
pub trait InferCtxtExt < ' a , ' tcx > {
12
14
fn implied_outlives_bounds (
13
15
& self ,
@@ -20,8 +22,8 @@ pub trait InferCtxtExt<'a, 'tcx> {
20
22
& ' a self ,
21
23
param_env : ty:: ParamEnv < ' tcx > ,
22
24
body_id : hir:: HirId ,
23
- tys : impl IntoIterator < Item = Ty < ' tcx > > + ' a ,
24
- ) -> Box < dyn Iterator < Item = OutlivesBound < ' tcx > > + ' a > ;
25
+ tys : FxHashSet < Ty < ' tcx > > ,
26
+ ) -> Bounds < ' a , ' tcx > ;
25
27
}
26
28
27
29
impl < ' a , ' cx , ' tcx : ' a > InferCtxtExt < ' a , ' tcx > for InferCtxt < ' cx , ' tcx > {
@@ -100,15 +102,13 @@ impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx> {
100
102
& ' a self ,
101
103
param_env : ParamEnv < ' tcx > ,
102
104
body_id : HirId ,
103
- tys : impl IntoIterator < Item = Ty < ' tcx > > + ' a ,
104
- ) -> Box < dyn Iterator < Item = OutlivesBound < ' tcx > > + ' a > {
105
- Box :: new (
106
- tys. into_iter ( )
107
- . map ( move |ty| {
108
- let ty = self . resolve_vars_if_possible ( ty) ;
109
- self . implied_outlives_bounds ( param_env, body_id, ty)
110
- } )
111
- . flatten ( ) ,
112
- )
105
+ tys : FxHashSet < Ty < ' tcx > > ,
106
+ ) -> Bounds < ' a , ' tcx > {
107
+ tys. into_iter ( )
108
+ . map ( move |ty| {
109
+ let ty = self . resolve_vars_if_possible ( ty) ;
110
+ self . implied_outlives_bounds ( param_env, body_id, ty)
111
+ } )
112
+ . flatten ( )
113
113
}
114
114
}
0 commit comments