-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Inconsistency with 1-tuples #4898
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
Comments
I am going to go ahead and implement 1-tuple literals in a branch (with the same syntax as patterns) and see how ugly it ends up making things. |
1-tuples strike me as a bit silly; if it's solvable inside the macro I'd prefer that. Otherwise I won't lose a ton of sleep over 1-tuples. The biggest risk to me seems to be in the grammar, concerning potential ambiguity of commas, and I imagine any such risks are already present. |
Still to-do: to_str and eq impls for 1-tuples (needs a snapshot). I guess we might as well... |
Also needing a snapshot: fix repr, and add a test to the exact_repr tests. |
r? @graydon - This is for greater uniformity (for example, macros that generate tuples). rustc already supported 1-tuple patterns, but there was no way to construct a 1-tuple term. @graydon , as far as your comment on #4898 - it did turn out to be solvable inside the macro (since @luqmana already fixed it using structs instead), but I still think it's a good idea to allow 1-tuples, for uniformity. I don't think anyone is likely to trip over it, and I'm not too worried that it changes the amount of ambiguity.
looks like there is a test in for this now; is it done? |
non-critical for 0.6, de-milestoning |
It's not done yet -- there were some parts waiting for a snapshot, which has happened now. |
Done, pending bors (#5547) |
Done in 5011d05 |
We allow patterns on 1-tuples, at least in theory:
The parser code for 1-tuple patterns didn't quite work as intended, and I fixed that. But then I ran into the problem that I couldn't write a test because there's no way to write a 1-tuple literal or type (
(x)
gets parsed asx
).Is this intentional? It seems like if we're going to allow 1-tuple patterns, we should also allow 1-tuple terms (perhaps with the same
(x,)
syntax?)This came up, as you might expect, because of macros: I was trying to replace structural records with tuples in the pipes code (that seemed easier than dynamically generating new struct type names) and I ran into the parser problem, which I was able to fix but not test.
The text was updated successfully, but these errors were encountered: