Skip to content

docs: demonstrate cleanup with panic strategies - #2044

Open
TXyy2023 wants to merge 1 commit into
rust-lang:masterfrom
TXyy2023:codex/issue-1957-panic-cleanup-example
Open

TXyy2023 wants to merge 1 commit into
rust-lang:masterfrom
TXyy2023:codex/issue-1957-panic-cleanup-example

Conversation

@TXyy2023

Copy link
Copy Markdown

The abort/unwind examples currently only print different messages based on cfg; neither one actually panics. Add a small Drop example and commands for both strategies so readers can observe cleanup during unwinding and its absence when aborting. Preserve the existing conditional-compilation examples and clarify their purpose.

Fixes #1957.

Validation:

  • mdbook test (including the new should_panic example).
  • Compiled and ran all three examples with both -C panic=unwind and -C panic=abort; only the unwinding panic runs the destructor, and the existing examples still exit normally.
  • English, Japanese, Chinese, Spanish and Korean builds, plus the official full-tree link checker for all five outputs.
  • git diff --check.

AI assistance: this change and its validation were prepared with OpenAI Codex in an automated contribution workflow.

@rustbot

rustbot commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @marioidival (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @marioidival

This branch has not been deployed

No deployments
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.

Chapter 18.2: abort & unwind - non-illustrative example

3 participants