Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable clippy lint borrow_as_ptr #1152

Open
y86-dev opened this issue Mar 25, 2025 · 6 comments
Open

Enable clippy lint borrow_as_ptr #1152

y86-dev opened this issue Mar 25, 2025 · 6 comments
Labels
easy Expected to be an easy issue to resolve. good first issue Good for newcomers • lib Related to the `rust/` library.

Comments

@y86-dev
Copy link
Member

y86-dev commented Mar 25, 2025

Clean the tree for any errors that would occur and then enable the clippy lint borrow_as_ptr.


This requires submitting a proper patch to the LKML and the Rust for Linux mailing list. Please recall to test your changes (including generating the documentation if changed, running the Rust doctests if changed, etc.), to use a proper title for the commit, to sign your commit under the Developer's Certificate of Origin and to add a Suggested-by: tag, and a Link: tag to this issue. Please see https://docs.kernel.org/process/submitting-patches.html and https://rust-for-linux.com/contributing for details."

Please take this issue only if you are new to the kernel development process and you would like to use it as a test to submit your first patch to the kernel. Please do not take it if you do not plan to make other contributions to the kernel.

@y86-dev y86-dev added • lib Related to the `rust/` library. good first issue Good for newcomers easy Expected to be an easy issue to resolve. labels Mar 25, 2025
@tamird
Copy link

tamird commented Mar 25, 2025

Note that this lint is MSRV-aware. Because &raw syntax was stabilized in 1.82.0, the lint is no-op until we bump the MSRV in our .clippy.toml.

This kind of thing will continue to bite us as long as we use unstable features because the MSRV infrastructure in clippy is not #[feature]-aware. We could request that in clippy but I suspect it'd be a good bit of work to implement.

@y86-dev
Copy link
Member Author

y86-dev commented Mar 25, 2025

Note that this lint is MSRV-aware. Because &raw syntax was stabilized in 1.82.0, the lint is no-op until we bump the MSRV in our .clippy.toml.

That is a bit annoying... Thanks for noticing it :) Do you know what the advantages of having a msrv in .clippy.toml? (If you don't, maybe @ojeda knows?)

This kind of thing will continue to bite us as long as we use unstable features because the MSRV infrastructure in clippy is not #[feature]-aware. We could request that in clippy but I suspect it'd be a good bit of work to implement.

Since they can't change the current behavior from 1.78-1.85, it won't help us at the moment...

@tamird
Copy link

tamird commented Mar 25, 2025

Note that this lint is MSRV-aware. Because &raw syntax was stabilized in 1.82.0, the lint is no-op until we bump the MSRV in our .clippy.toml.

That is a bit annoying... Thanks for noticing it :) Do you know what the advantages of having a msrv in .clippy.toml? (If you don't, maybe @ojeda knows?)

I imagine the intent is that you get more uniform behavior regardless of the rustc version you happen to be using.

This kind of thing will continue to bite us as long as we use unstable features because the MSRV infrastructure in clippy is not #[feature]-aware. We could request that in clippy but I suspect it'd be a good bit of work to implement.

Since they can't change the current behavior from 1.78-1.85, it won't help us at the moment...

True.

@ojeda
Copy link
Member

ojeda commented Mar 26, 2025

Do you know what the advantages of having a msrv in .clippy.toml? (If you don't, maybe @ojeda knows?)

The justification was on f0915ac ("rust: give Clippy the minimum supported Rust version"), which mentioned the disadvantage -- if we are losing too much we care about, then we could comment it for the time being and then re-enable it e.g. when we bump to the new MSRV.

Since they can't change the current behavior from 1.78-1.85, it won't help us at the moment...

If it worked, then I guess it wouldn't be too bad to have those Clippy lints only working on the newer ones -- we would be in a similar situation like an existing lint catching more cases in a new release, if I understand correctly.

Sadly, 1.85 will likely be the next Debian one. Even if it wasn't, eventually there will be enough developers using only distro versions and thus not seeing all lints anyway, whatever the reason behind it. So we will have to deal with situations like this and do asynchronous cleanups (we already had to, in fact).

Anyway, this is all assuming Clippy would give us something to say "we actually use this particular feature across all our supported versions".

@tamird
Copy link

tamird commented Mar 26, 2025

Filed it. rust-lang/rust-clippy#14477

@ojeda
Copy link
Member

ojeda commented Mar 26, 2025

Thanks! Added a couple notes there and linked back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy Expected to be an easy issue to resolve. good first issue Good for newcomers • lib Related to the `rust/` library.
Development

No branches or pull requests

3 participants