Re: [PATCH v4 14/16] rust: drm: Add RegistrationData to drm::Driver
From: Danilo Krummrich
Date: Mon Jun 22 2026 - 17:33:08 EST
On Mon Jun 22, 2026 at 10:17 PM CEST, Lyude Paul wrote:
> This patch seems mostly fine to me, but it'd be wonderful if we could figure
> out a way to prevent making ::new() unsafe. But even after staring at this for
> quite a while, I can't really think of anything either :S. Maybe someone else
> on the list can think of something
There's currently no way to prevent bypassing the destructor in stable Rust.
However, there's an offical Rust project goal [1] to address this with a new
language feature.
Since this affects almost all Registration types, we could also consider making
it safe and accept it as a temporary soundness hole.
Getting this wrong seems rather unlikely anyway since in most cases
Registrations live in the bus device private data, which can't be forgotten.
But even in the rare cases where they do not, forgetting a Registration would be
a very odd thing to do.
In the DRM case the unsafe is not very annoying, but I'm also reworking the IRQ
registration and there it scatters a bit more, so it might be worth considering.
[1] https://rust-lang.github.io/rust-project-goals/2026/move-trait.html