Skip to content

Commit 0fe1d45

Browse files
authored
Merge pull request #4411 from nyurik/clippy
chore: add clippy CI tests
2 parents 920cfdc + e09683e commit 0fe1d45

File tree

5 files changed

+92
-1
lines changed

5 files changed

+92
-1
lines changed

.github/workflows/ci.yaml

+18-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ jobs:
2929
- name: Check style
3030
run: ./ci/style.sh
3131

32+
clippy:
33+
name: Clippy on ${{ matrix.os }}
34+
strategy:
35+
matrix:
36+
os: [ubuntu-24.04, macos-14, windows-2022]
37+
runs-on: ${{ matrix.os }}
38+
timeout-minutes: 10
39+
steps:
40+
- uses: actions/checkout@v4
41+
- run: rustup update stable --no-self-update
42+
- uses: Swatinem/rust-cache@v2
43+
# Here we use the latest stable Rust toolchain already installed by GitHub
44+
# Ideally we should run it for every target, but we cannot rely on unstable toolchains
45+
# due to Clippy not being consistent between them.
46+
- run: cargo clippy --workspace --exclude libc-test --exclude ctest-test --all-targets -- -D warnings
47+
3248
# This runs `cargo build --target ...` for all T1 and T2 targets`
3349
verify_build:
3450
name: Verify build
@@ -287,7 +303,8 @@ jobs:
287303
- verify_build
288304
- ctest_msrv
289305
- docs
290-
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
306+
- clippy
307+
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
291308
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
292309
# dependencies fails.
293310
if: always() # make sure this is never "skipped"

Cargo.toml

+21
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,24 @@ members = [
142142
"ctest-test",
143143
"libc-test",
144144
]
145+
146+
# FIXME(msrv): These should be renamed as `[workspace.lints.*]` once MSRV is above 1.64
147+
# This way all crates can use it with `[lints] workspace=true` section
148+
149+
[lints.rust]
150+
# FIXME(cleanup): make ident usage consistent in each file
151+
unused_qualifications = "allow"
152+
153+
[lints.clippy]
154+
missing_safety_doc = "allow"
155+
156+
# FIXME(clippy): all these are default lints and should probably be fixed
157+
identity_op = "allow"
158+
if_same_then_else = "allow"
159+
non_minimal_cfg = "allow"
160+
precedence = "allow"
161+
redundant_field_names = "allow"
162+
redundant_static_lifetimes = "allow"
163+
unnecessary_cast = "allow"
164+
unused_unit = "allow"
165+
zero_ptr = "allow"

ctest-test/Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ test = false
2828
[[bin]]
2929
name = "t2_cxx"
3030
test = false
31+
32+
# FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]`
33+
# once MSRV is above 1.64 and replaced with `[lints] workspace=true`
34+
35+
[lints.rust]
36+
# FIXME(cleanup): make ident usage consistent in each file
37+
unused_qualifications = "allow"
38+
39+
[lints.clippy]
40+
# FIXME(clippy): fix these
41+
match_like_matches_macro = "allow"
42+
eq_op = "allow"

ctest/Cargo.toml

+20
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,23 @@ garando_syntax = "0.1"
1313
cc = "1.0.1"
1414
rustc_version = "0.4"
1515
indoc = "2.0.6"
16+
17+
# FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]`
18+
# once MSRV is above 1.64 and replaced with `[lints] workspace=true`
19+
20+
[lints.rust]
21+
# FIXME(cleanup): make ident usage consistent in each file
22+
unused_qualifications = "allow"
23+
24+
[lints.clippy]
25+
# FIXME(clippy): fix these
26+
doc_lazy_continuation = "allow"
27+
if_same_then_else = "allow"
28+
needless_borrow = "allow"
29+
needless_borrowed_reference = "allow"
30+
needless_borrows_for_generic_args = "allow"
31+
needless_lifetimes = "allow"
32+
only_used_in_recursion = "allow"
33+
option_as_ref_deref = "allow"
34+
type_complexity = "allow"
35+
useless_format = "allow"

libc-test/Cargo.toml

+21
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,24 @@ harness = true
102102
name = "style_tests"
103103
path = "test/style_tests.rs"
104104
harness = true
105+
106+
# FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]`
107+
# once MSRV is above 1.64 and replaced with `[lints] workspace=true`
108+
109+
[lints.rust]
110+
# FIXME(cleanup): make ident usage consistent in each file
111+
unused_qualifications = "allow"
112+
113+
[lints.clippy]
114+
# FIXME(clippy): fix these
115+
needless_return = "allow"
116+
comparison_to_empty = "allow"
117+
unused_io_amount = "allow"
118+
write_with_newline = "allow"
119+
needless_borrows_for_generic_args = "allow"
120+
only_used_in_recursion = "allow"
121+
match_like_matches_macro = "allow"
122+
useless_format = "allow"
123+
wildcard_in_or_patterns = "allow"
124+
nonminimal_bool = "allow"
125+
match_single_binding = "allow"

0 commit comments

Comments
 (0)