From 40a0e0c6b0f6ab51c37a903ee392a58e4ff8b8e8 Mon Sep 17 00:00:00 2001 From: Filippo Veneri Date: Fri, 27 Sep 2013 08:54:18 +0200 Subject: [PATCH] Fixed issue 9243 --- src/librustc/middle/trans/adt.rs | 6 ++++-- src/test/run-pass/issue-9243-1.rs | 26 ++++++++++++++++++++++++++ src/test/run-pass/issue-9243-2.rs | 22 ++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/issue-9243-1.rs create mode 100644 src/test/run-pass/issue-9243-2.rs diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 5c255ad081811..8d380aee8ea78 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -503,9 +503,11 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr, assert!(min <= discr && discr <= max); C_disr(ccx, discr) } - Univariant(ref st, _dro) => { + Univariant(ref st, drop_flag) => { assert_eq!(discr, 0); - C_struct(build_const_struct(ccx, st, vals)) + let values = if drop_flag { ~[C_bool(true)] + vals } + else { vals.to_owned() }; + C_struct(build_const_struct(ccx, st, values)) } General(ref cases) => { let case = &cases[discr]; diff --git a/src/test/run-pass/issue-9243-1.rs b/src/test/run-pass/issue-9243-1.rs new file mode 100644 index 0000000000000..278c6d3e3facb --- /dev/null +++ b/src/test/run-pass/issue-9243-1.rs @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Test { + mem: int, +} + +pub static g_test: Test = Test { + mem: 0, +}; + +impl Drop for Test { + fn drop(&mut self) { + } +} + +fn main() { + +} diff --git a/src/test/run-pass/issue-9243-2.rs b/src/test/run-pass/issue-9243-2.rs new file mode 100644 index 0000000000000..d5cb22c1f2cb9 --- /dev/null +++ b/src/test/run-pass/issue-9243-2.rs @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Test; + +pub static g_test: Test = Test; + +impl Drop for Test { + fn drop(&mut self) { + } +} + +fn main() { + +}