Skip to content

Commit 281ce57

Browse files
authored
Cargo.toml: add workspace-level clippy config (#1411)
Adds a set of workspace-level lints including common ones we've used in the past and others collected via running `clippy::pedantic` on several of our crates and looking for interesting ones. Workspace-level lints require explict opt-in from each crate's Cargo.toml, so there's nothing forcing any crate to use them: [lints] workspace = true That said, I have opted every crate in the workspace into these lints and gotten them all to pass except for `wycheproof2blb` which is an internal utility tool and I didn't feel like it was worth the hassle. Even then, the lints are all set to `"warn"`, so they can be easily overridden by `#[allow(...)]` attributes, including `#![allow(...)]` to shut them off at the granularity of an entire crate. I managed to fix most of the issues that `cargo clippy --fix` didn't fix automatically including some missing documentation and documentation formatting issues. The main thing I didn't fix was adding missing `SAFETY` comments, which is a problem with a few of the crates in this repo. I disabled a lint at the crate level and added a TODO where we're missing them and it wasn't easily corrected.
1 parent 7f459a5 commit 281ce57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+416
-257
lines changed

.clippy.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
allow-unwrap-in-consts = true
2+
allow-unwrap-in-tests = true

.github/workflows/blobby.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: blobby
22

33
on:
44
pull_request:
5-
paths:
6-
- "blobby/**"
7-
- "Cargo.*"
5+
paths:
6+
- "blobby/**"
7+
- "Cargo.*"
88
push:
99
branches: master
1010

@@ -38,11 +38,4 @@ jobs:
3838
- uses: dtolnay/rust-toolchain@master
3939
with:
4040
toolchain: ${{ matrix.rust }}
41-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
42-
- run: rm ../Cargo.toml
4341
- run: cargo test
44-
45-
minimal-versions:
46-
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
47-
with:
48-
working-directory: ${{ github.workflow }}

.github/workflows/block-buffer.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: block-buffer
22

33
on:
44
pull_request:
5-
paths:
6-
- "block-buffer/**"
7-
- "Cargo.*"
5+
paths:
6+
- "block-buffer/**"
7+
- "Cargo.*"
88
push:
99
branches: master
1010

.github/workflows/block-padding.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: block-padding
22

33
on:
44
pull_request:
5-
paths:
6-
- "block-padding/**"
7-
- "Cargo.*"
5+
paths:
6+
- "block-padding/**"
7+
- "Cargo.*"
88
push:
99
branches: master
1010

@@ -47,7 +47,7 @@ jobs:
4747
minimal-versions:
4848
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
4949
with:
50-
working-directory: ${{ github.workflow }}
50+
working-directory: ${{ github.workflow }}
5151

5252
test:
5353
runs-on: ubuntu-latest

.github/workflows/cpufeatures.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
minimal-versions:
2929
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
3030
with:
31-
working-directory: ${{ github.workflow }}
31+
working-directory: ${{ github.workflow }}
3232

3333
# Linux tests
3434
linux:
@@ -56,8 +56,6 @@ jobs:
5656
with:
5757
toolchain: ${{ matrix.rust }}
5858
targets: ${{ matrix.target }}
59-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
60-
- run: rm ../Cargo.toml
6159
- run: ${{ matrix.deps }}
6260
- run: cargo test --target ${{ matrix.target }}
6361

@@ -76,8 +74,6 @@ jobs:
7674
with:
7775
toolchain: ${{ matrix.toolchain }}
7876
targets: x86_64-apple-darwin
79-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
80-
- run: rm ../Cargo.toml
8177
- run: cargo test
8278

8379
# Windows tests
@@ -98,8 +94,6 @@ jobs:
9894
with:
9995
toolchain: ${{ matrix.toolchain }}
10096
targets: ${{ matrix.target }}
101-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
102-
- run: rm ../Cargo.toml
10397
- run: cargo test --target ${{ matrix.target }}
10498

10599
# Cross-compiled tests
@@ -121,8 +115,6 @@ jobs:
121115
toolchain: ${{ matrix.rust }}
122116
targets: ${{ matrix.target }}
123117
- uses: RustCrypto/actions/cross-install@master
124-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
125-
- run: rm ../Cargo.toml
126118
- run: cross test --target ${{ matrix.target }}
127119

128120
# Build-only tests

.github/workflows/hex-literal.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: hex-literal
22

33
on:
44
pull_request:
5-
paths:
6-
- "hex-literal/**"
7-
- "Cargo.*"
5+
paths:
6+
- "hex-literal/**"
7+
- "Cargo.*"
88
push:
99
branches: master
1010

@@ -42,14 +42,12 @@ jobs:
4242
with:
4343
toolchain: ${{ matrix.rust }}
4444
targets: ${{ matrix.target }}
45-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
46-
- run: rm ../Cargo.toml
4745
- run: cargo build --target ${{ matrix.target }}
4846

4947
minimal-versions:
5048
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
5149
with:
52-
working-directory: ${{ github.workflow }}
50+
working-directory: ${{ github.workflow }}
5351

5452
test:
5553
runs-on: ubuntu-latest
@@ -64,6 +62,4 @@ jobs:
6462
- uses: dtolnay/rust-toolchain@master
6563
with:
6664
toolchain: ${{ matrix.rust }}
67-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
68-
- run: rm ../Cargo.toml
6965
- run: cargo test

.github/workflows/inout.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: inout
22

33
on:
44
pull_request:
5-
paths:
6-
- "inout/**"
7-
- "Cargo.*"
5+
paths:
6+
- "inout/**"
7+
- "Cargo.*"
88
push:
99
branches: master
1010

@@ -48,7 +48,7 @@ jobs:
4848
minimal-versions:
4949
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
5050
with:
51-
working-directory: ${{ github.workflow }}
51+
working-directory: ${{ github.workflow }}
5252

5353
test:
5454
runs-on: ubuntu-latest

.github/workflows/opaque-debug.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: opaque-debug
22

33
on:
44
pull_request:
5-
paths:
6-
- "opaque-debug/**"
7-
- "Cargo.*"
5+
paths:
6+
- "opaque-debug/**"
7+
- "Cargo.*"
88
push:
99
branches: master
1010

@@ -42,15 +42,8 @@ jobs:
4242
with:
4343
toolchain: ${{ matrix.rust }}
4444
targets: ${{ matrix.target }}
45-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
46-
- run: rm ../Cargo.toml
4745
- run: cargo build --target ${{ matrix.target }}
4846

49-
minimal-versions:
50-
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
51-
with:
52-
working-directory: ${{ github.workflow }}
53-
5447
test:
5548
runs-on: ubuntu-latest
5649
strategy:
@@ -64,6 +57,4 @@ jobs:
6457
- uses: dtolnay/rust-toolchain@master
6558
with:
6659
toolchain: ${{ matrix.rust }}
67-
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
68-
- run: rm ../Cargo.toml
6960
- run: cargo test

Cargo.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,42 @@ opt-level = 2
2929

3030
[patch.crates-io]
3131
cmov = { path = "cmov" }
32+
33+
[workspace.lints.clippy]
34+
borrow_as_ptr = "warn"
35+
cast_lossless = "warn"
36+
cast_possible_truncation = "warn"
37+
cast_possible_wrap = "warn"
38+
cast_precision_loss = "warn"
39+
cast_sign_loss = "warn"
40+
checked_conversions = "warn"
41+
doc_markdown = "warn"
42+
from_iter_instead_of_collect = "warn"
43+
manual_assert = "warn"
44+
map_unwrap_or = "warn"
45+
missing_errors_doc = "warn"
46+
missing_panics_doc = "warn"
47+
mod_module_files = "warn"
48+
must_use_candidate = "warn"
49+
implicit_saturating_sub = "warn"
50+
ptr_as_ptr = "warn"
51+
redundant_closure_for_method_calls = "warn"
52+
ref_as_ptr = "warn"
53+
return_self_not_must_use = "warn"
54+
semicolon_if_nothing_returned = "warn"
55+
trivially_copy_pass_by_ref = "warn"
56+
std_instead_of_alloc = "warn"
57+
std_instead_of_core = "warn"
58+
undocumented_unsafe_blocks = "warn"
59+
unnecessary_safety_comment = "warn"
60+
unwrap_in_result = "warn"
61+
unwrap_used = "warn"
62+
63+
[workspace.lints.rust]
64+
missing_copy_implementations = "warn"
65+
missing_debug_implementations = "warn"
66+
missing_docs = "warn"
67+
trivial_casts = "warn"
68+
trivial_numeric_casts = "warn"
69+
unused_lifetimes = "warn"
70+
unused_qualifications = "warn"

blobby/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ description = "Iterator over simple binary blob storage"
1313

1414
[features]
1515
alloc = []
16+
17+
[lints]
18+
workspace = true

0 commit comments

Comments
 (0)