Skip to content

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

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Darksonn:unpin-for-fut-tait
Jun 12, 2026
Merged

Test that you can't implement Unpin for a compiler-generated future using TAIT#157069
rust-bors[bot] merged 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


async fn my_async_fn() {}

#[define_opaque(MyFut)]

@RalfJung RalfJung Jun 11, 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.

Does adding this attribute to the impl change anything?
That's kind of how I'd assume I can circumvent the error.

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.

I believe all this attribute does is declare that this use of MyFut is the usage that defines what the type alias should correspond to.

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.

not really, for now the attribute is only allowed on things with bodies as only typeck/borrowck can define opaques. But even so, we would probably not allow revealing the hidden type when checking impl headers

@RalfJung

Copy link
Copy Markdown
Member

@bors r=lcnr,RalfJung rollup

@rust-bors

rust-bors Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 307310c has been approved by lcnr,RalfJung

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jun 12, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 12, 2026
…r,RalfJung

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

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
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 12, 2026
…r,RalfJung

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

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
rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #156950 (Staticlib rename internal symbols)
 - #157322 (test pre-stabilization items on CI)
 - #157490 (Add field-wise CoerceShared reborrow tests)
 - #157655 (Make Share::share final and improve docs)
 - #157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - #157796 (rustdoc: Some more lazy formatting)
 - #157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - #157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - #157622 (Disable retagging for variadic arguments in const-eval)
 - #157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - #157695 (Extend capabilities of `TypeFoldable_Generic`)
 - #157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
 - #157766 (interpret: avoid computing layout of sized raw pointee)
 - #157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - #157795 (revert 157013)
 - #157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - #157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))
rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #156950 (Staticlib rename internal symbols)
 - #157322 (test pre-stabilization items on CI)
 - #157490 (Add field-wise CoerceShared reborrow tests)
 - #157655 (Make Share::share final and improve docs)
 - #157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - #157796 (rustdoc: Some more lazy formatting)
 - #157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - #157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - #157622 (Disable retagging for variadic arguments in const-eval)
 - #157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - #157695 (Extend capabilities of `TypeFoldable_Generic`)
 - #157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
 - #157766 (interpret: avoid computing layout of sized raw pointee)
 - #157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - #157795 (revert 157013)
 - #157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - #157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 12, 2026
…r,RalfJung

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

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
rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #144220 (Add powerpc64-unknown-linux-gnuelfv2 target)
 - #153238 (debuginfo: slices are DW_TAG_array_type's)
 - #157112 (Update aarch64-unknown-freebsd target description)
 - #157322 (test pre-stabilization items on CI)
 - #157348 (Don't track cwd for `-Zremap-cwd-prefix` in incremental compilation)
 - #157490 (Add field-wise CoerceShared reborrow tests)
 - #157655 (Make Share::share final and improve docs)
 - #157672 (Region inference: Simplify initialisation of region values)
 - #157680 (Require `#[pin_v2]` for explicit pin-projection patterns)
 - #157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - #157796 (rustdoc: Some more lazy formatting)
 - #157818 (miri subtree update)
 - #157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - #157079 (Don't recover `&raw EXPR` as a missing comma)
 - #157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - #157622 (Disable retagging for variadic arguments in const-eval)
 - #157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - #157695 (Extend capabilities of `TypeFoldable_Generic`)
 - #157766 (interpret: avoid computing layout of sized raw pointee)
 - #157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - #157795 (revert 157013)
 - #157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - #157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))

Failed merges:

 - #157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
@rust-bors rust-bors Bot merged commit 55885d4 into rust-lang:main Jun 12, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 12, 2026
rust-timer added a commit that referenced this pull request Jun 12, 2026
Rollup merge of #157069 - Darksonn:unpin-for-fut-tait, r=lcnr,RalfJung

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

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
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jun 13, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - rust-lang/rust#144220 (Add powerpc64-unknown-linux-gnuelfv2 target)
 - rust-lang/rust#153238 (debuginfo: slices are DW_TAG_array_type's)
 - rust-lang/rust#157112 (Update aarch64-unknown-freebsd target description)
 - rust-lang/rust#157322 (test pre-stabilization items on CI)
 - rust-lang/rust#157348 (Don't track cwd for `-Zremap-cwd-prefix` in incremental compilation)
 - rust-lang/rust#157490 (Add field-wise CoerceShared reborrow tests)
 - rust-lang/rust#157655 (Make Share::share final and improve docs)
 - rust-lang/rust#157672 (Region inference: Simplify initialisation of region values)
 - rust-lang/rust#157680 (Require `#[pin_v2]` for explicit pin-projection patterns)
 - rust-lang/rust#157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images)
 - rust-lang/rust#157796 (rustdoc: Some more lazy formatting)
 - rust-lang/rust#157818 (miri subtree update)
 - rust-lang/rust#157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT)
 - rust-lang/rust#157079 (Don't recover `&raw EXPR` as a missing comma)
 - rust-lang/rust#157202 (add #[rustc_no_writable] to slice::get_unchecked_mut)
 - rust-lang/rust#157622 (Disable retagging for variadic arguments in const-eval)
 - rust-lang/rust#157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver)
 - rust-lang/rust#157695 (Extend capabilities of `TypeFoldable_Generic`)
 - rust-lang/rust#157766 (interpret: avoid computing layout of sized raw pointee)
 - rust-lang/rust#157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia)
 - rust-lang/rust#157795 (revert 157013)
 - rust-lang/rust#157798 (Prevent approving PRs that wait for Crater or formal decisions)
 - rust-lang/rust#157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N))

Failed merges:

 - rust-lang/rust#157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
@Darksonn Darksonn deleted the unpin-for-fut-tait branch June 13, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants