]> git.proxmox.com Git - rustc.git/blame - src/test/run-fail/mir_drop_panics.rs
New upstream version 1.13.0+dfsg1
[rustc.git] / src / test / run-fail / mir_drop_panics.rs
CommitLineData
7453a54e 1// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
223e47cc
LB
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
7453a54e
SL
11// error-pattern:panic 1
12// error-pattern:drop 2
13use std::io::{self, Write};
223e47cc 14
7453a54e
SL
15struct Droppable(u32);
16impl Drop for Droppable {
1a4d82fc 17 fn drop(&mut self) {
7453a54e
SL
18 if self.0 == 1 {
19 panic!("panic 1");
20 } else {
21 write!(io::stderr(), "drop {}", self.0);
223e47cc
LB
22 }
23 }
24}
25
7453a54e
SL
26fn mir() {
27 let x = Droppable(2);
28 let y = Droppable(1);
223e47cc
LB
29}
30
31fn main() {
7453a54e 32 mir();
223e47cc 33}