-
Notifications
You must be signed in to change notification settings - Fork 520
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
Minimum signed integer literal #779
Comments
Yea, I see how that could be confusing. I think the key point is that it is treated that way at the syntactic level (here is the parser where it is immediately interpreted as unary operator). At the semantic level it has a particular meaning which is AFAIK undocumented. One situation where it really matters is for a macro consuming tokens. I'm not sure where/how this should be described. Maybe something in Negation operators? I don't really know how constants work internally. |
cc @oli-obk |
While the parser and the AST consider |
Thanks! Yea, I think those should cover the negation behavior. |
In the section about integer literals, the Reference says:
However, this is a bit misleading due to the way Rust handles literals that are "out of range": values like
-128i8
actually work (due to const eval?). AFAIK you can use any integer literal in the range[0, 2^128)
as long as it evaluates to something in range, but either way things get a bit weird. For example:Playground
The text was updated successfully, but these errors were encountered: