-
Notifications
You must be signed in to change notification settings - Fork 544
Remove tuple index carve out #1966
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
base: master
Are you sure you want to change the base?
Conversation
The grammar is defined by the AST. It is essentially the pre-expansion accepted text, or to think of it another way, it is the valid input to a macro metavariable. I haven't looked at your PR to determine exactly what it does, but from what I can tell it rejects the suffix at parsing time. So I think the new grammar is something like:
Personally I think that is weird, and would be simpler if it could just be DEC_LITERAL. However, since it is an exact textual match, it still has the oddity that |
It really does feel weird, because e.g. let _x = (4,).0x0;
^^^ clearly does not work... before or after my PR. |
To be clear, that does parse successfully. For example: // Parse, but don't process:
#[cfg(false)]
fn f() {
let _x = (4,).0x0;
}
// Or via a macro:
macro_rules! m {
($e:expr) => {};
}
fn main() {
m!((4,).0x0);
}
|
Right... I'll update it to
like you suggested. |
9994c12
to
89311c3
Compare
This is being proposed to be removed in <rust-lang/rust#145463> as we never intended for this to be valid syntax. Also include an invalid tuple index with underscore example.
89311c3
to
dcfbebe
Compare
Included let underscore = example.0_0; // ERROR no field `0_0` on type `(&str, &str, &str)` example. |
Caution
This should only be merged after FCP on rust-lang/rust#145463 passes and the PR is itself merged.
This is being proposed to be removed in rust-lang/rust#145463 as we never intended for this to be valid syntax. The concrete example forms are in the nomination report in rust-lang/rust#145463 (comment).
Outdated discussion on the grammar
Note on
TUPLE_INDEX
This production looks wrong to me
INTEGER_LITERAL
covers all the decimal, binary, octal and hex literal forms, but AFAICTTUPLE_INDEX
as implemented does not even accept the full range of decimal syntax. I.e.but e.g.
I believe the accepted
TUPLE_INDEX
grammar here is onlyLet me know if that sounds right.