Skip to content

Commit 356bf52

Browse files
committed
Fix tests
1 parent 77be4ec commit 356bf52

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

src/test/run-fail/mir_dynamic_drops_1.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ use std::io::{self, Write};
1414

1515

1616
/// Structure which will not allow to be dropped twice.
17-
struct Droppable(bool, u32);
18-
impl Drop for Droppable {
17+
struct Droppable<'a>(&'a mut bool, u32);
18+
impl<'a> Drop for Droppable<'a> {
1919
fn drop(&mut self) {
20-
if self.0 {
20+
if *self.0 {
2121
writeln!(io::stderr(), "{} dropped twice", self.1);
2222
::std::process::exit(1);
2323
}
2424
writeln!(io::stderr(), "drop {}", self.1);
25-
self.0 = true;
25+
*self.0 = true;
2626
}
2727
}
2828

2929
#[rustc_mir]
3030
fn mir(){
31-
let x = Droppable(false, 1);
32-
let y = Droppable(false, 2);
31+
let (mut xv, mut yv) = (false, false);
32+
let x = Droppable(&mut xv, 1);
33+
let y = Droppable(&mut yv, 2);
3334
let mut z = x;
3435
let k = y;
3536
z = k;

src/test/run-fail/mir_dynamic_drops_2.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,28 @@ use std::io::{self, Write};
1313

1414

1515
/// Structure which will not allow to be dropped twice.
16-
struct Droppable(bool, u32);
17-
impl Drop for Droppable {
16+
struct Droppable<'a>(&'a mut bool, u32);
17+
impl<'a> Drop for Droppable<'a> {
1818
fn drop(&mut self) {
19-
if self.0 {
19+
if *self.0 {
2020
writeln!(io::stderr(), "{} dropped twice", self.1);
2121
::std::process::exit(1);
2222
}
2323
writeln!(io::stderr(), "drop {}", self.1);
24-
self.0 = true;
24+
*self.0 = true;
2525
}
2626
}
2727

2828
#[rustc_mir]
29-
fn mir(d: Droppable){
29+
fn mir<'a>(d: Droppable<'a>){
3030
loop {
3131
let x = d;
3232
break;
3333
}
3434
}
3535

3636
fn main() {
37-
mir(Droppable(false, 1));
37+
let mut xv = false;
38+
mir(Droppable(&mut xv, 1));
3839
panic!();
3940
}

src/test/run-fail/mir_dynamic_drops_3.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,30 @@ use std::io::{self, Write};
1616

1717

1818
/// Structure which will not allow to be dropped twice.
19-
struct Droppable(bool, u32);
20-
impl Drop for Droppable {
19+
struct Droppable<'a>(&'a mut bool, u32);
20+
impl<'a> Drop for Droppable<'a> {
2121
fn drop(&mut self) {
22-
if self.0 {
22+
if *self.0 {
2323
writeln!(io::stderr(), "{} dropped twice", self.1);
2424
::std::process::exit(1);
2525
}
2626
writeln!(io::stderr(), "drop {}", self.1);
27-
self.0 = true;
27+
*self.0 = true;
2828
}
2929
}
3030

31-
fn may_panic() -> Droppable {
31+
fn may_panic<'a>() -> Droppable<'a> {
3232
panic!("unwind happens");
3333
}
3434

3535
#[rustc_mir]
36-
fn mir(d: Droppable){
37-
let y = Droppable(false, 2);
38-
let x = [Droppable(false, 1), y, d, may_panic()];
36+
fn mir<'a>(d: Droppable<'a>){
37+
let (mut a, mut b) = (false, false);
38+
let y = Droppable(&mut a, 2);
39+
let x = [Droppable(&mut b, 1), y, d, may_panic()];
3940
}
4041

4142
fn main() {
42-
mir(Droppable(false, 3));
43+
let mut c = false;
44+
mir(Droppable(&mut c, 3));
4345
}

0 commit comments

Comments
 (0)