Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
estebank opened this issue May 8, 2019 · 0 comments · Fixed by #61441
Closed

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

estebank opened this issue May 8, 2019 · 0 comments · Fixed by #61441
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools

Comments

@estebank
Copy link
Contributor

estebank commented May 8, 2019

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

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels May 8, 2019
Centril added a commit to Centril/rust that referenced this issue Jun 2, 2019
Tweak wording when encountering `fn` call in pattern

Fix rust-lang#60642
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant