Skip to content

TAIT: closure and RPIT causes "concrete type differs from previous defining opaque type use" #122775

Closed
@Dirbaio

Description

@Dirbaio

Replacing -> impl Sized with -> F in fn spawn makes it compile, so it feels to me the RPIT version should be accepted too.

This is minimized from the embassy-executor task macro.

playground

#![feature(type_alias_impl_trait)]

fn spawn<T, F>(future: F) -> impl Sized
where
    F: FnOnce() -> T,
{
    future
}

fn spawn_task(sender: &'static ()) -> impl Sized {
    type Tait = impl Sized + 'static;
    spawn::<Tait, _>(move || sender)
}
error: concrete type differs from previous defining opaque type use
  --> src/lib.rs:12:30
   |
12 |     spawn::<Tait, _>(move || sender)
   |                              ^^^^^^ expected `Tait`, got `&'static ()`
   |
note: previous use here
  --> src/lib.rs:12:5
   |
12 |     spawn::<Tait, _>(move || sender)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

bisected:

searched nightlies: from nightly-2024-03-14 to nightly-2024-03-20
regressed nightly: nightly-2024-03-16
searched commit range: f4b771b...c67326b
regressed commit: 1ca424c

bisected with cargo-bisect-rustc v0.6.8

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --preserve 

@rustbot label F-type-alias-impl-trait

Metadata

Metadata

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-trait-systemArea: Trait systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions