Skip to content

Add tests for mutability #574

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Add tests for mutability #574

wants to merge 10 commits into from

Conversation

dkcumming
Copy link
Collaborator

@dkcumming dkcumming commented May 8, 2025

Adding tests to examine the boundaries of mutability and immutability, not all of these use unsafe but only the ones I listed as unsafe do we annotate unsafe directly:

  • mut_const.rs: A UB test that mutates the data under an immutable value through pointer arithmetic
  • interior-mut-fail.rs: Safely has interior mutability through RefCell (stuck on Rvalue::AddressOf)
  • interior-mut2-fail.rs: Safely has interior mutability through Cell (stuck on Rvalue::AddressOf)
  • interior-mut3-fail.rs: Unsafe but sound interior mutability through UnsafeCell (stuck on Rvalue::AddressOf)

We discussed the possibility of adding tests that show demonstrate immutable field of mutable structs, but this is not possible in rust. There is a notion of private fields if structs come from other modules, but this is not the same as mutability.

@dkcumming dkcumming self-assigned this May 8, 2025
@dkcumming dkcumming requested a review from ehildenb May 9, 2025 00:47
PROVE_RS_SHOW_SPECS = [
'local-raw-fail',
]
PROVE_RS_SHOW_SPECS = ['local-raw-fail', 'interior-mut-fail', 'interior-mut2-fail', 'interior-mut3-fail']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do these one per line instead. Will make it easier to add/delete them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do

@ehildenb
Copy link
Member

ehildenb commented May 9, 2025

Can we rebase this on master to get current master behavior? I want to open a PR with the refactoring from #573), and make sure we all agree on the changes that happen then.

@dkcumming dkcumming force-pushed the dc/add-mut-tests branch from e46665a to ac342de Compare May 9, 2025 16:04
@dkcumming dkcumming changed the base branch from remove-project-mut to master May 9, 2025 16:04
@dkcumming dkcumming requested a review from ehildenb May 9, 2025 16:50
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.

3 participants