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() { + +}