Skip to content

Commit

Permalink
always eagerly eval consts in Relate
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jan 23, 2021
1 parent 4d0dd02 commit 5fe84c8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compiler/rustc_middle/src/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,14 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
let t = relation.relate(a_t, b_t)?;
match relation.relate(sz_a, sz_b) {
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
// FIXME(#72219) Implement improved diagnostics for mismatched array
// length?
Err(err) if relation.tcx().lazy_normalization() => Err(err),
Err(err) => {
// Check whether the lengths are both concrete/known values,
// but are unequal, for better diagnostics.
//
// It might seem dubious to eagerly evaluate these constants here,
// we however cannot end up with errors in `Relate` during both
// `type_of` and `predicates_of`. This means that evaluating the
// constants should not cause cycle errors here.
let sz_a = sz_a.try_eval_usize(tcx, relation.param_env());
let sz_b = sz_b.try_eval_usize(tcx, relation.param_env());
match (sz_a, sz_b) {
Expand Down

0 comments on commit 5fe84c8

Please sign in to comment.