Remove unused clippy warning suppression (missing_const_for_fn) (#2115)

This commit is contained in:
Juan 2024-03-07 20:08:28 +01:00 committed by GitHub
parent f130cd5068
commit 43af49bab4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 16 additions and 18 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Changed
* re-enable clippy `missing_const_for_fn` linter warning and added const to functions where applicable ([#2116](https://github.com/extrawurst/gitui/issues/2116))
## [0.25.1] - 2024-02-23 ## [0.25.1] - 2024-02-23
### Fixes ### Fixes

View File

@ -82,8 +82,6 @@ pub struct CommitDetails {
impl CommitDetails { impl CommitDetails {
/// ///
#[allow(clippy::missing_const_for_fn)]
// clippy doesn't realise indexing a String is not const
pub fn short_hash(&self) -> &str { pub fn short_hash(&self) -> &str {
&self.hash[0..7] &self.hash[0..7]
} }

View File

@ -20,8 +20,6 @@ pub struct Tag {
impl Tag { impl Tag {
/// ///
#[allow(clippy::missing_const_for_fn)]
// clippy doesn't realise allocating a String is not const
pub fn new(name: &str) -> Self { pub fn new(name: &str) -> Self {
Self { Self {
name: name.into(), name: name.into(),

View File

@ -296,7 +296,6 @@ impl CommitList {
self.current_size.get() self.current_size.get()
} }
#[allow(clippy::missing_const_for_fn)]
fn selection_max(&self) -> usize { fn selection_max(&self) -> usize {
self.commits.len().saturating_sub(1) self.commits.len().saturating_sub(1)
} }
@ -664,7 +663,6 @@ impl CommitList {
}) })
} }
#[allow(clippy::missing_const_for_fn)]
fn relative_selection(&self) -> usize { fn relative_selection(&self) -> usize {
self.selection.saturating_sub(self.items.index_offset()) self.selection.saturating_sub(self.items.index_offset())
} }

View File

@ -21,8 +21,6 @@
clippy::bool_to_int_with_if, clippy::bool_to_int_with_if,
clippy::module_name_repetitions clippy::module_name_repetitions
)] )]
// high number of false positives on nightly (as of Oct 2022 with 1.66.0-nightly)
#![allow(clippy::missing_const_for_fn)]
//TODO: //TODO:
// #![deny(clippy::expect_used)] // #![deny(clippy::expect_used)]

View File

@ -45,11 +45,11 @@ impl SyntaxFileBlame {
&self.file_blame.path &self.file_blame.path
} }
fn commit_id(&self) -> &CommitId { const fn commit_id(&self) -> &CommitId {
&self.file_blame.commit_id &self.file_blame.commit_id
} }
fn lines(&self) -> &Vec<(Option<BlameHunk>, String)> { const fn lines(&self) -> &Vec<(Option<BlameHunk>, String)> {
&self.file_blame.lines &self.file_blame.lines
} }
} }
@ -64,7 +64,7 @@ enum BlameProcess {
} }
impl BlameProcess { impl BlameProcess {
fn result(&self) -> Option<&SyntaxFileBlame> { const fn result(&self) -> Option<&SyntaxFileBlame> {
match self { match self {
Self::GettingBlame(_) => None, Self::GettingBlame(_) => None,
Self::SyntaxHighlighting { Self::SyntaxHighlighting {
@ -386,7 +386,7 @@ impl BlameFilePopup {
} }
/// ///
pub fn any_work_pending(&self) -> bool { pub const fn any_work_pending(&self) -> bool {
self.blame.is_some() self.blame.is_some()
&& !matches!(self.blame, Some(BlameProcess::Result(_))) && !matches!(self.blame, Some(BlameProcess::Result(_)))
} }

View File

@ -267,7 +267,7 @@ impl LogSearchPopupPopup {
] ]
} }
fn option_selected(&self) -> bool { const fn option_selected(&self) -> bool {
!matches!(self.selection, Selection::EnterText) !matches!(self.selection, Selection::EnterText)
} }

View File

@ -342,7 +342,7 @@ impl Revlog {
} }
} }
fn is_in_search_mode(&self) -> bool { const fn is_in_search_mode(&self) -> bool {
!matches!(self.search, LogSearch::Off) !matches!(self.search, LogSearch::Off)
} }
@ -396,7 +396,7 @@ impl Revlog {
); );
} }
fn can_close_search(&self) -> bool { const fn can_close_search(&self) -> bool {
self.is_in_search_mode() && !self.is_search_pending() self.is_in_search_mode() && !self.is_search_pending()
} }

View File

@ -34,7 +34,6 @@ where
} }
} }
#[allow(clippy::missing_const_for_fn)]
fn block(mut self, block: Block<'b>) -> Self { fn block(mut self, block: Block<'b>) -> Self {
self.block = Some(block); self.block = Some(block);
self self

View File

@ -89,7 +89,6 @@ impl<'a> StatefulParagraph<'a> {
} }
} }
#[allow(clippy::missing_const_for_fn)]
pub fn block(mut self, block: Block<'a>) -> Self { pub fn block(mut self, block: Block<'a>) -> Self {
self.block = Some(block); self.block = Some(block);
self self

View File

@ -143,7 +143,11 @@ impl Theme {
self.apply_select(style, selected) self.apply_select(style, selected)
} }
fn apply_select(&self, style: Style, selected: bool) -> Style { const fn apply_select(
&self,
style: Style,
selected: bool,
) -> Style {
if selected { if selected {
style.bg(self.selection_bg).fg(self.selection_fg) style.bg(self.selection_bg).fg(self.selection_fg)
} else { } else {