From a2de36ddfb307f77de0d666944f520e5ea51e418 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Tue, 29 Jul 2025 11:01:16 +0200 Subject: [PATCH] chore: Fix clippy warnings w/ 1.85.1 --- bin/commands/inbox/list/ui.rs | 2 +- bin/commands/issue/list/ui.rs | 2 +- bin/commands/patch/list/rmui.rs | 2 +- bin/commands/patch/review.rs | 16 ++++++++-------- bin/test.rs | 14 +++++++------- bin/ui/im.rs | 2 +- bin/ui/items.rs | 8 ++++---- src/ui/im/widget.rs | 34 ++++++++++++++++----------------- src/ui/rm/widget.rs | 2 +- src/ui/rm/widget/container.rs | 8 ++++---- src/ui/rm/widget/input.rs | 8 ++++---- src/ui/rm/widget/list.rs | 2 +- src/ui/rm/widget/window.rs | 3 +-- 13 files changed, 50 insertions(+), 53 deletions(-) diff --git a/bin/commands/inbox/list/ui.rs b/bin/commands/inbox/list/ui.rs index 91ababf9..b53864a7 100644 --- a/bin/commands/inbox/list/ui.rs +++ b/bin/commands/inbox/list/ui.rs @@ -51,7 +51,7 @@ pub struct BrowserProps<'a> { search: String, } -impl<'a> From<&State> for BrowserProps<'a> { +impl From<&State> for BrowserProps<'_> { fn from(state: &State) -> Self { let header = match state.mode.repository() { RepositoryMode::Contextual => state.project.name().to_string(), diff --git a/bin/commands/issue/list/ui.rs b/bin/commands/issue/list/ui.rs index d85dd854..c26762a6 100644 --- a/bin/commands/issue/list/ui.rs +++ b/bin/commands/issue/list/ui.rs @@ -49,7 +49,7 @@ pub struct BrowserProps<'a> { search: String, } -impl<'a> From<&State> for BrowserProps<'a> { +impl From<&State> for BrowserProps<'_> { fn from(state: &State) -> Self { use radicle::issue::State; diff --git a/bin/commands/patch/list/rmui.rs b/bin/commands/patch/list/rmui.rs index 459226c2..3895306f 100644 --- a/bin/commands/patch/list/rmui.rs +++ b/bin/commands/patch/list/rmui.rs @@ -51,7 +51,7 @@ pub struct BrowserProps<'a> { search: String, } -impl<'a> From<&State> for BrowserProps<'a> { +impl From<&State> for BrowserProps<'_> { fn from(state: &State) -> Self { let mut draft = 0; let mut open = 0; diff --git a/bin/commands/patch/review.rs b/bin/commands/patch/review.rs index 928af17b..6adfde23 100644 --- a/bin/commands/patch/review.rs +++ b/bin/commands/patch/review.rs @@ -244,7 +244,7 @@ pub struct App<'a> { state: Arc>, } -impl<'a> App<'a> { +impl App<'_> { pub fn new( storage: Storage, review: Review, @@ -318,7 +318,7 @@ impl<'a> App<'a> { } } -impl<'a> App<'a> { +impl App<'_> { fn show_hunk_list(&self, ui: &mut Ui, frame: &mut Frame) { let hunks = self.hunks.lock().unwrap(); let state = self.state.lock().unwrap(); @@ -486,7 +486,7 @@ impl<'a> App<'a> { } } -impl<'a> Show for App<'a> { +impl Show for App<'_> { fn show(&self, ctx: &Context, frame: &mut Frame) -> Result<(), anyhow::Error> { Window::default().show(ctx, |ui| { let page = { @@ -558,7 +558,7 @@ impl<'a> Show for App<'a> { } } -impl<'a> store::Update for App<'a> { +impl store::Update for App<'_> { type Return = Response; fn update(&mut self, message: Message) -> Option> { @@ -677,7 +677,7 @@ mod test { use super::*; use crate::test; - impl<'a> App<'a> { + impl App<'_> { pub fn hunks(&self) -> Vec { self.hunks.lock().unwrap().clone() } @@ -703,10 +703,10 @@ mod test { ) -> Result> { let draft_store = DraftStore::new(&node.repo.repo, *node.signer.public_key()); let mut drafts = Cache::no_cache(&draft_store)?; - let mut draft = drafts.get_mut(&patch.id())?; + let mut draft = drafts.get_mut(patch.id())?; let (_, revision) = patch.latest(); - let (_, review) = draft_review(&node, &mut draft, revision)?; + let (_, review) = draft_review(node, &mut draft, revision)?; let hunks = ReviewBuilder::new(&node.repo).hunks(revision)?; @@ -835,7 +835,7 @@ mod test { app.update(Message::Accept); let state = app.state.lock().unwrap(); - let state = &state.hunk_states().get(0).unwrap(); + let state = &state.hunk_states().first().unwrap(); assert_eq!(**state, HunkState::Accepted); diff --git a/bin/test.rs b/bin/test.rs index 2fcd5a42..ef6f7101 100644 --- a/bin/test.rs +++ b/bin/test.rs @@ -118,7 +118,7 @@ pub mod setup { } pub mod fixtures { - use std::path::{Path, PathBuf}; + use std::path::Path; use anyhow::Result; @@ -301,14 +301,14 @@ fn main() { /// 8 7 /// 9 8 // This is the main function. /// 10 9 fn main() { - pub fn simple_modified_hunk_diff(path: &PathBuf, commit: Oid) -> Result { + pub fn simple_modified_hunk_diff(path: &Path, commit: Oid) -> Result { let diff = DiffFile { oid: commit, mode: diff::FileMode::Blob, }; Ok(HunkDiff::Modified { - path: path.clone(), + path: path.to_path_buf(), header: FileHeader::Modified { path: path.to_path_buf(), old: diff.clone(), @@ -368,14 +368,14 @@ fn main() { /// 15 13 /// 16 14 use super::ui::{IdSelect, OperationSelect}; /// 17 15 use super::{IssueOperation, Message}; - pub fn complex_modified_hunk_diff(path: &PathBuf, commit: Oid) -> Result { + pub fn complex_modified_hunk_diff(path: &Path, commit: Oid) -> Result { let diff = DiffFile { oid: commit, mode: diff::FileMode::Blob, }; Ok(HunkDiff::Modified { - path: path.clone(), + path: path.to_path_buf(), header: FileHeader::Modified { path: path.to_path_buf(), old: diff.clone(), @@ -449,14 +449,14 @@ fn main() { /// @@ -1,1 +0,0 @@ /// - TBD - pub fn deleted_hunk_diff(path: &PathBuf, commit: Oid) -> Result { + pub fn deleted_hunk_diff(path: &Path, commit: Oid) -> Result { let diff = DiffFile { oid: commit, mode: diff::FileMode::Blob, }; Ok(HunkDiff::Deleted { - path: path.clone(), + path: path.to_path_buf(), header: FileHeader::Deleted { path: path.to_path_buf(), old: diff.clone(), diff --git a/bin/ui/im.rs b/bin/ui/im.rs index 791341a0..f43db605 100644 --- a/bin/ui/im.rs +++ b/bin/ui/im.rs @@ -105,7 +105,7 @@ impl<'a, R, const W: usize> Browser<'a, R, W> { /// TODO(erikli): Implement `show` that returns an `InnerResponse` such that it can /// used like a group. -impl<'a, R, const W: usize> Widget for Browser<'a, R, W> +impl Widget for Browser<'_, R, W> where R: ToRow + Clone, { diff --git a/bin/ui/items.rs b/bin/ui/items.rs index 0c5d196d..4f24623d 100644 --- a/bin/ui/items.rs +++ b/bin/ui/items.rs @@ -1037,7 +1037,7 @@ impl ToTree for CommentItem { pub struct TermLine(terminal::Line); -impl<'a> From for Line<'a> { +impl From for Line<'_> { fn from(val: TermLine) -> Self { Line::raw(val.0.to_string()) } @@ -1252,7 +1252,7 @@ pub struct HunkItem<'a> { pub comments: HunkComments, } -impl<'a> From<(&Repository, &Review, &HunkDiff)> for HunkItem<'a> { +impl From<(&Repository, &Review, &HunkDiff)> for HunkItem<'_> { fn from(value: (&Repository, &Review, &HunkDiff)) -> Self { let (repo, review, item) = value; let hi = Highlighter::default(); @@ -1299,7 +1299,7 @@ impl<'a> From<(&Repository, &Review, &HunkDiff)> for HunkItem<'a> { } } -impl<'a> ToRow<3> for StatefulHunkItem<'a> { +impl ToRow<3> for StatefulHunkItem<'_> { fn to_row(&self) -> [Cell; 3] { let build_stats_spans = |stats: &DiffStats| -> Vec> { let mut cell = vec![]; @@ -1736,7 +1736,7 @@ impl<'a> HunkItem<'a> { } } -impl<'a> Debug for HunkItem<'a> { +impl Debug for HunkItem<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("HunkItem") .field("inner", &self.diff) diff --git a/src/ui/im/widget.rs b/src/ui/im/widget.rs index a98fe196..45bd3151 100644 --- a/src/ui/im/widget.rs +++ b/src/ui/im/widget.rs @@ -255,7 +255,7 @@ impl<'a> Label<'a> { } } -impl<'a> Widget for Label<'a> { +impl Widget for Label<'_> { fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response { let (area, _) = ui.next_area().unwrap_or_default(); frame.render_widget(self.content, area); @@ -380,7 +380,7 @@ where } } -impl<'a, R, const W: usize> Widget for Table<'a, R, W> +impl Widget for Table<'_, R, W> where R: ToRow + Clone, { @@ -515,16 +515,14 @@ where frame.render_stateful_widget(scroller, scroller_area, &mut state); } - } else { - if let Some(message) = self.empty_message { - let center = layout::centered_rect(area, 50, 10); - let hint = Text::from(span::default(&message)) - .centered() - .light_magenta() - .dim(); + } else if let Some(message) = self.empty_message { + let center = layout::centered_rect(area, 50, 10); + let hint = Text::from(span::default(&message)) + .centered() + .light_magenta() + .dim(); - frame.render_widget(hint, center); - } + frame.render_widget(hint, center); } *self.selected = state.selected(); @@ -565,7 +563,7 @@ impl<'a, R, const W: usize> HeaderedTable<'a, R, W> { /// TODO(erikli): Implement `show` that returns an `InnerResponse` such that it can /// used like a group. -impl<'a, R, const W: usize> Widget for HeaderedTable<'a, R, W> +impl Widget for HeaderedTable<'_, R, W> where R: ToRow + Clone, { @@ -608,7 +606,7 @@ impl<'a> Columns<'a> { } } -impl<'a> Widget for Columns<'a> { +impl Widget for Columns<'_> { fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response where M: Clone, @@ -667,7 +665,7 @@ impl<'a> Bar<'a> { } } -impl<'a> Widget for Bar<'a> { +impl Widget for Bar<'_> { fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response where M: Clone, @@ -773,7 +771,7 @@ impl<'a> TextView<'a> { } } -impl<'a> Widget for TextView<'a> { +impl Widget for TextView<'_> { fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response where M: Clone, @@ -893,7 +891,7 @@ impl<'a> CenteredTextView<'a> { } } -impl<'a> Widget for CenteredTextView<'a> { +impl Widget for CenteredTextView<'_> { fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response { let (area, area_focus) = ui.next_area().unwrap_or_default(); @@ -1024,7 +1022,7 @@ impl<'a> TextEdit<'a> { } } -impl<'a> TextEdit<'a> { +impl TextEdit<'_> { pub fn show(self, ui: &mut Ui, frame: &mut Frame) -> TextEditOutput where M: Clone, @@ -1130,7 +1128,7 @@ impl<'a> TextEdit<'a> { } } -impl<'a> Widget for TextEdit<'a> { +impl Widget for TextEdit<'_> { fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response where M: Clone, diff --git a/src/ui/rm/widget.rs b/src/ui/rm/widget.rs index f28b53bd..b8833ed5 100644 --- a/src/ui/rm/widget.rs +++ b/src/ui/rm/widget.rs @@ -245,7 +245,7 @@ pub trait View { /// define the data, configuration etc. of a widget. They are updated by the framework /// taking the properties built by the `on_update` callback. The `on_event` callback is /// used to emit application messages whenever a widget receives an event. - +/// /// The main idea is to build widgets that handle their specific events already, /// and that are updated with the properties built by the `on_update` callback. /// Custom logic is added by setting the `on_event` callback. E.g. the `Table` widget diff --git a/src/ui/rm/widget/container.rs b/src/ui/rm/widget/container.rs index bdd348d0..7c7d39d5 100644 --- a/src/ui/rm/widget/container.rs +++ b/src/ui/rm/widget/container.rs @@ -44,7 +44,7 @@ impl<'a> HeaderProps<'a> { } } -impl<'a> Default for HeaderProps<'a> { +impl Default for HeaderProps<'_> { fn default() -> Self { let theme = Theme::default(); @@ -71,7 +71,7 @@ impl Default for Header { } } -impl<'a: 'static, S, M> View for Header { +impl View for Header { type Message = M; type State = S; @@ -169,7 +169,7 @@ impl<'a> FooterProps<'a> { } } -impl<'a> Default for FooterProps<'a> { +impl Default for FooterProps<'_> { fn default() -> Self { let theme = Theme::default(); @@ -220,7 +220,7 @@ impl<'a, S, M> Footer { } } -impl<'a: 'static, S, M> View for Footer { +impl View for Footer { type Message = M; type State = S; diff --git a/src/ui/rm/widget/input.rs b/src/ui/rm/widget/input.rs index 55e42dbb..b1e9588c 100644 --- a/src/ui/rm/widget/input.rs +++ b/src/ui/rm/widget/input.rs @@ -335,7 +335,7 @@ pub struct TextAreaProps<'a> { dim: bool, } -impl<'a> Default for TextAreaProps<'a> { +impl Default for TextAreaProps<'_> { fn default() -> Self { Self { content: String::new().into(), @@ -392,7 +392,7 @@ pub struct TextArea<'a, S, M> { area: (u16, u16), } -impl<'a, S, M> Default for TextArea<'a, S, M> { +impl Default for TextArea<'_, S, M> { fn default() -> Self { Self { phantom: PhantomData, @@ -402,7 +402,7 @@ impl<'a, S, M> Default for TextArea<'a, S, M> { } } -impl<'a, S, M> View for TextArea<'a, S, M> { +impl View for TextArea<'_, S, M> { type State = S; type Message = M; @@ -663,7 +663,7 @@ impl<'a> TextViewProps<'a> { } } -impl<'a> Default for TextViewProps<'a> { +impl Default for TextViewProps<'_> { fn default() -> Self { let theme = Theme::default(); diff --git a/src/ui/rm/widget/list.rs b/src/ui/rm/widget/list.rs index 9ed0f357..bf8667b4 100644 --- a/src/ui/rm/widget/list.rs +++ b/src/ui/rm/widget/list.rs @@ -34,7 +34,7 @@ where pub dim: bool, } -impl<'a, R, const W: usize> Default for TableProps<'a, R, W> +impl Default for TableProps<'_, R, W> where R: ToRow, { diff --git a/src/ui/rm/widget/window.rs b/src/ui/rm/widget/window.rs index 609daa48..75d61b4d 100644 --- a/src/ui/rm/widget/window.rs +++ b/src/ui/rm/widget/window.rs @@ -54,9 +54,8 @@ where } } -impl<'a, S, M, Id> View for Window +impl View for Window where - 'a: 'static, S: 'static, M: 'static, Id: Clone + Hash + Eq + PartialEq + 'static,