Skip to content

Borrowed @mut boxes are not unborrowed during unwinding #7049

Closed
@brson

Description

@brson
use std::task::spawn_unlinked;
use std::unstable::finally::Finally;

fn main() {
    let (port, chan) = stream();
    do spawn_unlinked {
        let buf = @mut ~[0];
        do (|| {
            fn take(_b: &mut ~[uint]) {
                fail!();
            }
            take(&mut *buf);
        }).finally {
            // This fails because buf is already borrowed
            let x = &*buf;
            assert!(*x == ~[0]);
            chan.send(());
        }
    }

    // This will fail if the finally block doesn't complete
    port.recv();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions