-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: ..
in patterns
#1492
RFC: ..
in patterns
#1492
Conversation
cf5dc8c
to
2cd24ce
Compare
[unresolved]: #unresolved-questions | ||
|
||
Sublist binding syntax conflicts with possible exclusive range patterns | ||
`begin .. end`/`begin..`/`..end`. This problem already exists for slice patterns and has to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slice patterns are unstable (and buggy), and thus can easily be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extensions proposed in this RFC are going to be unstable too and are supposed to be changed together with slice patterns if changed at all.
Should |
Yes, |
This was pretty Always The Plan -- but we never did it because it involved work. I'm basically 👍 though I've not read the details of the RFC. |
And split `PatKind::Enum` into `PatKind::TupleStruct` and `PatKind::Path`. This is the HIR part of #31581. This is also kind of a preparation for rust-lang/rfcs#1492. r? @eddyb
Implementation (without sub-list bindings): rust-lang/rust#32079 |
Nominating for FCP. |
Hear ye, hear ye! This RFC is now entering final comment period. |
@petrochenkov very well... to be honest I've not read this closely, though I'm in favor of the spirit. We had decided to put this into FCP, but would you rather we wait? (We can keep your proposed edit in mind, I imagine.) |
[subpat1, .., subpatN] | ||
// Slice patterns, any of the above with a subslice binding. | ||
// By ref bindings are allowed, slices and subslices always have compatible layouts. | ||
[subpat1, binding.., subpatN] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this binding
mean? This feels like it overlaps with slice patterns, which (I think) still require some further RFC to "complete"? I can't remember if we postponed that work or not. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this binding mean?
A subslice pattern, see above - "The binding is not actually a binding, but one more pattern ..."
I'd be (more) in favor of a variant of this that excludes all "bindings". In other words, allowing:
and I'd probably prefer to exclude The binding forms introduce complicated semantics. |
This RFC doesn't propose any changes to slice patterns, it only uses them for analogy.
With this I agree. |
Huh. OK, I must have misread it. So much the better. |
I missed that subtlety too - maybe removing the slice examples might make it clearer? |
Huzzah! The @rust-lang/lang team has decided to accept this RFC. Specifically:
|
Tracking issue: rust-lang/rust#33627 If you'd like to keep following the development of this feature, please subscribe to that issue, thanks! :) |
And split `PatKind::Enum` into `PatKind::TupleStruct` and `PatKind::Path`. This is the HIR part of rust-lang/rust#31581. This is also kind of a preparation for rust-lang/rfcs#1492. r? @eddyb
Permit the
..
pattern fragment in more contexts.Rendered