-
Notifications
You must be signed in to change notification settings - Fork 100
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
Function Contracts: Interior Mutability Tests #3351
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to update our RFC to describe any limitations around interior mutability.
tests/expected/function-contract/interior-mutability/oncecell.rs
Outdated
Show resolved
Hide resolved
This comment should be included in the test cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need the transmute
in any of these cases. You should be able to use the public methods to get the data address or a copy of the data.
We have two problems, and I think it might be helpful to think about them separately, although you might want to add a test that has both. The first problem is interior mutability, and the second one is encapsulation.
Using transmute
is necessary if you want to break encapsulation. The interior mutability could be a problem for identifying expressions that are side-effect free.
tests/expected/function-contract/interior-mutability/cell_stub.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/transmute/oncecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/cell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/cell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/unsafecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/transmute/cell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/transmute/cell_stub.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/transmute/oncecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/transmute/unsafecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/unsafecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/unsafecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/cell_stub.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/cell_stub.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/api/cell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/whole-struct/oncecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/whole-struct/refcell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/whole-struct/refcell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/whole-struct/unsafecell.rs
Outdated
Show resolved
Hide resolved
tests/expected/function-contract/interior-mutability/whole-struct/unsafecell.rs
Outdated
Show resolved
Hide resolved
…uct/unsafecell.rs
…uct/unsafecell.rs
Test cases for interior mutability using Cell, OnceCell, UnsafeCell, and RefCell.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.