Skip to content

Commit 2589eba

Browse files
committed
When repr'ing an enum value, assert that it matched some variant.
1 parent 640e8ae commit 2589eba

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libcore/repr.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,10 @@ impl TyVisitor for ReprVisitor {
624624
fn visit_leave_enum(&self, _n_variants: uint,
625625
_get_disr: extern unsafe fn(ptr: *Opaque) -> int,
626626
_sz: uint, _align: uint) -> bool {
627-
// NOTE should this assert that it's not still SearchingFor the right variant?
628-
self.var_stk.pop();
629-
true
627+
match self.var_stk.pop() {
628+
SearchingFor(*) => fail!(~"enum value matched no variant"),
629+
_ => true
630+
}
630631
}
631632
632633
fn visit_enter_fn(&self, _purity: uint, _proto: uint,

0 commit comments

Comments
 (0)