Re: [PATCH v2 3/4] rust: pci: impl TryFrom<&Device> for &pci::Device
From: Miguel Ojeda
Date: Fri Mar 21 2025 - 15:01:04 EST
On Fri, Mar 21, 2025 at 6:44 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> This requires an unsafe block for compilers < 1.82. For compilers >= 1.82 it
> turns into a warning *if* using an unsafe block.
>
> *Not* requiring unsafe for this seems like the correct thing -- was this a
> bugfix in the compiler?
>
> I guess to make it work for all compiler versions supported by the kernel we
> have to use unsafe and suppress the warning?
It was a feature, but it has been fairly annoying -- it affected
several series, e.g. the latest KUnit one as well as:
https://lore.kernel.org/rust-for-linux/CANiq72kuebpOa4aPxmTXNMA0eo-SLL+Ht9u1SGHymXBF5_92eA@xxxxxxxxxxxxxx/
Please see:
https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#safely-addressing-unsafe-statics
So, yeah, we use `allow(unused_unsafe)` (no `expect`, since it depends
on the version).
I hope that helps.
Cheers,
Miguel