Skip to content

Commit d55e30d

Browse files
authored
Cleanup clippy::missing_const_for_fn warnings (#869)
No functional change. Bench: 2981881
1 parent 2b33519 commit d55e30d

File tree

13 files changed

+20
-20
lines changed

13 files changed

+20
-20
lines changed

build/attacks.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub enum Color {
1818
Black,
1919
}
2020

21-
pub fn pawn_attacks(square: u8, color: Color) -> u64 {
21+
pub const fn pawn_attacks(square: u8, color: Color) -> u64 {
2222
let bitboard = 1 << square;
2323
if matches!(color, Color::White) {
2424
(bitboard & !A_FILE) << 7 | (bitboard & !H_FILE) << 9
@@ -27,7 +27,7 @@ pub fn pawn_attacks(square: u8, color: Color) -> u64 {
2727
}
2828
}
2929

30-
pub fn king_attacks(square: u8) -> u64 {
30+
pub const fn king_attacks(square: u8) -> u64 {
3131
let bitboard = 1 << square;
3232

3333
(bitboard >> 8 | bitboard << 8)
@@ -39,7 +39,7 @@ pub fn king_attacks(square: u8) -> u64 {
3939
| (bitboard & !H_FILE) << 9
4040
}
4141

42-
pub fn knight_attacks(square: u8) -> u64 {
42+
pub const fn knight_attacks(square: u8) -> u64 {
4343
let bitboard = 1 << square;
4444

4545
(bitboard & !A_FILE) >> 17

build/maps.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ fn generate_sliding_map(size: usize, magics: &[MagicEntry], directions: &[(i8, i
6767
map
6868
}
6969

70-
fn get_permutation_count(mask: u64) -> u64 {
70+
const fn get_permutation_count(mask: u64) -> u64 {
7171
1 << mask.count_ones()
7272
}
7373

74-
fn magic_index(occupancies: u64, entry: &MagicEntry) -> usize {
74+
const fn magic_index(occupancies: u64, entry: &MagicEntry) -> usize {
7575
let mut hash = occupancies & entry.mask;
7676
hash = hash.wrapping_mul(entry.magic) >> entry.shift;
7777
hash as usize + entry.offset

src/board.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ impl Board {
197197
(self.pieces(PieceType::Pawn) | self.pieces(PieceType::King)) != self.occupancies()
198198
}
199199

200-
pub fn advance_fullmove_counter(&mut self) {
200+
pub const fn advance_fullmove_counter(&mut self) {
201201
self.fullmove_number += self.side_to_move() as usize;
202202
}
203203

204-
pub fn set_frc(&mut self, frc: bool) {
204+
pub const fn set_frc(&mut self, frc: bool) {
205205
self.frc = frc;
206206
}
207207

src/history.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl QuietHistoryEntry {
2323
const MAX_FACTORIZER: i32 = 1852;
2424
const MAX_BUCKET: i32 = 6324;
2525

26-
pub fn bucket(&self, threats: Bitboard, mv: Move) -> i16 {
26+
pub const fn bucket(&self, threats: Bitboard, mv: Move) -> i16 {
2727
let from_threatened = threats.contains(mv.from()) as usize;
2828
let to_threatened = threats.contains(mv.to()) as usize;
2929

src/nnue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Network {
119119
self.threat_stack[self.index].delta.clear();
120120
}
121121

122-
pub fn pop(&mut self) {
122+
pub const fn pop(&mut self) {
123123
self.index -= 1;
124124
}
125125

src/nnue/accumulator/threats/vectorized/avx2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn closest_on_rays(rays: [__m256i; 2]) -> u64 {
3737
x & occupied
3838
}
3939

40-
pub fn ray_fill(x: u64) -> u64 {
40+
pub const fn ray_fill(x: u64) -> u64 {
4141
let x = (x + 0x7E7E7E7E7E7E7E7E) & 0x8080808080808080;
4242
x - (x >> 7)
4343
}

src/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl PrincipalVariationTable {
308308
&self.table[0][..self.len[0]]
309309
}
310310

311-
pub fn clear(&mut self, ply: usize) {
311+
pub const fn clear(&mut self, ply: usize) {
312312
self.len[ply] = 0;
313313
}
314314

src/threadpool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl ThreadPool {
5353
&mut self.vector[0]
5454
}
5555

56-
pub fn len(&self) -> usize {
56+
pub const fn len(&self) -> usize {
5757
self.vector.len()
5858
}
5959

src/transposition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub struct InternalEntry {
7878
}
7979

8080
impl InternalEntry {
81-
fn depth(&self) -> i32 {
81+
const fn depth(&self) -> i32 {
8282
TtDepth::from_tt(self.offset_depth)
8383
}
8484
}
@@ -89,7 +89,7 @@ impl TtDepth {
8989
pub const NONE: i32 = 0;
9090
pub const SOME: i32 = -1;
9191

92-
fn from_tt(offset_depth: u8) -> i32 {
92+
const fn from_tt(offset_depth: u8) -> i32 {
9393
offset_depth as i32 - 1
9494
}
9595

src/types/arrayvec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ impl<T: Copy, const N: usize> ArrayVec<T, N> {
4242
self.len += mask as usize;
4343
}
4444

45-
pub fn clear(&mut self) {
45+
pub const fn clear(&mut self) {
4646
self.len = 0;
4747
}
4848

49-
pub fn swap_remove(&mut self, index: usize) -> T {
49+
pub const fn swap_remove(&mut self, index: usize) -> T {
5050
unsafe {
5151
let value = std::ptr::read(self.data[index].as_ptr());
5252

0 commit comments

Comments
 (0)