Skip to content

rust: lint improvements

Miguel Ojeda linux-patches lkml rust-for-linux 1 version Applied

Status from this message: Applied to `rust-next` -- thanks everyone!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest19 patches 52 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/19rust: workqueue: remove unneeded ``#[allow(clippy::new_ret_no_self)]`rust/kernel/workqueue.rs+0 -12 replies
2/19rust: sort global Rust flagsMakefile+4 -42 replies
3/19rust: types: avoid repetition in `{As,From}Bytes` implsrust/kernel/types.rs+35 -332 replies
4/19rust: enable `clippy::undocumented_unsafe_blocks` lintMakefile rust/bindings/lib.rs rust/kernel/alloc/allocator.rs +12 more+46 -103 replies
5/19rust: enable `clippy::unnecessary_safety_comment` lintMakefile rust/kernel/sync/arc.rs rust/kernel/workqueue.rs+4 -33 replies
6/19rust: enable `clippy::unnecessary_safety_doc` lintMakefile+1 -02 replies
7/19rust: enable `clippy::ignored_unit_patterns` lintMakefile rust/kernel/types.rs+2 -12 replies
8/19rust: enable `rustdoc::unescaped_backticks` lintMakefile rust/Makefile+6 -23 replies
9/19rust: init: remove unneeded `#[allow(clippy::disallowed_names)]`rust/kernel/init.rs+0 -42 replies
10/19rust: sync: remove unneeded `#[allow(clippy::non_send_fields_in_send_ty)]`rust/kernel/sync/condvar.rs+0 -12 replies
11/19rust: introduce `.clippy.toml`.clippy.toml .gitignore MAINTAINERS +1 more+6 -02 replies
12/19rust: replace `clippy::dbg_macro` with `disallowed_macros`.clippy.toml Makefile rust/kernel/std_vendor.rs +1 more+12 -63 replies
13/19rust: rbtree: fix `SAFETY` comments that should be `# Safety` sectionsrust/kernel/rbtree.rs+6 -32 replies
14/19rust: provide proper code documentation titlesrust/kernel/init/__internal.rs rust/kernel/std_vendor.rs rust/kernel/sync/arc/std_vendor.rs+8 -33 replies
15/19rust: enable Clippy's `check-private-items`.clippy.toml rust/kernel/init.rs rust/kernel/init/__internal.rs +2 more+7 -02 replies
16/19Documentation: rust: add coding guidelines on lintsDocumentation/rust/coding-guidelines.rst+29 -07 replies
17/19rust: start using the `#[expect(...)]` attributerust/kernel/error.rs rust/kernel/init.rs rust/kernel/init/__internal.rs +8 more+31 -302 replies
18/19Documentation: rust: discuss `#[expect(...)]` in the guidelinesDocumentation/rust/coding-guidelines.rst+110 -02 replies
19/19rust: std_vendor: simplify `{ .. macro! .. }` with inner attributesrust/kernel/std_vendor.rs+2 -64 replies

Reviews trailers per patch

17 of 19 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAlice RyhlVincenzo PalazzoGary GuoTrevor Gross
SeriesT-b R-b
1/19R-b R-b
2/19R-b R-b
3/19R-b R-b
4/19R-b R-b
5/19R-b R-b R-b
6/19R-b R-b
7/19R-b R-b
8/19R-b R-b
9/19R-b R-b
10/19R-b R-b
11/19R-b R-b
12/19
13/19R-b R-b
14/19R-b R-b
15/19R-b R-b
16/19R-b R-b
17/19R-b R-b
18/19
19/19R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/19] rust: lint improvements

Hi all,

This is a series that contains a series of lint-related things:

- Cleanups and other improvements and fixes, including removing allows that are not needed anymore for different reasons and a workaround for dbg_macro detection.

- The enablement of some safety lints so that the toolchain enforces that we write // SAFETY comments and # Safety sections properly.

- The addition of .clippy.toml, which allows us to take advantage of a few configuration options.

- Start using the new #[expect(...)] feature and add documentation on it as well as lints in general.

Overall, this should improve the quality of the code and documentation as well as reduce the time needed in reviews.

I want to mention Trevor's nice work on lints from a while ago [1]. I think we should still do something like that: discuss which lints we would like to have one-by-one and start enabling them (and perhaps have a file like Trevor proposed etc.).

For the moment, though, I am sending these, since we would like to have at least the safety-related ones enabled soon [2]: now that more code and developers are joining, it sounds like a good time to start enforcing it -- it should make new Rust kernel developers aware of the need of writing them, which has proven to be a common request from reviewers.

If needed, the series can be applied partially or split, but most of it should be fairly uncontroversial.

Miguel Ojeda (19):
rust: workqueue: remove unneeded ``#[allow(clippy::new_ret_no_self)]`
rust: sort global Rust flags
rust: types: avoid repetition in {As,From}Bytes impls
rust: enable clippy::undocumented_unsafe_blocks lint
rust: enable clippy::unnecessary_safety_comment lint
rust: enable clippy::unnecessary_safety_doc lint
rust: enable clippy::ignored_unit_patterns lint
rust: enable rustdoc::unescaped_backticks lint
rust: init: remove unneeded #[allow(clippy::disallowed_names)]
rust: sync: remove unneeded

    `#[allow(clippy::non_send_fields_in_send_ty)]`

rust: introduce .clippy.toml
rust: replace clippy::dbg_macro with disallowed_macros
rust: rbtree: fix SAFETY comments that should be # Safety sections
rust: provide proper code documentation titles
rust: enable Clippy's check-private-items
Documentation: rust: add coding guidelines on lints
rust: start using the #[expect(...)] attribute
Documentation: rust: discuss #[expect(...)] in the guidelines
rust: std_vendor: simplify { .. macro! .. } with inner attributes

 .clippy.toml                             |   9 ++
 .gitignore                               |   1 +
 Documentation/rust/coding-guidelines.rst | 139 +++++++++++++++++++++++
 MAINTAINERS                              |   1 +
 Makefile                                 |  15 ++-
 rust/Makefile                            |   5 +-
 rust/bindings/lib.rs                     |   1 +
 rust/kernel/alloc/allocator.rs           |   2 +
 rust/kernel/error.rs                     |  11 +-
 rust/kernel/init.rs                      |  30 ++---
 rust/kernel/init/__internal.rs           |  11 +-
 rust/kernel/init/macros.rs               |  18 ++-
 rust/kernel/ioctl.rs                     |   2 +-
 rust/kernel/lib.rs                       |   1 +
 rust/kernel/list.rs                      |   1 +
 rust/kernel/list/arc_field.rs            |   2 +-
 rust/kernel/print.rs                     |   5 +-
 rust/kernel/rbtree.rs                    |   9 +-
 rust/kernel/std_vendor.rs                |  16 ++-
 rust/kernel/str.rs                       |   7 +-
 rust/kernel/sync/arc.rs                  |   2 +-
 rust/kernel/sync/arc/std_vendor.rs       |   2 +
 rust/kernel/sync/condvar.rs              |   1 -
 rust/kernel/sync/lock.rs                 |   6 +-
 rust/kernel/types.rs                     |  74 ++++++------
 rust/kernel/workqueue.rs                 |   9 +-
 rust/uapi/lib.rs                         |   1 +
 samples/rust/rust_print.rs               |   1 +
 scripts/Makefile.build                   |   2 +-
 29 files changed, 293 insertions(+), 91 deletions(-)
 create mode 100644 .clippy.toml

base-commit: 68d3b6aa08708bb3907c2c13eaf4b3ccf4805160 --
2.46.0