-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Check type of place base (not projection) for Freeze
in IndirectlyMutableLocals
#65030
Closed
ecstatic-morse
wants to merge
6
commits into
rust-lang:master
from
ecstatic-morse:fix-indirectly-mutable
Closed
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
64457a1
Check type of place base (not projection) for `!Freeze`
ecstatic-morse da0969f
Update `IndirectlyMutableLocals` test with correct behavior
ecstatic-morse 6487ce0
Add more peek tests for `IndirectlyMutableLocals`
ecstatic-morse 2f89429
Remove `borrowck_graphviz_postflow` from test
ecstatic-morse 895f9c4
Downgrade unnecessary `warn` to `trace`
ecstatic-morse 91c77e9
Enusure tests would build outside of peek
ecstatic-morse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm a bit confused. This line is UB. You obtained a reference to
cell
from a reference tozst
. I'm certain miri will slap this code around if it were runtime codeThere 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'm confused about rust's memory model then. If you're not allowed to obtain a reference to one part of a struct and convert it to a reference to a disjoint part of that same struct, then there's no need to consider this in the analysis.
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.
The following quote is from the
ptr::offset
docs (non-normative, I know). I don't actually useptr::offset
, because it's not supported in MIRI. Instead I use a zero-sized type in a#[repr(C)]
struct to ensure that the two fields have the same address.I was assuming that the stack-allocated instance of
PartialInteriorMut
was a single "allocated object" in rust's memory model, and thus converting a pointer to one of its fields into a pointer to another was not UB.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'm not sure at all. Maybe @RalfJung can have a look?
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.
Stacked Borrows disallows this, to keep aliasing under control. But we don't have a final memory model yet. See this document for further details on Stacked Borrows.
Also, with Stacked Borrows you can do things like this through raw pointers. Like,
&x as *mut T
and then do whatever you want with the resulting raw pointer -- anything that C allows, we also allow.