From 3aca4a166331e26a12f14e619c78ddd5ef590f70 Mon Sep 17 00:00:00 2001 From: Jed Davis <jld@panix.com> Date: Mon, 7 Jan 2013 02:07:56 -0800 Subject: [PATCH] Regression tests for passing enum-typed consts by reference. If the PointerCast in trans_def_lvalue is removed, these cases cause LLVM assertion failures. --- src/test/run-pass/const-enum-byref-self.rs | 25 ++++++++++++++++++++++ src/test/run-pass/const-enum-byref.rs | 23 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/test/run-pass/const-enum-byref-self.rs create mode 100644 src/test/run-pass/const-enum-byref.rs diff --git a/src/test/run-pass/const-enum-byref-self.rs b/src/test/run-pass/const-enum-byref-self.rs new file mode 100644 index 00000000000..cd939bc14d4 --- /dev/null +++ b/src/test/run-pass/const-enum-byref-self.rs @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum E { V, VV(int) } +const C: E = V; + +impl E { + fn method(&self) { + match *self { + V => {} + VV(*) => fail + } + } +} + +fn main() { + C.method() +} diff --git a/src/test/run-pass/const-enum-byref.rs b/src/test/run-pass/const-enum-byref.rs new file mode 100644 index 00000000000..8ee9e79670b --- /dev/null +++ b/src/test/run-pass/const-enum-byref.rs @@ -0,0 +1,23 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum E { V, VV(int) } +const C: E = V; + +fn f(a: &E) { + match *a { + V => {} + VV(*) => fail + } +} + +fn main() { + f(&C) +}