Skip to content

Soundness bug? (use after move) #42729

Closed
Closed
@dpc

Description

@dpc
struct MyObject {
    text: String,
}

fn do_something_owned(_o: MyObject) {}

fn main() {
    let mut my_object = MyObject { text: String::from("sometest") };

    do_something_owned(my_object);

    my_object.text = String::from("we're done");
}

Playground link: https://is.gd/3eEKsV

I would expect it to be a compile time error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions