Skip to content

Commit 2d2bbcc

Browse files
committed
chore: Move all lints to Cargo.toml
1 parent c465c79 commit 2d2bbcc

10 files changed

Lines changed: 22 additions & 49 deletions

File tree

Cargo.toml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,16 @@ ignored = ["bindgen", "semver", "serde", "serde_derive", "toml"]
3737

3838
[lints.rust]
3939
absolute_paths_not_starting_with_crate = "warn"
40-
# TODO: Re-activate with MSRV 1.82.0. See
41-
# https://github.com/mozilla/neqo/pull/2661 for details.
42-
# ambiguous_negative_literals = "warn"
40+
ambiguous_negative_literals = "warn"
4341
explicit_outlives_requirements = "warn"
4442
macro_use_extern_crate = "warn"
4543
missing_abi = "warn"
4644
non_ascii_idents = "warn"
47-
# TODO: Re-activate with MSRV 1.82.0. See
48-
# https://github.com/mozilla/neqo/pull/2661 for details.
49-
# redundant_imports = "warn"
45+
redundant_imports = "warn"
5046
redundant_lifetimes = "warn"
5147
trivial_numeric_casts = "warn"
5248
unit_bindings = "warn"
53-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
49+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly,fuzzing)'] }
5450
unused_import_braces = "warn"
5551
unused_lifetimes = "warn"
5652
unused_macro_rules = "warn"
@@ -74,21 +70,22 @@ float_cmp_const = "warn"
7470
fn_to_numeric_cast_any = "warn"
7571
get_unwrap = "warn"
7672
if_then_some_else_none = "warn"
77-
# TODO: Re-activate with MSRV 1.82.0. See
78-
# https://github.com/mozilla/neqo/pull/2661 for details.
79-
# impl_trait_in_params = "warn"
73+
impl_trait_in_params = "warn"
8074
infinite_loop = "warn"
8175
iter_over_hash_type = "warn"
8276
large_include_file = "warn"
8377
let_underscore_must_use = "warn"
8478
let_underscore_untyped = "warn"
85-
literal_string_with_formatting_args = "allow" # FIXME: Re-enable "warn" when MSRV is > 1.87. See https://github.com/rust-lang/rust-clippy/pull/13953#issuecomment-2676336899
79+
literal_string_with_formatting_args = "warn"
8680
lossy_float_literal = "warn"
8781
map_with_unused_argument_over_ranges = "warn"
8882
mem_forget = "warn"
8983
missing_asserts_for_indexing = "warn"
84+
missing_errors_doc = "allow"
85+
missing_panics_doc = "allow"
86+
missing_safety_doc = "allow"
9087
mixed_read_write_in_expression = "warn"
91-
module_name_repetitions = "warn"
88+
module_name_repetitions = "allow"
9289
multiple_crate_versions = "allow"
9390
multiple_inherent_impl = "warn"
9491
mutex_atomic = "warn"

src/aead.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ use std::{
1212
use crate::{
1313
constants::{Cipher, Version},
1414
err::{sec::SEC_ERROR_BAD_DATA, Error, Res},
15-
experimental_api,
1615
p11::{
1716
self, Context, PK11SymKey, PK11_AEADOp, PK11_CreateContextBySymKey, CKA_DECRYPT,
1817
CKA_ENCRYPT, CKA_NSS_MESSAGE, CKG_GENERATE_COUNTER_XOR, CKG_NO_GENERATE, CKM_AES_GCM,
1918
CKM_CHACHA20_POLY1305, CK_ATTRIBUTE_TYPE, CK_GENERATOR_FUNCTION, CK_MECHANISM_TYPE,
2019
},
21-
scoped_ptr, secstatus_to_res,
20+
secstatus_to_res,
2221
ssl::{PRUint16, PRUint64, PRUint8, SSLAeadContext},
2322
SECItemBorrowed, SymKey,
2423
};
@@ -374,7 +373,7 @@ impl Aead {
374373
aad.as_ptr(),
375374
c_int_len(aad.len())?,
376375
ct.as_mut_ptr(),
377-
&mut ct_len,
376+
&raw mut ct_len,
378377
c_int_len(ct.len())?, // signed :(
379378
tag.as_mut_ptr(),
380379
c_int_len(tag.len())?,
@@ -409,7 +408,7 @@ impl Aead {
409408
aad.as_ptr(),
410409
c_int_len(aad.len())?,
411410
pt.as_mut_ptr(),
412-
&mut pt_len,
411+
&raw mut pt_len,
413412
c_int_len(pt.len())?,
414413
ct.as_ptr().add(pt_expected).cast_mut(),
415414
c_int_len(TAG_LEN)?,

src/constants.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
// option. This file may not be copied, modified, or distributed
55
// except according to those terms.
66

7-
use std::convert::TryFrom;
8-
97
use enum_map::Enum;
108
use strum::FromRepr;
119

src/ec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub fn ecdh_keygen(curve: &EcCurve) -> Result<EcdhKeypair, Error> {
144144
*slot,
145145
ckm,
146146
oid_ptr.cast(),
147-
&mut pk_ptr,
147+
&raw mut pk_ptr,
148148
CK_FALSE.into(),
149149
CK_FALSE.into(),
150150
ptr::null_mut(),
@@ -211,7 +211,7 @@ pub fn import_ec_private_key_pkcs8(pki: &[u8]) -> Result<PrivateKey, Error> {
211211
0,
212212
0,
213213
KU_ALL,
214-
&mut pk_ptr,
214+
&raw mut pk_ptr,
215215
ptr::null_mut(),
216216
))?;
217217

src/hkdf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// option. This file may not be copied, modified, or distributed
55
// except according to those terms.
66

7-
#![allow(non_camel_case_types)]
7+
#![allow(non_camel_case_types, reason = "C enum naming")]
88

99
use std::{
1010
convert::TryFrom as _,
@@ -101,7 +101,7 @@ impl<'a, T: Sized + 'a> ParamItem<'a, T> {
101101
})
102102
}
103103

104-
pub fn ptr(&mut self) -> *mut SECItem {
104+
pub const fn ptr(&mut self) -> *mut SECItem {
105105
std::ptr::addr_of_mut!(self.item)
106106
}
107107
}

src/hmac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn hmac(alg: &HmacAlgorithm, key: &[u8], data: &[u8]) -> Result<Vec<u8>, Err
9292
PK11_DigestFinal(
9393
*context,
9494
digest.as_mut_ptr(),
95-
&mut digest_len,
95+
&raw mut digest_len,
9696
digest.len() as u32,
9797
)
9898
.into_result()?;

src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
// option. This file may not be copied, modified, or distributed
55
// except according to those terms.
66

7-
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
8-
#![warn(clippy::pedantic)]
9-
// Bindgen auto generated code
10-
// won't adhere to the clippy rules below
11-
#![allow(clippy::borrow_as_ptr)]
12-
#![allow(clippy::module_name_repetitions)]
13-
#![allow(clippy::unseparated_literal_suffix)]
14-
#![allow(clippy::used_underscore_binding)]
15-
#![allow(clippy::missing_panics_doc)]
16-
#![allow(clippy::missing_errors_doc)]
17-
#![allow(clippy::missing_safety_doc)]
187
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
198

209
#[cfg(feature = "disable-encryption")]
@@ -49,7 +38,6 @@ mod ssl;
4938
pub mod time;
5039

5140
use std::{
52-
convert::TryFrom,
5341
env,
5442
ffi::CString,
5543
path::{Path, PathBuf},

src/p11.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
};
2323

2424
#[must_use]
25-
pub fn hex_with_len(buf: impl AsRef<[u8]>) -> String {
25+
pub fn hex_with_len<B: AsRef<[u8]>>(buf: B) -> String {
2626
use std::fmt::Write as _;
2727
let buf = buf.as_ref();
2828
let mut ret = String::with_capacity(10 + buf.len() * 2);

src/time.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::{
1919
use once_cell::sync::OnceCell;
2020

2121
use crate::{
22+
agent::as_c_void,
2223
err::{Error, Res},
2324
prio::PRFileDesc,
2425
ssl::SSLTimeFunc,
@@ -175,19 +176,9 @@ impl TimeHolder {
175176
*p.as_ref().unwrap()
176177
}
177178

178-
#[expect(
179-
clippy::not_unsafe_ptr_arg_deref,
180-
clippy::ptr_as_ptr,
181-
clippy::ref_as_ptr
182-
)]
179+
#[expect(clippy::not_unsafe_ptr_arg_deref)]
183180
pub fn bind(&mut self, fd: *mut PRFileDesc) -> Res<()> {
184-
unsafe {
185-
SSL_SetTimeFunc(
186-
fd,
187-
Some(Self::time_func),
188-
&mut *self.t as *mut _ as *mut c_void,
189-
)
190-
}
181+
unsafe { SSL_SetTimeFunc(fd, Some(Self::time_func), as_c_void(&mut self.t)) }
191182
}
192183

193184
pub fn set(&mut self, t: Instant) -> Res<()> {

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl Drop for SECItemMut {
203203
// If the second argument is true, it also frees the SECItem itself,
204204
// which we don't want to do, because rust owns that memory.
205205
unsafe {
206-
SECITEM_FreeItem(&mut self.inner, PRBool::from(false));
206+
SECITEM_FreeItem(&raw mut self.inner, PRBool::from(false));
207207
}
208208
}
209209
}

0 commit comments

Comments
 (0)