@@ -171,7 +171,7 @@ impl<'tcx> InferCtxt<'tcx> {
171171 /// If possible, prefer the wrapper methods on `ObligationCtxt`,
172172 /// `FnCtxt`, or `TypeChecker`.
173173 pub fn sub_raw < T > (
174- self ,
174+ & self ,
175175 cause : & ObligationCause < ' tcx > ,
176176 param_env : ParamEnv < ' tcx > ,
177177 define_opaque_types : DefineOpaqueTypes ,
@@ -181,7 +181,20 @@ impl<'tcx> InferCtxt<'tcx> {
181181 where
182182 T : ToTrace < ' tcx > ,
183183 {
184- self . at ( cause, param_env) . sub ( define_opaque_types, expected, actual)
184+ if self . next_trait_solver {
185+ NextSolverRelate :: relate ( self , param_env, expected, ty:: Covariant , actual, cause. span )
186+ . map ( |goals| self . goals_to_obligations ( cause, goals) )
187+ } else {
188+ let mut op = TypeRelating :: new (
189+ self ,
190+ ToTrace :: to_trace ( cause, expected, actual) ,
191+ param_env,
192+ define_opaque_types,
193+ ty:: Covariant ,
194+ ) ;
195+ op. relate ( expected, actual) ?;
196+ Ok ( InferOk { value : ( ) , obligations : op. into_obligations ( ) } )
197+ }
185198 }
186199
187200 /// Makes `expected == actual`.
@@ -288,41 +301,6 @@ pub trait ToTrace<'tcx>: Relate<TyCtxt<'tcx>> + Copy {
288301}
289302
290303impl < ' a , ' tcx > At < ' a , ' tcx > {
291- /// Makes `expected <: actual`.
292- ///
293- /// FIXME: To be removed in favor of the [`InferCtxt::sub_raw`] method instead.
294- pub fn sub < T > (
295- self ,
296- define_opaque_types : DefineOpaqueTypes ,
297- expected : T ,
298- actual : T ,
299- ) -> InferResult < ' tcx , ( ) >
300- where
301- T : ToTrace < ' tcx > ,
302- {
303- if self . infcx . next_trait_solver {
304- NextSolverRelate :: relate (
305- self . infcx ,
306- self . param_env ,
307- expected,
308- ty:: Covariant ,
309- actual,
310- self . cause . span ,
311- )
312- . map ( |goals| self . goals_to_obligations ( goals) )
313- } else {
314- let mut op = TypeRelating :: new (
315- self . infcx ,
316- ToTrace :: to_trace ( self . cause , expected, actual) ,
317- self . param_env ,
318- define_opaque_types,
319- ty:: Covariant ,
320- ) ;
321- op. relate ( expected, actual) ?;
322- Ok ( InferOk { value : ( ) , obligations : op. into_obligations ( ) } )
323- }
324- }
325-
326304 /// Makes `expected == actual`.
327305 ///
328306 /// FIXME: To be removed in favor of the [`InferCtxt::eq_raw`] method instead.
@@ -391,7 +369,13 @@ impl<'a, 'tcx> At<'a, 'tcx> {
391369 T : ToTrace < ' tcx > ,
392370 {
393371 match variance {
394- ty:: Covariant => self . sub ( define_opaque_types, expected, actual) ,
372+ ty:: Covariant => self . infcx . sub_raw (
373+ self . cause ,
374+ self . param_env ,
375+ define_opaque_types,
376+ expected,
377+ actual,
378+ ) ,
395379 ty:: Invariant => self . eq ( define_opaque_types, expected, actual) ,
396380 ty:: Contravariant => self . infcx . sup_raw (
397381 self . cause ,
0 commit comments