Skip to content
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

Return a value from find_format_args instead of using a callback #11444

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

Alexendoo
Copy link
Member

@Alexendoo Alexendoo commented Sep 1, 2023

r? @flip1995

changelog: none

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 1, 2023
@flip1995
Copy link
Member

flip1995 commented Sep 1, 2023

I haven't reviewed the PR yet. But I don't like the doc comment of Symbol::as_str

in practice it works out ok.

I'll have to look more closely on this PR though, before making a decision.

@Alexendoo
Copy link
Member Author

Assuming I've done it correctly it should be less of a crime than Symbol::as_str, since it's tied to a lifetime that's shorter than the thread local

@Jarcho
Copy link
Contributor

Jarcho commented Sep 1, 2023

There's nothing that actually stops a &'static LateContext<'_> value from existing. Box::leak is the easy way to do it, but there are others. Symbol::as_ref is unsafe for exactly the same reason as there's nothing stopping &'static Symbol from existing.

Neither of these are really a problem in practice, but there isn't a lifetime you can extend to that isn't technically unsafe.

@Alexendoo Alexendoo force-pushed the find-format-args-lifetime-crimes branch from 9e68abe to d3cb51c Compare September 1, 2023 23:53
@Alexendoo
Copy link
Member Author

Yeah that's true, I've updated the comment a bit

@bors
Copy link
Contributor

bors commented Sep 12, 2023

☔ The latest upstream changes (presumably #11473) made this pull request unmergeable. Please resolve the merge conflicts.

@Alexendoo Alexendoo force-pushed the find-format-args-lifetime-crimes branch from d3cb51c to ca978aa Compare September 12, 2023 20:38
@Alexendoo Alexendoo force-pushed the find-format-args-lifetime-crimes branch from ca978aa to c29de92 Compare September 14, 2023 15:54
@Alexendoo
Copy link
Member Author

I thought about this again today and realised we could stick the FormatArgs in an Rc, which means it no longer needs any unsafe code since it's not borrowing from the thread local. Updated the PR to use that

Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

Wow, turns out if you wait long enough, PR reviews resolve themselves. Sorry for taking so long.

Since this PR doesn't add unsafe code now, it was an easy review.

Thanks!

@flip1995
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 14, 2023

📌 Commit c29de92 has been approved by flip1995

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 14, 2023

⌛ Testing commit c29de92 with merge b27fc10...

@bors
Copy link
Contributor

bors commented Sep 14, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing b27fc10 to master...

@bors bors merged commit b27fc10 into rust-lang:master Sep 14, 2023
4 checks passed
@Alexendoo Alexendoo deleted the find-format-args-lifetime-crimes branch September 14, 2023 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants