Skip to content

Mark unreachable panics with #[expect(clippy::missing_panics_doc)] - #10761

Closed
emilk wants to merge 7 commits into
apache:mainfrom
emilk:emilk/panics-expect
Closed

emilk wants to merge 7 commits into
apache:mainfrom
emilk:emilk/panics-expect

Conversation

@emilk

@emilk emilk commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

This is one of four PRs splitting up the clippy::missing_panics_doc work.
Each one stands on its own and touches its own set of functions, but they are
meant to land in order, since the later ones assume the earlier ones:

  1. Return errors instead of panicking in fallible functions #10755 - return errors from fallible functions
  2. Add OffsetBuffer::first/last to always return offset & remove some unwraps #10759 - remove unreachable panics
  3. Document the panics of public functions #10760 - document the panics that genuinely remain
  4. Mark unreachable panics with #[expect(clippy::missing_panics_doc)] #10761 - #[expect] the unreachable ones, so the lint can be turned on

What is left after the first three PRs is functions whose unwrap cannot fail,
but where removing it would mean restructuring code for no gain. Those get an
#[expect] with a reason, which is the repo's documented convention for a lint
you disagree with on a given item.

With all four merged, clippy::missing_panics_doc is clean across the workspace,
so it can be turned on with the rest of the pedantic lints.

What changes are included in this PR?

  • #[expect(clippy::missing_panics_doc, reason = "...")] on the functions whose
    panic is unreachable, each reason naming the invariant that makes it so, for
    example "an OffsetBuffer is never empty" or "an array always matches the
    concrete type of its data type"
  • file-level #![expect(...)] for tests, benchmarks and the helpers they use,
    since those are free to panic
  • the same for the whole arrow-integration-testing crate, which is
    publish = false and holds only the integration test binaries, so nothing
    downstream reads its docs. arrow-integration-test keeps its # Panics
    sections, since it is published
  • records that convention in CONTRIBUTING.md, next to the existing guidance on
    suppressing lints

The lint itself is still not enabled here; that comes with the rest of the
pedantic lints.

One trivial conflict is expected against #10755: both add something directly
above concat_elements_utf8_many, an # Errors section there and an #[expect]
here. Keep both. It resolves itself when this branch is rebased after #10755
lands.

Are these changes tested?

Verified with cargo clippy --workspace --all-features --all-targets with
missing_panics_doc = "warn" added to [workspace.lints.clippy] locally, on top
of the other three PRs: no warnings, and no unfulfilled expectations.

Are there any user-facing changes?

No.

emilk and others added 5 commits August 19, 2026 21:21
A handful of `unwrap`/`expect`/`assert!` calls cannot fail, but removing
them would need real restructuring. Silence
`clippy::missing_panics_doc` for those with a reason instead of
documenting a panic that cannot happen.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Tests, benchmarks and their helpers are free to panic, so silence
`clippy::missing_panics_doc` for those files instead of documenting each
function.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`arrow::util::test_util` and `arrow::util::bench_util` are public, and the
file-level `#![expect(clippy::missing_panics_doc)]` means callers get no panic
documentation at all. State it once in the module docs instead.

