translate array drop glue using MIR
This fixes leakage on panic with arrays & slices. I am using a C-style for-loop instead of a pointer-based loop because that would be ugly-er to implement.
This commit is contained in:
parent
5d2512ec5b
commit
9da2aaccfe
5 changed files with 152 additions and 46 deletions
|
|
@ -125,6 +125,14 @@ fn union1(a: &Allocator) {
|
|||
}
|
||||
}
|
||||
|
||||
fn array_simple(a: &Allocator) {
|
||||
let _x = [a.alloc(), a.alloc(), a.alloc(), a.alloc()];
|
||||
}
|
||||
|
||||
fn vec_simple(a: &Allocator) {
|
||||
let _x = vec![a.alloc(), a.alloc(), a.alloc(), a.alloc()];
|
||||
}
|
||||
|
||||
fn run_test<F>(mut f: F)
|
||||
where F: FnMut(&Allocator)
|
||||
{
|
||||
|
|
@ -171,5 +179,8 @@ fn main() {
|
|||
run_test(|a| assignment1(a, false));
|
||||
run_test(|a| assignment1(a, true));
|
||||
|
||||
run_test(|a| array_simple(a));
|
||||
run_test(|a| vec_simple(a));
|
||||
|
||||
run_test_nopanic(|a| union1(a));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue