Skip to content

impl Trait doesn't understand that empty functions return () #36379

Closed
@Stebalien

Description

@Stebalien

The following should compile because (): Default:

#![feature(conservative_impl_trait)]
fn test() -> impl Default {}

However, it fails with:

error[E0282]: unable to infer enough type information about `_`
 --> tmp.rs:2:14
  |
2 | fn test() -> impl Default {}
  |              ^^^^^^^^^^^^ cannot infer type for `_`
  |
  = note: type annotations or generic parameter binding required

(Obviously, nobody will ever run into this in practice...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemA-type-systemArea: Type systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions