Skip to content

Restrict static mut#228

Closed
gereeter wants to merge 2 commits intorust-lang:masterfrom
gereeter:restrict-static-mut
Closed

Restrict static mut#228
gereeter wants to merge 2 commits intorust-lang:masterfrom
gereeter:restrict-static-mut

Conversation

@gereeter
Copy link

@gereeter gereeter commented Sep 7, 2014

This is an alternative to #177.

@sfackler
Copy link
Member

sfackler commented Sep 7, 2014

How are you defining "mutation"? Calling MY_ATOMIC_INT.store(1, SeqCst) certainly modifies it.

@gereeter
Copy link
Author

gereeter commented Sep 7, 2014

I should have been more clear - I meant direct mutation, without going through UnsafeCell.

@reem
Copy link

reem commented Sep 8, 2014

I'm unclear as to what "directly" mutating something means. Could you clarify this further? Code examples would really help.

@bharrisau
Copy link

The only issue I have with this is that static effectively becomes const and static mut becomes static. By that, I mean the only distinction is the location in the binary; rodata or data.

Are there any use cases of the current static mut that can't be handed by UnsafeCell? (UnsafeCell can return a *mut for anyone unfamiliar).

@lilyball
Copy link
Contributor

Am I correct in reading this as static mut now differs from static purely in that static mut may contain UnsafeCell?

I'm still in favor of @nikomatsakis's approach that was described in a comment on #177 (possibly modified, as described in the comments after, to remove static mut in favor of static + UnsafeCell).

@Tobba
Copy link

Tobba commented Sep 19, 2014

-1
This isnt even an alternative

@nikomatsakis
Copy link
Contributor

Hello! Thank you for the RFC submission. In triage meeting, we decided to close this RFC in favor of #246, as that design encompasses the goals of this one (providing a safe path for people to use Atomic integers and so forth).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants