Skip to content

Correctly handle should_panic doctest attribute #143453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jul 4, 2025

Fixes #143009.

Instead of checking the exit code, we directly wrap the doctest code with catch_unwind and if a panic happened, then we return success for the test, otherwise we display the appropriate error message.

I think last one who reviewed doctest changes was @fmease so setting you as reviewer. :)

r? fmease

@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2025

fmease is not on the review rotation at the moment.
They may take a while to respond.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jul 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2025

This PR modifies run-make tests.

cc @jieyouxu

@GuillaumeGomez
Copy link
Member Author

Ah, someone else then (sorry for the ping).

r? notriddle

@rust-log-analyzer
Copy link
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@purplesyringa
Copy link
Contributor

I don't like this: this causes std::process::exit(0); to be considered as a successfully passed test, and fn main() { panic!(); } is treated as an error rather than a panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

should_panic in doctests accepts crashes, aborts, std::process::exit
6 participants