Skip to content

Commit c87bfca

Browse files
chore: clippy deny ref_option and ref_option_ref (#7692)
Prefer option_ref over ref_option Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 6608a71 commit c87bfca

13 files changed

Lines changed: 43 additions & 44 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ mem_forget = "deny"
347347
multiple_crate_versions = "allow"
348348
needless_range_loop = "allow"
349349
or_fun_call = "deny"
350+
ref_option = "deny"
351+
ref_option_ref = "deny"
350352
panic = "deny"
351353
# panic_in_result_fn = "deny" -- we cannot disable this for tests to use assertions
352354
clone_on_ref_ptr = "deny"

encodings/alp/src/alp/array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl VTable for ALP {
160160
})
161161
.transpose()?;
162162

163-
let slots = ALPData::make_slots(&encoded, &patches);
163+
let slots = ALPData::make_slots(&encoded, patches.as_ref());
164164
let data = ALPData::new(
165165
Exponents {
166166
e: u8::try_from(metadata.exp_e)?,
@@ -371,7 +371,7 @@ impl ALP {
371371
pub fn new(encoded: ArrayRef, exponents: Exponents, patches: Option<Patches>) -> ALPArray {
372372
let dtype = ALPData::logical_dtype(&encoded).vortex_expect("ALP encoded dtype");
373373
let len = encoded.len();
374-
let slots = ALPData::make_slots(&encoded, &patches);
374+
let slots = ALPData::make_slots(&encoded, patches.as_ref());
375375
unsafe {
376376
Array::from_parts_unchecked(
377377
ArrayParts::new(ALP, dtype, len, ALPData::new(exponents, patches))
@@ -387,7 +387,7 @@ impl ALP {
387387
) -> VortexResult<ALPArray> {
388388
let dtype = ALPData::logical_dtype(&encoded)?;
389389
let len = encoded.len();
390-
let slots = ALPData::make_slots(&encoded, &patches);
390+
let slots = ALPData::make_slots(&encoded, patches.as_ref());
391391
let data = ALPData::new(exponents, patches);
392392
Array::try_from_parts(ArrayParts::new(ALP, dtype, len, data).with_slots(slots))
393393
}
@@ -401,7 +401,7 @@ impl ALP {
401401
) -> ALPArray {
402402
let dtype = ALPData::logical_dtype(&encoded).vortex_expect("ALP encoded dtype");
403403
let len = encoded.len();
404-
let slots = ALPData::make_slots(&encoded, &patches);
404+
let slots = ALPData::make_slots(&encoded, patches.as_ref());
405405
let data = unsafe { ALPData::new_unchecked(exponents, patches) };
406406
unsafe {
407407
Array::from_parts_unchecked(ArrayParts::new(ALP, dtype, len, data).with_slots(slots))
@@ -410,7 +410,7 @@ impl ALP {
410410
}
411411

412412
impl ALPData {
413-
fn make_slots(encoded: &ArrayRef, patches: &Option<Patches>) -> Vec<Option<ArrayRef>> {
413+
fn make_slots(encoded: &ArrayRef, patches: Option<&Patches>) -> Vec<Option<ArrayRef>> {
414414
let (patch_indices, patch_values, patch_chunk_offsets) = match patches {
415415
Some(p) => (
416416
Some(p.indices().clone()),

encodings/alp/src/alp_rd/array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl VTable for ALPRD {
221221
left_parts_patches,
222222
&mut LEGACY_SESSION.create_execution_ctx(),
223223
)?;
224-
let slots = ALPRDData::make_slots(&left_parts, &right_parts, &left_parts_patches);
224+
let slots = ALPRDData::make_slots(&left_parts, &right_parts, left_parts_patches.as_ref());
225225
let data = ALPRDData::new(
226226
left_parts_dictionary,
227227
u8::try_from(metadata.right_bit_width).map_err(|_| {
@@ -383,7 +383,7 @@ impl ALPRD {
383383
let len = left_parts.len();
384384
let left_parts_patches =
385385
ALPRDData::canonicalize_patches(&left_parts, left_parts_patches, ctx)?;
386-
let slots = ALPRDData::make_slots(&left_parts, &right_parts, &left_parts_patches);
386+
let slots = ALPRDData::make_slots(&left_parts, &right_parts, left_parts_patches.as_ref());
387387
let data = ALPRDData::new(left_parts_dictionary, right_bit_width, left_parts_patches);
388388
Array::try_from_parts(ArrayParts::new(ALPRD, dtype, len, data).with_slots(slots))
389389
}
@@ -399,7 +399,7 @@ impl ALPRD {
399399
left_parts_patches: Option<Patches>,
400400
) -> ALPRDArray {
401401
let len = left_parts.len();
402-
let slots = ALPRDData::make_slots(&left_parts, &right_parts, &left_parts_patches);
402+
let slots = ALPRDData::make_slots(&left_parts, &right_parts, left_parts_patches.as_ref());
403403
let data = unsafe {
404404
ALPRDData::new_unchecked(left_parts_dictionary, right_bit_width, left_parts_patches)
405405
};
@@ -464,7 +464,7 @@ impl ALPRDData {
464464
fn make_slots(
465465
left_parts: &ArrayRef,
466466
right_parts: &ArrayRef,
467-
patches: &Option<Patches>,
467+
patches: Option<&Patches>,
468468
) -> Vec<Option<ArrayRef>> {
469469
let (pi, pv, pco) = match patches {
470470
Some(p) => (

fuzz/src/array/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ pub fn run_fuzz_action(fuzz_action: FuzzArrayAction) -> VortexFuzzResult<bool> {
657657
Action::MinMax => {
658658
let min_max_result = min_max(&current_array, &mut ctx)
659659
.vortex_expect("min_max operation should succeed in fuzz test");
660-
assert_min_max_eq(&expected.min_max(), &min_max_result, i)?;
660+
assert_min_max_eq(expected.min_max().as_ref(), min_max_result.as_ref(), i)?;
661661
}
662662
Action::FillNull(fill_value) => {
663663
current_array = current_array
@@ -770,14 +770,14 @@ pub fn assert_scalar_eq(lhs: &Scalar, rhs: &Scalar, step: usize) -> VortexFuzzRe
770770
/// Assert two min/max results are equal.
771771
#[expect(clippy::result_large_err)]
772772
pub fn assert_min_max_eq(
773-
lhs: &Option<MinMaxResult>,
774-
rhs: &Option<MinMaxResult>,
773+
lhs: Option<&MinMaxResult>,
774+
rhs: Option<&MinMaxResult>,
775775
step: usize,
776776
) -> VortexFuzzResult<()> {
777777
if lhs != rhs {
778778
return Err(VortexFuzzError::MinMaxMismatch(
779-
lhs.clone(),
780-
rhs.clone(),
779+
lhs.cloned(),
780+
rhs.cloned(),
781781
step,
782782
Backtrace::capture(),
783783
));

vortex-array/src/arrow/executor/temporal.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ pub(super) fn to_arrow_temporal(
8686

8787
match (unit, arrow_unit) {
8888
(TimeUnit::Seconds, ArrowTimeUnit::Second) => {
89-
to_arrow_timestamp::<TimestampSecondType>(array, arrow_tz, ctx)
89+
to_arrow_timestamp::<TimestampSecondType>(array, arrow_tz.as_ref(), ctx)
9090
}
9191
(TimeUnit::Milliseconds, ArrowTimeUnit::Millisecond) => {
92-
to_arrow_timestamp::<TimestampMillisecondType>(array, arrow_tz, ctx)
92+
to_arrow_timestamp::<TimestampMillisecondType>(array, arrow_tz.as_ref(), ctx)
9393
}
9494
(TimeUnit::Microseconds, ArrowTimeUnit::Microsecond) => {
95-
to_arrow_timestamp::<TimestampMicrosecondType>(array, arrow_tz, ctx)
95+
to_arrow_timestamp::<TimestampMicrosecondType>(array, arrow_tz.as_ref(), ctx)
9696
}
9797
(TimeUnit::Nanoseconds, ArrowTimeUnit::Nanosecond) => {
98-
to_arrow_timestamp::<TimestampNanosecondType>(array, arrow_tz, ctx)
98+
to_arrow_timestamp::<TimestampNanosecondType>(array, arrow_tz.as_ref(), ctx)
9999
}
100100
_ => vortex_bail!(
101101
"Cannot convert {} array to Arrow type {}",
@@ -125,14 +125,14 @@ where
125125

126126
fn to_arrow_timestamp<T: ArrowTimestampType>(
127127
array: ArrayRef,
128-
arrow_tz: &Option<Arc<str>>,
128+
arrow_tz: Option<&Arc<str>>,
129129
ctx: &mut ExecutionCtx,
130130
) -> VortexResult<ArrowArrayRef>
131131
where
132132
T::Native: NativePType,
133133
{
134134
Ok(Arc::new(
135-
to_arrow_temporal_primitive::<T>(array, ctx)?.with_timezone_opt(arrow_tz.clone()),
135+
to_arrow_temporal_primitive::<T>(array, ctx)?.with_timezone_opt(arrow_tz.cloned()),
136136
))
137137
}
138138

vortex-bench/src/clickbench/benchmark.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ impl ClickBenchBenchmark {
2828
queries_file: Option<String>,
2929
use_remote_data_dir: Option<String>,
3030
) -> Result<Self> {
31-
let url = Self::create_data_url(&use_remote_data_dir, flavor)?;
31+
let url = Self::create_data_url(use_remote_data_dir.as_deref(), flavor)?;
3232
Ok(Self {
3333
flavor,
3434
queries_file,
3535
data_url: url,
3636
})
3737
}
3838

39-
fn create_data_url(remote_data_dir: &Option<String>, flavor: Flavor) -> Result<Url> {
40-
resolve_data_url(remote_data_dir.as_deref(), &format!("clickbench_{flavor}"))
39+
fn create_data_url(remote_data_dir: Option<&str>, flavor: Flavor) -> Result<Url> {
40+
resolve_data_url(remote_data_dir, &format!("clickbench_{flavor}"))
4141
}
4242
}
4343

vortex-bench/src/fineweb/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ impl FinewebBenchmark {
5050
}
5151

5252
pub fn with_remote_data_dir(use_remote_data_dir: Option<String>) -> anyhow::Result<Self> {
53-
let data_url = Self::create_data_url(&use_remote_data_dir)?;
53+
let data_url = Self::create_data_url(use_remote_data_dir.as_deref())?;
5454
Ok(Self { data_url })
5555
}
5656

57-
fn create_data_url(remote_data_dir: &Option<String>) -> anyhow::Result<Url> {
58-
resolve_data_url(remote_data_dir.as_deref(), "fineweb")
57+
fn create_data_url(remote_data_dir: Option<&str>) -> anyhow::Result<Url> {
58+
resolve_data_url(remote_data_dir, "fineweb")
5959
}
6060
}
6161

vortex-bench/src/realnest/gharchive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ impl GithubArchiveBenchmark {
4343
}
4444

4545
pub fn with_remote_data_dir(use_remote_data_dir: Option<String>) -> anyhow::Result<Self> {
46-
let data_url = Self::create_data_url(&use_remote_data_dir)?;
46+
let data_url = Self::create_data_url(use_remote_data_dir.as_deref())?;
4747
Ok(Self { data_url })
4848
}
4949

50-
fn create_data_url(remote_data_dir: &Option<String>) -> anyhow::Result<Url> {
51-
resolve_data_url(remote_data_dir.as_deref(), "gharchive")
50+
fn create_data_url(remote_data_dir: Option<&str>) -> anyhow::Result<Url> {
51+
resolve_data_url(remote_data_dir, "gharchive")
5252
}
5353
}
5454

vortex-bench/src/tpcds/tpcds_benchmark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ impl TpcDsBenchmark {
2727
pub fn new(scale_factor: String, use_remote_data_dir: Option<String>) -> Result<Self> {
2828
Ok(Self {
2929
scale_factor: scale_factor.clone(),
30-
data_url: Self::create_data_url(&use_remote_data_dir, &scale_factor)?,
30+
data_url: Self::create_data_url(use_remote_data_dir.as_deref(), &scale_factor)?,
3131
})
3232
}
3333

34-
fn create_data_url(remote_data_dir: &Option<String>, scale_factor: &str) -> Result<Url> {
34+
fn create_data_url(remote_data_dir: Option<&str>, scale_factor: &str) -> Result<Url> {
3535
match remote_data_dir {
3636
None => {
3737
let data_dir = "tpcds".to_data_path();

vortex-bench/src/tpch/benchmark.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,11 @@ impl TpcHBenchmark {
3737
pub fn new(scale_factor: String, use_remote_data_dir: Option<String>) -> anyhow::Result<Self> {
3838
Ok(Self {
3939
scale_factor: scale_factor.clone(),
40-
data_url: Self::create_data_url(&use_remote_data_dir, &scale_factor)?,
40+
data_url: Self::create_data_url(use_remote_data_dir.as_deref(), &scale_factor)?,
4141
})
4242
}
4343

44-
fn create_data_url(
45-
remote_data_dir: &Option<String>,
46-
scale_factor: &str,
47-
) -> anyhow::Result<Url> {
44+
fn create_data_url(remote_data_dir: Option<&str>, scale_factor: &str) -> anyhow::Result<Url> {
4845
match remote_data_dir {
4946
None => {
5047
let data_dir = "tpch".to_data_path();

0 commit comments

Comments
 (0)