-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
std: Don't abort process when printing panics in tests #69959
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me if my understanding is right
I guess this just adds another case where our thread-local set_error/set_print functions aren't a great fit but that seems largely fine.
if let Some(mut w) = prev { | ||
let result = w.write_fmt(args); | ||
*s.borrow_mut() = Some(w); | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure I'm understanding correctly, the reason this does not need a try_borrow_mut anymore is because there's no possibility of a recursive lock, right? I believe the try_borrow was added in e2fd2df FWIW.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right yeah the scope of the borrow should always be one line of code which doesn't execute other arbitrary lines of code (e.g. an arbitrary Write
implementation). As a result we should be guaranteed that it always succeeds.
@bors: r=Mark-Simulacrum I agree! This is all probably great reasons why |
📌 Commit 96e4d12afc8a362227ad14e5ab0ec2bb7f223ded has been approved by |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
96e4d12
to
7d31795
Compare
@bors r- Looks like some tests are passing now and are expected to fail?
|
@bors: r=Mark-Simulacrum Oh just forgot the annotation to say they're expected to pass |
📌 Commit 7d31795 has been approved by |
…Mark-Simulacrum std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
7d31795
to
773c04c
Compare
@bors: r=Mark-Simulacrum |
📌 Commit 773c04c has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
…Mark-Simulacrum std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
773c04c
to
d5b6a20
Compare
@bors: r=Mark-Simulacrum |
📌 Commit d5b6a20 has been approved by |
…Mark-Simulacrum std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes rust-lang#69558
Rollup of 9 pull requests Successful merges: - #69036 (rustc: don't resolve Instances which would produce malformed shims.) - #69443 (tidy: Better license checks.) - #69814 (Smaller and more correct generator codegen) - #69929 (Regenerate tables for Unicode 13.0.0) - #69959 (std: Don't abort process when printing panics in tests) - #69969 (unix: Set a guard page at the end of signal stacks) - #70005 ([rustdoc] Improve visibility for code blocks warnings) - #70088 (Use copy bound in atomic operations to generate simpler MIR) - #70095 (Implement -Zlink-native-libraries) Failed merges: r? @ghost
Rollup of 9 pull requests Successful merges: - #68941 (Properly handle Spans that reference imported SourceFiles) - #69036 (rustc: don't resolve Instances which would produce malformed shims.) - #69443 (tidy: Better license checks.) - #69814 (Smaller and more correct generator codegen) - #69929 (Regenerate tables for Unicode 13.0.0) - #69959 (std: Don't abort process when printing panics in tests) - #69969 (unix: Set a guard page at the end of signal stacks) - #70005 ([rustdoc] Improve visibility for code blocks warnings) - #70088 (Use copy bound in atomic operations to generate simpler MIR) Failed merges: r? @ghost
This commit fixes an issue when using
set_print
and friends, notablyused by libtest, to avoid aborting the process if printing panics. This
previously panicked due to borrowing a mutable
RefCell
twice, and thisis worked around by borrowing these cells for less time, instead
taking out and removing contents temporarily.
Closes #69558