Skip to content

Commit b80cbcf

Browse files
committed
Use expect for lint exceptions
1 parent 4b1e683 commit b80cbcf

File tree

16 files changed

+112
-132
lines changed

16 files changed

+112
-132
lines changed

benches/parallel.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2024, The Tari Project
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
#![allow(missing_docs)]
4+
#![expect(missing_docs)]
55

66
#[macro_use]
77
extern crate criterion;
@@ -27,8 +27,8 @@ const M_VALUES: [u32; 4] = [2, 4, 8, 10];
2727
const BATCH_SIZES: [usize; 1] = [2];
2828

2929
// Generate a batch of witnesses, statements, and transcripts
30-
#[allow(non_snake_case)]
31-
#[allow(clippy::arithmetic_side_effects)]
30+
#[expect(non_snake_case)]
31+
#[expect(clippy::arithmetic_side_effects)]
3232
fn generate_data<R: CryptoRngCore>(
3333
params: &TriptychParameters,
3434
b: usize,
@@ -82,8 +82,6 @@ fn generate_data<R: CryptoRngCore>(
8282
(witnesses, statements, transcripts)
8383
}
8484

85-
#[allow(non_snake_case)]
86-
#[allow(non_upper_case_globals)]
8785
fn generate_proof(c: &mut Criterion) {
8886
let mut group = c.benchmark_group("generate_proof");
8987
let mut rng = ChaCha12Rng::seed_from_u64(8675309);
@@ -113,8 +111,6 @@ fn generate_proof(c: &mut Criterion) {
113111
group.finish();
114112
}
115113

116-
#[allow(non_snake_case)]
117-
#[allow(non_upper_case_globals)]
118114
fn generate_proof_vartime(c: &mut Criterion) {
119115
let mut group = c.benchmark_group("generate_proof_vartime");
120116
let mut rng = ChaCha12Rng::seed_from_u64(8675309);
@@ -149,8 +145,6 @@ fn generate_proof_vartime(c: &mut Criterion) {
149145
group.finish();
150146
}
151147

152-
#[allow(non_snake_case)]
153-
#[allow(non_upper_case_globals)]
154148
fn verify_proof(c: &mut Criterion) {
155149
let mut group = c.benchmark_group("verify_proof");
156150
let mut rng = ChaCha12Rng::seed_from_u64(8675309);
@@ -185,8 +179,6 @@ fn verify_proof(c: &mut Criterion) {
185179
group.finish();
186180
}
187181

188-
#[allow(non_snake_case)]
189-
#[allow(non_upper_case_globals)]
190182
fn verify_batch_proof(c: &mut Criterion) {
191183
let mut group = c.benchmark_group("verify_batch_proof");
192184
let mut rng = ChaCha12Rng::seed_from_u64(8675309);

benches/triptych.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2024, The Tari Project
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
#![allow(missing_docs)]
4+
#![expect(missing_docs)]
55

66
#[macro_use]
77
extern crate criterion;
@@ -25,8 +25,8 @@ const M_VALUES: [u32; 4] = [2, 4, 8, 10];
2525
const BATCH_SIZES: [usize; 1] = [2];
2626

2727
// Generate a batch of witnesses, statements, and transcripts
28-
#[allow(non_snake_case)]
29-
#[allow(clippy::arithmetic_side_effects)]
28+
#[expect(non_snake_case)]
29+
#[expect(clippy::arithmetic_side_effects)]
3030
fn generate_data<R: CryptoRngCore>(
3131
params: &TriptychParameters,
3232
b: usize,
@@ -72,8 +72,6 @@ fn generate_data<R: CryptoRngCore>(
7272
(witnesses, statements, transcripts)
7373
}
7474

75-
#[allow(non_snake_case)]
76-
#[allow(non_upper_case_globals)]
7775
fn generate_proof(c: &mut Criterion) {
7876
let mut group = c.benchmark_group("generate_proof");
7977
let mut rng = ChaCha12Rng::seed_from_u64(8675309);
@@ -103,8 +101,6 @@ fn generate_proof(c: &mut Criterion) {
103101
group.finish();
104102
}
105103

106-
#[allow(non_snake_case)]
107-
#[allow(non_upper_case_globals)]
108104
fn generate_proof_vartime(c: &mut Criterion) {
109105
let mut group = c.benchmark_group("generate_proof_vartime");
110106
let mut rng = ChaCha12Rng::seed_from_u64(8675309);
@@ -139,8 +135,6 @@ fn generate_proof_vartime(c: &mut Criterion) {
139135
group.finish();
140136
}
141137

142-
#[allow(non_snake_case)]
143-
#[allow(non_upper_case_globals)]
144138
fn verify_proof(c: &mut Criterion) {
145139
let mut group = c.benchmark_group("verify_proof");
146140
let mut rng = ChaCha12Rng::seed_from_u64(8675309);
@@ -175,8 +169,6 @@ fn verify_proof(c: &mut Criterion) {
175169
group.finish();
176170
}
177171

178-
#[allow(non_snake_case)]
179-
#[allow(non_upper_case_globals)]
180172
fn verify_batch_proof(c: &mut Criterion) {
181173
let mut group = c.benchmark_group("verify_batch_proof");
182174
let mut rng = ChaCha12Rng::seed_from_u64(8675309);

examples/ringct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod test {
1515
use rand_core::OsRng;
1616
use triptych::parallel::*;
1717

18-
#[allow(non_snake_case)]
18+
#[expect(non_snake_case)]
1919
#[test]
2020
fn ringct() {
2121
// It's important to use a cryptographically-secure random number generator!

lints.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
deny = [
22
# Prevent spelling mistakes in lints
33
'unknown_lints',
4+
5+
# Ensure all expectations are met
6+
'unfulfilled_lint_expectations',
47

58
# Use the default groups:
69
# correctness, suspicious, style, complexity, perf
@@ -24,7 +27,6 @@ deny = [
2427
'clippy::else_if_without_else',
2528
'clippy::enum_glob_use',
2629
'clippy::inline_always',
27-
'clippy::match_on_vec_items',
2830
'clippy::match_wild_err_arm',
2931

3032
# Style preferences
@@ -52,4 +54,4 @@ deny = [
5254
warn = [
5355
'clippy::uninlined_format_args',
5456
'clippy::too_many_arguments',
55-
]
57+
]

src/gray.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::num::NonZeroU32;
77
use crypto_bigint::{NonZero, U64};
88

99
/// An iterator for arbitrary-base Gray codes.
10-
#[allow(non_snake_case)]
10+
#[expect(non_snake_case)]
1111
pub(crate) struct GrayIterator {
1212
N: u32, // base
1313
M: u32, // number of digits
@@ -24,7 +24,7 @@ impl GrayIterator {
2424
///
2525
/// Operations using this iterator run in variable time, so don't use this for secret data.
2626
/// If you need to get the Gray code decomposition for a secret value, use `decompose` directly.
27-
#[allow(non_snake_case)]
27+
#[expect(non_snake_case)]
2828
pub(crate) fn new(N: u32, M: u32) -> Option<Self> {
2929
// Check inputs
3030
if N <= 1 || M == 0 {
@@ -45,7 +45,7 @@ impl GrayIterator {
4545
/// You must provide a valid value `v` based on the supplied parameters `N` and `M`.
4646
/// If anything goes wrong, returns `None`.
4747
/// Otherwise, returns the Gray code as a `u32` digit vector.
48-
#[allow(non_snake_case)]
48+
#[expect(non_snake_case)]
4949
pub(crate) fn decompose_vartime(N: u32, M: u32, mut v: u32) -> Option<Vec<u32>> {
5050
if N <= 1 || M == 0 {
5151
return None;
@@ -76,7 +76,7 @@ impl GrayIterator {
7676
/// You must provide a valid value `v` based on the supplied parameters `N` and `M`.
7777
/// If anything goes wrong, returns `None`.
7878
/// Otherwise, returns the Gray code as a `u32` digit vector.
79-
#[allow(non_snake_case)]
79+
#[expect(non_snake_case)]
8080
pub(crate) fn decompose(N: u32, M: u32, v: u32) -> Option<Vec<u32>> {
8181
if N <= 1 || M == 0 {
8282
return None;
@@ -126,7 +126,6 @@ impl Iterator for GrayIterator {
126126
///
127127
/// Keep in mind that this does not return the actual Gray code!
128128
/// You must keep track of that yourself.
129-
#[allow(non_snake_case)]
130129
fn next(&mut self) -> Option<Self::Item> {
131130
if self.i == 0 {
132131
self.i = 1;
@@ -163,7 +162,7 @@ mod test {
163162
use super::*;
164163

165164
#[test]
166-
#[allow(non_snake_case)]
165+
#[expect(non_snake_case)]
167166
fn test_gray_iterator() {
168167
// Set up parameters
169168
let N = 3u32;
@@ -195,7 +194,7 @@ mod test {
195194
}
196195

197196
#[test]
198-
#[allow(non_snake_case)]
197+
#[expect(non_snake_case)]
199198
fn test_gray_iterator_vartime() {
200199
// Set up parameters
201200
let N = 3u32;

src/parallel/parameters.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{domains, util::OperationTiming, Transcript};
2121
/// `G`, `G1`, and `U` required by the protocol. You can either use [`TriptychParameters::new`] to have these generators
2222
/// defined securely for you, or use [`TriptychParameters::new_with_generators`] if your use case requires specific
2323
/// values for these.
24-
#[allow(non_snake_case)]
24+
#[expect(non_snake_case)]
2525
#[derive(Clone, Eq, PartialEq)]
2626
pub struct TriptychParameters {
2727
n: u32,
@@ -53,7 +53,7 @@ impl TriptychParameters {
5353
///
5454
/// This function produces group generators `G`, `G1` and `U` for you.
5555
/// If your use case requires specific generators, use [`TriptychParameters::new_with_generators`] instead.
56-
#[allow(non_snake_case)]
56+
#[expect(non_snake_case)]
5757
pub fn new(n: u32, m: u32) -> Result<Self, ParameterError> {
5858
// Use the default base point for `G` (this is arbitrary)
5959
let G = RISTRETTO_BASEPOINT_POINT;
@@ -89,7 +89,7 @@ impl TriptychParameters {
8989
///
9090
/// The security of these generators cannot be checked by this function.
9191
/// If you'd rather have the generators securely defined for you, use [`TriptychParameters::new`] instead.
92-
#[allow(non_snake_case)]
92+
#[expect(non_snake_case)]
9393
pub fn new_with_generators(
9494
n: u32,
9595
m: u32,
@@ -199,23 +199,23 @@ impl TriptychParameters {
199199
/// Get the group generator `G` from these [`TriptychParameters`].
200200
///
201201
/// This is the generator used for defining verification keys.
202-
#[allow(non_snake_case)]
202+
#[expect(non_snake_case)]
203203
pub fn get_G(&self) -> &RistrettoPoint {
204204
&self.G
205205
}
206206

207207
/// Get the group generator `G1` from these [`TriptychParameters`].
208208
///
209209
/// This is the generator used for defining auxiliary verification keys.
210-
#[allow(non_snake_case)]
210+
#[expect(non_snake_case)]
211211
pub fn get_G1(&self) -> &RistrettoPoint {
212212
&self.G1
213213
}
214214

215215
/// Get the group generator `U` from these [`TriptychParameters`].
216216
///
217217
/// This is the generator used for defining linking tags.
218-
#[allow(non_snake_case)]
218+
#[expect(non_snake_case)]
219219
pub fn get_U(&self) -> &RistrettoPoint {
220220
&self.U
221221
}
@@ -237,20 +237,20 @@ impl TriptychParameters {
237237
/// Get the value `N == n**m` from these [`TriptychParameters`].
238238
///
239239
/// This is the verification key vector size.
240-
#[allow(non_snake_case)]
240+
#[expect(non_snake_case)]
241241
pub fn get_N(&self) -> u32 {
242242
// This is guaranteed not to overflow
243243
self.n.pow(self.m)
244244
}
245245

246246
/// Get the value `CommitmentG` from these [`TriptychParameters`].
247-
#[allow(non_snake_case)]
247+
#[expect(non_snake_case)]
248248
pub(crate) fn get_CommitmentG(&self) -> &Vec<RistrettoPoint> {
249249
&self.CommitmentG
250250
}
251251

252252
/// Get the value `CommitmentH` from these [`TriptychParameters`].
253-
#[allow(non_snake_case)]
253+
#[expect(non_snake_case)]
254254
pub(crate) fn get_CommitmentH(&self) -> &RistrettoPoint {
255255
&self.CommitmentH
256256
}

0 commit comments

Comments
 (0)