Open
Description
This requires the unstable #![feature(unsafe_fields)]
(rust-lang/rust#132922). (So feel free to close if this should wait until the feature is closer to stabilization).
Implementing Copy
for a struct
with an unsafe
field requires an unsafe impl
as of rust-lang/rust#134008.
However, rust-analyzer reports an "unsafe impl for safe trait (trait-impl-incorrect-safety)" error for such an impl
.
rust-analyzer version: rust-analyzer version: 0.4.2359-standalone (2e1ff255ae 2025-03-28)
rustc version: rustc 1.87.0-nightly (3f5502370 2025-03-27)
editor or extension: VSCode
code snippet to reproduce:
#![feature(unsafe_fields)]
#![allow(incomplete_features)]
#[repr(transparent)]
pub struct Alpha { unsafe a: u8 }
impl Clone for Alpha {
fn clone(&self) -> Self { *self }
}
unsafe impl Copy for Alpha {}