Skip to content

sref3 as *const i32 as *mut i32; in chapter 6.6 doesn't work for stable #312

@skorobogatydmitry

Description

@skorobogatydmitry

I's going through the examples for shared references here and found that replacing let ptr4 = sref3 as *mut i32; with let ptr4 = sref3 as *const i32 as *mut i32; doesn't work even without miri on

stable-x86_64-unknown-linux-gnu (default)
rustc 1.75.0 (82e1608df 2023-12-21)

cargo run gives the following:

error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`

I'm not sure if I just messed-up something locally or it's a new stable safety feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions