Skip to content

Commit 43af49b

Browse files
authored
Remove unused clippy warning suppression (missing_const_for_fn) (#2115)
1 parent f130cd5 commit 43af49b

File tree

11 files changed

+16
-18
lines changed

11 files changed

+16
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Changed
11+
12+
* re-enable clippy `missing_const_for_fn` linter warning and added const to functions where applicable ([#2116](https://github.com/extrawurst/gitui/issues/2116))
13+
1014
## [0.25.1] - 2024-02-23
1115

1216
### Fixes

asyncgit/src/sync/commit_details.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ pub struct CommitDetails {
8282

8383
impl CommitDetails {
8484
///
85-
#[allow(clippy::missing_const_for_fn)]
86-
// clippy doesn't realise indexing a String is not const
8785
pub fn short_hash(&self) -> &str {
8886
&self.hash[0..7]
8987
}

asyncgit/src/sync/tags.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ pub struct Tag {
2020

2121
impl Tag {
2222
///
23-
#[allow(clippy::missing_const_for_fn)]
24-
// clippy doesn't realise allocating a String is not const
2523
pub fn new(name: &str) -> Self {
2624
Self {
2725
name: name.into(),

src/components/commitlist.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ impl CommitList {
296296
self.current_size.get()
297297
}
298298

299-
#[allow(clippy::missing_const_for_fn)]
300299
fn selection_max(&self) -> usize {
301300
self.commits.len().saturating_sub(1)
302301
}
@@ -664,7 +663,6 @@ impl CommitList {
664663
})
665664
}
666665

667-
#[allow(clippy::missing_const_for_fn)]
668666
fn relative_selection(&self) -> usize {
669667
self.selection.saturating_sub(self.items.index_offset())
670668
}

src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
clippy::bool_to_int_with_if,
2222
clippy::module_name_repetitions
2323
)]
24-
// high number of false positives on nightly (as of Oct 2022 with 1.66.0-nightly)
25-
#![allow(clippy::missing_const_for_fn)]
2624

2725
//TODO:
2826
// #![deny(clippy::expect_used)]

src/popups/blame_file.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ impl SyntaxFileBlame {
4545
&self.file_blame.path
4646
}
4747

48-
fn commit_id(&self) -> &CommitId {
48+
const fn commit_id(&self) -> &CommitId {
4949
&self.file_blame.commit_id
5050
}
5151

52-
fn lines(&self) -> &Vec<(Option<BlameHunk>, String)> {
52+
const fn lines(&self) -> &Vec<(Option<BlameHunk>, String)> {
5353
&self.file_blame.lines
5454
}
5555
}
@@ -64,7 +64,7 @@ enum BlameProcess {
6464
}
6565

6666
impl BlameProcess {
67-
fn result(&self) -> Option<&SyntaxFileBlame> {
67+
const fn result(&self) -> Option<&SyntaxFileBlame> {
6868
match self {
6969
Self::GettingBlame(_) => None,
7070
Self::SyntaxHighlighting {
@@ -386,7 +386,7 @@ impl BlameFilePopup {
386386
}
387387

388388
///
389-
pub fn any_work_pending(&self) -> bool {
389+
pub const fn any_work_pending(&self) -> bool {
390390
self.blame.is_some()
391391
&& !matches!(self.blame, Some(BlameProcess::Result(_)))
392392
}

src/popups/log_search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl LogSearchPopupPopup {
267267
]
268268
}
269269

270-
fn option_selected(&self) -> bool {
270+
const fn option_selected(&self) -> bool {
271271
!matches!(self.selection, Selection::EnterText)
272272
}
273273

src/tabs/revlog.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl Revlog {
342342
}
343343
}
344344

345-
fn is_in_search_mode(&self) -> bool {
345+
const fn is_in_search_mode(&self) -> bool {
346346
!matches!(self.search, LogSearch::Off)
347347
}
348348

@@ -396,7 +396,7 @@ impl Revlog {
396396
);
397397
}
398398

399-
fn can_close_search(&self) -> bool {
399+
const fn can_close_search(&self) -> bool {
400400
self.is_in_search_mode() && !self.is_search_pending()
401401
}
402402

src/ui/scrolllist.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ where
3434
}
3535
}
3636

37-
#[allow(clippy::missing_const_for_fn)]
3837
fn block(mut self, block: Block<'b>) -> Self {
3938
self.block = Some(block);
4039
self

src/ui/stateful_paragraph.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ impl<'a> StatefulParagraph<'a> {
8989
}
9090
}
9191

92-
#[allow(clippy::missing_const_for_fn)]
9392
pub fn block(mut self, block: Block<'a>) -> Self {
9493
self.block = Some(block);
9594
self

0 commit comments

Comments
 (0)