Document the panics of public functions - #10760
Draft
emilk wants to merge 6 commits into
Draft
Conversation
Add `# Panics` sections to public functions that can panic, in preparation for enabling the `clippy::missing_panics_doc` lint. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The `#[expect]` reason claimed that `write` always flushes, so `into_inner` could not fail. That only holds on the success path: `write` flushes at the very end, so a `write` that returned an error leaves rows buffered, and the flush inside `into_inner` can then fail and panic. `into_inner` returns `W`, so there is nowhere to report that. Document it instead of asserting it cannot happen. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A doc comment placed after `#[inline]`, `#[deprecated]` or `#[proc_macro_derive]` still renders, but it splits the doc block in two and reads as if the attribute belongs to the section. Move the new `# Panics` sections above the attribute, where the rest of the docs are. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two of the documented panics are deliberate, and the docs now say so rather than leaving the reader to wonder why the function does not report the failure: * `try_for_each_valid_idx` takes the caller's error type, so it has no error value to build * the `arrow-integration-test` JSON readers parse fixtures, where malformed input is a broken test rather than bad data Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
emilk
force-pushed
the
emilk/panics-docs
branch
from
August 19, 2026 19:29
683d113 to
7939894
Compare
This was referenced Aug 19, 2026
`MutableArrayData::try_with_capacities` arrived with apache#10675. It only turns the dictionary key overflow into an error, and still panics for the other cases, so say so under a heading the lint recognises. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
This is one of four PRs splitting up the
clippy::missing_panics_docwork.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:
unwraps #10759 - remove unreachable panics#[expect(clippy::missing_panics_doc)]#10761 -#[expect]the unreachable ones, so the lint can be turned onWhat is left after the first two PRs is panics that are real and that the
function cannot report any other way. Those get a
# Panicssection.What changes are included in this PR?
# Panicssections on the public functions that can still panic, includingthe ones that only panic under the
force_validatefeaturewonder:
try_for_each_valid_idxtakes the caller's error type and so has noerror value to build, and the
arrow-integration-testJSON readers parsefixtures, where malformed input is a broken test rather than bad data
arrow-csv'sWriter::into_innerdocuments its panic honestly. A successfulwriteflushes, but awritethat returned an error leaves rows buffered, andthe flush inside
into_innercan then fail. It returnsW, so there isnowhere to report that
arrow::util::test_utilandarrow::util::bench_utilare public, so theirmodule docs say the helpers panic on invalid input
# Panicssections go before#[inline],#[deprecated]and#[proc_macro_derive], rather than after, so the doc block stays in one piecePrimitiveDictionaryBuilderarrow-integration-testingis deliberately left undocumented: it ispublish = falseand holds only integration test binaries. #10761 suppresses thelint for that crate instead.
Are these changes tested?
Documentation only.
cargo doc --workspace --all-featuresis clean.Are there any user-facing changes?
Documentation only.