Skip to content

Commit 2898d76

Browse files
shayne-fletchermeta-codesync[bot]
authored andcommitted
fix new lints since rust-1.90.0 upgrade (#1438)
Summary: we upgraded the rust toolchain to 1.90.0 last week introducing new lints. ```bash cargo clippy --fix --lib -p ndslice cargo clippy --fix --lib -p hyperactor cargo clippy --fix --lib -p hyperactor_mesh ``` Pull Request resolved: #1438 Reviewed By: dulinriley, mariusae Differential Revision: D83939684 Pulled By: shayne-fletcher fbshipit-source-id: 3f47c3bc497b630ffd837fd1494238c428300b7a
1 parent 99aaa5f commit 2898d76

File tree

24 files changed

+183
-166
lines changed

24 files changed

+183
-166
lines changed

hyperactor/src/actor.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,9 @@ impl ActorStatus {
492492
Self::Initializing => Self::Initializing,
493493
Self::Client => Self::Client,
494494
Self::Idle => Self::Idle,
495-
Self::Processing(instant, handler) => {
496-
Self::Processing(instant.clone(), handler.clone())
497-
}
498-
Self::Saving(instant) => Self::Saving(instant.clone()),
499-
Self::Loading(instant) => Self::Loading(instant.clone()),
495+
Self::Processing(instant, handler) => Self::Processing(*instant, handler.clone()),
496+
Self::Saving(instant) => Self::Saving(*instant),
497+
Self::Loading(instant) => Self::Loading(*instant),
500498
Self::Stopping => Self::Stopping,
501499
Self::Stopped => Self::Stopped,
502500
Self::Failed(err) => Self::Failed(err.clone()),
@@ -521,7 +519,7 @@ impl fmt::Display for ActorStatus {
521519
"processing for {}ms",
522520
RealClock
523521
.system_time_now()
524-
.duration_since(instant.clone())
522+
.duration_since(*instant)
525523
.unwrap_or_default()
526524
.as_millis()
527525
)
@@ -533,7 +531,7 @@ impl fmt::Display for ActorStatus {
533531
handler,
534532
RealClock
535533
.system_time_now()
536-
.duration_since(instant.clone())
534+
.duration_since(*instant)
537535
.unwrap_or_default()
538536
.as_millis()
539537
)
@@ -546,7 +544,7 @@ impl fmt::Display for ActorStatus {
546544
arm,
547545
RealClock
548546
.system_time_now()
549-
.duration_since(instant.clone())
547+
.duration_since(*instant)
550548
.unwrap_or_default()
551549
.as_millis()
552550
)
@@ -557,7 +555,7 @@ impl fmt::Display for ActorStatus {
557555
"saving for {}ms",
558556
RealClock
559557
.system_time_now()
560-
.duration_since(instant.clone())
558+
.duration_since(*instant)
561559
.unwrap_or_default()
562560
.as_millis()
563561
)
@@ -568,7 +566,7 @@ impl fmt::Display for ActorStatus {
568566
"loading for {}ms",
569567
RealClock
570568
.system_time_now()
571-
.duration_since(instant.clone())
569+
.duration_since(*instant)
572570
.unwrap_or_default()
573571
.as_millis()
574572
)

hyperactor/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl AttrValue for std::time::Duration {
343343

344344
impl AttrValue for std::time::SystemTime {
345345
fn display(&self) -> String {
346-
let datetime: DateTime<Utc> = self.clone().into();
346+
let datetime: DateTime<Utc> = (*self).into();
347347
datetime.to_rfc3339()
348348
}
349349

hyperactor/src/channel/net.rs

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,14 @@ impl<M: RemoteMessage> NetTx<M> {
393393
}
394394

395395
fn requeue_unacked(&mut self, unacked: MessageDeque<M>) {
396-
match (unacked.back(), self.deque.front()) {
397-
(Some(last), Some(first)) => {
398-
assert!(
399-
last.seq < first.seq,
400-
"{}: seq should be in ascending order, but got {} vs {}",
401-
self.log_id,
402-
last.seq,
403-
first.seq,
404-
);
405-
}
406-
_ => (),
396+
if let (Some(last), Some(first)) = (unacked.back(), self.deque.front()) {
397+
assert!(
398+
last.seq < first.seq,
399+
"{}: seq should be in ascending order, but got {} vs {}",
400+
self.log_id,
401+
last.seq,
402+
first.seq,
403+
);
407404
}
408405

409406
let mut outbox = unacked;
@@ -537,7 +534,7 @@ impl<M: RemoteMessage> NetTx<M> {
537534
Some(msg) => {
538535
RealClock
539536
.sleep_until(
540-
msg.received_at.clone()
537+
msg.received_at
541538
+ config::global::get(config::MESSAGE_DELIVERY_TIMEOUT),
542539
)
543540
.await
@@ -964,10 +961,10 @@ impl<M: RemoteMessage> NetTx<M> {
964961
}
965962
};
966963

967-
if !matches!(state, State::Closing { .. }) {
968-
if let Conn::Disconnected(ref mut backoff) = conn {
969-
RealClock.sleep(backoff.next_backoff().unwrap()).await;
970-
}
964+
if !matches!(state, State::Closing { .. })
965+
&& let Conn::Disconnected(ref mut backoff) = conn
966+
{
967+
RealClock.sleep(backoff.next_backoff().unwrap()).await;
971968
}
972969
}; // loop
973970
tracing::debug!("{log_id}: NetTx exited its loop with state: {state}");
@@ -1435,13 +1432,10 @@ impl<S: AsyncRead + AsyncWrite + Send + 'static + Unpin> ServerConn<S> {
14351432
let mut final_ack = final_next.ack;
14361433
// Flush any ongoing write.
14371434
if self.write_state.is_writing() {
1438-
match self.write_state.send().await {
1439-
Ok(acked_seq) => {
1440-
if acked_seq > final_ack {
1441-
final_ack = acked_seq;
1442-
}
1435+
if let Ok(acked_seq) = self.write_state.send().await {
1436+
if acked_seq > final_ack {
1437+
final_ack = acked_seq;
14431438
}
1444-
Err(_) => (),
14451439
};
14461440
}
14471441
// best effort: "flush" any remaining ack before closing this session
@@ -1480,26 +1474,23 @@ impl<S: AsyncRead + AsyncWrite + Send + 'static + Unpin> ServerConn<S> {
14801474
let Ok(writer) = replace(&mut self.write_state, WriteState::Broken).into_idle() else {
14811475
panic!("illegal state");
14821476
};
1483-
match serialize_response(NetRxResponse::Reject) {
1484-
Ok(data) => {
1485-
match FrameWrite::new(
1486-
writer,
1487-
data,
1488-
config::global::get(config::CODEC_MAX_FRAME_LENGTH),
1489-
) {
1490-
Ok(fw) => {
1491-
self.write_state = WriteState::Writing(fw, 0);
1492-
let _ = self.write_state.send().await;
1493-
}
1494-
Err((w, e)) => {
1495-
debug_assert_eq!(e.kind(), io::ErrorKind::InvalidData);
1496-
tracing::debug!("failed to create reject frame (should be tiny): {e}");
1497-
self.write_state = WriteState::Idle(w);
1498-
// drop the reject; we're closing anyway
1499-
}
1477+
if let Ok(data) = serialize_response(NetRxResponse::Reject) {
1478+
match FrameWrite::new(
1479+
writer,
1480+
data,
1481+
config::global::get(config::CODEC_MAX_FRAME_LENGTH),
1482+
) {
1483+
Ok(fw) => {
1484+
self.write_state = WriteState::Writing(fw, 0);
1485+
let _ = self.write_state.send().await;
1486+
}
1487+
Err((w, e)) => {
1488+
debug_assert_eq!(e.kind(), io::ErrorKind::InvalidData);
1489+
tracing::debug!("failed to create reject frame (should be tiny): {e}");
1490+
self.write_state = WriteState::Idle(w);
1491+
// drop the reject; we're closing anyway
15001492
}
15011493
}
1502-
Err(_) => (),
15031494
};
15041495
}
15051496

@@ -2104,7 +2095,7 @@ pub(crate) mod tcp {
21042095
type Stream = TcpStream;
21052096

21062097
fn dest(&self) -> ChannelAddr {
2107-
ChannelAddr::Tcp(self.0.clone())
2098+
ChannelAddr::Tcp(self.0)
21082099
}
21092100

21102101
async fn connect(&self) -> Result<Self::Stream, ClientError> {

hyperactor/src/clock.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct SimTime {
4343
static SIM_TIME: LazyLock<SimTime> = LazyLock::new(|| {
4444
let now = tokio::time::Instant::now();
4545
SimTime {
46-
start: now.clone(),
46+
start: now,
4747
now: Mutex::new(now),
4848
system_start: SystemTime::now(),
4949
}
@@ -222,11 +222,11 @@ impl Clock for SimClock {
222222
}
223223
/// Get the current time according to the simnet
224224
fn now(&self) -> tokio::time::Instant {
225-
SIM_TIME.now.lock().unwrap().clone()
225+
*SIM_TIME.now.lock().unwrap()
226226
}
227227

228228
fn system_time_now(&self) -> SystemTime {
229-
SIM_TIME.system_start.clone() + self.now().duration_since(SIM_TIME.start)
229+
SIM_TIME.system_start + self.now().duration_since(SIM_TIME.start)
230230
}
231231

232232
#[allow(clippy::disallowed_methods)]
@@ -290,7 +290,7 @@ impl SimClock {
290290

291291
/// Instant marking the start of the simulation
292292
pub fn start(&self) -> tokio::time::Instant {
293-
SIM_TIME.start.clone()
293+
SIM_TIME.start
294294
}
295295
}
296296

hyperactor/src/config/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fn test_override_index(layers: &Layers) -> Option<usize> {
353353
.position(|l| matches!(l.source, Source::TestOverride))
354354
}
355355

356-
fn ensure_test_override_layer_mut<'a>(layers: &'a mut Layers) -> &'a mut Attrs {
356+
fn ensure_test_override_layer_mut(layers: &mut Layers) -> &mut Attrs {
357357
if let Some(i) = test_override_index(layers) {
358358
return &mut layers.ordered[i].attrs;
359359
}

hyperactor/src/mailbox.rs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,10 +1719,10 @@ impl<M> PortReceiver<M> {
17191719
pub fn try_recv(&mut self) -> Result<Option<M>, MailboxError> {
17201720
let mut next = self.receiver.try_recv();
17211721
// To coalesce, drain the mpsc queue and only keep the last one.
1722-
if self.coalesce {
1723-
if let Some(latest) = self.drain().pop() {
1724-
next = Ok(latest);
1725-
}
1722+
if self.coalesce
1723+
&& let Some(latest) = self.drain().pop()
1724+
{
1725+
next = Ok(latest);
17261726
}
17271727
match next {
17281728
Ok(msg) => Ok(Some(msg)),
@@ -1740,10 +1740,10 @@ impl<M> PortReceiver<M> {
17401740
let mut next = self.receiver.recv().await;
17411741
// To coalesce, get the last message from the queue if there are
17421742
// more on the mspc queue.
1743-
if self.coalesce {
1744-
if let Some(latest) = self.drain().pop() {
1745-
next = Some(latest);
1746-
}
1743+
if self.coalesce
1744+
&& let Some(latest) = self.drain().pop()
1745+
{
1746+
next = Some(latest);
17471747
}
17481748
next.ok_or(MailboxError::new(
17491749
self.actor_id().clone(),
@@ -2152,6 +2152,12 @@ pub struct MailboxMuxer {
21522152
mailboxes: Arc<DashMap<ActorId, Box<dyn MailboxSender + Send + Sync>>>,
21532153
}
21542154

2155+
impl Default for MailboxMuxer {
2156+
fn default() -> Self {
2157+
Self::new()
2158+
}
2159+
}
2160+
21552161
impl MailboxMuxer {
21562162
/// Create a new, empty, muxer.
21572163
pub fn new() -> Self {
@@ -2216,6 +2222,12 @@ pub struct MailboxRouter {
22162222
entries: Arc<RwLock<BTreeMap<Reference, Arc<dyn MailboxSender + Send + Sync>>>>,
22172223
}
22182224

2225+
impl Default for MailboxRouter {
2226+
fn default() -> Self {
2227+
Self::new()
2228+
}
2229+
}
2230+
22192231
impl MailboxRouter {
22202232
/// Create a new, empty router.
22212233
pub fn new() -> Self {
@@ -2364,6 +2376,12 @@ pub struct DialMailboxRouter {
23642376
direct_addressed_remote_only: bool,
23652377
}
23662378

2379+
impl Default for DialMailboxRouter {
2380+
fn default() -> Self {
2381+
Self::new()
2382+
}
2383+
}
2384+
23672385
impl DialMailboxRouter {
23682386
/// Create a new [`DialMailboxRouter`] with an empty routing table.
23692387
pub fn new() -> Self {
@@ -2403,11 +2421,11 @@ impl DialMailboxRouter {
24032421
/// cache to ensure fresh routing on next use.
24042422
pub fn bind(&self, dest: Reference, addr: ChannelAddr) {
24052423
if let Ok(mut w) = self.address_book.write() {
2406-
if let Some(old_addr) = w.insert(dest.clone(), addr.clone()) {
2407-
if old_addr != addr {
2408-
tracing::info!("rebinding {:?} from {:?} to {:?}", dest, old_addr, addr);
2409-
self.sender_cache.remove(&old_addr);
2410-
}
2424+
if let Some(old_addr) = w.insert(dest.clone(), addr.clone())
2425+
&& old_addr != addr
2426+
{
2427+
tracing::info!("rebinding {:?} from {:?} to {:?}", dest, old_addr, addr);
2428+
self.sender_cache.remove(&old_addr);
24112429
}
24122430
} else {
24132431
tracing::error!("address book poisoned during bind of {:?}", dest);

hyperactor/src/mailbox/durable_mailbox_sender.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ pub mod test_utils {
185185
observer: Option<mpsc::UnboundedSender<(String, M)>>,
186186
}
187187

188+
impl<M: RemoteMessage> Default for TestLog<M> {
189+
fn default() -> Self {
190+
Self::new()
191+
}
192+
}
193+
188194
impl<M: RemoteMessage> TestLog<M> {
189195
/// Create a new, empty [`TestLog`].
190196
pub fn new() -> Self {
@@ -255,10 +261,10 @@ pub mod test_utils {
255261
.map(|(seq_id, msg)| Ok((*seq_id, msg.clone())))
256262
.collect();
257263
for entry in filtered_items.iter() {
258-
if let Some(observer) = &self.observer {
259-
if let Ok((_, msg)) = entry.as_ref() {
260-
observer.send(("read".to_string(), msg.clone())).unwrap();
261-
}
264+
if let Some(observer) = &self.observer
265+
&& let Ok((_, msg)) = entry.as_ref()
266+
{
267+
observer.send(("read".to_string(), msg.clone())).unwrap();
262268
}
263269
}
264270
Ok(futures::stream::iter(filtered_items.into_iter()))

hyperactor/src/proc.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ impl Proc {
712712
.iter()
713713
.filter(|(actor_id, _)| !stopped_actors.contains(actor_id))
714714
.map(|(actor_id, _)| {
715-
let f = self.abort_root_actor(actor_id, this_handle.clone());
715+
let f = self.abort_root_actor(actor_id, this_handle);
716716
async move {
717717
let _ = if let Some(f) = f { Some(f.await) } else { None };
718718
// If `is_none(&_)` then the proc's `ledger.roots`
@@ -1200,11 +1200,8 @@ impl<A: Actor> Instance<A> {
12001200

12011201
let (mut signal_receiver, _) = actor_loop_receivers;
12021202
while self.cell.child_count() > 0 {
1203-
match signal_receiver.recv().await? {
1204-
Signal::ChildStopped(pid) => {
1205-
assert!(self.cell.get_child(pid).is_none());
1206-
}
1207-
_ => (),
1203+
if let Signal::ChildStopped(pid) = signal_receiver.recv().await? {
1204+
assert!(self.cell.get_child(pid).is_none());
12081205
}
12091206
}
12101207

@@ -1345,7 +1342,7 @@ impl<A: Actor> Instance<A> {
13451342
)
13461343
});
13471344

1348-
let _ = self.change_status(ActorStatus::Processing(
1345+
self.change_status(ActorStatus::Processing(
13491346
self.clock().system_time_now(),
13501347
handler,
13511348
));
@@ -1427,7 +1424,7 @@ impl<A: Actor> Instance<A> {
14271424
ports: self.ports.clone(),
14281425
status_tx: self.status_tx.clone(),
14291426
sequencer: self.sequencer.clone(),
1430-
id: self.id.clone(),
1427+
id: self.id,
14311428
}
14321429
}
14331430

@@ -1801,6 +1798,12 @@ pub struct WeakInstanceCell {
18011798
inner: Weak<InstanceState>,
18021799
}
18031800

1801+
impl Default for WeakInstanceCell {
1802+
fn default() -> Self {
1803+
Self::new()
1804+
}
1805+
}
1806+
18041807
impl WeakInstanceCell {
18051808
/// Create a new weak instance cell that is never upgradeable.
18061809
pub fn new() -> Self {

0 commit comments

Comments
 (0)