Skip to content

Commit 9116400

Browse files
committed
Split dst-dtor-{1,2} tests into four.
1 parent ab54fa7 commit 9116400

File tree

4 files changed

+63
-4
lines changed

4 files changed

+63
-4
lines changed

src/test/run-pass-valgrind/dst-dtor-1.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ struct Fat<T: ?Sized> {
2828

2929
pub fn main() {
3030
{
31-
let _x: Box<(i32, Fat<Trait>)> =
32-
Box::<(i32, Fat<Foo>)>::new((42, Fat { f: Foo }));
31+
let _x: Box<Fat<Trait>> = Box::<Fat<Foo>>::new(Fat { f: Foo });
3332
}
3433
unsafe {
3534
assert!(DROP_RAN);

src/test/run-pass-valgrind/dst-dtor-2.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ struct Fat<T: ?Sized> {
2525

2626
pub fn main() {
2727
{
28-
let _x: Box<(Fat<[Foo]>,)> =
29-
Box::<(Fat<[Foo; 3]>,)>::new((Fat { f: [Foo, Foo, Foo] },));
28+
let _x: Box<Fat<[Foo]>> = Box::<Fat<[Foo; 3]>>::new(Fat { f: [Foo, Foo, Foo] });
3029
}
3130
unsafe {
3231
assert_eq!(DROP_RAN, 3);
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2014 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+
// no-prefer-dynamic
12+
13+
static mut DROP_RAN: bool = false;
14+
15+
struct Foo;
16+
impl Drop for Foo {
17+
fn drop(&mut self) {
18+
unsafe { DROP_RAN = true; }
19+
}
20+
}
21+
22+
trait Trait { fn dummy(&self) { } }
23+
impl Trait for Foo {}
24+
25+
pub fn main() {
26+
{
27+
let _x: Box<(i32, Trait)> = Box::<(i32, Foo)>::new((42, Foo));
28+
}
29+
unsafe {
30+
assert!(DROP_RAN);
31+
}
32+
}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 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+
// no-prefer-dynamic
12+
13+
static mut DROP_RAN: isize = 0;
14+
15+
struct Foo;
16+
impl Drop for Foo {
17+
fn drop(&mut self) {
18+
unsafe { DROP_RAN += 1; }
19+
}
20+
}
21+
22+
pub fn main() {
23+
{
24+
let _x: Box<(i32, [Foo])> = Box::<(i32, [Foo; 3])>::new((42, [Foo, Foo, Foo]));
25+
}
26+
unsafe {
27+
assert_eq!(DROP_RAN, 3);
28+
}
29+
}

0 commit comments

Comments
 (0)