Skip to content

Commit b9cc054

Browse files
committed
Add workaround for index out of bounds on escaping substs
See rust-lang#188 for some discussion. The proper fix would probably be a bigger refactoring endeavor, but this avoids the index out of bounds access for now.
1 parent 0431504 commit b9cc054

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/mismatch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
207207
None
208208
}
209209
(&TyKind::FnDef(a_def_id, a_substs), &TyKind::FnDef(b_def_id, b_substs)) => {
210-
if self.check_substs(a_substs, b_substs) {
210+
// NEEDSWORK: the second half of this check is more of a workaround; see #188
211+
if self.check_substs(a_substs, b_substs) && !self.tcx.variances_of(a_def_id).is_empty() {
211212
let a_sig = a.fn_sig(self.tcx);
212213
let b_sig = b.fn_sig(self.tcx);
213214
let _ = self.relate_item_substs(a_def_id, a_substs, b_substs)?;

0 commit comments

Comments
 (0)