Skip to content

Stacked Borrows: redo retag-to-raw #106

Closed
@RalfJung

Description

@RalfJung

@matthewjasper realized that the current rules for retag-to-raw are not working well when the redundant reborrows around raw ptr casts are gone:

let mut x = 12;
let x = &mut x;

&*x; // Stack is frozen

let raw = &raw mut *x; // No longer creates a temporary `&mut i32`
unsafe { *raw = 42; } // Error because no Raw item got pushed

However, this will likely mean that &raw const x and &raw mut x are not the same operation, because the following code must not be UB:

let mut x = 12;
let x = &mut x;

let shr = &*x; // Stack is frozen

let raw = &raw const *x; // If this unfreezes...
let _val = *shr; // ... then this is UB

Also see this discussion on Zulip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-aliasing-modelTopic: Related to the aliasing model (e.g. Stacked/Tree Borrows)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions