From 3b2fcf9f5991effa96c0102adc155bad0b5a4feb Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sun, 24 Mar 2013 21:04:01 -0700 Subject: [PATCH] librustc: Fix bug with newtype structs containing dtors --- src/librustc/middle/trans/datum.rs | 2 -- src/test/run-pass/newtype-struct-with-dtor.rs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/newtype-struct-with-dtor.rs diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index bb7fae9ae33a..f81973e169da 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -679,7 +679,6 @@ pub impl Datum { } let repr = adt::represent_type(ccx, self.ty); - fail_unless!(adt::is_newtypeish(repr)); let ty = ty::subst(ccx.tcx, substs, variants[0].args[0]); return match self.mode { ByRef => { @@ -719,7 +718,6 @@ pub impl Datum { } let repr = adt::represent_type(ccx, self.ty); - fail_unless!(adt::is_newtypeish(repr)); let ty = fields[0].mt.ty; return match self.mode { ByRef => { diff --git a/src/test/run-pass/newtype-struct-with-dtor.rs b/src/test/run-pass/newtype-struct-with-dtor.rs new file mode 100644 index 000000000000..f4a059018d20 --- /dev/null +++ b/src/test/run-pass/newtype-struct-with-dtor.rs @@ -0,0 +1,17 @@ +use core::libc::c_int; +use core::libc; + +pub struct Fd(c_int); + +impl Drop for Fd { + fn finalize(&self) { + unsafe { + libc::close(**self); + } + } +} + +fn main() { +} + +