-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team
Description
I believe the following should compile but doesn't.
trait Foo {}
fn bar() -> impl Foo {
unimplemented!()
}
I get the following error:
--> src/main.rs:7:13
|
7 | fn bar() -> impl Foo {
| ^^^^^^^^ the trait `Foo` is not implemented for `()`
|
= note: the return type of a function must have a statically known size
However, this compiles:
fn bar<X: Foo>() -> X {
unimplemented!()
}
Could anybody confirm if this is a bug or I am missing something very obvious?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team