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.
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
inIndirectlyMutableLocals
#65030Check type of place base (not projection) for
Freeze
inIndirectlyMutableLocals
#65030Changes from 5 commits
64457a1
da0969f
6487ce0
2f89429
895f9c4
91c77e9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
cell
is immutable, how does this line not error?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.
stop_after_dataflow
prevents later all subsequent compiler passes from running, so we never actually get to the pass that would fail on this broken code. I'll make sure these tests compile outside ofrustc_peek
mode when possible though.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.