Skip to content

Commit eec47cd

Browse files
ojedaintel-lab-lkp
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 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 <[email protected]> Tested-by: Benno Lossin <[email protected]> Tested-by: Andreas Hindborg <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 769478c commit eec47cd

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
@@ -461,17 +461,19 @@ 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 \
465+
-Dnon_ascii_idents \
466+
-Wrust_2018_idioms \
467+
-Wunreachable_pub \
466468
-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 \
469+
-Wrustdoc::missing_crate_level_docs \
470+
-Wclippy::correctness -Wclippy::style \
471+
-Wclippy::suspicious -Wclippy::complexity \
472+
-Wclippy::perf \
473+
-Wclippy::let_unit_value -Wclippy::mut_mut \
474+
-Wclippy::needless_bitwise_bool \
475+
-Wclippy::needless_continue \
476+
-Wclippy::no_mangle_with_rust_abi \
475477
-Wclippy::dbg_macro
476478

477479
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
@@ -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)