-
Notifications
You must be signed in to change notification settings - Fork 114
Idea for disabling interior mutability that plays nicely with Stacked Borrows #1760
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
Comments
@RalfJung Does this look sound to you? |
I am confused. When I don't think I understand what you are trying to achieve, and the comments don't explain that either.
Stacked Borrows has no |
My goal is to be able to convert a My hope was that, with this example, I'd found a way to disable I think I understand your point, which is that
It is, and I do 🙂 |
What does this even have to do with rust-lang/unsafe-code-guidelines#303? That issue is about converting e.g. |
Ah okay that's good to know! I had misinterpreted rust-lang/unsafe-code-guidelines#303 as implying that SB couldn't reason about "disabling interior mutability" in both directions (ie, |
See it on the Rust Playground
The key idea is that, while Stacked Borrows can't be used to disable
UnsafeCell
s if you've started out with a&UnsafeCell
, which hasSharedReadWrite
permissions (see rust-lang/unsafe-code-guidelines#303), it's still sound so long as you never create a pointer withSharedReadWrite
permissions in the first place. You can do that by only constructing aReadOnly
by value or by&mut
.The text was updated successfully, but these errors were encountered: