core::ptr::read(p), unsafe, shouldn't compile under #![deny(unsafe_code)]
#![feature(reborrow)]
#![deny(unsafe_code)]
#![allow(dead_code)]
use core::marker::Reborrow;
struct Thing<'a> { p: &'a mut i32 }
impl<'a> Reborrow for Thing<'a> {}
fn takes(_: Thing<'_>) {}
fn main() {
let mut x = 0;
let thing = Thing { p: &mut x };
let y: i32 = 123;
takes({
let p: *const i32 = &y;
core::hint::black_box(core::ptr::read(p));
thing
});
}
Compilation passes:
$ rustc +nightly-2026-05-10 --edition=2021 repro.rs -o repro
core::ptr::read(p), unsafe, shouldn't compile under#![deny(unsafe_code)]Compilation passes: