Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Enable clippy clone_on_ref_ptr lint #2314

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ unused_macro_rules = "warn"
cargo = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
clone_on_ref_ptr = "warn"
if_then_some_else_none = "warn"
get_unwrap = "warn"
multiple_inherent_impl = "warn"
Expand Down
10 changes: 5 additions & 5 deletions neqo-http3/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ impl Http3Connection {
MessageType::Request,
stream_type,
stream_id,
self.qpack_encoder.clone(),
Rc::clone(&self.qpack_encoder),
send_events,
);

Expand Down Expand Up @@ -1133,8 +1133,8 @@ impl Http3Connection {
)));
self.add_streams(
id,
Box::new(extended_conn.clone()),
Box::new(extended_conn.clone()),
Box::new(Rc::clone(&extended_conn)),
Box::new(Rc::clone(&extended_conn)),
);

let final_headers = Self::create_fetch_headers(&RequestDescription {
Expand Down Expand Up @@ -1217,7 +1217,7 @@ impl Http3Connection {
)));
self.add_streams(
stream_id,
Box::new(extended_conn.clone()),
Box::new(Rc::clone(&extended_conn)),
Box::new(extended_conn),
);
self.streams_with_pending_data.insert(stream_id);
Expand Down Expand Up @@ -1368,7 +1368,7 @@ impl Http3Connection {
stream_id,
session_id,
send_events,
webtransport_session.clone(),
Rc::clone(&webtransport_session),
local,
)),
Box::new(WebTransportRecvStream::new(
Expand Down
2 changes: 1 addition & 1 deletion neqo-http3/src/connection_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl Http3ServerHandler {
MessageType::Response,
Http3StreamType::Http,
stream_id,
self.base_handler.qpack_encoder.clone(),
Rc::clone(&self.base_handler.qpack_encoder),
Box::new(self.events.clone()),
)),
Box::new(RecvMessage::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl WebTransportSession {
first_frame_type: None,
},
qpack_decoder,
Box::new(stream_event_listener.clone()),
Box::new(Rc::clone(&stream_event_listener)),
None,
PriorityHandler::new(false, Priority::default()),
)),
Expand All @@ -82,7 +82,7 @@ impl WebTransportSession {
Http3StreamType::ExtendedConnect,
session_id,
qpack_encoder,
Box::new(stream_event_listener.clone()),
Box::new(Rc::clone(&stream_event_listener)),
)),
stream_event_listener,
session_id,
Expand Down Expand Up @@ -111,11 +111,11 @@ impl WebTransportSession {
control_stream_recv
.http_stream()
.unwrap()
.set_new_listener(Box::new(stream_event_listener.clone()));
.set_new_listener(Box::new(Rc::clone(&stream_event_listener)));
control_stream_send
.http_stream()
.unwrap()
.set_new_listener(Box::new(stream_event_listener.clone()));
.set_new_listener(Box::new(Rc::clone(&stream_event_listener)));
Self {
control_stream_recv,
control_stream_send,
Expand Down Expand Up @@ -451,7 +451,7 @@ impl RecvStream for Rc<RefCell<WebTransportSession>> {
}

fn webtransport(&self) -> Option<Rc<RefCell<WebTransportSession>>> {
Some(self.clone())
Some(Self::clone(self))
}
}

Expand Down
29 changes: 19 additions & 10 deletions neqo-http3/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl Http3Server {
}
}

#[allow(clippy::too_many_lines)]
fn process_events(&mut self, conn: &ConnectionRef, now: Instant) {
let mut remove = false;
let http3_parameters = &self.http3_parameters;
Expand All @@ -172,7 +173,11 @@ impl Http3Server {
headers,
fin,
} => self.events.headers(
Http3OrWebTransportStream::new(conn.clone(), handler.clone(), stream_info),
Http3OrWebTransportStream::new(
conn.clone(),
Rc::clone(handler),
stream_info,
),
headers,
fin,
),
Expand All @@ -188,15 +193,19 @@ impl Http3Server {
}
Http3ServerConnEvent::DataWritable { stream_info } => self
.events
.data_writable(conn.clone(), handler.clone(), stream_info),
.data_writable(conn.clone(), Rc::clone(handler), stream_info),
Http3ServerConnEvent::StreamReset { stream_info, error } => {
self.events
.stream_reset(conn.clone(), handler.clone(), stream_info, error);
self.events.stream_reset(
conn.clone(),
Rc::clone(handler),
stream_info,
error,
);
}
Http3ServerConnEvent::StreamStopSending { stream_info, error } => {
self.events.stream_stop_sending(
conn.clone(),
handler.clone(),
Rc::clone(handler),
stream_info,
error,
);
Expand All @@ -216,7 +225,7 @@ impl Http3Server {
}
Http3ServerConnEvent::ExtendedConnect { stream_id, headers } => {
self.events.webtransport_new_session(
WebTransportRequest::new(conn.clone(), handler.clone(), stream_id),
WebTransportRequest::new(conn.clone(), Rc::clone(handler), stream_id),
headers,
);
}
Expand All @@ -226,22 +235,22 @@ impl Http3Server {
headers,
..
} => self.events.webtransport_session_closed(
WebTransportRequest::new(conn.clone(), handler.clone(), stream_id),
WebTransportRequest::new(conn.clone(), Rc::clone(handler), stream_id),
reason,
headers,
),
Http3ServerConnEvent::ExtendedConnectNewStream(stream_info) => self
.events
.webtransport_new_stream(Http3OrWebTransportStream::new(
conn.clone(),
handler.clone(),
Rc::clone(handler),
stream_info,
)),
Http3ServerConnEvent::ExtendedConnectDatagram {
session_id,
datagram,
} => self.events.webtransport_datagram(
WebTransportRequest::new(conn.clone(), handler.clone(), session_id),
WebTransportRequest::new(conn.clone(), Rc::clone(handler), session_id),
datagram,
),
}
Expand Down Expand Up @@ -294,7 +303,7 @@ fn prepare_data(
data.resize(amount, 0);
}

events.data(conn.clone(), handler.clone(), stream_info, data, fin);
events.data(conn.clone(), Rc::clone(handler), stream_info, data, fin);
}
if amount < MAX_EVENT_DATA_SIZE || fin {
break;
Expand Down
2 changes: 1 addition & 1 deletion neqo-http3/src/server_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl WebTransportRequest {

Ok(Http3OrWebTransportStream::new(
self.stream_handler.conn.clone(),
self.stream_handler.handler.clone(),
Rc::clone(&self.stream_handler.handler),
Http3StreamInfo::new(id, Http3StreamType::WebTransport(session_id)),
))
}
Expand Down
4 changes: 2 additions & 2 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl Connection {
state: State::Init,
paths: Paths::default(),
cid_manager,
tps: tphandler.clone(),
tps: Rc::clone(&tphandler),
zero_rtt_state: ZeroRttState::Init,
address_validation: AddressValidationInfo::None,
local_initial_source_cid,
Expand Down Expand Up @@ -444,7 +444,7 @@ impl Connection {
zero_rtt_checker: impl ZeroRttChecker + 'static,
) -> Res<()> {
self.crypto
.server_enable_0rtt(self.tps.clone(), anti_replay, zero_rtt_checker)
.server_enable_0rtt(Rc::clone(&self.tps), anti_replay, zero_rtt_checker)
}

/// # Errors
Expand Down
2 changes: 1 addition & 1 deletion test-fixture/src/sim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl Simulator {

qinfo!("{}: seed {}", self.name, self.rng.borrow().seed_str());
for n in &mut self.nodes {
n.init(self.rng.clone(), start);
n.init(Rc::clone(&self.rng), start);
}

let setup_start = Instant::now();
Expand Down
Loading