mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
commit
320bd6f874
@ -355,7 +355,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
let ty = Type::from_ref(llvm::LLVMTypeOf(dtor_addr));
|
let ty = Type::from_ref(llvm::LLVMTypeOf(dtor_addr));
|
||||||
ty.element_type().func_params()
|
ty.element_type().func_params()
|
||||||
};
|
};
|
||||||
assert_eq!(params.len(), 1);
|
assert_eq!(params.len(), if type_is_sized(bcx.tcx(), t) { 1 } else { 2 });
|
||||||
|
|
||||||
// Be sure to put the contents into a scope so we can use an invoke
|
// Be sure to put the contents into a scope so we can use an invoke
|
||||||
// instruction to call the user destructor but still call the field
|
// instruction to call the user destructor but still call the field
|
||||||
@ -371,7 +371,12 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
|
|
||||||
let glue_type = get_drop_glue_type(bcx.ccx(), t);
|
let glue_type = get_drop_glue_type(bcx.ccx(), t);
|
||||||
let dtor_ty = bcx.tcx().mk_ctor_fn(class_did, &[glue_type], bcx.tcx().mk_nil());
|
let dtor_ty = bcx.tcx().mk_ctor_fn(class_did, &[glue_type], bcx.tcx().mk_nil());
|
||||||
let (_, bcx) = invoke(bcx, dtor_addr, &[v0], dtor_ty, DebugLoc::None);
|
let (_, bcx) = if type_is_sized(bcx.tcx(), t) {
|
||||||
|
invoke(bcx, dtor_addr, &[v0], dtor_ty, DebugLoc::None)
|
||||||
|
} else {
|
||||||
|
let args = [Load(bcx, expr::get_dataptr(bcx, v0)), Load(bcx, expr::get_len(bcx, v0))];
|
||||||
|
invoke(bcx, dtor_addr, &args, dtor_ty, DebugLoc::None)
|
||||||
|
};
|
||||||
|
|
||||||
bcx.fcx.pop_and_trans_custom_cleanup_scope(bcx, contents_scope)
|
bcx.fcx.pop_and_trans_custom_cleanup_scope(bcx, contents_scope)
|
||||||
}
|
}
|
||||||
|
26
src/test/run-pass/issue-26709.rs
Normal file
26
src/test/run-pass/issue-26709.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
struct Wrapper<'a, T: ?Sized>(&'a mut i32, T);
|
||||||
|
|
||||||
|
impl<'a, T: ?Sized> Drop for Wrapper<'a, T> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
*self.0 = 432;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut x = 0;
|
||||||
|
{
|
||||||
|
let wrapper = Box::new(Wrapper(&mut x, 123));
|
||||||
|
let _: Box<Wrapper<Send>> = wrapper;
|
||||||
|
}
|
||||||
|
assert_eq!(432, x)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user