1
0
mirror of https://github.com/actix/actix synced 2025-02-21 09:24:48 +01:00

chore: prevent dead code warnings

This commit is contained in:
Rob Ede 2024-02-01 04:56:20 +00:00
parent 37b92c6bee
commit b555813c77
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933

View File

@ -12,7 +12,7 @@ use actix::{prelude::*, WeakRecipient};
use actix_rt::time::sleep; use actix_rt::time::sleep;
#[derive(Debug)] #[derive(Debug)]
struct Ping(usize); struct Ping;
impl Message for Ping { impl Message for Ping {
type Result = (); type Result = ();
@ -98,14 +98,14 @@ fn test_address() {
let addr = MyActor(count2).start(); let addr = MyActor(count2).start();
let addr2 = addr.clone(); let addr2 = addr.clone();
let addr3 = addr.clone(); let addr3 = addr.clone();
addr.do_send(Ping(1)); addr.do_send(Ping);
arbiter.spawn_fn(move || { arbiter.spawn_fn(move || {
addr3.do_send(Ping(2)); addr3.do_send(Ping);
actix_rt::spawn(async move { actix_rt::spawn(async move {
let _ = addr2.send(Ping(3)).await; let _ = addr2.send(Ping).await;
let _ = addr2.send(Ping(4)).await; let _ = addr2.send(Ping).await;
System::current().stop(); System::current().stop();
}); });
}); });
@ -213,13 +213,13 @@ fn test_weak_recipient_can_be_cloned() {
weak_recipient weak_recipient
.upgrade() .upgrade()
.expect("must be able to upgrade the weak recipient here") .expect("must be able to upgrade the weak recipient here")
.send(Ping(0)) .send(Ping)
.await .await
.expect("send must not fail"); .expect("send must not fail");
weak_recipient_clone weak_recipient_clone
.upgrade() .upgrade()
.expect("must be able to upgrade the cloned weak recipient here") .expect("must be able to upgrade the cloned weak recipient here")
.send(Ping(0)) .send(Ping)
.await .await
.expect("send must not fail"); .expect("send must not fail");
let pings = addr.send(CountPings {}).await.expect("send must not fail"); let pings = addr.send(CountPings {}).await.expect("send must not fail");
@ -244,14 +244,14 @@ fn test_recipient_can_be_downgraded() {
weak_recipient weak_recipient
.upgrade() .upgrade()
.expect("upgrade of weak recipient must not fail here") .expect("upgrade of weak recipient must not fail here")
.send(Ping(0)) .send(Ping)
.await .await
.unwrap(); .unwrap();
converted_weak_recipient converted_weak_recipient
.upgrade() .upgrade()
.expect("upgrade of weak recipient must not fail here") .expect("upgrade of weak recipient must not fail here")
.send(Ping(0)) .send(Ping)
.await .await
.unwrap(); .unwrap();
let ping_count = addr.send(CountPings {}).await.unwrap(); let ping_count = addr.send(CountPings {}).await.unwrap();
@ -318,11 +318,11 @@ fn test_sync_recipient_call() {
sys.block_on(async move { sys.block_on(async move {
let addr = MyActor(count2).start(); let addr = MyActor(count2).start();
let addr2 = addr.clone().recipient(); let addr2 = addr.clone().recipient();
addr.do_send(Ping(0)); addr.do_send(Ping);
actix_rt::spawn(async move { actix_rt::spawn(async move {
let _ = addr2.send(Ping(1)).await; let _ = addr2.send(Ping).await;
let _ = addr2.send(Ping(2)).await; let _ = addr2.send(Ping).await;
System::current().stop(); System::current().stop();
}); });
}); });
@ -338,7 +338,7 @@ fn test_error_result() {
let addr = MyActor3.start(); let addr = MyActor3.start();
actix_rt::spawn(async move { actix_rt::spawn(async move {
let res = addr.send(Ping(0)).await; let res = addr.send(Ping).await;
match res { match res {
Ok(_) => (), Ok(_) => (),
_ => panic!("Should not happen"), _ => panic!("Should not happen"),
@ -370,9 +370,9 @@ fn test_message_timeout() {
sys.block_on(async move { sys.block_on(async move {
let addr = TimeoutActor.start(); let addr = TimeoutActor.start();
addr.do_send(Ping(0)); addr.do_send(Ping);
actix_rt::spawn(async move { actix_rt::spawn(async move {
let res = addr.send(Ping(0)).timeout(Duration::from_millis(1)).await; let res = addr.send(Ping).timeout(Duration::from_millis(1)).await;
match res { match res {
Ok(_) => panic!("Should not happen"), Ok(_) => panic!("Should not happen"),
Err(MailboxError::Timeout) => { Err(MailboxError::Timeout) => {
@ -395,9 +395,9 @@ impl Actor for TimeoutActor3 {
type Context = Context<Self>; type Context = Context<Self>;
fn started(&mut self, ctx: &mut Self::Context) { fn started(&mut self, ctx: &mut Self::Context) {
self.0.do_send(Ping(0)); self.0.do_send(Ping);
self.0 self.0
.send(Ping(0)) .send(Ping)
.timeout(Duration::new(0, 1_000)) .timeout(Duration::new(0, 1_000))
.into_actor(self) .into_actor(self)
.then(move |res, act, _| { .then(move |res, act, _| {