diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2016-01-30 19:32:50 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2016-02-04 15:56:05 +0200 |
| commit | ebf6341d1dfe57a7ad6f7f87501b018ffe24bba8 (patch) | |
| tree | 5114224b231d1dfd7b3798d3488ba8c7eaf80eeb /src/test/run-fail | |
| parent | 98265d338556e32c8ab1f89e14c0b3fab6e52001 (diff) | |
| download | rust-ebf6341d1dfe57a7ad6f7f87501b018ffe24bba8.tar.gz rust-ebf6341d1dfe57a7ad6f7f87501b018ffe24bba8.zip | |
Translation part of drop panic recovery
With this commit we now finally execute all the leftover drops once some drop panics for some reason!
Diffstat (limited to 'src/test/run-fail')
| -rw-r--r-- | src/test/run-fail/mir_drop_panics.rs | 34 |
1 files changed, 34 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..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 <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)] +// 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(); +} |
