Skip to content

TAIT: combining those types cannot compile #139003

Open
@Ddystopia

Description

@Ddystopia

Code:

#![feature(type_alias_impl_trait)]

type A = impl Sized;
type B = impl Future<Output = A>;

#[define_opaque(A)]
fn a() -> A {
    5
}

#[define_opaque(B)]
fn b(a: A) -> B {
    async { a }
}

// Or like this too:
//
// #[define_opaque(B)]
// fn b() -> B {
//     async { a() }
// }

I expected it to compile, but instead got an error:

 error: item does not constrain `A::{opaque#0}`
   --> src/main.rs:12:4
    |
 12 | fn b(a: A) -> B {
    |    ^
    |
    = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
 note: this opaque type is supposed to be constrained
   --> src/main.rs:3:10
    |
 3  | type A = impl Sized;
    |

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (b48576b4d 2025-03-22)
binary: rustc
commit-hash: b48576b4db5a595f453891f0b7243ef75d8c0afa
commit-date: 2025-03-22
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-typesRelevant to the types 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