Skip to content

Test that you can't implement Unpin for a compiler-generated future using TAIT#157069

Open
Darksonn wants to merge 1 commit into
rust-lang:mainfrom
Darksonn:unpin-for-fut-tait
Open

Test that you can't implement Unpin for a compiler-generated future using TAIT#157069
Darksonn wants to merge 1 commit into
rust-lang:mainfrom
Darksonn:unpin-for-fut-tait

Conversation

@Darksonn

Copy link
Copy Markdown
Member

I came up with this while trying to break pinning. Seems like a good idea to have a test that this doesn't change.

r? @RalfJung

@rustbot rustbot added 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. labels May 28, 2026
@rustbot

rustbot commented May 28, 2026

Copy link
Copy Markdown
Collaborator

RalfJung is not on the review rotation at the moment.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@Darksonn Darksonn force-pushed the unpin-for-fut-tait branch from 7023463 to 307310c Compare May 29, 2026 06:15
Comment on lines +19 to +20
impl Unpin for MyFut {}
//~^ ERROR: only traits defined in the current crate can be implemented for arbitrary types

@RalfJung RalfJung May 29, 2026

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.

That's an odd error, the type is defined in the current trait.

Is there an attribute we can add to this impl so that it is allowed to unfold the opaque? Cc @oli-obk @lcnr

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All compiler-generated futures should probably come with an implicit impl !Unpin so that this doesn't rely on orphan rules.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

opaque types are always considered to be an unknown type. You cannot get their underlying type during coherence (and we don't allow auto trait leakage during coherence either)

we may want to improve the diagnostics here, but it is very much intended that impls can't look into opaque types.

We could in theory add the functionality to reveal opaque types during coherence, and at this point either manually implement !Unpin for couroutines, forbid impls on coroutines by treating them as foreign, or sth else. But for now that doesn't matter as you cannot reveal opaque types during coherence checking at all

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.

5 participants