Skip to content

fix latest clippy #2597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asyncgit/src/sync/branch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn config_is_pull_rebase(repo_path: &RepoPath) -> Result<bool> {
let value =
rebase.value().map(String::from).unwrap_or_default();
return Ok(value == "true");
};
}

Ok(false)
}
Expand Down
1 change: 0 additions & 1 deletion asyncgit/src/sync/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub fn amend(
/// Wrap `Repository::signature` to allow unknown user.name.
///
/// See <https://github.com/gitui-org/gitui/issues/79>.
#[allow(clippy::redundant_pub_crate)]
pub(crate) fn signature_allow_undefined_name(
repo: &Repository,
) -> std::result::Result<Signature<'_>, git2::Error> {
Expand Down
3 changes: 2 additions & 1 deletion asyncgit/src/sync/remotes/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{
use crossbeam_channel::Sender;
use git2::{PackBuilderStage, PushOptions};
use scopetime::scope_time;
use std::fmt::Write as _;

///
pub trait AsyncProgress: Clone + Send + Sync {
Expand Down Expand Up @@ -182,7 +183,7 @@ pub fn push_raw(
if let Ok(Some(branch_upstream_merge)) =
get_branch_upstream_merge(repo_path, branch)
{
push_ref.push_str(&format!(":{branch_upstream_merge}"));
let _ = write!(push_ref, ":{branch_upstream_merge}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion filetreelist/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl TreeItemInfo {
Path::new(
self.full_path
.components()
.last()
.next_back()
.and_then(|c| c.as_os_str().to_str())
.unwrap_or_default(),
)
Expand Down
2 changes: 1 addition & 1 deletion filetreelist/src/treeitems_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a> Iterator for TreeItemsIterator<'a> {
*i += 1;
} else {
self.increments = Some(0);
};
}

loop {
if !init {
Expand Down
8 changes: 4 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl App {
3 => self.stashing_tab.draw(f, chunks_main[1])?,
4 => self.stashlist_tab.draw(f, chunks_main[1])?,
_ => bail!("unknown tab"),
};
}
}

self.draw_popups(f)?;
Expand Down Expand Up @@ -905,7 +905,7 @@ impl App {
InternalEvent::CommitSearch(options) => {
self.revlog.search(options);
}
};
}

Ok(flags)
}
Expand Down Expand Up @@ -997,7 +997,7 @@ impl App {
undo_last_commit(&self.repo.borrow())
);
}
};
}

flags.insert(NeedsUpdate::ALL);

Expand All @@ -1019,7 +1019,7 @@ impl App {
));

self.tags_popup.update_tags()?;
};
}
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl ChangesComponent {
&self.repo.borrow(),
path,
)?,
};
}
} else {
let config =
self.options.borrow().status_show_untracked();
Expand Down
4 changes: 4 additions & 0 deletions src/components/commitlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ impl CommitList {
}

///
#[expect(
clippy::missing_const_for_fn,
reason = "as of 1.86.0 clippy wants this to be const even though that breaks"
)]
pub fn marked(&self) -> &[(usize, CommitId)] {
&self.marked
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/textinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl TextInputComponent {
)
.title(self.title.clone()),
);
};
}
text_area
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/filetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl FileTreeItem {

match path
.components()
.last()
.next_back()
.map(std::path::Component::as_os_str)
.map(OsStr::to_string_lossy)
.map(String::from)
Expand Down
8 changes: 8 additions & 0 deletions src/keys/key_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ impl KeyConfig {
Ok(Self { keys, symbols })
}

#[expect(
clippy::missing_const_for_fn,
reason = "as of 1.86.0 clippy wants this to be const even though that breaks"
)]
fn get_key_symbol(&self, k: KeyCode) -> &str {
match k {
KeyCode::Enter => &self.symbols.enter,
Expand Down Expand Up @@ -106,6 +110,10 @@ impl KeyConfig {
}
}

#[expect(
clippy::missing_const_for_fn,
reason = "as of 1.86.0 clippy wants this to be const even though that breaks"
)]
fn get_modifier_hint(&self, modifier: KeyModifiers) -> &str {
match modifier {
KeyModifiers::CONTROL => &self.symbols.control,
Expand Down
4 changes: 4 additions & 0 deletions src/popups/blame_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ struct SyntaxFileBlame {
}

impl SyntaxFileBlame {
#[expect(
clippy::missing_const_for_fn,
reason = "as of 1.86.0 clippy wants this to be const even though that breaks"
)]
fn path(&self) -> &str {
&self.file_blame.path
}
Expand Down
6 changes: 3 additions & 3 deletions src/popups/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use ratatui::{
widgets::Paragraph,
Frame,
};

use std::{
fmt::Write as _,
fs::{read_to_string, File},
io::{Read, Write},
path::PathBuf,
Expand Down Expand Up @@ -470,9 +472,7 @@ impl CommitPopup {

let mut msg = msg.to_owned();
if let (Some(user), Some(mail)) = (user, mail) {
msg.push_str(&format!(
"\n\nSigned-off-by: {user} <{mail}>"
));
let _ = write!(msg, "\n\nSigned-off-by: {user} <{mail}>");
}

Ok(msg)
Expand Down
2 changes: 1 addition & 1 deletion src/popups/create_remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,6 @@ impl CreateRemotePopup {

self.hide();
}
};
}
}
}
2 changes: 1 addition & 1 deletion src/popups/file_revlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl Component for FileRevlogPopup {
InspectCommitOpen::new(commit_id),
),
));
};
}
} else if key_match(key, self.key_config.keys.blame) {
if let Some(open_request) =
self.open_request.clone()
Expand Down
4 changes: 2 additions & 2 deletions src/popups/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl OptionsPopup {
.borrow_mut()
.diff_hunk_lines_change(true);
}
};
}
} else {
match self.selection {
AppOption::StatusShowUntracked => {
Expand Down Expand Up @@ -246,7 +246,7 @@ impl OptionsPopup {
.borrow_mut()
.diff_hunk_lines_change(false);
}
};
}
}

self.queue
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/stashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl Component for Stashing {
} else {
Ok(EventState::NotConsumed)
};
};
}
}

Ok(EventState::NotConsumed)
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/stashlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl StashList {
Action::StashDrop(ids) => self.drop(repo, ids)?,
Action::StashPop(id) => self.pop(repo, *id)?,
_ => (),
};
}

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl Status {

self.diff.focus(true);
}
};
}

self.update_diff()?;

Expand Down
4 changes: 2 additions & 2 deletions src/ui/scrollbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Scrollbar {
let right = area.right().saturating_sub(1);
if right <= area.left() {
return;
};
}

let (bar_top, bar_height) = {
let scrollbar_area = area.inner(Margin {
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Scrollbar {
let bottom = area.bottom().saturating_sub(1);
if bottom <= area.top() {
return;
};
}

let (bar_left, bar_width) = {
let scrollbar_area = area.inner(Margin {
Expand Down
4 changes: 4 additions & 0 deletions src/ui/syntax_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ impl SyntaxText {
}

///
#[expect(
clippy::missing_const_for_fn,
reason = "as of 1.86.0 clippy wants this to be const even though that breaks"
)]
pub fn path(&self) -> &Path {
&self.path
}
Expand Down
Loading