Latent bug in iter_structural_ty: handle `_match::Single` on zero-variant enum.
(This may not be the *best* fix, compared to e.g. returning `_match::NoBranch` from `trans_switch` on a zero-variant enum. But it is one of the *simplest* fixes available.)
This commit is contained in:
parent
5910dc0e8e
commit
f7d9b43972
|
@ -769,6 +769,7 @@ pub fn trans_switch<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
(_match::Switch, Some(trans_get_discr(bcx, r, scrutinee, None)))
|
||||
}
|
||||
Univariant(..) => {
|
||||
// N.B.: Univariant means <= 1 enum variants (*not* == 1 variants).
|
||||
(_match::Single, None)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -471,8 +471,11 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
|
||||
match adt::trans_switch(cx, &*repr, av) {
|
||||
(_match::Single, None) => {
|
||||
cx = iter_variant(cx, &*repr, av, &*(*variants)[0],
|
||||
substs, &mut f);
|
||||
if n_variants != 0 {
|
||||
assert!(n_variants == 1);
|
||||
cx = iter_variant(cx, &*repr, av, &*(*variants)[0],
|
||||
substs, &mut f);
|
||||
}
|
||||
}
|
||||
(_match::Switch, Some(lldiscrim_a)) => {
|
||||
cx = f(cx, lldiscrim_a, cx.tcx().types.isize);
|
||||
|
|
Loading…
Reference in New Issue