@@ -140,27 +140,7 @@ impl<'tcx> InferCtxt<'tcx> {
140140 where
141141 T : ToTrace < ' tcx > ,
142142 {
143- if self . next_trait_solver {
144- NextSolverRelate :: relate (
145- & self ,
146- param_env,
147- expected,
148- ty:: Contravariant ,
149- actual,
150- cause. span ,
151- )
152- . map ( |goals| self . at ( & cause, param_env) . goals_to_obligations ( goals) )
153- } else {
154- let mut op = TypeRelating :: new (
155- & self ,
156- ToTrace :: to_trace ( & cause, expected, actual) ,
157- param_env,
158- define_opaque_types,
159- ty:: Contravariant ,
160- ) ;
161- op. relate ( expected, actual) ?;
162- Ok ( InferOk { value : ( ) , obligations : op. into_obligations ( ) } )
163- }
143+ self . at ( cause, param_env) . sup ( define_opaque_types, expected, actual)
164144 }
165145
166146 /// Makes `expected <: actual`.
@@ -175,20 +155,7 @@ impl<'tcx> InferCtxt<'tcx> {
175155 where
176156 T : ToTrace < ' tcx > ,
177157 {
178- if self . next_trait_solver {
179- NextSolverRelate :: relate ( & self , param_env, expected, ty:: Covariant , actual, cause. span )
180- . map ( |goals| self . at ( & cause, param_env) . goals_to_obligations ( goals) )
181- } else {
182- let mut op = TypeRelating :: new (
183- & self ,
184- ToTrace :: to_trace ( & cause, expected, actual) ,
185- param_env,
186- define_opaque_types,
187- ty:: Covariant ,
188- ) ;
189- op. relate ( expected, actual) ?;
190- Ok ( InferOk { value : ( ) , obligations : op. into_obligations ( ) } )
191- }
158+ self . at ( cause, param_env) . sub ( define_opaque_types, expected, actual)
192159 }
193160
194161 /// Makes `expected == actual`.
@@ -226,15 +193,7 @@ impl<'tcx> InferCtxt<'tcx> {
226193 where
227194 T : Relate < TyCtxt < ' tcx > > ,
228195 {
229- if self . next_trait_solver {
230- NextSolverRelate :: relate ( & self , param_env, expected, ty:: Invariant , actual, cause. span )
231- . map ( |goals| self . at ( & cause, param_env) . goals_to_obligations ( goals) )
232- } else {
233- let mut op =
234- TypeRelating :: new ( & self , trace, param_env, define_opaque_types, ty:: Invariant ) ;
235- op. relate ( expected, actual) ?;
236- Ok ( InferOk { value : ( ) , obligations : op. into_obligations ( ) } )
237- }
196+ self . at ( cause, param_env) . eq_trace ( define_opaque_types, trace, expected, actual)
238197 }
239198
240199 pub fn relate < T > (
@@ -249,18 +208,7 @@ impl<'tcx> InferCtxt<'tcx> {
249208 where
250209 T : ToTrace < ' tcx > ,
251210 {
252- match variance {
253- ty:: Covariant => self . sub ( cause, param_env, define_opaque_types, expected, actual) ,
254- ty:: Invariant => self . eq ( cause, param_env, define_opaque_types, expected, actual) ,
255- ty:: Contravariant => self . sup ( cause, param_env, define_opaque_types, expected, actual) ,
256-
257- // We could make this make sense but it's not readily
258- // exposed and I don't feel like dealing with it. Note
259- // that bivariance in general does a bit more than just
260- // *nothing*, it checks that the types are the same
261- // "modulo variance" basically.
262- ty:: Bivariant => panic ! ( "Bivariant given to `relate()`" ) ,
263- }
211+ self . at ( cause, param_env) . relate ( define_opaque_types, expected, variance, actual)
264212 }
265213}
266214
0 commit comments