Skip to content

Commit 4910b7a

Browse files
committed
auto merge of #10242 : thestinger/rust/inline_dtor, r=alexcrichton
Closes #7793
2 parents b5c1b48 + e582702 commit 4910b7a

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

src/librustc/middle/trans/base.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -523,16 +523,23 @@ pub fn get_res_dtor(ccx: @mut CrateContext,
523523
substs: &[ty::t])
524524
-> ValueRef {
525525
let _icx = push_ctxt("trans_res_dtor");
526+
let did = if did.crate != ast::LOCAL_CRATE {
527+
inline::maybe_instantiate_inline(ccx, did)
528+
} else {
529+
did
530+
};
526531
if !substs.is_empty() {
527-
let did = if did.crate != ast::LOCAL_CRATE {
528-
inline::maybe_instantiate_inline(ccx, did)
529-
} else {
530-
did
531-
};
532532
assert_eq!(did.crate, ast::LOCAL_CRATE);
533533
let tsubsts = ty::substs {regions: ty::ErasedRegions,
534534
self_ty: None,
535535
tps: /*bad*/ substs.to_owned() };
536+
537+
// FIXME: #4252: Generic destructors with type bounds are broken.
538+
//
539+
// Since the vtables aren't passed to `monomorphic_fn` here, generic destructors with type
540+
// bounds are broken. Sadly, the `typeck` pass isn't outputting the necessary metadata
541+
// because it does so based on method calls present in the AST. Destructor calls are not yet
542+
// known about at that stage of compilation, since `trans` handles cleanups.
536543
let (val, _) = monomorphize::monomorphic_fn(ccx,
537544
did,
538545
&tsubsts,

src/test/auxiliary/inline_dtor.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[link(name="inline_dtor", vers="0.1")];
12+
13+
pub struct Foo;
14+
15+
impl Drop for Foo {
16+
#[inline]
17+
fn drop(&mut self) {}
18+
}

src/test/run-pass/use_inline_dtor.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:inline_dtor.rs
12+
// xfail-fast
13+
14+
extern mod inline_dtor;
15+
16+
fn main() {
17+
let _x = inline_dtor::Foo;
18+
}

0 commit comments

Comments
 (0)