@@ -510,12 +510,21 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
510510 let tcx = relation. tcx ( ) ;
511511
512512 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.
513517 if !x. val . needs_infer ( ) {
514518 return x. eval ( tcx, relation. param_env ( ) ) . val ;
515519 }
516520 x. val
517521 } ;
518522
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+
519528 // Currently, the values that can be unified are primitive types,
520529 // and those that derive both `PartialEq` and `Eq`, corresponding
521530 // to structural-match types.
@@ -524,6 +533,9 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
524533 // The caller should handle these cases!
525534 bug ! ( "var types encountered in super_relate_consts: {:?} {:?}" , a, b)
526535 }
536+
537+ ( ty:: ConstKind :: Error , _) | ( _, ty:: ConstKind :: Error ) => Ok ( ty:: ConstKind :: Error ) ,
538+
527539 ( ty:: ConstKind :: Param ( a_p) , ty:: ConstKind :: Param ( b_p) ) if a_p. index == b_p. index => {
528540 return Ok ( a) ;
529541 }
0 commit comments