Skip to content

Commit 27f9bc2

Browse files
emilkclaude
andcommitted
Fix new redundant_else hits from main
Sites that only `panic!` in the `if` branch become `assert!`, since dropping the `else` there would trip `manual_assert` instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 2bc850e commit 27f9bc2

14 files changed

Lines changed: 36 additions & 52 deletions

File tree

‎benchmarks/src/cancellation.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,12 @@ async fn find_or_generate_files(
220220
println!("Done generating files");
221221
let files_on_disk = find_files_on_disk(data_dir)?;
222222

223-
if files_on_disk.is_empty() {
224-
panic!("Tried to generate data files but there are still no files on disk");
225-
} else {
226-
println!("Using {} files now on disk", files_on_disk.len());
227-
Ok(files_on_disk)
228-
}
223+
assert!(
224+
!files_on_disk.is_empty(),
225+
"Tried to generate data files but there are still no files on disk"
226+
);
227+
println!("Using {} files now on disk", files_on_disk.len());
228+
Ok(files_on_disk)
229229
} else {
230230
println!("Using {} files found on disk", files_on_disk.len());
231231
Ok(files_on_disk)

‎datafusion/common-runtime/src/common.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ impl<R: 'static> SpawnedTask<R> {
8989
// `JoinError` can be caused either by panic or cancellation. We have to handle panics:
9090
if e.is_panic() {
9191
std::panic::resume_unwind(e.into_panic());
92-
} else {
93-
log::warn!("SpawnedTask was polled during shutdown");
94-
e
9592
}
93+
log::warn!("SpawnedTask was polled during shutdown");
94+
e
9695
})
9796
}
9897
}

‎datafusion/core/tests/fuzz_cases/topk_filter_pushdown.rs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,6 @@ async fn test_fuzz_topk_filter_pushdown() {
391391
println!("\n\n");
392392
}
393393

394-
if !failures.is_empty() {
395-
panic!("Some test cases failed");
396-
} else {
397-
println!("All test cases passed");
398-
}
394+
assert!(failures.is_empty(), "Some test cases failed");
395+
println!("All test cases passed");
399396
}

‎datafusion/core/tests/memory_limit/mod.rs‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,14 +1371,12 @@ impl TestCase {
13711371
);
13721372
}
13731373
Err(e) => {
1374-
if expected_success {
1375-
panic!(
1376-
"Unexpected failure when running, expected success but got: {e}"
1377-
)
1378-
} else {
1379-
for error_substring in expected_errors {
1380-
assert_contains!(e.to_string(), error_substring);
1381-
}
1374+
assert!(
1375+
!expected_success,
1376+
"Unexpected failure when running, expected success but got: {e}"
1377+
);
1378+
for error_substring in expected_errors {
1379+
assert_contains!(e.to_string(), error_substring);
13821380
}
13831381
}
13841382
}

‎datafusion/datasource-arrow/src/file_format.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,8 @@ impl FileSink for ArrowFileSink {
326326
Err(e) => {
327327
if e.is_panic() {
328328
std::panic::resume_unwind(e.into_panic());
329-
} else {
330-
unreachable!();
331329
}
330+
unreachable!();
332331
}
333332
}
334333
}

‎datafusion/datasource-avro/src/file_format.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,8 @@ impl FileSink for AvroFileSink {
291291
Err(e) => {
292292
if e.is_panic() {
293293
std::panic::resume_unwind(e.into_panic());
294-
} else {
295-
unreachable!();
296294
}
295+
unreachable!();
297296
}
298297
}
299298
}

‎datafusion/datasource-csv/src/source.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,8 @@ pub async fn plan_to_csv(
546546
Err(e) => {
547547
if e.is_panic() {
548548
std::panic::resume_unwind(e.into_panic());
549-
} else {
550-
unreachable!();
551549
}
550+
unreachable!();
552551
}
553552
}
554553
}

‎datafusion/datasource-json/src/source.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,8 @@ pub async fn plan_to_json(
601601
Err(e) => {
602602
if e.is_panic() {
603603
std::panic::resume_unwind(e.into_panic());
604-
} else {
605-
unreachable!();
606604
}
605+
unreachable!();
607606
}
608607
}
609608
}

‎datafusion/datasource-parquet/src/sink.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,8 @@ impl FileSink for ParquetSink {
388388
Err(e) => {
389389
if e.is_panic() {
390390
std::panic::resume_unwind(e.into_panic());
391-
} else {
392-
unreachable!();
393391
}
392+
unreachable!();
394393
}
395394
}
396395
}

‎datafusion/datasource-parquet/src/writer.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ pub async fn plan_to_parquet(
7777
Err(e) => {
7878
if e.is_panic() {
7979
std::panic::resume_unwind(e.into_panic());
80-
} else {
81-
unreachable!();
8280
}
81+
unreachable!();
8382
}
8483
}
8584
}

0 commit comments

Comments
 (0)