@@ -129,7 +129,10 @@ impl<'tcx> InferCtxt<'tcx> {
129129 /// call like `foo(x)`, where `foo: fn(i32)`, you might have
130130 /// `sup(i32, x)`, since the "expected" type is the type that
131131 /// appears in the signature.
132- pub fn sup < T > (
132+ ///
133+ /// If possible, prefer the wrapper methods on `ObligationCtxt`,
134+ /// `FnCtxt`, or `TypeChecker`.
135+ pub fn sup_raw < T > (
133136 self ,
134137 cause : & ObligationCause < ' tcx > ,
135138 param_env : ParamEnv < ' tcx > ,
@@ -144,7 +147,10 @@ impl<'tcx> InferCtxt<'tcx> {
144147 }
145148
146149 /// Makes `expected <: actual`.
147- pub fn sub < T > (
150+ ///
151+ /// If possible, prefer the wrapper methods on `ObligationCtxt`,
152+ /// `FnCtxt`, or `TypeChecker`.
153+ pub fn sub_raw < T > (
148154 self ,
149155 cause : & ObligationCause < ' tcx > ,
150156 param_env : ParamEnv < ' tcx > ,
@@ -159,7 +165,10 @@ impl<'tcx> InferCtxt<'tcx> {
159165 }
160166
161167 /// Makes `expected == actual`.
162- pub fn eq < T > (
168+ ///
169+ /// If possible, prefer the wrapper methods on `ObligationCtxt`,
170+ /// `FnCtxt`, or `TypeChecker`.
171+ pub fn eq_raw < T > (
163172 self ,
164173 cause : & ObligationCause < ' tcx > ,
165174 param_env : ParamEnv < ' tcx > ,
@@ -170,7 +179,7 @@ impl<'tcx> InferCtxt<'tcx> {
170179 where
171180 T : ToTrace < ' tcx > ,
172181 {
173- self . eq_trace (
182+ self . eq_trace_raw (
174183 cause,
175184 param_env,
176185 define_opaque_types,
@@ -181,7 +190,10 @@ impl<'tcx> InferCtxt<'tcx> {
181190 }
182191
183192 /// Makes `expected == actual`.
184- pub fn eq_trace < T > (
193+ ///
194+ /// If possible, prefer the wrapper methods on `ObligationCtxt`,
195+ /// `FnCtxt`, or `TypeChecker`.
196+ pub fn eq_trace_raw < T > (
185197 self ,
186198 cause : & ObligationCause < ' tcx > ,
187199 param_env : ParamEnv < ' tcx > ,
@@ -196,7 +208,9 @@ impl<'tcx> InferCtxt<'tcx> {
196208 self . at ( cause, param_env) . eq_trace ( define_opaque_types, trace, expected, actual)
197209 }
198210
199- pub fn relate < T > (
211+ /// If possible, prefer the wrapper methods on `ObligationCtxt`,
212+ /// `FnCtxt`, or `TypeChecker`.
213+ pub fn relate_raw < T > (
200214 self ,
201215 cause : & ObligationCause < ' tcx > ,
202216 param_env : ParamEnv < ' tcx > ,
@@ -210,6 +224,43 @@ impl<'tcx> InferCtxt<'tcx> {
210224 {
211225 self . at ( cause, param_env) . relate ( define_opaque_types, expected, variance, actual)
212226 }
227+
228+ /// Computes the least-upper-bound, or mutual supertype, of two
229+ /// values. The order of the arguments doesn't matter, but since
230+ /// this can result in an error (e.g., if asked to compute LUB of
231+ /// u32 and i32), it is meaningful to call one of them the
232+ /// "expected type".
233+ ///
234+ /// If possible, prefer the wrapper methods on `ObligationCtxt`,
235+ /// `FnCtxt`, or `TypeChecker`.
236+ pub fn lub_raw < T > (
237+ self ,
238+ cause : & ObligationCause < ' tcx > ,
239+ param_env : ParamEnv < ' tcx > ,
240+ expected : T ,
241+ actual : T ,
242+ ) -> InferResult < ' tcx , T >
243+ where
244+ T : ToTrace < ' tcx > ,
245+ {
246+ self . at ( cause, param_env) . lub ( expected, actual)
247+ }
248+
249+ pub fn goals_to_obligations (
250+ & self ,
251+ cause : & ObligationCause < ' tcx > ,
252+ goals : Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
253+ ) -> InferOk < ' tcx , ( ) > {
254+ InferOk {
255+ value : ( ) ,
256+ obligations : goals
257+ . into_iter ( )
258+ . map ( |goal| {
259+ Obligation :: new ( self . tcx , cause. clone ( ) , goal. param_env , goal. predicate )
260+ } )
261+ . collect ( ) ,
262+ }
263+ }
213264}
214265
215266pub trait ToTrace < ' tcx > : Relate < TyCtxt < ' tcx > > + Copy {
@@ -221,6 +272,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
221272 /// call like `foo(x)`, where `foo: fn(i32)`, you might have
222273 /// `sup(i32, x)`, since the "expected" type is the type that
223274 /// appears in the signature.
275+ ///
276+ /// FIXME: To be removed in favor of the [`InferCtxt::sup_raw`] method instead.
224277 pub fn sup < T > (
225278 self ,
226279 define_opaque_types : DefineOpaqueTypes ,
@@ -254,6 +307,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
254307 }
255308
256309 /// Makes `expected <: actual`.
310+ ///
311+ /// FIXME: To be removed in favor of the [`InferCtxt::sub_raw`] method instead.
257312 pub fn sub < T > (
258313 self ,
259314 define_opaque_types : DefineOpaqueTypes ,
@@ -287,6 +342,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
287342 }
288343
289344 /// Makes `expected == actual`.
345+ ///
346+ /// FIXME: To be removed in favor of the [`InferCtxt::eq_raw`] method instead.
290347 pub fn eq < T > (
291348 self ,
292349 define_opaque_types : DefineOpaqueTypes ,
@@ -305,6 +362,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
305362 }
306363
307364 /// Makes `expected == actual`.
365+ ///
366+ /// FIXME: To be removed in favor of the [`InferCtxt::eq_trace_raw`] method instead.
308367 pub fn eq_trace < T > (
309368 self ,
310369 define_opaque_types : DefineOpaqueTypes ,
@@ -338,6 +397,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
338397 }
339398 }
340399
400+ /// FIXME: To be removed in favor of the [`InferCtxt::relate_raw`] method instead.
341401 pub fn relate < T > (
342402 self ,
343403 define_opaque_types : DefineOpaqueTypes ,
@@ -367,6 +427,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
367427 /// this can result in an error (e.g., if asked to compute LUB of
368428 /// u32 and i32), it is meaningful to call one of them the
369429 /// "expected type".
430+ ///
431+ /// FIXME: To be removed in favor of the [`InferCtxt::lub_raw`] method instead.
370432 pub fn lub < T > ( self , expected : T , actual : T ) -> InferResult < ' tcx , T >
371433 where
372434 T : ToTrace < ' tcx > ,
@@ -381,6 +443,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
381443 Ok ( InferOk { value, obligations : op. into_obligations ( ) } )
382444 }
383445
446+ /// FIXME: To be removed in favor of the [`InferCtxt::goals_to_obligations`] method instead.
384447 fn goals_to_obligations (
385448 & self ,
386449 goals : Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ,
0 commit comments