-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
I tried this code:
playground
#![feature(type_alias_impl_trait)]
type Foo = impl Sized;
#[define_opaque(Foo)]
fn foo() -> Foo {
0i32
}
fn bar() {
type Bar = Foo;
}
fn main() {}I expected to see this happen: code checks, just like this one (type alias moved out from the function):
#![feature(type_alias_impl_trait)]
type Foo = impl Sized;
#[define_opaque(Foo)]
fn foo() -> Foo {
0i32
}
type Bar = Foo;
fn bar() {}
fn main() {}Instead, this happened:
error: item does not constrain `Foo::{opaque#0}`
--> src/main.rs:10:4
|
10 | fn bar() {
| ^^^
|
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
note: this opaque type is supposed to be constrained
--> src/main.rs:3:12
|
3 | type Foo = impl Sized;
| ^^^^^^^^^^
error: could not compile `play` (bin "play") due to 1 previous error
Meta
rustc --version --verbose:
> rustc --version --verbose
rustc 1.93.0-nightly (adaa83897 2025-10-27)
binary: rustc
commit-hash: adaa838976ff99a4f0661136322f64cb466b58a0
commit-date: 2025-10-27
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.3
fmease
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.