From 2589eba957ee5632dc9060022b5ca09cbfb782f9 Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Sun, 7 Apr 2013 20:26:48 -0700 Subject: [PATCH] When repr'ing an enum value, assert that it matched some variant. --- src/libcore/repr.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index 30ae3c3b8331..530f80ef764c 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -624,9 +624,10 @@ impl TyVisitor for ReprVisitor { fn visit_leave_enum(&self, _n_variants: uint, _get_disr: extern unsafe fn(ptr: *Opaque) -> int, _sz: uint, _align: uint) -> bool { - // NOTE should this assert that it's not still SearchingFor the right variant? - self.var_stk.pop(); - true + match self.var_stk.pop() { + SearchingFor(*) => fail!(~"enum value matched no variant"), + _ => true + } } fn visit_enter_fn(&self, _purity: uint, _proto: uint,