@@ -388,24 +388,24 @@ impl<'tcx> Relate<'tcx> for Ty<'tcx> {
388
388
}
389
389
}
390
390
391
- /// The main "type relation" routine. Note that this does not handle
392
- /// inference artifacts, so you should filter those out before calling
393
- /// it .
394
- pub fn super_relate_tys < ' tcx , R : TypeRelation < ' tcx > > (
391
+ /// Relates `a` and `b` structurally, calling the relation for all nested values.
392
+ /// Any semantic equality, e.g. of projections, and inference variables have to be
393
+ /// handled by the caller .
394
+ pub fn structurally_relate_tys < ' tcx , R : TypeRelation < ' tcx > > (
395
395
relation : & mut R ,
396
396
a : Ty < ' tcx > ,
397
397
b : Ty < ' tcx > ,
398
398
) -> RelateResult < ' tcx , Ty < ' tcx > > {
399
399
let tcx = relation. tcx ( ) ;
400
- debug ! ( "super_relate_tys : a={:?} b={:?}" , a, b) ;
400
+ debug ! ( "structurally_relate_tys : a={:?} b={:?}" , a, b) ;
401
401
match ( a. kind ( ) , b. kind ( ) ) {
402
402
( & ty:: Infer ( _) , _) | ( _, & ty:: Infer ( _) ) => {
403
403
// The caller should handle these cases!
404
- bug ! ( "var types encountered in super_relate_tys " )
404
+ bug ! ( "var types encountered in structurally_relate_tys " )
405
405
}
406
406
407
407
( ty:: Bound ( ..) , _) | ( _, ty:: Bound ( ..) ) => {
408
- bug ! ( "bound types encountered in super_relate_tys " )
408
+ bug ! ( "bound types encountered in structurally_relate_tys " )
409
409
}
410
410
411
411
( & ty:: Error ( guar) , _) | ( _, & ty:: Error ( guar) ) => Ok ( tcx. ty_error ( guar) ) ,
@@ -575,15 +575,18 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
575
575
}
576
576
}
577
577
578
- /// The main "const relation" routine. Note that this does not handle
579
- /// inference artifacts, so you should filter those out before calling
580
- /// it.
581
- pub fn super_relate_consts < ' tcx , R : TypeRelation < ' tcx > > (
578
+ /// Relates `a` and `b` structurally, calling the relation for all nested values.
579
+ /// Any semantic equality, e.g. of unevaluated consts, and inference variables have
580
+ /// to be handled by the caller.
581
+ ///
582
+ /// FIXME: This is not totally structual, which probably should be fixed.
583
+ /// See the HACKs below.
584
+ pub fn structurally_relate_consts < ' tcx , R : TypeRelation < ' tcx > > (
582
585
relation : & mut R ,
583
586
mut a : ty:: Const < ' tcx > ,
584
587
mut b : ty:: Const < ' tcx > ,
585
588
) -> RelateResult < ' tcx , ty:: Const < ' tcx > > {
586
- debug ! ( "{}.super_relate_consts (a = {:?}, b = {:?})" , relation. tag( ) , a, b) ;
589
+ debug ! ( "{}.structurally_relate_consts (a = {:?}, b = {:?})" , relation. tag( ) , a, b) ;
587
590
let tcx = relation. tcx ( ) ;
588
591
589
592
// HACK(const_generics): We still need to eagerly evaluate consts when
@@ -602,15 +605,15 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
602
605
b = tcx. expand_abstract_consts ( b) ;
603
606
}
604
607
605
- debug ! ( "{}.super_relate_consts (normed_a = {:?}, normed_b = {:?})" , relation. tag( ) , a, b) ;
608
+ debug ! ( "{}.structurally_relate_consts (normed_a = {:?}, normed_b = {:?})" , relation. tag( ) , a, b) ;
606
609
607
610
// Currently, the values that can be unified are primitive types,
608
611
// and those that derive both `PartialEq` and `Eq`, corresponding
609
612
// to structural-match types.
610
613
let is_match = match ( a. kind ( ) , b. kind ( ) ) {
611
614
( ty:: ConstKind :: Infer ( _) , _) | ( _, ty:: ConstKind :: Infer ( _) ) => {
612
615
// The caller should handle these cases!
613
- bug ! ( "var types encountered in super_relate_consts : {:?} {:?}" , a, b)
616
+ bug ! ( "var types encountered in structurally_relate_consts : {:?} {:?}" , a, b)
614
617
}
615
618
616
619
( ty:: ConstKind :: Error ( _) , _) => return Ok ( a) ,
0 commit comments