Skip to content

Commit

Permalink
librustc: Fix bug with newtype structs containing dtors
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Mar 25, 2013
1 parent f1f99b3 commit 9e26d16
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/librustc/middle/trans/datum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down
17 changes: 17 additions & 0 deletions src/test/run-pass/newtype-struct-with-dtor.rs
Original file line number Diff line number Diff line change
@@ -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() {
}


4 comments on commit 9e26d16

@bors
Copy link
Contributor

@bors bors commented on 9e26d16 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jld
at pcwalton@9e26d16

@bors
Copy link
Contributor

@bors bors commented on 9e26d16 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging pcwalton/rust/newtype-struct-with-dtor = 9e26d16 into auto

@bors
Copy link
Contributor

@bors bors commented on 9e26d16 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pcwalton/rust/newtype-struct-with-dtor = 9e26d16 merged ok, testing candidate = ebbd94f3

@bors
Copy link
Contributor

@bors bors commented on 9e26d16 Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.