Skip to content

Mutable Static docs (owned pointers / sync) #25851

Closed
@mitaa

Description

@mitaa
static mut FOO: Option<Box<usize>> = None;
//<anon>:1:38: 1:42 error: mutable statics are not allowed to have owned pointers
//<anon>:1 static mut FOO: Option<Box<usize>> = None;
                                                ^~~~

I am not sure why this is forbidden, but it is certainly undocumented.

Also the TRPL says Furthermore, any type stored in a static must be Sync. but does not mention that this is not true for static mut's.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions