Skip to content

Document panics in public API#1174

Merged
tomtau merged 1 commit into
pest-parser:masterfrom
syu-toutousai:master
Jun 23, 2026
Merged

Document panics in public API#1174
tomtau merged 1 commit into
pest-parser:masterfrom
syu-toutousai:master

Conversation

@syu-toutousai

@syu-toutousai syu-toutousai commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Add missing # Panics sections to:

  • Position::line_of() - panics when position is out of bounds
  • ParserState::stack_peek() - panics when called on empty stack
  • ParserState::stack_pop() - panics when called on empty stack
  • Position::Ord::cmp() - panics when comparing positions from different input strings

Fixes #999

---Payment info---
PayPal: n6085530@gmail.com

Summary by CodeRabbit

  • Documentation
    • Clarified panic conditions for stack operations to help users understand when the stack is empty.
    • Enhanced documentation for position operations to document panic conditions when positions are out of bounds or when comparing positions from different input strings.

Document panics in:
- Position::line_of() - panics on out-of-bounds position
- ParserState::stack_peek() - panics on empty stack
- ParserState::stack_pop() - panics on empty stack
@syu-toutousai syu-toutousai requested a review from a team as a code owner June 23, 2026 01:23
@syu-toutousai syu-toutousai requested review from tomtau and removed request for a team June 23, 2026 01:23
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c53405af-4ca7-4595-909f-2acd3ac27fd5

📥 Commits

Reviewing files that changed from the base of the PR and between 02c5ad8 and 72938dc.

📒 Files selected for processing (2)
  • pest/src/parser_state.rs
  • pest/src/position.rs

📝 Walkthrough

Walkthrough

Rustdoc-only update adding # Panics sections to ParserState::stack_peek, ParserState::stack_pop, Position::line_of, and the Ord implementation for Position. No logic or behavior was changed.

Changes

Panic Documentation

Layer / File(s) Summary
stack_peek and stack_pop panic docs
pest/src/parser_state.rs
Adds # Panics sections documenting that both methods panic when called on an empty stack.
Position::line_of and Ord panic docs
pest/src/position.rs
Adds a # Panics section to line_of for out-of-bounds input, and inserts doc comments before the Ord impl noting panics when comparing positions from different input strings.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • pest-parser/pest#1167: Also adds # Panics Rustdoc sections in pest/src/position.rs for out-of-bounds position handling, directly parallel to this PR's changes in the same file.

Poem

🐇 A bunny hopped through docs one day,
And found some panics gone astray —
No warnings left, no hints to find!
So penned each # Panics line,
Now stacks and positions both align. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly summarizes the main change: adding documentation for panics in public API methods.
Linked Issues check ✅ Passed The PR successfully documents panics for all four public API methods mentioned in issue #999, following the standard library convention with # Panics sections.
Out of Scope Changes check ✅ Passed All changes are directly related to documenting panics in public API methods as required by issue #999; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request has been flagged as potential spam (promotional) by CodeRabbit slop detection and should be reviewed carefully.

@tomtau tomtau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tomtau tomtau enabled auto-merge (squash) June 23, 2026 11:39
@tomtau tomtau disabled auto-merge June 23, 2026 11:39
@tomtau tomtau enabled auto-merge (squash) June 23, 2026 11:40
@tomtau tomtau merged commit b24fa55 into pest-parser:master Jun 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document panics

2 participants