Skip to content

"Moving" out of a static could be a memcpy #13233

Closed
@alexcrichton

Description

@alexcrichton

This was discussed at the recent work week, but it appears that our notes to not reflect a decision one way or another. I would expect this code to compile:

use std::sync::atomics;

fn main() {
    let a = atomics::INIT_ATOMIC_UINT;
}

Specifically, you can "move" out of any non-mut static, it just turns in to a memcpy. The contents of the static have already been validated to not own anything and have no destructors, so this should be safe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions