Skip to content

Commit 9cc3a5c

Browse files
committed
crypto-common: apply workspace-level lints
Adds the workspace-level config from RustCrypto/utils#1411 to this repo and applies it to `crypto-common`.
1 parent acdf155 commit 9cc3a5c

7 files changed

Lines changed: 265 additions & 193 deletions

File tree

.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/workspace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- uses: RustCrypto/actions/cargo-cache@master
3030
- uses: dtolnay/rust-toolchain@master
3131
with:
32-
toolchain: 1.87.0
32+
toolchain: 1.93.0
3333
components: clippy
3434
- run: cargo clippy --all --all-features --tests -- -D warnings
3535

Cargo.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,46 @@ members = [
1414
"signature",
1515
]
1616

17+
[workspace.lints.clippy]
18+
borrow_as_ptr = "warn"
19+
cast_lossless = "warn"
20+
cast_possible_truncation = "warn"
21+
cast_possible_wrap = "warn"
22+
cast_precision_loss = "warn"
23+
cast_sign_loss = "warn"
24+
checked_conversions = "warn"
25+
doc_markdown = "warn"
26+
from_iter_instead_of_collect = "warn"
27+
implicit_saturating_sub = "warn"
28+
manual_assert = "warn"
29+
map_unwrap_or = "warn"
30+
missing_errors_doc = "warn"
31+
missing_panics_doc = "warn"
32+
mod_module_files = "warn"
33+
must_use_candidate = "warn"
34+
needless_range_loop = "allow"
35+
ptr_as_ptr = "warn"
36+
redundant_closure_for_method_calls = "warn"
37+
ref_as_ptr = "warn"
38+
return_self_not_must_use = "warn"
39+
semicolon_if_nothing_returned = "warn"
40+
trivially_copy_pass_by_ref = "warn"
41+
std_instead_of_alloc = "warn"
42+
std_instead_of_core = "warn"
43+
undocumented_unsafe_blocks = "warn"
44+
unnecessary_safety_comment = "warn"
45+
unwrap_in_result = "warn"
46+
unwrap_used = "warn"
47+
48+
[workspace.lints.rust]
49+
missing_copy_implementations = "warn"
50+
missing_debug_implementations = "warn"
51+
missing_docs = "warn"
52+
trivial_casts = "warn"
53+
trivial_numeric_casts = "warn"
54+
unused_lifetimes = "warn"
55+
unused_qualifications = "warn"
56+
1757
[patch.crates-io]
1858
crypto-common = { path = "crypto-common" }
1959
digest = { path = "digest" }

crypto-common/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ getrandom = ["rand_core", "dep:getrandom"]
2424
rand_core = ["dep:rand_core"]
2525
zeroize = ["hybrid-array/zeroize"]
2626

27+
[lints]
28+
workspace = true
29+
2730
[package.metadata.docs.rs]
2831
all-features = true

crypto-common/src/generate.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ use getrandom::{SysRng, rand_core::UnwrapErr};
77
/// Secure random generation.
88
pub trait Generate: Sized {
99
/// Generate random key using the provided [`TryCryptoRng`].
10+
///
11+
/// # Errors
12+
/// Returns `R::Error` in the event the provided RNG `R` experiences an internal failure.
1013
fn try_generate_from_rng<R: TryCryptoRng + ?Sized>(rng: &mut R) -> Result<Self, R::Error>;
1114

1215
/// Generate random key using the provided [`CryptoRng`].
16+
#[must_use]
1317
fn generate_from_rng<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
1418
let Ok(ret) = Self::try_generate_from_rng(rng);
1519
ret
@@ -35,6 +39,7 @@ pub trait Generate: Sized {
3539
///
3640
/// This shouldn't happen on most modern operating systems.
3741
#[cfg(feature = "getrandom")]
42+
#[must_use]
3843
fn generate() -> Self {
3944
Self::generate_from_rng(&mut UnwrapErr(SysRng))
4045
}

0 commit comments

Comments
 (0)