Skip to content

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

Open
sandersaares wants to merge 1 commit intorust-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 intorust-lang:mainfrom
sandersaares:higher-ranked-auto-trait-test-phantomdata-rawptr

Conversation

@sandersaares
Copy link
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.

…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>).

This is a known instance of rust-lang#110338 — the compiler 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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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
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
Copy link
Collaborator

rustbot commented Mar 26, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

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. 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