diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2016-02-24 20:36:20 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2016-02-24 22:04:27 +0200 |
| commit | 356bf529eedaea523b4266057b2ce8a13435b737 (patch) | |
| tree | 62ef3a8a4785f309654741404397d3e8829d1d8e | |
| parent | 77be4ecc1795787eab4b51b9def35096546122ec (diff) | |
| download | rust-356bf529eedaea523b4266057b2ce8a13435b737.tar.gz rust-356bf529eedaea523b4266057b2ce8a13435b737.zip | |
Fix tests
| -rw-r--r-- | src/test/run-fail/mir_dynamic_drops_1.rs | 13 | ||||
| -rw-r--r-- | src/test/run-fail/mir_dynamic_drops_2.rs | 13 | ||||
| -rw-r--r-- | src/test/run-fail/mir_dynamic_drops_3.rs | 20 |
3 files changed, 25 insertions, 21 deletions
diff --git a/src/test/run-fail/mir_dynamic_drops_1.rs b/src/test/run-fail/mir_dynamic_drops_1.rs index f3c2eafde24..590b9fbe43c 100644 --- a/src/test/run-fail/mir_dynamic_drops_1.rs +++ b/src/test/run-fail/mir_dynamic_drops_1.rs @@ -14,22 +14,23 @@ use std::io::{self, Write}; /// Structure which will not allow to be dropped twice. -struct Droppable(bool, u32); -impl Drop for Droppable { +struct Droppable<'a>(&'a mut bool, u32); +impl<'a> Drop for Droppable<'a> { fn drop(&mut self) { - if self.0 { + if *self.0 { writeln!(io::stderr(), "{} dropped twice", self.1); ::std::process::exit(1); } writeln!(io::stderr(), "drop {}", self.1); - self.0 = true; + *self.0 = true; } } #[rustc_mir] fn mir(){ - let x = Droppable(false, 1); - let y = Droppable(false, 2); + let (mut xv, mut yv) = (false, false); + let x = Droppable(&mut xv, 1); + let y = Droppable(&mut yv, 2); let mut z = x; let k = y; z = k; diff --git a/src/test/run-fail/mir_dynamic_drops_2.rs b/src/test/run-fail/mir_dynamic_drops_2.rs index ada04dfce64..eafd3d351fb 100644 --- a/src/test/run-fail/mir_dynamic_drops_2.rs +++ b/src/test/run-fail/mir_dynamic_drops_2.rs @@ -13,20 +13,20 @@ use std::io::{self, Write}; /// Structure which will not allow to be dropped twice. -struct Droppable(bool, u32); -impl Drop for Droppable { +struct Droppable<'a>(&'a mut bool, u32); +impl<'a> Drop for Droppable<'a> { fn drop(&mut self) { - if self.0 { + if *self.0 { writeln!(io::stderr(), "{} dropped twice", self.1); ::std::process::exit(1); } writeln!(io::stderr(), "drop {}", self.1); - self.0 = true; + *self.0 = true; } } #[rustc_mir] -fn mir(d: Droppable){ +fn mir<'a>(d: Droppable<'a>){ loop { let x = d; break; @@ -34,6 +34,7 @@ fn mir(d: Droppable){ } fn main() { - mir(Droppable(false, 1)); + let mut xv = false; + mir(Droppable(&mut xv, 1)); panic!(); } diff --git a/src/test/run-fail/mir_dynamic_drops_3.rs b/src/test/run-fail/mir_dynamic_drops_3.rs index cfbfb075954..730d9c8f226 100644 --- a/src/test/run-fail/mir_dynamic_drops_3.rs +++ b/src/test/run-fail/mir_dynamic_drops_3.rs @@ -16,28 +16,30 @@ use std::io::{self, Write}; /// Structure which will not allow to be dropped twice. -struct Droppable(bool, u32); -impl Drop for Droppable { +struct Droppable<'a>(&'a mut bool, u32); +impl<'a> Drop for Droppable<'a> { fn drop(&mut self) { - if self.0 { + if *self.0 { writeln!(io::stderr(), "{} dropped twice", self.1); ::std::process::exit(1); } writeln!(io::stderr(), "drop {}", self.1); - self.0 = true; + *self.0 = true; } } -fn may_panic() -> Droppable { +fn may_panic<'a>() -> Droppable<'a> { panic!("unwind happens"); } #[rustc_mir] -fn mir(d: Droppable){ - let y = Droppable(false, 2); - let x = [Droppable(false, 1), y, d, may_panic()]; +fn mir<'a>(d: Droppable<'a>){ + let (mut a, mut b) = (false, false); + let y = Droppable(&mut a, 2); + let x = [Droppable(&mut b, 1), y, d, may_panic()]; } fn main() { - mir(Droppable(false, 3)); + let mut c = false; + mir(Droppable(&mut c, 3)); } |
