Skip to content

Commit dbaabe8

Browse files
ojedaSasha Levin
authored and
Sasha Levin
committed
rust: relax most deny-level lints to warnings
[ Upstream commit f8f88aa ] Since we are starting to support several Rust toolchains, lints (including Clippy ones) now may behave differently and lint groups may include new lints. Therefore, to maximize the chances a given version works, relax some deny-level lints to warnings. It may also make our lives a bit easier while developing new code or refactoring. To be clear, the requirements for in-tree code are still the same, since Rust code still needs to be warning-free (patches should be clean under `WERROR=y`) and the set of lints is not changed. `unsafe_op_in_unsafe_fn` is left unmodified, i.e. as an error, since it is becoming the default in the language (warn-by-default in Rust 2024 [1] and ideally an error later on) and thus it should also be very well tested. In addition, it is simple enough that it should not have false positives (unlike e.g. `rust_2018_idioms`'s `explicit_outlives_requirements`). `non_ascii_idents` is left unmodified as well, i.e. as an error, since it is unlikely one gains any productivity during development if it were a warning (in fact, it may be worse, since it is likely one made a typo). In addition, it should not have false positives. Finally, put the two `-D` ones at the top and take the chance to do one per line. Link: rust-lang/rust#112038 [1] Reviewed-by: Finn Behrens <me@kloenk.dev> Tested-by: Benno Lossin <benno.lossin@proton.me> Tested-by: Andreas Hindborg <a.hindborg@samsung.com> Link: https://lore.kernel.org/r/20240709160615.998336-5-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Stable-dep-of: 60fc1e6 ("rust: allow `clippy::needless_lifetimes`") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d9b93a1 commit dbaabe8

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Makefile

+13-11
Original file line numberDiff line numberDiff line change
@@ -457,17 +457,19 @@ KBUILD_USERLDFLAGS := $(USERLDFLAGS)
457457
# host programs.
458458
export rust_common_flags := --edition=2021 \
459459
-Zbinary_dep_depinfo=y \
460-
-Dunsafe_op_in_unsafe_fn -Drust_2018_idioms \
461-
-Dunreachable_pub -Dnon_ascii_idents \
460+
-Dunsafe_op_in_unsafe_fn \
461+
-Dnon_ascii_idents \
462+
-Wrust_2018_idioms \
463+
-Wunreachable_pub \
462464
-Wmissing_docs \
463-
-Drustdoc::missing_crate_level_docs \
464-
-Dclippy::correctness -Dclippy::style \
465-
-Dclippy::suspicious -Dclippy::complexity \
466-
-Dclippy::perf \
467-
-Dclippy::let_unit_value -Dclippy::mut_mut \
468-
-Dclippy::needless_bitwise_bool \
469-
-Dclippy::needless_continue \
470-
-Dclippy::no_mangle_with_rust_abi \
465+
-Wrustdoc::missing_crate_level_docs \
466+
-Wclippy::correctness -Wclippy::style \
467+
-Wclippy::suspicious -Wclippy::complexity \
468+
-Wclippy::perf \
469+
-Wclippy::let_unit_value -Wclippy::mut_mut \
470+
-Wclippy::needless_bitwise_bool \
471+
-Wclippy::needless_continue \
472+
-Wclippy::no_mangle_with_rust_abi \
471473
-Wclippy::dbg_macro
472474

473475
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
@@ -572,7 +574,7 @@ KBUILD_RUSTFLAGS := $(rust_common_flags) \
572574
-Csymbol-mangling-version=v0 \
573575
-Crelocation-model=static \
574576
-Zfunction-sections=n \
575-
-Dclippy::float_arithmetic
577+
-Wclippy::float_arithmetic
576578

577579
KBUILD_AFLAGS_KERNEL :=
578580
KBUILD_CFLAGS_KERNEL :=

rust/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),)
422422
endif
423423

424424
$(obj)/core.o: private skip_clippy = 1
425-
$(obj)/core.o: private skip_flags = -Dunreachable_pub
425+
$(obj)/core.o: private skip_flags = -Wunreachable_pub
426426
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
427427
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
428428
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE
@@ -433,7 +433,7 @@ $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
433433
$(call if_changed_dep,rustc_library)
434434

435435
$(obj)/alloc.o: private skip_clippy = 1
436-
$(obj)/alloc.o: private skip_flags = -Dunreachable_pub
436+
$(obj)/alloc.o: private skip_flags = -Wunreachable_pub
437437
$(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs)
438438
$(obj)/alloc.o: $(src)/alloc/lib.rs $(obj)/compiler_builtins.o FORCE
439439
$(call if_changed_dep,rustc_library)

0 commit comments

Comments
 (0)