Commit 3629f15e0d

3629f15e0d1fd296888e547280bbad490a60bb86

parent: fd72cf5c4e

Unregistered key

Ulyssa <git@ulyssa.dev> · 2023-01-30 21:51 UTC

Fix newer Clippy warnings for 1.67.0 (#33)

Layout: unified · split

src/commands.rs +1 −1
@@ -40,7 +40,7 @@ fn tag_name(name: String) -> Result<TagName, CommandError> {
4040 if let Ok(tag) = name.parse() {
4141 TagName::User(tag)
4242 } else {
43 let msg = format!("Invalid user tag name: {}", name);
43 let msg = format!("Invalid user tag name: {name}");
4444
4545 return Err(CommandError::Error(msg));
4646 }
src/main.rs +4 −4
@@ -455,13 +455,13 @@ async fn login(worker: Requester, settings: &ApplicationSettings) -> IambResult<
455455 match worker.login(LoginStyle::Password(password)) {
456456 Ok(info) => {
457457 if let Some(msg) = info {
458 println!("{}", msg);
458 println!("{msg}");
459459 }
460460
461461 break;
462462 },
463463 Err(err) => {
464 println!("Failed to login: {}", err);
464 println!("Failed to login: {err}");
465465 continue;
466466 },
467467 }
@@ -471,7 +471,7 @@ async fn login(worker: Requester, settings: &ApplicationSettings) -> IambResult<
471471}
472472
473473fn print_exit<T: Display, N>(v: T) -> N {
474 println!("{}", v);
474 println!("{v}");
475475 process::exit(2);
476476}
477477
@@ -532,7 +532,7 @@ fn main() -> IambResult<()> {
532532 .thread_name_fn(|| {
533533 static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
534534 let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
535 format!("iamb-worker-{}", id)
535 format!("iamb-worker-{id}")
536536 })
537537 .build()
538538 .unwrap();
src/message/mod.rs +2 −2
@@ -134,7 +134,7 @@ impl MessageTimeStamp {
134134 match self {
135135 MessageTimeStamp::OriginServer(ms) => {
136136 let time = millis_to_datetime(*ms).format("%T");
137 let time = format!(" [{}]", time);
137 let time = format!(" [{time}]");
138138
139139 Span::raw(time).into()
140140 },
@@ -343,7 +343,7 @@ impl MessageEvent {
343343 .and_then(|r| r.content.reason.as_ref());
344344
345345 if let Some(r) = reason {
346 Cow::Owned(format!("[Redacted: {:?}]", r))
346 Cow::Owned(format!("[Redacted: {r:?}]"))
347347 } else {
348348 Cow::Borrowed("[Redacted]")
349349 }
src/windows/mod.rs +4 −4
@@ -168,7 +168,7 @@ fn append_tags<'a>(tags: &'a Tags, spans: &mut Vec<Span<'a>>, style: Style) {
168168 spans.push(Span::styled("User Tag: ", style));
169169 spans.push(Span::styled(tag.as_ref(), style));
170170 },
171 tag => spans.push(Span::styled(format!("{:?}", tag), style)),
171 tag => spans.push(Span::styled(format!("{tag:?}"), style)),
172172 }
173173 }
174174
@@ -594,7 +594,7 @@ impl Window<IambInfo> for IambWindow {
594594 }
595595
596596 fn posn(index: usize, _: &mut ProgramStore) -> IambResult<Self> {
597 let msg = format!("Cannot find indexed buffer (index = {})", index);
597 let msg = format!("Cannot find indexed buffer (index = {index})");
598598 let err = UIError::Unimplemented(msg);
599599
600600 Err(err)
@@ -852,7 +852,7 @@ impl VerifyItem {
852852 let device = self.sasv1.other_device();
853853
854854 if let Some(display_name) = device.display_name() {
855 format!("Device verification with {} ({})", display_name, state)
855 format!("Device verification with {display_name} ({state})")
856856 } else {
857857 format!("Device verification with device {} ({})", device.device_id(), state)
858858 }
@@ -958,7 +958,7 @@ impl ListItem<IambInfo> for VerifyItem {
958958 lines.push(Spans::from(""));
959959
960960 for line in format_emojis(emoji).lines() {
961 lines.push(Spans::from(format!(" {}", line)));
961 lines.push(Spans::from(format!(" {line}")));
962962 }
963963
964964 lines.push(Spans::from(""));
src/windows/room/chat.rs +1 −1
@@ -383,7 +383,7 @@ impl ChatState {
383383 .map_err(IambError::from)?;
384384
385385 // Mock up the local echo message for the scrollback.
386 let msg = TextMessageEventContent::plain(format!("[Attached File: {}]", name));
386 let msg = TextMessageEventContent::plain(format!("[Attached File: {name}]"));
387387 let msg = MessageType::Text(msg);
388388 let msg = RoomMessageEventContent::new(msg);
389389
src/windows/room/mod.rs +1 −4
@@ -132,10 +132,7 @@ impl RoomState {
132132 None => format!("{:?}", store.application.get_room_title(self.id())),
133133 };
134134
135 let mut invited = vec![Span::from(format!(
136 "You have been invited to join {}",
137 name
138 ))];
135 let mut invited = vec![Span::from(format!("You have been invited to join {name}"))];
139136
140137 if let Ok(Some(inviter)) = &inviter {
141138 invited.push(Span::from(" by "));
src/windows/room/scrollback.rs +6 −6
@@ -615,7 +615,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
615615 },
616616
617617 _ => {
618 let msg = format!("Unknown editing target: {:?}", motion);
618 let msg = format!("Unknown editing target: {motion:?}");
619619 let err = EditError::Unimplemented(msg);
620620
621621 return Err(err);
@@ -702,7 +702,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
702702 },
703703
704704 _ => {
705 let msg = format!("Unknown motion: {:?}", motion);
705 let msg = format!("Unknown motion: {motion:?}");
706706 let err = EditError::Unimplemented(msg);
707707
708708 return Err(err);
@@ -790,7 +790,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
790790 HistoryAction::Checkpoint => Ok(None),
791791 HistoryAction::Undo(_) => Err(EditError::Failure("Nothing to undo".into())),
792792 HistoryAction::Redo(_) => Err(EditError::Failure("Nothing to redo".into())),
793 _ => Err(EditError::Unimplemented(format!("Unknown action: {:?}", act))),
793 _ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))),
794794 }
795795 }
796796
@@ -847,7 +847,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
847847
848848 Ok(None)
849849 },
850 _ => Err(EditError::Unimplemented(format!("Unknown action: {:?}", act))),
850 _ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))),
851851 }
852852 }
853853}
@@ -874,7 +874,7 @@ impl Editable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
874874 Err(err)
875875 },
876876
877 _ => Err(EditError::Unimplemented(format!("Unknown action: {:?}", act))),
877 _ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))),
878878 }
879879 }
880880}
@@ -973,7 +973,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
973973 return Err(err);
974974 },
975975 _ => {
976 let msg = format!("Messages scrollback doesn't support {:?}", act);
976 let msg = format!("Messages scrollback doesn't support {act:?}");
977977 let err = EditError::Unimplemented(msg);
978978
979979 return Err(err);
src/worker.rs +14 −6
@@ -350,6 +350,7 @@ pub struct ClientWorker {
350350 settings: ApplicationSettings,
351351 client: Client,
352352 sync_handle: Option<JoinHandle<()>>,
353 rcpt_handle: Option<JoinHandle<()>>,
353354}
354355
355356impl ClientWorker {
@@ -388,9 +389,10 @@ impl ClientWorker {
388389 settings,
389390 client: client.clone(),
390391 sync_handle: None,
392 rcpt_handle: None,
391393 };
392394
393 let _ = tokio::spawn(async move {
395 tokio::spawn(async move {
394396 worker.work(rx).await;
395397 });
396398
@@ -412,6 +414,10 @@ impl ClientWorker {
412414 if let Some(handle) = self.sync_handle.take() {
413415 handle.abort();
414416 }
417
418 if let Some(handle) = self.rcpt_handle.take() {
419 handle.abort();
420 }
415421 }
416422
417423 async fn run(&mut self, task: WorkerTask) {
@@ -685,7 +691,8 @@ impl ClientWorker {
685691 );
686692
687693 let client = self.client.clone();
688 let _ = tokio::spawn(async move {
694
695 self.rcpt_handle = tokio::spawn(async move {
689696 // Update the displayed read receipts ever 5 seconds.
690697 let mut interval = tokio::time::interval(Duration::from_secs(5));
691698
@@ -695,7 +702,8 @@ impl ClientWorker {
695702 let receipts = update_receipts(&client).await;
696703 store.lock().await.application.set_receipts(receipts).await;
697704 }
698 });
705 })
706 .into();
699707
700708 self.initialized = true;
701709 }
@@ -762,7 +770,7 @@ impl ClientWorker {
762770 "Failed to create direct message room"
763771 );
764772
765 let msg = format!("Could not open a room with {}", user);
773 let msg = format!("Could not open a room with {user}");
766774 let err = UIError::Failure(msg);
767775
768776 Err(err)
@@ -1007,12 +1015,12 @@ impl ClientWorker {
10071015 let methods = vec![VerificationMethod::SasV1];
10081016 let request = identity.request_verification_with_methods(methods);
10091017 let _req = request.await.map_err(IambError::from)?;
1010 let info = format!("Sent verification request to {}", user_id);
1018 let info = format!("Sent verification request to {user_id}");
10111019
10121020 Ok(InfoMessage::from(info).into())
10131021 },
10141022 None => {
1015 let msg = format!("Could not find identity information for {}", user_id);
1023 let msg = format!("Could not find identity information for {user_id}");
10161024 let err = UIError::Failure(msg);
10171025
10181026 Err(err)