Fix tests
This commit is contained in:
parent
77be4ecc17
commit
356bf529ee
3 changed files with 25 additions and 21 deletions
|
|
@ -14,22 +14,23 @@ use std::io::{self, Write};
|
|||
|
||||
|
||||
/// 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;
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@ use std::io::{self, Write};
|
|||
|
||||
|
||||
/// 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!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,28 +16,30 @@ use std::io::{self, Write};
|
|||
|
||||
|
||||
/// 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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue