Do not evaluate in structurally_relate_tys

This commit is contained in:
Michael Goulet 2023-12-18 21:21:56 +00:00
parent 558ac1cfb7
commit e6d6b1d92c

View File

@ -505,13 +505,9 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
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_target_usize(tcx, relation.param_env());
let sz_b = sz_b.try_eval_target_usize(tcx, relation.param_env());
let sz_a = sz_a.try_to_target_usize(tcx);
let sz_b = sz_b.try_to_target_usize(tcx);
match (sz_a, sz_b) {
(Some(sz_a_val), Some(sz_b_val)) if sz_a_val != sz_b_val => Err(
TypeError::FixedArraySize(expected_found(relation, sz_a_val, sz_b_val)),