From ebf6341d1dfe57a7ad6f7f87501b018ffe24bba8 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sat, 30 Jan 2016 19:32:50 +0200 Subject: Translation part of drop panic recovery With this commit we now finally execute all the leftover drops once some drop panics for some reason! --- src/test/run-fail/mir_drop_panics.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/run-fail/mir_drop_panics.rs (limited to 'src/test/run-fail') 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..9868ff4c241 --- /dev/null +++ b/src/test/run-fail/mir_drop_panics.rs @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![feature(rustc_attrs)] +// 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(); +} -- cgit 1.4.1-3-g733a5