Skip to content

Commit 79e5d76

Browse files
CopilotCommanderStormnyurik
authored
Enable clippy::use_self at workspace level and align codec implementations (#79)
This change enables `clippy::use_self` in workspace lint configuration so the rule is enforced consistently. It also updates existing Rust codec code to conform to the newly enabled lint without changing behavior. - **Workspace lint configuration** - Added `use_self = "warn"` under `[lints.clippy]` in: - root `Cargo.toml` - `fuzz/Cargo.toml` (to keep fuzz crate lint settings aligned with workspace expectations) - **Code updates required by `use_self`** - Replaced explicit type repetitions with `Self` in constructors/default impls and associated method calls: - `src/rust/integer_compression/fastpfor.rs` - `src/rust/integer_compression/just_copy.rs` - `src/rust/integer_compression/variable_byte.rs` - **Representative change** ```rust impl VariableByte { #[must_use] pub fn new() -> Self { Self } } impl Default for VariableByte { fn default() -> Self { Self::new() } } ``` <!-- START COPILOT CODING AGENT TIPS --> --- 📍 Connect Copilot coding agent with [Jira](https://gh.io/cca-jira-docs), [Azure Boards](https://gh.io/cca-azure-boards-docs) or [Linear](https://gh.io/cca-linear-docs) to delegate work to Copilot in one click without leaving your project management tool. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: CommanderStorm <26258709+CommanderStorm@users.noreply.github.com> Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
1 parent 388f4ff commit 79e5d76

5 files changed

Lines changed: 10 additions & 20 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ missing_docs = "warn"
5353
[lints.clippy]
5454
cargo = { level = "warn", priority = -1 }
5555
pedantic = { level = "warn", priority = -1 }
56+
use_self = "warn"
5657
cast_possible_truncation = "allow"
5758
cast_possible_wrap = "allow"
5859
cast_sign_loss = "allow"

fuzz/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ unused_qualifications = "warn"
2222
[lints.clippy]
2323
cargo = { level = "warn", priority = -1 }
2424
pedantic = { level = "warn", priority = -1 }
25+
use_self = "warn"
2526
# Allow certain lints that are common in fuzz targets and not worth fixing.
2627
doc_markdown = "allow"
2728
wildcard_imports = "allow"

src/rust/integer_compression/fastpfor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<const N: usize> FastPFor<N> {
9393
block_size: N as u32,
9494
});
9595
}
96-
Ok(FastPFor {
96+
Ok(Self {
9797
bytes_container: BytesMut::with_capacity(
9898
(3 * page_size / N as u32 + page_size) as usize,
9999
),

src/rust/integer_compression/just_copy.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@ use crate::helpers::AsUsize;
55
/// A no-op codec that copies data without compression.
66
///
77
/// Useful as a baseline for benchmarking or when a codec interface is required.
8-
#[derive(Debug)]
8+
#[derive(Debug, Default)]
99
pub struct JustCopy;
1010

1111
impl JustCopy {
1212
/// Creates a new instance
1313
#[must_use]
1414
pub fn new() -> Self {
15-
JustCopy
16-
}
17-
}
18-
19-
impl Default for JustCopy {
20-
fn default() -> Self {
21-
JustCopy::new()
15+
Self
2216
}
2317
}
2418

src/rust/integer_compression/variable_byte.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::rust::cursor::IncrementCursor;
88
use crate::{FastPForError, FastPForResult};
99

1010
/// Variable-byte encoding codec for integer compression.
11-
#[derive(Debug)]
11+
#[derive(Debug, Default)]
1212
pub struct VariableByte;
1313

1414
// Helper functions with const generics for extracting 7-bit chunks
@@ -28,8 +28,8 @@ impl VariableByte {
2828
impl VariableByte {
2929
/// Creates a new instance
3030
#[must_use]
31-
pub fn new() -> VariableByte {
32-
VariableByte
31+
pub fn new() -> Self {
32+
Self
3333
}
3434

3535
/// Compress `input_length` u32 values from `input[input_offset..]` into
@@ -301,20 +301,14 @@ impl VariableByte {
301301
}
302302
}
303303

304-
impl Default for VariableByte {
305-
fn default() -> Self {
306-
VariableByte::new()
307-
}
308-
}
309-
310304
impl AnyLenCodec for VariableByte {
311305
fn encode(&mut self, input: &[u32], out: &mut Vec<u32>) -> FastPForResult<()> {
312306
let capacity = input.len() * 2 + 4;
313307
let start = out.len();
314308
out.resize(start + capacity, 0);
315309
let mut in_off = Cursor::new(0u32);
316310
let mut out_off = Cursor::new(0u32);
317-
VariableByte::compress_into_slice(
311+
Self::compress_into_slice(
318312
input,
319313
input.len() as u32,
320314
&mut in_off,
@@ -342,7 +336,7 @@ impl AnyLenCodec for VariableByte {
342336
out.resize(start + capacity, 0);
343337
let mut in_off = Cursor::new(0u32);
344338
let mut out_off = Cursor::new(0u32);
345-
VariableByte::decompress_from_u32_slice(
339+
Self::decompress_from_u32_slice(
346340
input,
347341
input.len() as u32,
348342
&mut in_off,

0 commit comments

Comments
 (0)