Skip to content

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

Closed

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...)

Activity

  1. Mark-Simulacrum commented on May 18, 2017

    @Mark-Simulacrum
    Member

    This works today; E-needstest.

  2. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on May 18, 2017
  3. venkatagiri commented on May 25, 2017

    @venkatagiri
    Contributor

    @Mark-Simulacrum would a run-pass be fine for this?

  4. Mark-Simulacrum commented on May 25, 2017

    @Mark-Simulacrum
    Member

    Let's go with a compile-fail test that look something like this one; meaningful part being these two lines. Let me know if you have any more questions!

  5. added a commit that references this issue on May 26, 2017
    e988851
  6. added 2 commits that reference this issue on May 26, 2017
    076a422
    2c3aa91
  7. added and removed on Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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