Skip to content

use Once instead of Mutex to manage capture resolution - #80736

Merged
bors merged 1 commit into
rust-lang:masterfrom
KodrAus:feat/lazy-resolve
Jan 13, 2021
Merged

use Once instead of Mutex to manage capture resolution#80736
bors merged 1 commit into
rust-lang:masterfrom
KodrAus:feat/lazy-resolve

Conversation

@KodrAus

Copy link
Copy Markdown
Contributor

For #78299

This allows us to return borrows of the captured backtrace frames that are tied to a borrow of the Backtrace itself, instead of to some short-lived Mutex guard.

We could alternatively share &Mutex<Capture>s and lock on-demand, but then we could potentially forget to call resolve() before working with the capture. It also makes it semantically clearer what synchronization is needed on the capture.

cc @seanchen1991 @rust-lang/project-error-handling

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @joshtriplett

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2021
Comment threadlibrary/std/src/backtrace.rs Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It's not visible in the diff, but we do have a test to ensure Backtrace is Send + Sync

@rust-log-analyzer

This comment has been minimized.

This allows us to return borrows of the captured backtrace frames
that are tied to a borrow of the Backtrace itself, instead of to
some short-lived Mutex guard.
It also makes it semantically clearer what synchronization is needed
on the capture.
@KodrAusKodrAus added the PG-error-handling Project group: Error handling (https://github.com/rust-lang/project-error-handling) label Jan 6, 2021
flub
flub approved these changes Jan 7, 2021
@yaahc

yaahc commented Jan 7, 2021

Copy link
Copy Markdown
Member

LGTM

@KodrAus

Copy link
Copy Markdown
ContributorAuthor

r? @dtolnay

@dtolnaydtolnay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@dtolnay

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Jan 12, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit db4585a has been approved by dtolnay

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 12, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 13, 2021
Rollup of 10 pull requests
Successful merges:
- rust-lang#78901 (diagnostics: Note capturing closures can't be coerced to fns)
- rust-lang#79588 (Provide more information for HRTB lifetime errors involving closures)
- rust-lang#80232 (Remove redundant def_id lookups)
- rust-lang#80662 (Added support for i386-unknown-linux-gnu and i486-unknown-linux-gnu)
- rust-lang#80736 (use Once instead of Mutex to manage capture resolution)
- rust-lang#80796 (Update to LLVM 11.0.1)
- rust-lang#80859 (Fix --pretty=expanded with --remap-path-prefix)
- rust-lang#80922 (Revert "Auto merge of rust-lang#76896 - spastorino:codegen-inline-fns2)
- rust-lang#80924 (Fix rustdoc --test-builder argument parsing)
- rust-lang#80935 (Rename `rustc_middle::lint::LevelSource` to `LevelAndSource`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit e73ee1d into rust-lang:masterJan 13, 2021
@rustbotrustbot added this to the 1.51.0 milestone Jan 13, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-error-handlingProject group: Error handling (https://github.com/rust-lang/project-error-handling)S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@KodrAus@rust-highfive@rust-log-analyzer@yaahc@dtolnay@bors@flub@joshtriplett@rustbot