@@ -510,12 +510,21 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
510
510
let tcx = relation. tcx ( ) ;
511
511
512
512
let eagerly_eval = |x : & ' tcx ty:: Const < ' tcx > | {
513
+ // FIXME(eddyb) this doesn't account for lifetime inference variables
514
+ // being erased by `eval`, *nor* for the polymorphic aspect of `eval`.
515
+ // That is, we could always use `eval` and it will just return the
516
+ // old value back if it doesn't succeed.
513
517
if !x. val . needs_infer ( ) {
514
518
return x. eval ( tcx, relation. param_env ( ) ) . val ;
515
519
}
516
520
x. val
517
521
} ;
518
522
523
+ // FIXME(eddyb) doesn't look like everything below checks that `a.ty == b.ty`.
524
+ // We could probably always assert it early, as `const` generic parameters
525
+ // are not allowed to depend on other generic parameters, i.e. are concrete.
526
+ // (although there could be normalization differences)
527
+
519
528
// Currently, the values that can be unified are primitive types,
520
529
// and those that derive both `PartialEq` and `Eq`, corresponding
521
530
// to structural-match types.
@@ -524,6 +533,9 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
524
533
// The caller should handle these cases!
525
534
bug ! ( "var types encountered in super_relate_consts: {:?} {:?}" , a, b)
526
535
}
536
+
537
+ ( ty:: ConstKind :: Error , _) | ( _, ty:: ConstKind :: Error ) => Ok ( ty:: ConstKind :: Error ) ,
538
+
527
539
( ty:: ConstKind :: Param ( a_p) , ty:: ConstKind :: Param ( b_p) ) if a_p. index == b_p. index => {
528
540
return Ok ( a) ;
529
541
}
0 commit comments