diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index e2466c1c4c6..9291c4ba3ee 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -410,6 +410,11 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { C_named_struct(llty, ~[ lldiscrim, C_null(llstructtys[1]) ]) } + Some(ast::def_class(_)) => { + let ety = ty::expr_ty(cx.tcx, e); + let llty = type_of::type_of(cx, ety); + C_null(llty) + } _ => { cx.sess.span_bug(e.span, ~"expected a const, fn, or variant def") diff --git a/src/test/run-pass/const-unit-struct.rs b/src/test/run-pass/const-unit-struct.rs new file mode 100644 index 00000000000..c0a0201ed74 --- /dev/null +++ b/src/test/run-pass/const-unit-struct.rs @@ -0,0 +1,10 @@ +struct Foo; + +const X: Foo = Foo; + +fn main() { + match X { + Foo => {} + } +} +