Cast-to-raw: inherit permission from parent pointer? #227
Labels
A-aliasing-model
Topic: Related to the aliasing model (e.g. Stacked/Tree Borrows)
A-SB-vs-TB
Topic: Design questions where SB and TB are opposite sides of the design axis
C-open-question
Category: An open question that we should revisit
With the introduction of
&raw
, casting a reference to a raw pointer no longer incurs an implicit reborrow.x as *const _
translates to&raw const *x
, so whatever tagx
has is the parent tag of the raw reborrow that occurs.This gives us a chance to do something about rust-lang/rust#56604: currently, on a raw reborrow, we use the raw ptr type to figure out which permission to add for the new tag. But instead we could (per location) check which permission the parent pointer has, and use that. Then
*mut _
vs*const _
would truly not make a different for Stacked Borrows.Problems with this approach:
*mut _
and*const _
differently, not matching that could cause issues.*mut T
, the new pointer will always get read-write permission. So maybe the pointer type should still be relevant in this specific case?The text was updated successfully, but these errors were encountered: