Skip to content

Provide more of an explanation when using function as pattern #60642

Closed
@estebank

Description

@estebank

(Follow up to #60635 and #60641)

When trying to match on the result of a fn call, we emit:

error[E0164]: expected tuple struct/variant, found method `<A>::new`
  --> src/lib.rs:15:9
   |
15 |         A::new() => (),
   |         ^^^^^^^^ not a tuple variant or struct

We should explain that fn calls are not allowed ever in patterns, only refutable (or even irrefutable, as you can match on a struct, although it is silly) types, possibly linking to (or cribbing text from) the appropriate chapter in The Book.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions