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> { |
| 40 | 40 | if let Ok(tag) = name.parse() { |
| 41 | 41 | TagName::User(tag) |
| 42 | 42 | } else { |
| 43 | | let msg = format!("Invalid user tag name: {}", name); |
| 43 | let msg = format!("Invalid user tag name: {name}"); |
| 44 | 44 | |
| 45 | 45 | return Err(CommandError::Error(msg)); |
| 46 | 46 | } |
src/main.rs
+4 −4
| @@ -455,13 +455,13 @@ async fn login(worker: Requester, settings: &ApplicationSettings) -> IambResult< |
| 455 | 455 | match worker.login(LoginStyle::Password(password)) { |
| 456 | 456 | Ok(info) => { |
| 457 | 457 | if let Some(msg) = info { |
| 458 | | println!("{}", msg); |
| 458 | println!("{msg}"); |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | break; |
| 462 | 462 | }, |
| 463 | 463 | Err(err) => { |
| 464 | | println!("Failed to login: {}", err); |
| 464 | println!("Failed to login: {err}"); |
| 465 | 465 | continue; |
| 466 | 466 | }, |
| 467 | 467 | } |
| @@ -471,7 +471,7 @@ async fn login(worker: Requester, settings: &ApplicationSettings) -> IambResult< |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | fn print_exit<T: Display, N>(v: T) -> N { |
| 474 | | println!("{}", v); |
| 474 | println!("{v}"); |
| 475 | 475 | process::exit(2); |
| 476 | 476 | } |
| 477 | 477 | |
| @@ -532,7 +532,7 @@ fn main() -> IambResult<()> { |
| 532 | 532 | .thread_name_fn(|| { |
| 533 | 533 | static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0); |
| 534 | 534 | let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst); |
| 535 | | format!("iamb-worker-{}", id) |
| 535 | format!("iamb-worker-{id}") |
| 536 | 536 | }) |
| 537 | 537 | .build() |
| 538 | 538 | .unwrap(); |
src/message/mod.rs
+2 −2
| @@ -134,7 +134,7 @@ impl MessageTimeStamp { |
| 134 | 134 | match self { |
| 135 | 135 | MessageTimeStamp::OriginServer(ms) => { |
| 136 | 136 | let time = millis_to_datetime(*ms).format("%T"); |
| 137 | | let time = format!(" [{}]", time); |
| 137 | let time = format!(" [{time}]"); |
| 138 | 138 | |
| 139 | 139 | Span::raw(time).into() |
| 140 | 140 | }, |
| @@ -343,7 +343,7 @@ impl MessageEvent { |
| 343 | 343 | .and_then(|r| r.content.reason.as_ref()); |
| 344 | 344 | |
| 345 | 345 | if let Some(r) = reason { |
| 346 | | Cow::Owned(format!("[Redacted: {:?}]", r)) |
| 346 | Cow::Owned(format!("[Redacted: {r:?}]")) |
| 347 | 347 | } else { |
| 348 | 348 | Cow::Borrowed("[Redacted]") |
| 349 | 349 | } |
src/windows/mod.rs
+4 −4
| @@ -168,7 +168,7 @@ fn append_tags<'a>(tags: &'a Tags, spans: &mut Vec<Span<'a>>, style: Style) { |
| 168 | 168 | spans.push(Span::styled("User Tag: ", style)); |
| 169 | 169 | spans.push(Span::styled(tag.as_ref(), style)); |
| 170 | 170 | }, |
| 171 | | tag => spans.push(Span::styled(format!("{:?}", tag), style)), |
| 171 | tag => spans.push(Span::styled(format!("{tag:?}"), style)), |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
| @@ -594,7 +594,7 @@ impl Window<IambInfo> for IambWindow { |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | 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})"); |
| 598 | 598 | let err = UIError::Unimplemented(msg); |
| 599 | 599 | |
| 600 | 600 | Err(err) |
| @@ -852,7 +852,7 @@ impl VerifyItem { |
| 852 | 852 | let device = self.sasv1.other_device(); |
| 853 | 853 | |
| 854 | 854 | if let Some(display_name) = device.display_name() { |
| 855 | | format!("Device verification with {} ({})", display_name, state) |
| 855 | format!("Device verification with {display_name} ({state})") |
| 856 | 856 | } else { |
| 857 | 857 | format!("Device verification with device {} ({})", device.device_id(), state) |
| 858 | 858 | } |
| @@ -958,7 +958,7 @@ impl ListItem<IambInfo> for VerifyItem { |
| 958 | 958 | lines.push(Spans::from("")); |
| 959 | 959 | |
| 960 | 960 | for line in format_emojis(emoji).lines() { |
| 961 | | lines.push(Spans::from(format!(" {}", line))); |
| 961 | lines.push(Spans::from(format!(" {line}"))); |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | lines.push(Spans::from("")); |
src/windows/room/chat.rs
+1 −1
| @@ -383,7 +383,7 @@ impl ChatState { |
| 383 | 383 | .map_err(IambError::from)?; |
| 384 | 384 | |
| 385 | 385 | // 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}]")); |
| 387 | 387 | let msg = MessageType::Text(msg); |
| 388 | 388 | let msg = RoomMessageEventContent::new(msg); |
| 389 | 389 | |
src/windows/room/mod.rs
+1 −4
| @@ -132,10 +132,7 @@ impl RoomState { |
| 132 | 132 | None => format!("{:?}", store.application.get_room_title(self.id())), |
| 133 | 133 | }; |
| 134 | 134 | |
| 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}"))]; |
| 139 | 136 | |
| 140 | 137 | if let Ok(Some(inviter)) = &inviter { |
| 141 | 138 | invited.push(Span::from(" by ")); |
src/windows/room/scrollback.rs
+6 −6
| @@ -615,7 +615,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { |
| 615 | 615 | }, |
| 616 | 616 | |
| 617 | 617 | _ => { |
| 618 | | let msg = format!("Unknown editing target: {:?}", motion); |
| 618 | let msg = format!("Unknown editing target: {motion:?}"); |
| 619 | 619 | let err = EditError::Unimplemented(msg); |
| 620 | 620 | |
| 621 | 621 | return Err(err); |
| @@ -702,7 +702,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { |
| 702 | 702 | }, |
| 703 | 703 | |
| 704 | 704 | _ => { |
| 705 | | let msg = format!("Unknown motion: {:?}", motion); |
| 705 | let msg = format!("Unknown motion: {motion:?}"); |
| 706 | 706 | let err = EditError::Unimplemented(msg); |
| 707 | 707 | |
| 708 | 708 | return Err(err); |
| @@ -790,7 +790,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { |
| 790 | 790 | HistoryAction::Checkpoint => Ok(None), |
| 791 | 791 | HistoryAction::Undo(_) => Err(EditError::Failure("Nothing to undo".into())), |
| 792 | 792 | 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:?}"))), |
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | |
| @@ -847,7 +847,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { |
| 847 | 847 | |
| 848 | 848 | Ok(None) |
| 849 | 849 | }, |
| 850 | | _ => Err(EditError::Unimplemented(format!("Unknown action: {:?}", act))), |
| 850 | _ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))), |
| 851 | 851 | } |
| 852 | 852 | } |
| 853 | 853 | } |
| @@ -874,7 +874,7 @@ impl Editable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { |
| 874 | 874 | Err(err) |
| 875 | 875 | }, |
| 876 | 876 | |
| 877 | | _ => Err(EditError::Unimplemented(format!("Unknown action: {:?}", act))), |
| 877 | _ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))), |
| 878 | 878 | } |
| 879 | 879 | } |
| 880 | 880 | } |
| @@ -973,7 +973,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { |
| 973 | 973 | return Err(err); |
| 974 | 974 | }, |
| 975 | 975 | _ => { |
| 976 | | let msg = format!("Messages scrollback doesn't support {:?}", act); |
| 976 | let msg = format!("Messages scrollback doesn't support {act:?}"); |
| 977 | 977 | let err = EditError::Unimplemented(msg); |
| 978 | 978 | |
| 979 | 979 | return Err(err); |
src/worker.rs
+14 −6
| @@ -350,6 +350,7 @@ pub struct ClientWorker { |
| 350 | 350 | settings: ApplicationSettings, |
| 351 | 351 | client: Client, |
| 352 | 352 | sync_handle: Option<JoinHandle<()>>, |
| 353 | rcpt_handle: Option<JoinHandle<()>>, |
| 353 | 354 | } |
| 354 | 355 | |
| 355 | 356 | impl ClientWorker { |
| @@ -388,9 +389,10 @@ impl ClientWorker { |
| 388 | 389 | settings, |
| 389 | 390 | client: client.clone(), |
| 390 | 391 | sync_handle: None, |
| 392 | rcpt_handle: None, |
| 391 | 393 | }; |
| 392 | 394 | |
| 393 | | let _ = tokio::spawn(async move { |
| 395 | tokio::spawn(async move { |
| 394 | 396 | worker.work(rx).await; |
| 395 | 397 | }); |
| 396 | 398 | |
| @@ -412,6 +414,10 @@ impl ClientWorker { |
| 412 | 414 | if let Some(handle) = self.sync_handle.take() { |
| 413 | 415 | handle.abort(); |
| 414 | 416 | } |
| 417 | |
| 418 | if let Some(handle) = self.rcpt_handle.take() { |
| 419 | handle.abort(); |
| 420 | } |
| 415 | 421 | } |
| 416 | 422 | |
| 417 | 423 | async fn run(&mut self, task: WorkerTask) { |
| @@ -685,7 +691,8 @@ impl ClientWorker { |
| 685 | 691 | ); |
| 686 | 692 | |
| 687 | 693 | let client = self.client.clone(); |
| 688 | | let _ = tokio::spawn(async move { |
| 694 | |
| 695 | self.rcpt_handle = tokio::spawn(async move { |
| 689 | 696 | // Update the displayed read receipts ever 5 seconds. |
| 690 | 697 | let mut interval = tokio::time::interval(Duration::from_secs(5)); |
| 691 | 698 | |
| @@ -695,7 +702,8 @@ impl ClientWorker { |
| 695 | 702 | let receipts = update_receipts(&client).await; |
| 696 | 703 | store.lock().await.application.set_receipts(receipts).await; |
| 697 | 704 | } |
| 698 | | }); |
| 705 | }) |
| 706 | .into(); |
| 699 | 707 | |
| 700 | 708 | self.initialized = true; |
| 701 | 709 | } |
| @@ -762,7 +770,7 @@ impl ClientWorker { |
| 762 | 770 | "Failed to create direct message room" |
| 763 | 771 | ); |
| 764 | 772 | |
| 765 | | let msg = format!("Could not open a room with {}", user); |
| 773 | let msg = format!("Could not open a room with {user}"); |
| 766 | 774 | let err = UIError::Failure(msg); |
| 767 | 775 | |
| 768 | 776 | Err(err) |
| @@ -1007,12 +1015,12 @@ impl ClientWorker { |
| 1007 | 1015 | let methods = vec![VerificationMethod::SasV1]; |
| 1008 | 1016 | let request = identity.request_verification_with_methods(methods); |
| 1009 | 1017 | 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}"); |
| 1011 | 1019 | |
| 1012 | 1020 | Ok(InfoMessage::from(info).into()) |
| 1013 | 1021 | }, |
| 1014 | 1022 | 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}"); |
| 1016 | 1024 | let err = UIError::Failure(msg); |
| 1017 | 1025 | |
| 1018 | 1026 | Err(err) |