about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-11-02 23:26:00 -0700
committerbors <bors@rust-lang.org>2013-11-02 23:26:00 -0700
commit4910b7ac28a8c489672573696e81ef6c8d54d1b3 (patch)
treeae0939b4244a07f4a04cf7f056c18af1509259e1 /src
parentb5c1b48048cc911c3caa07ada776239123a97b50 (diff)
parente58270219fcb40e342d3f51ef140574960b21a67 (diff)
downloadrust-4910b7ac28a8c489672573696e81ef6c8d54d1b3.tar.gz
rust-4910b7ac28a8c489672573696e81ef6c8d54d1b3.zip
auto merge of #10242 : thestinger/rust/inline_dtor, r=alexcrichton
Closes #7793
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/trans/base.rs17
-rw-r--r--src/test/auxiliary/inline_dtor.rs18
-rw-r--r--src/test/run-pass/use_inline_dtor.rs18
3 files changed, 48 insertions, 5 deletions
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index b00e1fe383a..64a4c453b2d 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -523,16 +523,23 @@ pub fn get_res_dtor(ccx: @mut CrateContext,
                     substs: &[ty::t])
                  -> ValueRef {
     let _icx = push_ctxt("trans_res_dtor");
+    let did = if did.crate != ast::LOCAL_CRATE {
+        inline::maybe_instantiate_inline(ccx, did)
+    } else {
+        did
+    };
     if !substs.is_empty() {
-        let did = if did.crate != ast::LOCAL_CRATE {
-            inline::maybe_instantiate_inline(ccx, did)
-        } else {
-            did
-        };
         assert_eq!(did.crate, ast::LOCAL_CRATE);
         let tsubsts = ty::substs {regions: ty::ErasedRegions,
                                   self_ty: None,
                                   tps: /*bad*/ substs.to_owned() };
+
+        // FIXME: #4252: Generic destructors with type bounds are broken.
+        //
+        // Since the vtables aren't passed to `monomorphic_fn` here, generic destructors with type
+        // bounds are broken. Sadly, the `typeck` pass isn't outputting the necessary metadata
+        // because it does so based on method calls present in the AST. Destructor calls are not yet
+        // known about at that stage of compilation, since `trans` handles cleanups.
         let (val, _) = monomorphize::monomorphic_fn(ccx,
                                                     did,
                                                     &tsubsts,
diff --git a/src/test/auxiliary/inline_dtor.rs b/src/test/auxiliary/inline_dtor.rs
new file mode 100644
index 00000000000..1e93cd63591
--- /dev/null
+++ b/src/test/auxiliary/inline_dtor.rs
@@ -0,0 +1,18 @@
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[link(name="inline_dtor", vers="0.1")];
+
+pub struct Foo;
+
+impl Drop for Foo {
+    #[inline]
+    fn drop(&mut self) {}
+}
diff --git a/src/test/run-pass/use_inline_dtor.rs b/src/test/run-pass/use_inline_dtor.rs
new file mode 100644
index 00000000000..73b7013742b
--- /dev/null
+++ b/src/test/run-pass/use_inline_dtor.rs
@@ -0,0 +1,18 @@
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:inline_dtor.rs
+// xfail-fast
+
+extern mod inline_dtor;
+
+fn main() {
+    let _x = inline_dtor::Foo;
+}