Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutable Static docs (owned pointers / sync) #25851

Closed
mitaa opened this issue May 28, 2015 · 5 comments
Closed

Mutable Static docs (owned pointers / sync) #25851

mitaa opened this issue May 28, 2015 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@mitaa
Copy link
Contributor

mitaa commented May 28, 2015

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.

@steveklabnik
Copy link
Member

whoah, we still have 'owned pointers' in an error message?

@steveklabnik steveklabnik added A-diagnostics Area: Messages for errors, warnings, and lints A-docs labels May 28, 2015
@nham
Copy link
Contributor

nham commented May 28, 2015

@steveklabnik I'm planning on tackling this by adding an error code and an explanation. What do you think the error message should be instead? mutable statics are not allowed to have boxes ?

@steveklabnik
Copy link
Member

Yes, thanks!

steveklabnik added a commit to steveklabnik/rust that referenced this issue May 29, 2015
The E0397 explanation, as I've written it, isn't really an explanation, but I'm not sure what to put here. I will happily take suggestions.

Partially addresses rust-lang#25851
steveklabnik added a commit to steveklabnik/rust that referenced this issue May 29, 2015
The E0397 explanation, as I've written it, isn't really an explanation, but I'm not sure what to put here. I will happily take suggestions.

Partially addresses rust-lang#25851
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jun 9, 2015
Still some references left to this old term, I've updated them to say boxes.

Related to rust-lang#25851
@steveklabnik
Copy link
Member

This error now says 'hello.rs:1:38: 1:42 error: mutable statics are not allowed to have boxes [E0397]' on nightly

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jun 9, 2015
@nham
Copy link
Contributor

nham commented Jun 9, 2015

Yes, however the "explanation" is still lacking I think. It just says

It is not allowed for a mutable static to allocate or have destructors.

Not really an explanation ;) Also, RFC 246, which introduced this error, doesn't discuss this topic from what I read, so I'm not exactly sure why this is disallowed.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jun 9, 2015
…crichton

Fixes rust-lang#25851

I am 99% sure this is true for all `static`s and not just `static mut`, yes?
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 10, 2015
Still some references left to this old term, I've updated them to say boxes.

Related to rust-lang#25851
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants