Skip to content

update panicking() docs for panic=abort#153295

Open
biscuitrescue wants to merge 2 commits intorust-lang:mainfrom
biscuitrescue:fix-panicking-docs
Open

update panicking() docs for panic=abort#153295
biscuitrescue wants to merge 2 commits intorust-lang:mainfrom
biscuitrescue:fix-panicking-docs

Conversation

@biscuitrescue
Copy link
Contributor

@biscuitrescue biscuitrescue commented Mar 2, 2026

fixes #151458

The documentation for std::thread::panicking() has not been changed since v1.0, even though panic hooks were added in v1.10.
Current documentation is misleading for panic=abort

panicking() can return true in 2 different cases:

  1. Thread unwinds due to panic
  2. Panic hook is executing with panic=abort

r? @SpriteOvO

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 2, 2026
@SpriteOvO SpriteOvO added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Mar 2, 2026
Copy link
Member

@SpriteOvO SpriteOvO left a comment

Choose a reason for hiding this comment

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

Thank you!

Not sure if I have r+ permission for this repo, let me try it...

@bors r+ rollup

View changes since this review

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 2, 2026

@SpriteOvO: 🔑 Insufficient privileges: not in review users

@SpriteOvO
Copy link
Member

@rustbot reroll

@rustbot rustbot assigned tgross35 and unassigned SpriteOvO Mar 2, 2026
/// |-----------|----------------------------------------------------------------------|
/// | Linux | [clock_nanosleep] (Monotonic clock) |
/// | BSD except OpenBSD | [clock_nanosleep] (Monotonic Clock)] |
/// | BSD except OpenBSD | [clock_nanosleep] (Monotonic Clock) |
Copy link
Member

@SpriteOvO SpriteOvO Mar 2, 2026

Choose a reason for hiding this comment

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

Suggested change
/// | BSD except OpenBSD | [clock_nanosleep] (Monotonic Clock) |
/// | BSD except OpenBSD | [clock_nanosleep] (Monotonic Clock) |

Before merging, perhaps you'd like to fix this very very very minor nitpick 😇 -- aligning the table's divider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done and pushed.

}

/// Determines whether the current thread is unwinding because of panic.
/// Determines whether the current thread panicking.
Copy link
Contributor

Choose a reason for hiding this comment

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

“panicking” -> “is panicking”

///
/// Note that this returns `true` when thread is unwinding due to panic,
/// as well as when a panic hook is executing and program is configured to abort
/// on panic (`panic=abort`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this could be rephrased as

… unwinding due to a panic or executing a panic hook. The latter case will still happen when panic=abort is set.

Since this returns true during panic hooks even when unwinding, right?

Also grammar nits on the current version: “due to a panic”, “and the program”, and missing period at the end of the sentence.

Copy link
Contributor Author

@biscuitrescue biscuitrescue Mar 2, 2026

Choose a reason for hiding this comment

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

changed. also edited the underlying system calls table to match case and removed the trailing ] because it was sticking out to me

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 2, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@biscuitrescue
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 2, 2026
Comment on lines +173 to +174
/// Note that this returns `true` both when the thread is unwinding due to a
/// panic or executing a panic hook. The latter case will still happen when
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns true when the thread is either unwinding due to a panic, or when it is executing a panic hook. Note that the latter case ...

Minor rewording suggestion to move the "note" bit to the second sentence since it's more of a note, and slightly smooth out the first sentence.

Please squash commits after this then LGTM, thanks for the additional fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std::thread::panicking() doesn't simplify to false when compiled with panic=abort

4 participants