]> git.lizzy.rs Git - rust.git/commitdiff
Fix tests
authorSimonas Kazlauskas <git@kazlauskas.me>
Wed, 24 Feb 2016 18:36:20 +0000 (20:36 +0200)
committerSimonas Kazlauskas <git@kazlauskas.me>
Wed, 24 Feb 2016 20:04:27 +0000 (22:04 +0200)
src/test/run-fail/mir_dynamic_drops_1.rs
src/test/run-fail/mir_dynamic_drops_2.rs
src/test/run-fail/mir_dynamic_drops_3.rs

index f3c2eafde2459517922fcd57f9dcfcc9b6fca854..590b9fbe43cf5e49130a26c13cc74dcf2cb55d4f 100644 (file)
 
 
 /// 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;
index ada04dfce647114dc59edfb730906c4f10b9dadb..eafd3d351fb939030615ba69482c9798a854c3c1 100644 (file)
 
 
 /// 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!();
 }
index cfbfb075954624618cb48b4cf16946e21ac13d2c..730d9c8f22681be8860431e28499f25a5774c506 100644 (file)
 
 
 /// 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));
 }