-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
proc-macros should not automatically error on token groups that are "locally" syntactically correct #108385
Comments
We've had this discussion before about literals that are out of range of the maximal literal, and IIRC the consensus was that these should fail to lex into tokens and therefore not work. I can't remember the exact discussion though. |
So Rust does literal verification at lex time? I could imagine it doing steps like separating "-123.0f32" into groups like "- 123 . 0 f32" but it should detect and fail on overflow at another stage. If it lexes into some canonical form early on, what it should do for cases that don't match what Rust supports, is it should continue with the tokens as raw, and then normal Rust can fail on that case later and proc-macros can do what they want. |
It has been a while since I looked at |
Additionally, it looks like overflow checks are in fact happening after the lexing stage, because
doesn't produce any errors, so it looks to me like there are definitely unnecessary restrictions in place |
The discussion above about overflow does not seem germane. If |
The thing about |
My limited understanding is that
TokenStreams
inputs and outputs for proc-macros have to abide to some minimal level of syntax (e.x. can't have mismatched delimiters outside of string literals), but everything else should be fair game for the proc-macro to handle (please edit the title if there is a better term for what I am describing). However, I found a case where the proc-macro system will forcibly error just because Rust doesn't support it, and it doesn't involve any special delimiters.I am adding hexadecimal, binary, etc floating point support to my awint crate and encountered this problem:
this is frustrating because it works if I chose some other closely related convention like
0j123.456_i256f128
.I am titling this issue more generally because I want to make sure there are not other cases like it.
The text was updated successfully, but these errors were encountered: