Skip to content

Commit 3d1440b

Browse files
authored
Workspace-level lint configuration (#261)
Enables and fixes the same workspace-level lint configuration we originally implemented in RustCrypto/utils#1411, but for this repo. This primarily includes `clippy` lints, which have replaced the ones configured in individual lib.rs files. Since every crate in this repo previously declared `forbid(unsafe_code)` this has also been moved to the workspace-level.
1 parent 11d4f36 commit 3d1440b

33 files changed

+104
-40
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

Cargo.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,44 @@ members = [
1111

1212
[profile.dev]
1313
opt-level = 2
14+
15+
[workspace.lints.clippy]
16+
borrow_as_ptr = "warn"
17+
cast_lossless = "warn"
18+
cast_possible_truncation = "warn"
19+
cast_possible_wrap = "warn"
20+
cast_precision_loss = "warn"
21+
cast_sign_loss = "warn"
22+
checked_conversions = "warn"
23+
doc_markdown = "warn"
24+
from_iter_instead_of_collect = "warn"
25+
implicit_saturating_sub = "warn"
26+
manual_assert = "warn"
27+
map_unwrap_or = "warn"
28+
missing_errors_doc = "warn"
29+
missing_panics_doc = "warn"
30+
mod_module_files = "warn"
31+
must_use_candidate = "warn"
32+
needless_range_loop = "allow"
33+
ptr_as_ptr = "warn"
34+
redundant_closure_for_method_calls = "warn"
35+
ref_as_ptr = "warn"
36+
return_self_not_must_use = "warn"
37+
semicolon_if_nothing_returned = "warn"
38+
trivially_copy_pass_by_ref = "warn"
39+
std_instead_of_alloc = "warn"
40+
std_instead_of_core = "warn"
41+
undocumented_unsafe_blocks = "warn"
42+
unnecessary_safety_comment = "warn"
43+
unwrap_in_result = "warn"
44+
unwrap_used = "warn"
45+
46+
[workspace.lints.rust]
47+
missing_copy_implementations = "warn"
48+
missing_debug_implementations = "warn"
49+
missing_docs = "warn"
50+
trivial_casts = "warn"
51+
trivial_numeric_casts = "warn"
52+
unsafe_code = "forbid"
53+
unused_lifetimes = "warn"
54+
unused_qualifications = "warn"

belt-mac/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ hex-literal = "1"
2424
[features]
2525
zeroize = ["cipher/zeroize", "digest/zeroize"]
2626

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

belt-mac/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RustCrypto: belt-mac
1+
# [RustCrypto]: belt-mac
22

33
[![crate][crate-image]][crate-link]
44
[![Docs][docs-image]][docs-link]
@@ -61,4 +61,5 @@ dual licensed as above, without any additional terms or conditions.
6161

6262
[//]: # (general links)
6363

64+
[RustCrypto]: https://github.com/RustCrypto
6465
[1]: https://apmi.bsu.by/assets/files/std/belt-spec371.pdf

belt-mac/src/block_api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use digest::{
1414
#[cfg(feature = "zeroize")]
1515
use digest::zeroize::{Zeroize, ZeroizeOnDrop};
1616

17-
/// Generic core BeltMac instance, which operates over blocks.
17+
/// Generic core Belt MAC instance, which operates over blocks.
1818
#[derive(Clone)]
1919
pub struct BeltMacCore<C>
2020
where
@@ -94,7 +94,7 @@ where
9494
}
9595

9696
let Self { cipher, state, .. } = self;
97-
cipher.encrypt_with_backend(Closure { state, blocks })
97+
cipher.encrypt_with_backend(Closure { state, blocks });
9898
}
9999
}
100100

belt-mac/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg"
66
)]
77
#![cfg_attr(docsrs, feature(doc_cfg))]
8-
#![forbid(unsafe_code)]
9-
#![warn(missing_docs)]
108

119
pub use digest::{self, KeyInit, Mac};
1210

@@ -17,11 +15,11 @@ use cipher::BlockCipherEncrypt;
1715
use digest::block_api::SmallBlockSizeUser;
1816

1917
digest::buffer_fixed!(
20-
/// BeltMac instance generic over block cipher.
18+
/// Belt MAC instance generic over block cipher.
2119
#[derive(Clone)]
2220
pub struct GenericBeltMac<C: BlockCipherEncrypt + SmallBlockSizeUser>(block_api::BeltMacCore<C>);
2321
impl: ResetMacTraits AlgorithmName InnerInit;
2422
);
2523

26-
/// BeltMac instance.
24+
/// Belt MAC instance.
2725
pub type BeltMac = GenericBeltMac<belt_block::BeltBlock>;

belt-mac/tests/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test vectors.
2+
13
//use belt_mac::BeltMac;
24

35
// TODO(tarcieri): update tests to support RustCrypto/traits#1916

cbc-mac/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ des = "0.9.0-rc.3"
2525
[features]
2626
zeroize = ["cipher/zeroize", "digest/zeroize"]
2727

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

cbc-mac/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RustCrypto: CBC-MAC
1+
# [RustCrypto]: CBC-MAC
22

33
[![crate][crate-image]][crate-link]
44
[![Docs][docs-image]][docs-link]
@@ -60,4 +60,5 @@ dual licensed as above, without any additional terms or conditions.
6060

6161
[//]: # (general links)
6262

63+
[RustCrypto]: https://github.com/RustCrypto
6364
[CBC-MAC]: https://en.wikipedia.org/wiki/CBC-MAC

cbc-mac/src/block_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ where
9191
}
9292

9393
let Self { cipher, state } = self;
94-
cipher.encrypt_with_backend(Closure { state, blocks })
94+
cipher.encrypt_with_backend(Closure { state, blocks });
9595
}
9696
}
9797

0 commit comments

Comments
 (0)