Manishearth / humpty_dumpty

Implicit Drop/move protection for Rust (linear types)
12 stars 1 forks source link

handling of for loops doesn't correctly take breaks into account #16

Closed Munksgaard closed 9 years ago

Munksgaard commented 9 years ago

The following code compiles without errors:

#![feature(plugin)]
#![feature(custom_attribute)]
#![plugin(humpty_dumpty)]
#![allow(unused_attributes)]
#![allow(unused_variables)]
#![allow(dead_code)]

#[drop_protect]
struct Foo;

impl Foo {
    #[allow_drop="Foo"]
    fn close(self) { }
}

fn test1() {
    let f = vec!(Foo); //~ ERROR dropped
    for i in f {
        if true {
            break;
        }
        i.close();
    }
}

fn main() {}

It really shouldn't.