Skip to content

Commit 9724a15

Browse files
ojedafbq
authored andcommitted
rust: relax most deny-level lints to warnings
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 1) it is simple enough that it should not have false positives (unlike e.g. `rust_2018_idioms`'s `explicit_outlives_requirements`) and 2) 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. Link: rust-lang/rust#112038 [1] Signed-off-by: Miguel Ojeda <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1079949 commit 9724a15

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Makefile

+11-11
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,17 @@ KBUILD_USERLDFLAGS := $(USERLDFLAGS)
461461
# host programs.
462462
export rust_common_flags := --edition=2021 \
463463
-Zbinary_dep_depinfo=y \
464-
-Dunsafe_op_in_unsafe_fn -Drust_2018_idioms \
465-
-Dunreachable_pub -Dnon_ascii_idents \
464+
-Dunsafe_op_in_unsafe_fn -Wrust_2018_idioms \
465+
-Wunreachable_pub -Wnon_ascii_idents \
466466
-Wmissing_docs \
467-
-Drustdoc::missing_crate_level_docs \
468-
-Dclippy::correctness -Dclippy::style \
469-
-Dclippy::suspicious -Dclippy::complexity \
470-
-Dclippy::perf \
471-
-Dclippy::let_unit_value -Dclippy::mut_mut \
472-
-Dclippy::needless_bitwise_bool \
473-
-Dclippy::needless_continue \
474-
-Dclippy::no_mangle_with_rust_abi \
467+
-Wrustdoc::missing_crate_level_docs \
468+
-Wclippy::correctness -Wclippy::style \
469+
-Wclippy::suspicious -Wclippy::complexity \
470+
-Wclippy::perf \
471+
-Wclippy::let_unit_value -Wclippy::mut_mut \
472+
-Wclippy::needless_bitwise_bool \
473+
-Wclippy::needless_continue \
474+
-Wclippy::no_mangle_with_rust_abi \
475475
-Wclippy::dbg_macro
476476

477477
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
@@ -572,7 +572,7 @@ KBUILD_RUSTFLAGS := $(rust_common_flags) \
572572
-Csymbol-mangling-version=v0 \
573573
-Crelocation-model=static \
574574
-Zfunction-sections=n \
575-
-Dclippy::float_arithmetic
575+
-Wclippy::float_arithmetic
576576

577577
KBUILD_AFLAGS_KERNEL :=
578578
KBUILD_CFLAGS_KERNEL :=

rust/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),)
367367
endif
368368

369369
$(obj)/core.o: private skip_clippy = 1
370-
$(obj)/core.o: private skip_flags = -Dunreachable_pub
370+
$(obj)/core.o: private skip_flags = -Wunreachable_pub
371371
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
372372
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
373373
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
@@ -381,7 +381,7 @@ $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
381381
+$(call if_changed_dep,rustc_library)
382382

383383
$(obj)/alloc.o: private skip_clippy = 1
384-
$(obj)/alloc.o: private skip_flags = -Dunreachable_pub
384+
$(obj)/alloc.o: private skip_flags = -Wunreachable_pub
385385
$(obj)/alloc.o: private rustc_target_flags = $(alloc-cfgs)
386386
$(obj)/alloc.o: $(RUST_LIB_SRC)/alloc/src/lib.rs $(obj)/compiler_builtins.o FORCE
387387
+$(call if_changed_dep,rustc_library)

0 commit comments

Comments
 (0)