@@ -225,6 +225,50 @@ impl<'a, 'tcx> At<'a, 'tcx> {
225
225
}
226
226
}
227
227
228
+ /// Used in the new solver since we don't care about tracking an `ObligationCause`.
229
+ pub fn relate_no_trace < T > (
230
+ self ,
231
+ expected : T ,
232
+ variance : ty:: Variance ,
233
+ actual : T ,
234
+ ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution >
235
+ where
236
+ T : Relate < TyCtxt < ' tcx > > ,
237
+ {
238
+ let mut fields = CombineFields :: new (
239
+ self . infcx ,
240
+ TypeTrace :: dummy ( self . cause ) ,
241
+ self . param_env ,
242
+ DefineOpaqueTypes :: Yes ,
243
+ ) ;
244
+ fields. sub ( ) . relate_with_variance (
245
+ variance,
246
+ ty:: VarianceDiagInfo :: default ( ) ,
247
+ expected,
248
+ actual,
249
+ ) ?;
250
+ Ok ( fields. goals )
251
+ }
252
+
253
+ /// Used in the new solver since we don't care about tracking an `ObligationCause`.
254
+ pub fn eq_structurally_relating_aliases_no_trace < T > (
255
+ self ,
256
+ expected : T ,
257
+ actual : T ,
258
+ ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution >
259
+ where
260
+ T : Relate < TyCtxt < ' tcx > > ,
261
+ {
262
+ let mut fields = CombineFields :: new (
263
+ self . infcx ,
264
+ TypeTrace :: dummy ( self . cause ) ,
265
+ self . param_env ,
266
+ DefineOpaqueTypes :: Yes ,
267
+ ) ;
268
+ fields. equate ( StructurallyRelateAliases :: Yes ) . relate ( expected, actual) ?;
269
+ Ok ( fields. goals )
270
+ }
271
+
228
272
/// Computes the least-upper-bound, or mutual supertype, of two
229
273
/// values. The order of the arguments doesn't matter, but since
230
274
/// this can result in an error (e.g., if asked to compute LUB of
@@ -303,7 +347,7 @@ impl<'tcx> ToTrace<'tcx> for Ty<'tcx> {
303
347
) -> TypeTrace < ' tcx > {
304
348
TypeTrace {
305
349
cause : cause. clone ( ) ,
306
- values : Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
350
+ values : ValuePairs :: Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
307
351
}
308
352
}
309
353
}
@@ -315,7 +359,10 @@ impl<'tcx> ToTrace<'tcx> for ty::Region<'tcx> {
315
359
a : Self ,
316
360
b : Self ,
317
361
) -> TypeTrace < ' tcx > {
318
- TypeTrace { cause : cause. clone ( ) , values : Regions ( ExpectedFound :: new ( a_is_expected, a, b) ) }
362
+ TypeTrace {
363
+ cause : cause. clone ( ) ,
364
+ values : ValuePairs :: Regions ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
365
+ }
319
366
}
320
367
}
321
368
@@ -328,7 +375,7 @@ impl<'tcx> ToTrace<'tcx> for Const<'tcx> {
328
375
) -> TypeTrace < ' tcx > {
329
376
TypeTrace {
330
377
cause : cause. clone ( ) ,
331
- values : Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
378
+ values : ValuePairs :: Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
332
379
}
333
380
}
334
381
}
@@ -344,13 +391,13 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
344
391
cause : cause. clone ( ) ,
345
392
values : match ( a. unpack ( ) , b. unpack ( ) ) {
346
393
( GenericArgKind :: Lifetime ( a) , GenericArgKind :: Lifetime ( b) ) => {
347
- Regions ( ExpectedFound :: new ( a_is_expected, a, b) )
394
+ ValuePairs :: Regions ( ExpectedFound :: new ( a_is_expected, a, b) )
348
395
}
349
396
( GenericArgKind :: Type ( a) , GenericArgKind :: Type ( b) ) => {
350
- Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) )
397
+ ValuePairs :: Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) )
351
398
}
352
399
( GenericArgKind :: Const ( a) , GenericArgKind :: Const ( b) ) => {
353
- Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) )
400
+ ValuePairs :: Terms ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) )
354
401
}
355
402
356
403
(
@@ -379,7 +426,10 @@ impl<'tcx> ToTrace<'tcx> for ty::Term<'tcx> {
379
426
a : Self ,
380
427
b : Self ,
381
428
) -> TypeTrace < ' tcx > {
382
- TypeTrace { cause : cause. clone ( ) , values : Terms ( ExpectedFound :: new ( a_is_expected, a, b) ) }
429
+ TypeTrace {
430
+ cause : cause. clone ( ) ,
431
+ values : ValuePairs :: Terms ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
432
+ }
383
433
}
384
434
}
385
435
@@ -392,7 +442,7 @@ impl<'tcx> ToTrace<'tcx> for ty::TraitRef<'tcx> {
392
442
) -> TypeTrace < ' tcx > {
393
443
TypeTrace {
394
444
cause : cause. clone ( ) ,
395
- values : TraitRefs ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
445
+ values : ValuePairs :: TraitRefs ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
396
446
}
397
447
}
398
448
}
@@ -406,7 +456,7 @@ impl<'tcx> ToTrace<'tcx> for ty::AliasTy<'tcx> {
406
456
) -> TypeTrace < ' tcx > {
407
457
TypeTrace {
408
458
cause : cause. clone ( ) ,
409
- values : Aliases ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
459
+ values : ValuePairs :: Aliases ( ExpectedFound :: new ( a_is_expected, a. into ( ) , b. into ( ) ) ) ,
410
460
}
411
461
}
412
462
}
@@ -418,7 +468,10 @@ impl<'tcx> ToTrace<'tcx> for ty::AliasTerm<'tcx> {
418
468
a : Self ,
419
469
b : Self ,
420
470
) -> TypeTrace < ' tcx > {
421
- TypeTrace { cause : cause. clone ( ) , values : Aliases ( ExpectedFound :: new ( a_is_expected, a, b) ) }
471
+ TypeTrace {
472
+ cause : cause. clone ( ) ,
473
+ values : ValuePairs :: Aliases ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
474
+ }
422
475
}
423
476
}
424
477
@@ -431,7 +484,7 @@ impl<'tcx> ToTrace<'tcx> for ty::FnSig<'tcx> {
431
484
) -> TypeTrace < ' tcx > {
432
485
TypeTrace {
433
486
cause : cause. clone ( ) ,
434
- values : PolySigs ( ExpectedFound :: new (
487
+ values : ValuePairs :: PolySigs ( ExpectedFound :: new (
435
488
a_is_expected,
436
489
ty:: Binder :: dummy ( a) ,
437
490
ty:: Binder :: dummy ( b) ,
@@ -449,7 +502,7 @@ impl<'tcx> ToTrace<'tcx> for ty::PolyFnSig<'tcx> {
449
502
) -> TypeTrace < ' tcx > {
450
503
TypeTrace {
451
504
cause : cause. clone ( ) ,
452
- values : PolySigs ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
505
+ values : ValuePairs :: PolySigs ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
453
506
}
454
507
}
455
508
}
@@ -463,7 +516,7 @@ impl<'tcx> ToTrace<'tcx> for ty::PolyExistentialTraitRef<'tcx> {
463
516
) -> TypeTrace < ' tcx > {
464
517
TypeTrace {
465
518
cause : cause. clone ( ) ,
466
- values : ExistentialTraitRef ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
519
+ values : ValuePairs :: ExistentialTraitRef ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
467
520
}
468
521
}
469
522
}
@@ -477,7 +530,7 @@ impl<'tcx> ToTrace<'tcx> for ty::PolyExistentialProjection<'tcx> {
477
530
) -> TypeTrace < ' tcx > {
478
531
TypeTrace {
479
532
cause : cause. clone ( ) ,
480
- values : ExistentialProjection ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
533
+ values : ValuePairs :: ExistentialProjection ( ExpectedFound :: new ( a_is_expected, a, b) ) ,
481
534
}
482
535
}
483
536
}
0 commit comments