fix clippy nightly

This commit is contained in:
extrawurst 2023-02-27 23:26:14 +01:00
parent 000deb2cf8
commit c3e318fdd5
3 changed files with 20 additions and 11 deletions

View file

@ -21,6 +21,8 @@
#![allow(clippy::missing_errors_doc)] #![allow(clippy::missing_errors_doc)]
//TODO: get this in someday since expect still leads us to crashes sometimes //TODO: get this in someday since expect still leads us to crashes sometimes
// #![deny(clippy::expect_used)] // #![deny(clippy::expect_used)]
//TODO: consider cleaning some up and allow specific places
#![allow(clippy::significant_drop_tightening)]
pub mod asyncjob; pub mod asyncjob;
mod blame; mod blame;

View file

@ -131,11 +131,11 @@ fn setup_logging() -> Result<()> {
println!("Logging enabled. log written to: {path:?}"); println!("Logging enabled. log written to: {path:?}");
let _ = WriteLogger::init( WriteLogger::init(
LevelFilter::Trace, LevelFilter::Trace,
Config::default(), Config::default(),
File::create(path)?, File::create(path)?,
); )?;
Ok(()) Ok(())
} }

View file

@ -282,7 +282,11 @@ impl RevisionFilesComponent {
} }
} }
fn draw_tree<B: Backend>(&self, f: &mut Frame<B>, area: Rect) { fn draw_tree<B: Backend>(
&self,
f: &mut Frame<B>,
area: Rect,
) -> Result<()> {
let tree_height = usize::from(area.height.saturating_sub(2)); let tree_height = usize::from(area.height.saturating_sub(2));
let tree_width = usize::from(area.width); let tree_width = usize::from(area.width);
@ -313,7 +317,7 @@ impl RevisionFilesComponent {
let is_tree_focused = matches!(self.focus, Focus::Tree); let is_tree_focused = matches!(self.focus, Focus::Tree);
let title = self.title_within(tree_width); let title = self.title_within(tree_width)?;
let block = Block::default() let block = Block::default()
.title(Span::styled( .title(Span::styled(
title, title,
@ -342,12 +346,15 @@ impl RevisionFilesComponent {
if is_tree_focused { if is_tree_focused {
self.scroll.draw(f, area, &self.theme); self.scroll.draw(f, area, &self.theme);
} }
Ok(())
} }
fn title_within(&self, tree_width: usize) -> String { fn title_within(&self, tree_width: usize) -> Result<String> {
let mut title = String::from("Files at"); let mut title = String::from("Files at");
let message = self.revision.as_ref().and_then(|c| { let message = self.revision.as_ref().and_then(|c| {
let _ = write!(title, " {{{}}}", c.id.get_short_string()); let _ignore =
write!(title, " {{{}}}", c.id.get_short_string());
c.message.lines().next() c.message.lines().next()
}); });
@ -362,20 +369,20 @@ impl RevisionFilesComponent {
); );
if message.width() <= available { if message.width() <= available {
let _ = write!(title, " [{message}]"); write!(title, " [{message}]")?;
} else if available > 1 { } else if available > 1 {
let _ = write!( write!(
title, title,
" [{}{}]", " [{}{}]",
message.unicode_truncate(available - 1).0, message.unicode_truncate(available - 1).0,
ELLIPSIS ELLIPSIS
); )?;
} else { } else {
title.push(ELLIPSIS); title.push(ELLIPSIS);
} }
} }
title Ok(title)
} }
fn request_files(&mut self, commit: CommitId) { fn request_files(&mut self, commit: CommitId) {
@ -404,7 +411,7 @@ impl DrawableComponent for RevisionFilesComponent {
) )
.split(area); .split(area);
self.draw_tree(f, chunks[0]); self.draw_tree(f, chunks[0])?;
self.current_file.draw(f, chunks[1])?; self.current_file.draw(f, chunks[1])?;
} }