about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-02-06 01:24:22 +0000
committerbors <bors@rust-lang.org>2016-02-06 01:24:22 +0000
commit5147c1f2c04f62dceea5feaf6a2dcbebf5cd638f (patch)
tree4d8cd52215cb214be361a4fe29e750597fdd6a61 /src/test
parent34af2de4096b3b1c5d3a5b70171c6e27822aaefb (diff)
parentcaf62ef9846edfd41177b883181c5c045ca69859 (diff)
downloadrust-5147c1f2c04f62dceea5feaf6a2dcbebf5cd638f.tar.gz
rust-5147c1f2c04f62dceea5feaf6a2dcbebf5cd638f.zip
Auto merge of #31307 - nagisa:mir-drop-terminator, r=nikomatsakis
The scope of these refactorings is a little bit bigger than the title implies. See each commit for details.

I’m submitting this for nitpicking now (the first 4 commits), because I feel the basic idea/implementation is sound and should work. I will eventually expand this PR to cover the translator changes necessary for all this to work (+ tests), ~~and perhaps implement a dynamic dropping scheme while I’m at it as well.~~

r? @nikomatsakis
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-fail/mir_drop_panics.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/run-fail/mir_drop_panics.rs b/src/test/run-fail/mir_drop_panics.rs
new file mode 100644
index 00000000000..df20700e016
--- /dev/null
+++ b/src/test/run-fail/mir_drop_panics.rs
@@ -0,0 +1,36 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+#![feature(rustc_attrs)]
+
+// ignore-msvc: FIXME(#30941)
+// error-pattern:panic 1
+// error-pattern:drop 2
+use std::io::{self, Write};
+
+struct Droppable(u32);
+impl Drop for Droppable {
+    fn drop(&mut self) {
+        if self.0 == 1 {
+            panic!("panic 1");
+        } else {
+            write!(io::stderr(), "drop {}", self.0);
+        }
+    }
+}
+
+#[rustc_mir]
+fn mir() {
+    let x = Droppable(2);
+    let y = Droppable(1);
+}
+
+fn main() {
+    mir();
+}