Also records the tests-and-benches convention in CONTRIBUTING.md, next to the
existing guidance on suppressing lints.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…many`

The offsets of an array of length `size` always yield `size + 1` values, so
the `peek`/`next` calls over them cannot fail.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The crate is `publish = false` and, in its own words, holds the "binaries used
in the Arrow integration tests". Nothing downstream reads its docs and its
helpers are free to panic, so suppress the lint for the whole crate rather than
documenting a panic per function.

`arrow-integration-test` keeps its `# Panics` sections: it is published, as
support for the Arrow JSON test data format.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@emilk
emilk force-pushed the emilk/panics-expect branch from e60e569 to b0c9235 Compare August 19, 2026 19:29
@github-actions github-actions Bot removed parquet-derive parquet_derive crate arrow-select arrow-csv arrow-csv crate labels Aug 19, 2026
Jefffrey pushed a commit that referenced this pull request Aug 29, 2026
…e `unwrap`s (#10759)

# Which issue does this PR close?

- Part of #10553

# Rationale for this change

This is one of four PRs splitting up the `clippy::missing_panics_doc`
work.

1. #10755 - return errors from fallible functions
2. #10759 - remove unreachable panics
3. #10760 - document the panics that genuinely remain
4. #10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?
Replaces `unwrap`/`expect` calls that cannot fail with non-panicking
equivalents.

# Are these changes tested?

Covered by the existing tests. Every change here is a rewrite of code
whose
panic was unreachable, so there is no new behavior to test.

# Are there any user-facing changes?
Yes - `OffsetBuffer::last/first` no longer returns `Option`

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Jefffrey added a commit that referenced this pull request Sep 1, 2026
# Which issue does this PR close?

- Part of #10553

# Rationale for this change

While clearing `clippy::missing_panics_doc`, a pattern turned up:
functions that
already return `Result`, but report some failures by panicking. Several
are
reachable from untrusted input, so the panic is a denial of service
rather than a
bug report.

Documenting those panics would normalise them, so this returns errors
instead.

This is one of four PRs splitting up the work.

1. **this PR** - return errors from fallible functions
2. #10759 - remove unreachable panics
3. #10760 - document the panics that genuinely remain
4. #10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?

Functions that could report the failure and did not.

# Are these changes tested?

Covered by the existing tests, plus new tests for the `b64_decode` and
`ArrayData::validate_values` error paths.

# Are there any user-facing changes?

No API changes. Some calls that used to panic now return an `Err`, which
is the
point of the PR.

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Jeffrey Vo <[email protected]>
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 2, 2026
…e `unwrap`s (apache#10759)

# Which issue does this PR close?

- Part of apache#10553

# Rationale for this change

This is one of four PRs splitting up the `clippy::missing_panics_doc`
work.

1. apache#10755 - return errors from fallible functions
2. apache#10759 - remove unreachable panics
3. apache#10760 - document the panics that genuinely remain
4. apache#10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?
Replaces `unwrap`/`expect` calls that cannot fail with non-panicking
equivalents.

# Are these changes tested?

Covered by the existing tests. Every change here is a rewrite of code
whose
panic was unreachable, so there is no new behavior to test.

# Are there any user-facing changes?
Yes - `OffsetBuffer::last/first` no longer returns `Option`

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 18, 2026
…e `unwrap`s (apache#10759)

# Which issue does this PR close?

- Part of apache#10553

# Rationale for this change

This is one of four PRs splitting up the `clippy::missing_panics_doc`
work.

1. apache#10755 - return errors from fallible functions
2. apache#10759 - remove unreachable panics
3. apache#10760 - document the panics that genuinely remain
4. apache#10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?
Replaces `unwrap`/`expect` calls that cannot fail with non-panicking
equivalents.

# Are these changes tested?

Covered by the existing tests. Every change here is a rewrite of code
whose
panic was unreachable, so there is no new behavior to test.

# Are there any user-facing changes?
Yes - `OffsetBuffer::last/first` no longer returns `Option`

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 18, 2026
# Which issue does this PR close?

- Part of apache#10553

# Rationale for this change

While clearing `clippy::missing_panics_doc`, a pattern turned up:
functions that
already return `Result`, but report some failures by panicking. Several
are
reachable from untrusted input, so the panic is a denial of service
rather than a
bug report.

Documenting those panics would normalise them, so this returns errors
instead.

This is one of four PRs splitting up the work.

1. **this PR** - return errors from fallible functions
2. apache#10759 - remove unreachable panics
3. apache#10760 - document the panics that genuinely remain
4. apache#10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?

Functions that could report the failure and did not.

# Are these changes tested?

Covered by the existing tests, plus new tests for the `b64_decode` and
`ArrayData::validate_values` error paths.

# Are there any user-facing changes?

No API changes. Some calls that used to panic now return an `Err`, which
is the
point of the PR.

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Jeffrey Vo <[email protected]>
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 21, 2026
…e `unwrap`s (apache#10759)

# Which issue does this PR close?

- Part of apache#10553

# Rationale for this change

This is one of four PRs splitting up the `clippy::missing_panics_doc`
work.

1. apache#10755 - return errors from fallible functions
2. apache#10759 - remove unreachable panics
3. apache#10760 - document the panics that genuinely remain
4. apache#10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?
Replaces `unwrap`/`expect` calls that cannot fail with non-panicking
equivalents.

# Are these changes tested?

Covered by the existing tests. Every change here is a rewrite of code
whose
panic was unreachable, so there is no new behavior to test.

# Are there any user-facing changes?
Yes - `OffsetBuffer::last/first` no longer returns `Option`

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 21, 2026
# Which issue does this PR close?

- Part of apache#10553

# Rationale for this change

While clearing `clippy::missing_panics_doc`, a pattern turned up:
functions that
already return `Result`, but report some failures by panicking. Several
are
reachable from untrusted input, so the panic is a denial of service
rather than a
bug report.

Documenting those panics would normalise them, so this returns errors
instead.

This is one of four PRs splitting up the work.

1. **this PR** - return errors from fallible functions
2. apache#10759 - remove unreachable panics
3. apache#10760 - document the panics that genuinely remain
4. apache#10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?

Functions that could report the failure and did not.

# Are these changes tested?

Covered by the existing tests, plus new tests for the `b64_decode` and
`ArrayData::validate_values` error paths.

# Are there any user-facing changes?

No API changes. Some calls that used to panic now return an `Err`, which
is the
point of the PR.

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Jeffrey Vo <[email protected]>
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 25, 2026
…e `unwrap`s (apache#10759)

# Which issue does this PR close?

- Part of apache#10553

# Rationale for this change

This is one of four PRs splitting up the `clippy::missing_panics_doc`
work.

1. apache#10755 - return errors from fallible functions
2. apache#10759 - remove unreachable panics
3. apache#10760 - document the panics that genuinely remain
4. apache#10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?
Replaces `unwrap`/`expect` calls that cannot fail with non-panicking
equivalents.

# Are these changes tested?

Covered by the existing tests. Every change here is a rewrite of code
whose
panic was unreachable, so there is no new behavior to test.

# Are there any user-facing changes?
Yes - `OffsetBuffer::last/first` no longer returns `Option`

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 25, 2026
# Which issue does this PR close?

- Part of apache#10553

# Rationale for this change

While clearing `clippy::missing_panics_doc`, a pattern turned up:
functions that
already return `Result`, but report some failures by panicking. Several
are
reachable from untrusted input, so the panic is a denial of service
rather than a
bug report.

Documenting those panics would normalise them, so this returns errors
instead.

This is one of four PRs splitting up the work.

1. **this PR** - return errors from fallible functions
2. apache#10759 - remove unreachable panics
3. apache#10760 - document the panics that genuinely remain
4. apache#10761 - `#[expect]` the unreachable ones, so the lint can be turned
on

# What changes are included in this PR?

Functions that could report the failure and did not.

# Are these changes tested?

Covered by the existing tests, plus new tests for the `b64_decode` and
`ArrayData::validate_values` error paths.

# Are there any user-facing changes?

No API changes. Some calls that used to panic now return an `Err`, which
is the
point of the PR.

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Jeffrey Vo <[email protected]>
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions Bot added the Stale Used by workflow to mark PRs that will be auto-closed label Oct 19, 2026
emilk added 2 commits October 22, 2026 11:56
# Conflicts:
#	CONTRIBUTING.md
#	arrow-arith/src/arity.rs
#	arrow-string/src/concat_elements.rs
#	parquet-variant-compute/benches/variant_kernels.rs
@github-actions github-actions Bot added arrow-core Core crates related to representing arrow data arrow-kernels Crates that transform arrow data (e.g. compute, cast) and removed Stale Used by workflow to mark PRs that will be auto-closed labels Oct 22, 2026
@emilk emilk closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-arith arrow-array arrow-buffer arrow-cast arrow-core Core crates related to representing arrow data arrow-data arrow-flight arrow-flight crate arrow-integration-test arrow-ipc arrow-ipc crate arrow-json arrow-json crate arrow-kernels Crates that transform arrow data (e.g. compute, cast) arrow-schema arrow-string parquet parquet crate parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant