Fix all mismatched_lifetime_syntaxes warnings (#2727)

This commit is contained in:
linkmauve 2025-10-28 16:34:42 +01:00 committed by GitHub
parent 5f23781c10
commit 26a38183cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 34 additions and 26 deletions

View file

@ -10,6 +10,7 @@ It wraps libraries like git2 and gix.
#![forbid(missing_docs)] #![forbid(missing_docs)]
#![deny( #![deny(
mismatched_lifetime_syntaxes,
unused_imports, unused_imports,
unused_must_use, unused_must_use,
dead_code, dead_code,

View file

@ -120,7 +120,7 @@ pub fn get_default_remote(repo_path: &RepoPath) -> Result<String> {
/// and Err if there was a problem finding the branch /// and Err if there was a problem finding the branch
fn get_current_branch( fn get_current_branch(
repo: &Repository, repo: &Repository,
) -> Result<Option<git2::Branch>> { ) -> Result<Option<git2::Branch<'_>>> {
for b in repo.branches(None)? { for b in repo.branches(None)? {
let branch = b?.0; let branch = b?.0;
if branch.is_head() { if branch.is_head() {

View file

@ -62,7 +62,7 @@ pub fn reword(
/// and Err if there was a problem finding the branch /// and Err if there was a problem finding the branch
fn get_current_branch( fn get_current_branch(
repo: &Repository, repo: &Repository,
) -> Result<Option<git2::Branch>> { ) -> Result<Option<git2::Branch<'_>>> {
for b in repo.branches(None)? { for b in repo.branches(None)? {
let branch = b?.0; let branch = b?.0;
if branch.is_head() { if branch.is_head() {

View file

@ -1,6 +1,7 @@
// #![forbid(missing_docs)] // #![forbid(missing_docs)]
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![deny( #![deny(
mismatched_lifetime_syntaxes,
unused_imports, unused_imports,
unused_must_use, unused_must_use,
dead_code, dead_code,

View file

@ -11,6 +11,7 @@
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![deny( #![deny(
mismatched_lifetime_syntaxes,
unused_imports, unused_imports,
unused_must_use, unused_must_use,
dead_code, dead_code,

View file

@ -1,3 +1,5 @@
#![deny(mismatched_lifetime_syntaxes)]
use git2::Repository; use git2::Repository;
use tempfile::TempDir; use tempfile::TempDir;

View file

@ -1,3 +1,5 @@
#![deny(mismatched_lifetime_syntaxes)]
/// uses unsafe to postfix the string with invalid utf8 data /// uses unsafe to postfix the string with invalid utf8 data
#[allow(invalid_from_utf8_unchecked)] #[allow(invalid_from_utf8_unchecked)]
pub fn invalid_utf8(prefix: &str) -> String { pub fn invalid_utf8(prefix: &str) -> String {

View file

@ -1,7 +1,7 @@
//! simple macro to insert a scope based runtime measure that logs the result //! simple macro to insert a scope based runtime measure that logs the result
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![deny(unused_imports)] #![deny(mismatched_lifetime_syntaxes, unused_imports)]
#![deny(clippy::unwrap_used)] #![deny(clippy::unwrap_used)]
#![deny(clippy::perf)] #![deny(clippy::perf)]

View file

@ -58,7 +58,7 @@ impl CompareDetailsComponent {
}); });
} }
fn get_commit_text(&self, data: &CommitDetails) -> Vec<Line> { fn get_commit_text(&self, data: &CommitDetails) -> Vec<Line<'_>> {
let mut res = vec![ let mut res = vec![
Line::from(vec![ Line::from(vec![
style_detail(&self.theme, &Detail::Author), style_detail(&self.theme, &Detail::Author),

View file

@ -136,7 +136,7 @@ impl DetailsComponent {
&self, &self,
width: usize, width: usize,
height: usize, height: usize,
) -> Vec<Line> { ) -> Vec<Line<'_>> {
let (wrapped_title, wrapped_message) = let (wrapped_title, wrapped_message) =
Self::get_wrapped_lines(self.data.as_ref(), width); Self::get_wrapped_lines(self.data.as_ref(), width);
@ -156,7 +156,7 @@ impl DetailsComponent {
} }
#[allow(clippy::too_many_lines)] #[allow(clippy::too_many_lines)]
fn get_text_info(&self) -> Vec<Line> { fn get_text_info(&self) -> Vec<Line<'_>> {
self.data.as_ref().map_or_else(Vec::new, |data| { self.data.as_ref().map_or_else(Vec::new, |data| {
let mut res = vec![ let mut res = vec![
Line::from(vec![ Line::from(vec![

View file

@ -565,7 +565,7 @@ impl CommitList {
Line::from(txt) Line::from(txt)
} }
fn get_text(&self, height: usize, width: usize) -> Vec<Line> { fn get_text(&self, height: usize, width: usize) -> Vec<Line<'_>> {
let selection = self.relative_selection(); let selection = self.relative_selection();
let mut txt: Vec<Line> = Vec::with_capacity(height); let mut txt: Vec<Line> = Vec::with_capacity(height);

View file

@ -324,7 +324,7 @@ impl DiffComponent {
None None
} }
fn get_text(&self, width: u16, height: u16) -> Vec<Line> { fn get_text(&self, width: u16, height: u16) -> Vec<Line<'_>> {
if let Some(diff) = &self.diff { if let Some(diff) = &self.diff {
return if diff.hunks.is_empty() { return if diff.hunks.is_empty() {
self.get_text_binary(diff) self.get_text_binary(diff)
@ -387,7 +387,7 @@ impl DiffComponent {
vec![] vec![]
} }
fn get_text_binary(&self, diff: &FileDiff) -> Vec<Line> { fn get_text_binary(&self, diff: &FileDiff) -> Vec<Line<'_>> {
let is_positive = diff.size_delta >= 0; let is_positive = diff.size_delta >= 0;
let delta_byte_size = let delta_byte_size =
ByteSize::b(diff.size_delta.unsigned_abs()); ByteSize::b(diff.size_delta.unsigned_abs());

View file

@ -223,7 +223,7 @@ impl StatusTreeComponent {
/// allowing folders to be folded up if they are alone in their directory /// allowing folders to be folded up if they are alone in their directory
fn build_vec_text_draw_info_for_drawing( fn build_vec_text_draw_info_for_drawing(
&self, &self,
) -> (Vec<TextDrawInfo>, usize, usize) { ) -> (Vec<TextDrawInfo<'_>>, usize, usize) {
let mut should_skip_over: usize = 0; let mut should_skip_over: usize = 0;
let mut selection_offset: usize = 0; let mut selection_offset: usize = 0;
let mut selection_offset_visible: usize = 0; let mut selection_offset_visible: usize = 0;

View file

@ -33,6 +33,7 @@
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![deny( #![deny(
mismatched_lifetime_syntaxes,
unused_imports, unused_imports,
unused_must_use, unused_must_use,
dead_code, dead_code,

View file

@ -529,7 +529,7 @@ impl BlameFilePopup {
} }
/// ///
fn get_rows(&self, width: usize) -> Vec<Row> { fn get_rows(&self, width: usize) -> Vec<Row<'_>> {
self.blame self.blame
.as_ref() .as_ref()
.and_then(|blame| blame.result()) .and_then(|blame| blame.result())
@ -643,7 +643,7 @@ impl BlameFilePopup {
&self, &self,
width: usize, width: usize,
blame_hunk: Option<&BlameHunk>, blame_hunk: Option<&BlameHunk>,
) -> Vec<Cell> { ) -> Vec<Cell<'_>> {
let commit_hash = blame_hunk.map_or_else( let commit_hash = blame_hunk.map_or_else(
|| NO_COMMIT_ID.into(), || NO_COMMIT_ID.into(),
|hunk| hunk.commit_id.get_short_string(), |hunk| hunk.commit_id.get_short_string(),

View file

@ -473,7 +473,7 @@ impl BranchListPopup {
theme: &SharedTheme, theme: &SharedTheme,
width_available: u16, width_available: u16,
height: usize, height: usize,
) -> Text { ) -> Text<'_> {
const UPSTREAM_SYMBOL: char = '\u{2191}'; const UPSTREAM_SYMBOL: char = '\u{2191}';
const TRACKING_SYMBOL: char = '\u{2193}'; const TRACKING_SYMBOL: char = '\u{2193}';
const HEAD_SYMBOL: char = '*'; const HEAD_SYMBOL: char = '*';

View file

@ -263,7 +263,7 @@ impl FileRevlogPopup {
) )
} }
fn get_rows(&self, now: DateTime<Local>) -> Vec<Row> { fn get_rows(&self, now: DateTime<Local>) -> Vec<Row<'_>> {
self.items self.items
.iter() .iter()
.map(|entry| { .map(|entry| {

View file

@ -211,7 +211,7 @@ impl HelpPopup {
} }
} }
fn get_text(&self) -> Vec<Line> { fn get_text(&self) -> Vec<Line<'_>> {
let mut txt: Vec<Line> = Vec::new(); let mut txt: Vec<Line> = Vec::new();
let mut processed = 0_u16; let mut processed = 0_u16;

View file

@ -164,7 +164,7 @@ impl LogSearchPopupPopup {
} }
} }
fn get_text_options(&self) -> Vec<Line> { fn get_text_options(&self) -> Vec<Line<'_>> {
let x_summary = let x_summary =
if self.options.0.contains(SearchFields::MESSAGE_SUMMARY) if self.options.0.contains(SearchFields::MESSAGE_SUMMARY)
{ {

View file

@ -51,7 +51,7 @@ impl OptionsPopup {
} }
} }
fn get_text(&self, width: u16) -> Vec<Line> { fn get_text(&self, width: u16) -> Vec<Line<'_>> {
let mut txt: Vec<Line> = Vec::with_capacity(10); let mut txt: Vec<Line> = Vec::with_capacity(10);
self.add_status(&mut txt, width); self.add_status(&mut txt, width);

View file

@ -230,7 +230,7 @@ impl RemoteListPopup {
theme: &SharedTheme, theme: &SharedTheme,
width_available: u16, width_available: u16,
height: usize, height: usize,
) -> Text { ) -> Text<'_> {
const THREE_DOTS: &str = "..."; const THREE_DOTS: &str = "...";
const THREE_DOTS_LENGTH: usize = THREE_DOTS.len(); // "..." const THREE_DOTS_LENGTH: usize = THREE_DOTS.len(); // "..."

View file

@ -67,7 +67,7 @@ impl ResetPopup {
} }
} }
fn get_text(&self, _width: u16) -> Vec<Line> { fn get_text(&self, _width: u16) -> Vec<Line<'_>> {
let mut txt: Vec<Line> = Vec::with_capacity(10); let mut txt: Vec<Line> = Vec::with_capacity(10);
txt.push(Line::from(vec![ txt.push(Line::from(vec![

View file

@ -336,7 +336,7 @@ impl SubmodulesListPopup {
theme: &SharedTheme, theme: &SharedTheme,
width_available: u16, width_available: u16,
height: usize, height: usize,
) -> Text { ) -> Text<'_> {
const THREE_DOTS: &str = "..."; const THREE_DOTS: &str = "...";
const THREE_DOTS_LENGTH: usize = THREE_DOTS.len(); // "..." const THREE_DOTS_LENGTH: usize = THREE_DOTS.len(); // "..."
const COMMIT_HASH_LENGTH: usize = 8; const COMMIT_HASH_LENGTH: usize = 8;
@ -393,7 +393,7 @@ impl SubmodulesListPopup {
Text::from(txt) Text::from(txt)
} }
fn get_info_text(&self, theme: &SharedTheme) -> Text { fn get_info_text(&self, theme: &SharedTheme) -> Text<'_> {
self.selected_entry().map_or_else( self.selected_entry().map_or_else(
Text::default, Text::default,
|submodule| { |submodule| {
@ -442,7 +442,7 @@ impl SubmodulesListPopup {
) )
} }
fn get_local_info_text(&self, theme: &SharedTheme) -> Text { fn get_local_info_text(&self, theme: &SharedTheme) -> Text<'_> {
let mut spans = vec![ let mut spans = vec![
Line::from(vec![Span::styled( Line::from(vec![Span::styled(
"Current:", "Current:",

View file

@ -433,14 +433,14 @@ impl TagListPopup {
} }
/// ///
fn get_rows(&self) -> Vec<Row> { fn get_rows(&self) -> Vec<Row<'_>> {
self.tags.as_ref().map_or_else(Vec::new, |tags| { self.tags.as_ref().map_or_else(Vec::new, |tags| {
tags.iter().map(|tag| self.get_row(tag)).collect() tags.iter().map(|tag| self.get_row(tag)).collect()
}) })
} }
/// ///
fn get_row(&self, tag: &TagWithMetadata) -> Row { fn get_row(&self, tag: &TagWithMetadata) -> Row<'_> {
const UPSTREAM_SYMBOL: &str = "\u{2191}"; const UPSTREAM_SYMBOL: &str = "\u{2191}";
const ATTACHMENT_SYMBOL: &str = "@"; const ATTACHMENT_SYMBOL: &str = "@";
const EMPTY_SYMBOL: &str = " "; const EMPTY_SYMBOL: &str = " ";

View file

@ -423,7 +423,7 @@ pub fn copy_success(s: &str) -> String {
format!("{POPUP_SUCCESS_COPY} \"{s}\"") format!("{POPUP_SUCCESS_COPY} \"{s}\"")
} }
pub fn ellipsis_trim_start(s: &str, width: usize) -> Cow<str> { pub fn ellipsis_trim_start(s: &str, width: usize) -> Cow<'_, str> {
if s.width() <= width { if s.width() <= width {
Cow::Borrowed(s) Cow::Borrowed(s)
} else { } else {

View file

@ -98,7 +98,7 @@ impl Stashing {
Ok(()) Ok(())
} }
fn get_option_text(&self) -> Vec<Line> { fn get_option_text(&self) -> Vec<Line<'_>> {
let bracket_open = Span::raw(Cow::from("[")); let bracket_open = Span::raw(Cow::from("["));
let bracket_close = Span::raw(Cow::from("]")); let bracket_close = Span::raw(Cow::from("]"));
let option_on = let option_on =