Pattern reform. #3271
Labels
A-codegen
Area: Code generation
A-lifetimes
Area: Lifetimes / regions
A-type-system
Area: Type system
Milestone
This is a meta-bug for the way pattern-matching is being overhauled.
The old pattern-matching rules are:
This has several drawbacks. One, the implicit-ref thing is a big pain in our semantics, causes lots of "illegal borrow unless pure" errors to confuse newbies, and once implicit-ref argument modes go away, it will be the last thing of its kind. Two, moving out of multi-branch enums is impossible. I'm sure there are more.
New rules should be:
As a transitionary step, we are adding 'move' and 'copy' keywords that are to be used the same way as 'ref' in patterns. Once match's bind-by-implicit-ref goes away, 'copy' can become the default. Once there's a way to infer which of 'move' or 'copy' is meant, 'move' can go away too.
Here are some bugs:
#3224 - Patterning on
~
pointers. Moving out should be sometimes allowed.#3024 - Patterning on
@
pointers. Moving out should never be allowed.#3235,
#3256- 'ref' working properly#3097, moves into patterns always copy
The text was updated successfully, but these errors were encountered: