Re: [PATCH v2 1/2] rust: add untrusted data abstraction

Miguel Ojeda
2024-09-26T21:56:21Z

On Thu, Sep 26, 2024 at 11:40 PM Benno Lossin <benno.lossin@proton.me> wrote:
>
> I would like to use `#[cfg("rust version <= 1.82")]`, but I don't know
> how to do that. Do we already have support for checking the version in a
> cfg? The alternative would be `#[allow(unreachable_patterns)]`, but I
> would like to avoid that.

We can do it, but it requires adding a Kconfig symbol, sadly, since
`cfg` does not support numerical comparisons there.

See commit 93dc3be19450 ("docs: rust: include other expressions in
conditional compilation section") where I explained it.

So depending on how often we think we will hit this, we may want to
pay the "cost" of the extra Kconfig symbol. Otherwise, we can just
`allow` it as you say.

(There are discussions in Rust about `cfg(version(...))`, but that is
for the future -- I have some links at
https://github.com/Rust-for-Linux/linux/issues/354)

Cheers,
Miguel