Skip to content

Forgetting to call a variant constructor causes a confusing error message #35241

Closed
@arielb1

Description

@arielb1

STR

struct Foo(u32);

fn test() -> Foo { Foo }

fn main() {
}

Confusing result

error[E0308]: mismatched types
 --> <anon>:3:20
  |
3 | fn test() -> Foo { Foo }
  |                    ^^^ expected struct `Foo`, found fn item
  |
  = note: expected type `Foo`
  = note:    found type `fn(u32) -> Foo {Foo::{{constructor}}}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions