Skip to content
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

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

Open
skorobogatydmitry opened this issue Jan 4, 2025 · 0 comments

Comments

@skorobogatydmitry
Copy link

skorobogatydmitry commented Jan 4, 2025

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.

@skorobogatydmitry skorobogatydmitry changed the title sref3 as *const i32 as *mut i32; in chapter 6.6 doesn't work for nightly sref3 as *const i32 as *mut i32; in chapter 6.6 doesn't work for stable Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant