@@ -12,13 +12,17 @@ pub use rustc_middle::traits::query::OutlivesBound;
12
12
pub type BoundsCompat < ' a , ' tcx : ' a > = impl Iterator < Item = OutlivesBound < ' tcx > > + ' a ;
13
13
pub type Bounds < ' a , ' tcx : ' a > = impl Iterator < Item = OutlivesBound < ' tcx > > + ' a ;
14
14
pub trait InferCtxtExt < ' a , ' tcx > {
15
+ /// Do *NOT* call this directly.
15
16
fn implied_bounds_tys_compat (
16
17
& ' a self ,
17
18
param_env : ty:: ParamEnv < ' tcx > ,
18
19
body_id : LocalDefId ,
19
20
tys : & ' a FxIndexSet < Ty < ' tcx > > ,
21
+ compat : bool ,
20
22
) -> BoundsCompat < ' a , ' tcx > ;
21
23
24
+ /// If `-Z no-implied-bounds-compat` is set, calls `implied_bounds_tys_compat`
25
+ /// with `compat` set to `true`, otherwise `false`.
22
26
fn implied_bounds_tys (
23
27
& ' a self ,
24
28
param_env : ty:: ParamEnv < ' tcx > ,
@@ -132,8 +136,10 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
132
136
param_env : ParamEnv < ' tcx > ,
133
137
body_id : LocalDefId ,
134
138
tys : & ' a FxIndexSet < Ty < ' tcx > > ,
139
+ compat : bool ,
135
140
) -> BoundsCompat < ' a , ' tcx > {
136
- tys. iter ( ) . flat_map ( move |ty| implied_outlives_bounds ( self , param_env, body_id, * ty, true ) )
141
+ tys. iter ( )
142
+ . flat_map ( move |ty| implied_outlives_bounds ( self , param_env, body_id, * ty, compat) )
137
143
}
138
144
139
145
fn implied_bounds_tys (
@@ -142,6 +148,14 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
142
148
body_id : LocalDefId ,
143
149
tys : & ' a FxIndexSet < Ty < ' tcx > > ,
144
150
) -> Bounds < ' a , ' tcx > {
145
- tys. iter ( ) . flat_map ( move |ty| implied_outlives_bounds ( self , param_env, body_id, * ty, false ) )
151
+ tys. iter ( ) . flat_map ( move |ty| {
152
+ implied_outlives_bounds (
153
+ self ,
154
+ param_env,
155
+ body_id,
156
+ * ty,
157
+ !self . tcx . sess . opts . unstable_opts . no_implied_bounds_compat ,
158
+ )
159
+ } )
146
160
}
147
161
}
0 commit comments