@@ -388,24 +388,24 @@ impl<'tcx> Relate<'tcx> for Ty<'tcx> {
388388 }
389389}
390390
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 > > (
395395 relation : & mut R ,
396396 a : Ty < ' tcx > ,
397397 b : Ty < ' tcx > ,
398398) -> RelateResult < ' tcx , Ty < ' tcx > > {
399399 let tcx = relation. tcx ( ) ;
400- debug ! ( "super_relate_tys : a={:?} b={:?}" , a, b) ;
400+ debug ! ( "structurally_relate_tys : a={:?} b={:?}" , a, b) ;
401401 match ( a. kind ( ) , b. kind ( ) ) {
402402 ( & ty:: Infer ( _) , _) | ( _, & ty:: Infer ( _) ) => {
403403 // The caller should handle these cases!
404- bug ! ( "var types encountered in super_relate_tys " )
404+ bug ! ( "var types encountered in structurally_relate_tys " )
405405 }
406406
407407 ( ty:: Bound ( ..) , _) | ( _, ty:: Bound ( ..) ) => {
408- bug ! ( "bound types encountered in super_relate_tys " )
408+ bug ! ( "bound types encountered in structurally_relate_tys " )
409409 }
410410
411411 ( & ty:: Error ( guar) , _) | ( _, & ty:: Error ( guar) ) => Ok ( tcx. ty_error ( guar) ) ,
@@ -575,15 +575,18 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
575575 }
576576}
577577
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 > > (
582585 relation : & mut R ,
583586 mut a : ty:: Const < ' tcx > ,
584587 mut b : ty:: Const < ' tcx > ,
585588) -> 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) ;
587590 let tcx = relation. tcx ( ) ;
588591
589592 // HACK(const_generics): We still need to eagerly evaluate consts when
@@ -602,15 +605,15 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
602605 b = tcx. expand_abstract_consts ( b) ;
603606 }
604607
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) ;
606609
607610 // Currently, the values that can be unified are primitive types,
608611 // and those that derive both `PartialEq` and `Eq`, corresponding
609612 // to structural-match types.
610613 let is_match = match ( a. kind ( ) , b. kind ( ) ) {
611614 ( ty:: ConstKind :: Infer ( _) , _) | ( _, ty:: ConstKind :: Infer ( _) ) => {
612615 // 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)
614617 }
615618
616619 ( ty:: ConstKind :: Error ( _) , _) => return Ok ( a) ,
0 commit comments