Skip to content

@mut freezing bugs #5910

@thestinger

Description

@thestinger

You can unfreeze with a temporary borrowed pointer, because it doesn't restore the previous state:

fn main() {
    let x = @mut 5;

    let a = &*x;
    {
        let b = &*x;
    }
    let c = &mut *x;
}

Mutable borrows aren't tracked:

fn main() {
    let x = @mut 5;

    let a = &mut *x;
    let b = &mut *x;
    let c = &*x;
}

I think freezing needs to be enum Borrow { Mutable, Immutable, Nothing } with an immutable borrow failing if there was a Mutable one, and a mutable borrow failing on any freeze.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions