Skip to content

update panicking() docs for panic=abort#153295

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
biscuitrescue:fix-panicking-docs
Mar 4, 2026
Merged

update panicking() docs for panic=abort#153295
rust-bors[bot] merged 1 commit 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

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 commited. Sorry for the late work, I have an exam coming up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Replying within a day is not "late work", there is no rush in open source :) one more typo to fix then I'll approve

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, sorry about that. Also thankyou ;)

Comment on lines +173 to +174
/// This returns `true` both when the thread is unwinding due to a panic.
/// or executing a panic hook. Note that the latter case will still happen
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be a , not . after panic

Copy link
Contributor

@tgross35 tgross35 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!

@bors r+ rollup

View changes since this review

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

📌 Commit 014344b has been approved by tgross35

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 3, 2026
@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 3, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 3, 2026
…r=tgross35

update panicking() docs for panic=abort

fixes rust-lang#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
rust-bors bot pushed a commit that referenced this pull request Mar 3, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #153280 (Add regression test for `doc(fake_variadic)` on reexports)
 - #153358 (Boundary tests for various Duration-float operations)
 - #153272 (Add `Path::absolute` method as alias for `std::path::absolute`)
 - #153295 (update panicking() docs for panic=abort)
 - #153352 (Migration of `LintDiagnostic` - part 6)
rust-bors bot pushed a commit that referenced this pull request Mar 4, 2026
Rollup of 8 pull requests

Successful merges:

 - #153280 (Add regression test for `doc(fake_variadic)` on reexports)
 - #153302 (x86: reserve `bl` and `bh` registers to match `rbx`)
 - #153358 (Boundary tests for various Duration-float operations)
 - #153048 (Improve irrefutable let-else lint wording)
 - #153258 (diag: Suppress `.clone()` suggestion inside derive macro expansions)
 - #153272 (Add `Path::absolute` method as alias for `std::path::absolute`)
 - #153295 (update panicking() docs for panic=abort)
 - #153352 (Migration of `LintDiagnostic` - part 6)
@rust-bors rust-bors bot merged commit 49966fe into rust-lang:main Mar 4, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 4, 2026
rust-timer added a commit that referenced this pull request Mar 4, 2026
Rollup merge of #153295 - biscuitrescue:fix-panicking-docs, r=tgross35

update panicking() docs for panic=abort

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
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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