Skip to content

Commit 3754849

Browse files
committed
rust: move 'rust_common_flags' to a separate configuration file
Currently, 'rustc_common_flags' lives in the top-level 'Makefile'. This means that we need to touch this whenever adjustments to Rust's CLI configuration are desired, such as changing what lints Clippy should emit. This patch moves these flags to a separate file within 'rust/' so that necessary changes can be made without affecting 'Makefile'. It copies the behavior currently used with 'bindgen_parameters', which accepts comments. Additionally, 'let_unit_value` is no longer specifically named as it is now part of the 'style' group [1]. [1]: rust-lang/rust-clippy#8563 Signed-off-by: Trevor Gross <[email protected]>
1 parent d2e3115 commit 3754849

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

Makefile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -454,19 +454,7 @@ KBUILD_USERLDFLAGS := $(USERLDFLAGS)
454454

455455
# These flags apply to all Rust code in the tree, including the kernel and
456456
# host programs.
457-
export rust_common_flags := --edition=2021 \
458-
-Zbinary_dep_depinfo=y \
459-
-Dunsafe_op_in_unsafe_fn -Drust_2018_idioms \
460-
-Dunreachable_pub -Dnon_ascii_idents \
461-
-Wmissing_docs \
462-
-Drustdoc::missing_crate_level_docs \
463-
-Dclippy::correctness -Dclippy::style \
464-
-Dclippy::suspicious -Dclippy::complexity \
465-
-Dclippy::perf \
466-
-Dclippy::let_unit_value -Dclippy::mut_mut \
467-
-Dclippy::needless_bitwise_bool \
468-
-Dclippy::needless_continue \
469-
-Wclippy::dbg_macro
457+
export rust_common_flags := $(shell grep -v '^#\|^$$' $(srctree)/rust/rust_common_flags)
470458

471459
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
472460
KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)

rust/rust_common_flags

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Parameters passed to rust tools (`rustc`, `clippy`, `rustdoc`) whenever they
3+
# are run.
4+
5+
# Standard configuration
6+
--edition=2021
7+
-Zbinary_dep_depinfo=y
8+
9+
# Standard rust lints
10+
-Dnon_ascii_idents
11+
-Drust_2018_idioms
12+
-Dunreachable_pub
13+
-Dunsafe_op_in_unsafe_fn
14+
15+
# Documentation lints
16+
-Wmissing_docs
17+
-Drustdoc::missing_crate_level_docs
18+
19+
# Clippy groups
20+
-Dclippy::complexity
21+
-Dclippy::correctness
22+
-Dclippy::perf
23+
-Dclippy::style
24+
-Dclippy::suspicious
25+
26+
# Clippy lints from pedantic
27+
-Dclippy::mut_mut
28+
-Dclippy::needless_bitwise_bool
29+
-Dclippy::needless_continue
30+
31+
# Clippy lints that we only warn on
32+
-Wclippy::dbg_macro

0 commit comments

Comments
 (0)