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

Suggest using Arc on !Send/!Sync types #88936

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

estebank
Copy link
Contributor

No description provided.

@rust-highfive
Copy link
Collaborator

r? @yaahc

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 14, 2021
@bors

This comment has been minimized.

@yaahc yaahc added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 20, 2021
LL | | // Empty
LL | | }
| |_^ required by this bound in `Sync`
= note: consider using `std::sync::Arc<<<Self as Case1>::C as Iterator>::Item>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html>
Copy link
Member

Choose a reason for hiding this comment

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

This now seems to suggest to use Arc<..::Item> instead of ..::Item. It might be useful to say consider using Arc instead of Rc: ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But That's exactly what this is suggesting: we didn't have an Rc here. Ideally we should be able to tell what context this error is being emitted on, but sadly rustc_on_unimplemented doesn't have that filtering today.

@yaahc
Copy link
Member

yaahc commented Oct 4, 2021

r? rust-lang/compiler

@rust-highfive rust-highfive assigned nagisa and unassigned yaahc Oct 4, 2021
@@ -32,8 +32,11 @@ use crate::hash::Hasher;
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "send_trait")]
#[rustc_on_unimplemented(
on(_Self = "std::rc::Rc<T>", note = "use `std::sync::Arc` instead"),
Copy link
Member

@nagisa nagisa Oct 8, 2021

Choose a reason for hiding this comment

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

Use of Arc is not always applicable, as both Send and Sync impls for Arc<T> require T: Send + Sync. Unless we can verify T bounds here, I don't think this on clause adds any more clarity over the default note?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats fair, but was concerned the default would be too verbose for a case where we could be more straightforward. I can change it.

Copy link
Member

Choose a reason for hiding this comment

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

Well, we can always change this later too. r=me if you don't want to change it.

message = "`{Self}` cannot be sent between threads safely",
label = "`{Self}` cannot be sent between threads safely"
label = "`{Self}` cannot be sent between threads safely",
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, what's the effect of this label clause here? I was thinking that this text would appear near the span underline, but tests indicate that nothing really changed in that particular aspect, at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the primary span text.

@nagisa
Copy link
Member

nagisa commented Oct 17, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Oct 17, 2021

📌 Commit e2cffd73c83c54c629ed88b30bb7f8a486d0b1ec has been approved by nagisa

@bors bors 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 Oct 17, 2021
@bors
Copy link
Contributor

bors commented Oct 17, 2021

⌛ Testing commit e2cffd73c83c54c629ed88b30bb7f8a486d0b1ec with merge e5fb2513a52b92052d5e17ff7414a5e291ba205d...

@bors
Copy link
Contributor

bors commented Oct 17, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 17, 2021
@rust-log-analyzer

This comment has been minimized.

@jackh726 jackh726 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 Oct 21, 2021
@bors

This comment has been minimized.

@JohnCSimon JohnCSimon 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 13, 2021
@estebank
Copy link
Contributor Author

@bors r=nagisa

@bors
Copy link
Contributor

bors commented Nov 23, 2021

📌 Commit afd717c52628de0c39329c648e56abecf28b9e8f has been approved by nagisa

@JohnCSimon JohnCSimon 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 27, 2022
@bors
Copy link
Contributor

bors commented Mar 5, 2022

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout send-sync (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self send-sync --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging src/test/ui/traits/inductive-overflow/two-traits.stderr
Auto-merging src/test/ui/issues/issue-7364.stderr
Auto-merging src/test/ui/issues/issue-17718-static-sync.stderr
Auto-merging src/test/ui/issues/issue-16538.thir.stderr
CONFLICT (content): Merge conflict in src/test/ui/issues/issue-16538.thir.stderr
Auto-merging src/test/ui/issues/issue-16538.mir.stderr
CONFLICT (content): Merge conflict in src/test/ui/issues/issue-16538.mir.stderr
Auto-merging src/test/ui/impl-trait/auto-trait-leak2.stderr
CONFLICT (content): Merge conflict in src/test/ui/impl-trait/auto-trait-leak2.stderr
Auto-merging src/test/ui/generator/print/generator-print-verbose-1.stderr
Auto-merging src/test/ui/generator/issue-68112.stderr
Auto-merging src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
CONFLICT (content): Merge conflict in src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
Auto-merging src/test/ui/async-await/issue-71137.stderr
Auto-merging src/test/ui/async-await/issue-70935-complex-spans.stderr
Auto-merging src/test/ui/async-await/issue-68112.stderr
Auto-merging src/test/ui/async-await/issue-67252-unnamed-future.stderr
CONFLICT (content): Merge conflict in src/test/ui/async-await/issue-67252-unnamed-future.stderr
Auto-merging src/test/ui/async-await/issue-64130-non-send-future-diags.stderr
Auto-merging src/test/ui/async-await/issue-64130-4-async-move.stderr
Auto-merging src/test/ui/async-await/issue-64130-2-send.stderr
Auto-merging src/test/ui/async-await/issue-64130-1-sync.stderr
Auto-merging src/test/ui/async-await/async-fn-nonsend.stderr
CONFLICT (content): Merge conflict in src/test/ui/async-await/async-fn-nonsend.stderr
Auto-merging src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr
Auto-merging compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors
Copy link
Contributor

bors commented Mar 14, 2022

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout send-sync (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self send-sync --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging src/test/ui/traits/inductive-overflow/two-traits.stderr
Auto-merging src/test/ui/issues/issue-7364.stderr
Auto-merging src/test/ui/issues/issue-17718-static-sync.stderr
Auto-merging src/test/ui/issues/issue-16538.thir.stderr
CONFLICT (content): Merge conflict in src/test/ui/issues/issue-16538.thir.stderr
Auto-merging src/test/ui/issues/issue-16538.mir.stderr
CONFLICT (content): Merge conflict in src/test/ui/issues/issue-16538.mir.stderr
Auto-merging src/test/ui/impl-trait/auto-trait-leak2.stderr
CONFLICT (content): Merge conflict in src/test/ui/impl-trait/auto-trait-leak2.stderr
Auto-merging src/test/ui/generator/print/generator-print-verbose-1.stderr
Auto-merging src/test/ui/generator/issue-68112.stderr
Auto-merging src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
CONFLICT (content): Merge conflict in src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
Auto-merging src/test/ui/async-await/issue-71137.stderr
Auto-merging src/test/ui/async-await/issue-70935-complex-spans.stderr
Auto-merging src/test/ui/async-await/issue-68112.stderr
Auto-merging src/test/ui/async-await/issue-67252-unnamed-future.stderr
CONFLICT (content): Merge conflict in src/test/ui/async-await/issue-67252-unnamed-future.stderr
Auto-merging src/test/ui/async-await/issue-64130-non-send-future-diags.stderr
Auto-merging src/test/ui/async-await/issue-64130-4-async-move.stderr
Auto-merging src/test/ui/async-await/issue-64130-2-send.stderr
Auto-merging src/test/ui/async-await/issue-64130-1-sync.stderr
Auto-merging src/test/ui/async-await/async-fn-nonsend.stderr
CONFLICT (content): Merge conflict in src/test/ui/async-await/async-fn-nonsend.stderr
Auto-merging src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr
Auto-merging library/core/src/marker.rs
Auto-merging compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors
Copy link
Contributor

bors commented Mar 26, 2022

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout send-sync (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self send-sync --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging src/test/ui/traits/inductive-overflow/two-traits.stderr
Auto-merging src/test/ui/traits/alias/cross-crate.stderr
CONFLICT (content): Merge conflict in src/test/ui/traits/alias/cross-crate.stderr
Auto-merging src/test/ui/issues/issue-7364.stderr
Auto-merging src/test/ui/issues/issue-17718-static-sync.stderr
Auto-merging src/test/ui/issues/issue-16538.thir.stderr
CONFLICT (content): Merge conflict in src/test/ui/issues/issue-16538.thir.stderr
Auto-merging src/test/ui/issues/issue-16538.mir.stderr
CONFLICT (content): Merge conflict in src/test/ui/issues/issue-16538.mir.stderr
Auto-merging src/test/ui/impl-trait/auto-trait-leak2.stderr
CONFLICT (content): Merge conflict in src/test/ui/impl-trait/auto-trait-leak2.stderr
Auto-merging src/test/ui/generator/print/generator-print-verbose-1.stderr
Auto-merging src/test/ui/generator/issue-68112.stderr
Auto-merging src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
Auto-merging src/test/ui/async-await/issue-71137.stderr
Auto-merging src/test/ui/async-await/issue-70935-complex-spans.stderr
Auto-merging src/test/ui/async-await/issue-67252-unnamed-future.stderr
Auto-merging src/test/ui/async-await/issue-64130-non-send-future-diags.stderr
Auto-merging src/test/ui/async-await/issue-64130-4-async-move.stderr
Auto-merging src/test/ui/async-await/issue-64130-2-send.stderr
Auto-merging src/test/ui/async-await/issue-64130-1-sync.stderr
Auto-merging src/test/ui/async-await/async-fn-nonsend.stderr
CONFLICT (content): Merge conflict in src/test/ui/async-await/async-fn-nonsend.stderr
Auto-merging src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr
Auto-merging library/core/src/marker.rs
Auto-merging compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Automatic merge failed; fix conflicts and then commit the result.

@compiler-errors
Copy link
Member

A bors sync made this re-approved, sorry hehe

@bors r-

@Dylan-DPC
Copy link
Member

Closing this as it is inactive

@Dylan-DPC Dylan-DPC closed this Nov 21, 2022
@estebank estebank reopened this Aug 9, 2023
@estebank
Copy link
Contributor Author

estebank commented Aug 9, 2023

Squashed, rebased on top of current main and re-blessed the tests. No other changes since the prior approval.

@bors r=nagisa

@bors
Copy link
Contributor

bors commented Aug 9, 2023

📌 Commit 9de1a47 has been approved by nagisa

It is now in the queue for this repository.

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2023
@bors
Copy link
Contributor

bors commented Aug 9, 2023

⌛ Testing commit 9de1a47 with merge 27a43f0...

@@ -2743,6 +2743,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
ObligationCauseCode::BindingObligation(item_def_id, span)
| ObligationCauseCode::ExprBindingObligation(item_def_id, span, ..) => {
if self.tcx.is_diagnostic_item(sym::Send, item_def_id)
Copy link
Member

Choose a reason for hiding this comment

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

why isn't this commented? seems like something that could use a justification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a comment.

@bors
Copy link
Contributor

bors commented Aug 9, 2023

☀️ Test successful - checks-actions
Approved by: nagisa
Pushing 27a43f0 to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Aug 9, 2023

☀️ Test successful - checks-actions
Approved by: nagisa
Pushing 27a43f0 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (27a43f0): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.7% [1.2%, 2.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 632.651s -> 632.289s (-0.06%)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2023
Revert "Suggest using `Arc` on `!Send`/`!Sync` types"

Closes rust-lang#114687. This is a clean revert of rust-lang#88936 + rust-lang#115210. The suggestion to Arc\<{Self}\> when Self does not implement Send is *always* wrong.

rust-lang#114842 is considering a way to make a more refined suggestion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.