close
Skip to content

Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait#154398

Open
sandersaares wants to merge 1 commit into
rust-lang:mainfrom
sandersaares:higher-ranked-auto-trait-test-phantomdata-rawptr
Open

Add test for async Send with PhantomData<*mut ()> + unsafe impl Send + dyn Trait#154398
sandersaares wants to merge 1 commit into
rust-lang:mainfrom
sandersaares:higher-ranked-auto-trait-test-phantomdata-rawptr

Conversation

@sandersaares
Copy link
Copy Markdown
Contributor

@sandersaares sandersaares commented Mar 26, 2026

Add a regression test for #154397, covering the case where:

  • A type uses PhantomData<*mut ()> to opt out of Sync
  • Send is restored via unsafe impl<T: Send + 'static> Send
  • The type is captured across an .await in an async block
  • The type parameter is a trait object (Box<dyn Trait>)

This is an instance of #110338. The test includes both revisions:

  • assumptions: compiles with -Zhigher-ranked-assumptions (check-pass)
  • no_assumptions: documents the current failure as a known-bug

Also includes a PhantomData<Cell<()>> comparison showing the workaround compiles in all cases.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 26, 2026
@sandersaares sandersaares marked this pull request as ready for review March 26, 2026 02:47
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 26, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 12 candidates

@rustbot

This comment has been minimized.

@jackh726
Copy link
Copy Markdown
Member

So, see this comment: commit message needs to be updated.

Otherwise, r=me

@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 Apr 12, 2026
@sandersaares sandersaares force-pushed the higher-ranked-auto-trait-test-phantomdata-rawptr branch from fddaed2 to 6089970 Compare May 11, 2026 12:36
@rustbot

This comment has been minimized.

…impl Send + dyn Trait

Add a regression test covering the case where a type uses
PhantomData<*mut ()> to opt out of Sync, restores Send via an unsafe
impl, and is then captured across an .await point with a trait object
type parameter (Box<dyn Trait>).

The compiler currently erases lifetimes in MIR coroutine witnesses,
losing the 'static bound needed to apply the unsafe impl Send. The
test verifies this is fixed by -Zhigher-ranked-assumptions and
documents the PhantomData<Cell<()>> workaround as a comparison. See
the PR description for links to the relevant issues.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandersaares sandersaares force-pushed the higher-ranked-auto-trait-test-phantomdata-rawptr branch from 6089970 to d560d3a Compare May 11, 2026 12:37
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 11, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@sandersaares
Copy link
Copy Markdown
Contributor Author

@jackh726 commit message updated to resolve the notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

3 participants