Skip to content

Commit

Permalink
chore: Remove superfluous clippy allows (#1997)
Browse files Browse the repository at this point in the history
* chore: Remove superfluous clippy allows

Now that nightly has experimental support for
https://rust-lang.github.io/rfcs/2383-lint-reasons.html, use that to
identify superfluous clippy allows and remove them.

* Minimize diff

* fmt

* Minimize diff

* Fixes
  • Loading branch information
larseggert authored Jul 25, 2024
1 parent 1815c3c commit 7a39675
Show file tree
Hide file tree
Showing 40 changed files with 40 additions and 106 deletions.
6 changes: 1 addition & 5 deletions neqo-bin/src/client/http3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ use url::Url;
use super::{get_output_file, qlog_new, Args, CloseState, Res};

pub struct Handler<'a> {
#[allow(
unknown_lints,
clippy::struct_field_names,
clippy::redundant_field_names
)]
#[allow(clippy::struct_field_names)]
url_handler: UrlHandler<'a>,
token: Option<ResumptionToken>,
output_read_data: bool,
Expand Down
2 changes: 0 additions & 2 deletions neqo-common/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ impl Encoder {
/// # Panics
///
/// When `n` is outside the range `1..=8`.
#[allow(clippy::cast_possible_truncation)]
pub fn encode_uint<T: Into<u64>>(&mut self, n: usize, v: T) -> &mut Self {
let v = v.into();
assert!(n > 0 && n <= 8);
Expand Down Expand Up @@ -374,7 +373,6 @@ impl Encoder {
/// # Panics
///
/// When `f()` writes more than 2^62 bytes.
#[allow(clippy::cast_possible_truncation)]
pub fn encode_vvec_with<F: FnOnce(&mut Self)>(&mut self, f: F) -> &mut Self {
let start = self.buf.len();
// Optimize for short buffers, reserve a single byte for the length.
Expand Down
42 changes: 21 additions & 21 deletions neqo-common/src/hrtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,37 +287,37 @@ impl Time {
}
}

#[allow(clippy::unused_self)] // Only on some platforms is it unused.
#[allow(clippy::missing_const_for_fn)] // Only const on some platforms where the function is empty.
#[cfg(target_os = "macos")]
fn start(&self) {
#[cfg(target_os = "macos")]
{
if let Some(p) = self.active {
mac::set_realtime(p.scaled(self.scale));
} else {
mac::set_thread_policy(self.deflt);
}
if let Some(p) = self.active {
mac::set_realtime(p.scaled(self.scale));
} else {
mac::set_thread_policy(self.deflt);
}
}

#[cfg(windows)]
{
if let Some(p) = self.active {
_ = unsafe { timeBeginPeriod(p.as_uint()) };
}
#[cfg(target_os = "windows")]
fn start(&self) {
if let Some(p) = self.active {
_ = unsafe { timeBeginPeriod(p.as_uint()) };
}
}

#[allow(clippy::unused_self)] // Only on some platforms is it unused.
#[allow(clippy::missing_const_for_fn)] // Only const on some platforms where the function is empty.
#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))]
#[allow(clippy::unused_self)]
const fn start(&self) {}

#[cfg(windows)]
fn stop(&self) {
#[cfg(windows)]
{
if let Some(p) = self.active {
_ = unsafe { timeEndPeriod(p.as_uint()) };
}
if let Some(p) = self.active {
_ = unsafe { timeEndPeriod(p.as_uint()) };
}
}

#[cfg(not(target_os = "windows"))]
#[allow(clippy::unused_self)]
const fn stop(&self) {}

fn update(&mut self) {
let next = self.periods.min();
if next != self.active {
Expand Down
1 change: 0 additions & 1 deletion neqo-crypto/src/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ impl RealAead {
}

#[must_use]
#[allow(clippy::unused_self)]
pub const fn expansion(&self) -> usize {
16
}
Expand Down
9 changes: 2 additions & 7 deletions neqo-crypto/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ impl SecretAgent {
/// # Panics
///
/// If setup fails.
#[allow(unknown_lints, clippy::branches_sharing_code)]
#[allow(clippy::branches_sharing_code)]
pub fn close(&mut self) {
// It should be safe to close multiple times.
if self.fd.is_null() {
Expand Down Expand Up @@ -833,12 +833,7 @@ impl ResumptionToken {

/// A TLS Client.
#[derive(Debug)]
#[allow(
renamed_and_removed_lints,
clippy::box_vec,
unknown_lints,
clippy::box_collection
)] // We need the Box.
#[allow(clippy::box_collection)] // We need the Box.
pub struct Client {
agent: SecretAgent,

Expand Down
2 changes: 0 additions & 2 deletions neqo-crypto/src/agentio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ impl RecordList {
self.records.push(Record::new(epoch, ct, data));
}

#[allow(clippy::unused_self)]
unsafe extern "C" fn ingest(
_fd: *mut ssl::PRFileDesc,
epoch: ssl::PRUint16,
Expand Down Expand Up @@ -220,7 +219,6 @@ impl AgentIo {
}

unsafe fn borrow(fd: &mut PrFd) -> &mut Self {
#[allow(clippy::cast_ptr_alignment)]
(**fd).secret.cast::<Self>().as_mut().unwrap()
}

Expand Down
1 change: 0 additions & 1 deletion neqo-crypto/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// except according to those terms.

#![allow(dead_code)]
#![allow(clippy::upper_case_acronyms)]

use std::{os::raw::c_char, str::Utf8Error};

Expand Down
1 change: 0 additions & 1 deletion neqo-crypto/src/hp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ impl HpKey {
/// # Panics
///
/// When `cipher` is not known to this code.
#[allow(clippy::cast_sign_loss)] // Cast for PK11_GetBlockSize is safe.
pub fn extract(version: Version, cipher: Cipher, prk: &SymKey, label: &str) -> Res<Self> {
const ZERO: &[u8] = &[0; 12];

Expand Down
4 changes: 1 addition & 3 deletions neqo-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ pub use self::{
mod min_version;
use min_version::MINIMUM_NSS_VERSION;

#[allow(non_upper_case_globals, clippy::redundant_static_lifetimes)]
#[allow(clippy::upper_case_acronyms)]
#[allow(unknown_lints, clippy::borrow_as_ptr)]
#[allow(non_upper_case_globals)]
mod nss {
include!(concat!(env!("OUT_DIR"), "/nss_init.rs"));
}
Expand Down
5 changes: 1 addition & 4 deletions neqo-crypto/src/p11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ use crate::{
null_safe_slice,
};

#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::unreadable_literal)]
#[allow(unknown_lints, clippy::borrow_as_ptr)]
mod nss_p11 {
include!(concat!(env!("OUT_DIR"), "/nss_p11.rs"));
}
Expand Down Expand Up @@ -70,9 +68,8 @@ macro_rules! scoped_ptr {
}

impl Drop for $scoped {
#[allow(unused_must_use)]
fn drop(&mut self) {
unsafe { $dtor(self.ptr) };
unsafe { _ = $dtor(self.ptr) };
}
}
};
Expand Down
6 changes: 1 addition & 5 deletions neqo-crypto/src/prio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(clippy::upper_case_acronyms)]
#![allow(
dead_code,
non_upper_case_globals,
non_snake_case,
clippy::cognitive_complexity,
clippy::empty_enum,
clippy::too_many_lines,
unknown_lints,
clippy::borrow_as_ptr
clippy::too_many_lines
)]

include!(concat!(env!("OUT_DIR"), "/nspr_io.rs"));
Expand Down
2 changes: 0 additions & 2 deletions neqo-crypto/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ use crate::{
};

// This is an opaque struct in NSS.
#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::empty_enum)]
pub enum SSLAntiReplayContext {}

experimental_api!(SSL_CreateAntiReplayContext(
Expand Down
1 change: 0 additions & 1 deletion neqo-crypto/src/secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub struct Secrets {
}

impl Secrets {
#[allow(clippy::unused_self)]
unsafe extern "C" fn secret_available(
_fd: *mut PRFileDesc,
epoch: u16,
Expand Down
7 changes: 1 addition & 6 deletions neqo-crypto/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
dead_code,
non_upper_case_globals,
non_snake_case,
clippy::cognitive_complexity,
clippy::too_many_lines,
clippy::upper_case_acronyms,
unknown_lints,
clippy::borrow_as_ptr
clippy::cognitive_complexity
)]

use std::os::raw::{c_uint, c_void};
Expand All @@ -28,9 +25,7 @@ mod SSLOption {
}

// I clearly don't understand how bindgen operates.
#[allow(clippy::empty_enum)]
pub enum PLArenaPool {}
#[allow(clippy::empty_enum)]
pub enum PRFileDesc {}

// Remap some constants.
Expand Down
2 changes: 0 additions & 2 deletions neqo-crypto/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(clippy::upper_case_acronyms)]

use std::{
ops::Deref,
os::raw::c_void,
Expand Down
7 changes: 5 additions & 2 deletions neqo-crypto/tests/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// except according to those terms.

#![allow(dead_code)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::missing_errors_doc)]

use std::{mem, time::Instant};

Expand All @@ -18,6 +16,8 @@ use neqo_crypto::{
use test_fixture::{anti_replay, fixture_init, now};

/// Consume records until the handshake state changes.
#[allow(clippy::missing_panics_doc)]
#[allow(clippy::missing_errors_doc)]
pub fn forward_records(
now: Instant,
agent: &mut SecretAgent,
Expand Down Expand Up @@ -65,6 +65,7 @@ fn handshake(now: Instant, client: &mut SecretAgent, server: &mut SecretAgent) {
}
}

#[allow(clippy::missing_panics_doc)]
pub fn connect_at(now: Instant, client: &mut SecretAgent, server: &mut SecretAgent) {
handshake(now, client, server);
qinfo!("client: {:?}", client.state());
Expand All @@ -77,6 +78,7 @@ pub fn connect(client: &mut SecretAgent, server: &mut SecretAgent) {
connect_at(now(), client, server);
}

#[allow(clippy::missing_panics_doc)]
pub fn connect_fail(client: &mut SecretAgent, server: &mut SecretAgent) {
handshake(now(), client, server);
assert!(!client.state().is_connected());
Expand Down Expand Up @@ -131,6 +133,7 @@ fn zero_rtt_setup(mode: Resumption, client: &Client, server: &mut Server) -> Opt
}
}

#[allow(clippy::missing_panics_doc)]
#[must_use]
pub fn resumption_setup(mode: Resumption) -> (Option<AntiReplay>, ResumptionToken) {
fixture_init();
Expand Down
1 change: 0 additions & 1 deletion neqo-http3/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ impl Http3Connection {

/// The function calls `receive` for a stream. It also deals with the outcome of a read by
/// calling `handle_stream_manipulation_output`.
#[allow(clippy::option_if_let_else)] // False positive as borrow scope isn't lexical here.
fn stream_receive(&mut self, conn: &mut Connection, stream_id: StreamId) -> Res<ReceiveOutput> {
qtrace!([self], "Readable stream {}.", stream_id);

Expand Down
1 change: 0 additions & 1 deletion neqo-http3/src/connection_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,6 @@ mod tests {

// Send 2 data frames so that the second one cannot fit into the send_buf and it is only
// partialy sent. We check that the sent data is correct.
#[allow(clippy::useless_vec)]
fn fetch_with_two_data_frames(
first_frame: &[u8],
expected_first_data_frame_header: &[u8],
Expand Down
1 change: 0 additions & 1 deletion neqo-http3/src/control_stream_remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ impl RecvStream for ControlStreamRemote {
Err(Error::HttpClosedCriticalStream)
}

#[allow(clippy::vec_init_then_push)] // Clippy fail.
fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> {
let mut control_frames = Vec::new();

Expand Down
2 changes: 0 additions & 2 deletions neqo-http3/src/features/extended_connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(clippy::module_name_repetitions)]

pub(crate) mod webtransport_session;
pub(crate) mod webtransport_streams;

Expand Down
1 change: 0 additions & 1 deletion neqo-http3/src/frames/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::frames::{
reader::FrameDecoder, FrameReader, HFrame, StreamReaderConnectionWrapper, WebTransportFrame,
};

#[allow(clippy::many_single_char_names)]
pub fn enc_dec<T: FrameDecoder<T>>(d: &Encoder, st: &str, remaining: usize) -> T {
// For data, headers and push_promise we do not read all bytes from the buffer
let d2 = Encoder::from_hex(st);
Expand Down
2 changes: 0 additions & 2 deletions neqo-http3/src/headers_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(clippy::unused_unit)] // see https://github.com/Lymia/enumset/issues/44

use enumset::{enum_set, EnumSet, EnumSetType};
use neqo_common::Header;

Expand Down
2 changes: 0 additions & 2 deletions neqo-http3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(clippy::module_name_repetitions)] // This lint doesn't work here.

/*!
# The HTTP/3 protocol
Expand Down
2 changes: 0 additions & 2 deletions neqo-http3/src/stream_type_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(clippy::module_name_repetitions)]

use neqo_common::{qtrace, Decoder, IncrementalDecoderUint, Role};
use neqo_qpack::{decoder::QPACK_UNI_STREAM_TYPE_DECODER, encoder::QPACK_UNI_STREAM_TYPE_ENCODER};
use neqo_transport::{Connection, StreamId, StreamType};
Expand Down
2 changes: 0 additions & 2 deletions neqo-http3/tests/httpconn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(unused_assignments)]

use std::{
mem,
time::{Duration, Instant},
Expand Down
1 change: 0 additions & 1 deletion neqo-qpack/src/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#[derive(Copy, Clone, Debug)]
pub struct Prefix {
#[allow(unknown_lints)] // available with Rust v1.75
#[allow(clippy::struct_field_names)]
prefix: u8,
len: u8,
Expand Down
2 changes: 1 addition & 1 deletion neqo-transport/src/addr_valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl AddressValidation {

// Note: these lint override can be removed in later versions where the lints
// either don't trip a false positive or don't apply. rustc 1.46 is fine.
#[allow(dead_code, clippy::large_enum_variant)]
#[allow(clippy::large_enum_variant)]
pub enum NewTokenState {
Client {
/// Tokens that haven't been taken yet.
Expand Down
1 change: 0 additions & 1 deletion neqo-transport/src/connection/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ impl Ord for State {
if mem::discriminant(self) == mem::discriminant(other) {
return Ordering::Equal;
}
#[allow(clippy::match_same_arms)] // Lint bug: rust-lang/rust-clippy#860
match (self, other) {
(Self::Init, _) => Ordering::Less,
(_, Self::Init) => Ordering::Greater,
Expand Down
Loading

0 comments on commit 7a39675

Please sign in to comment.