-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Literal overflow warnings should only apply to decimal. #24361
Comments
Triage: @rust-lang/lang , what do you think about this? This does still warn today, and I'm not sure where i stand, personally. |
I would say that |
I agree with @eddyb Also, regarding the |
I'm going to go ahead and close this as I think we've essentially intentionally chosen a path here and I believe the suggestion has been implemented, if indirectly, by showing what the literal in i16 would be. It seems like largely writing the "end result" or allowing the lint is an acceptable tradeoff. |
E.g. 0x8888i16 should not warn. Similar to binary operations | and &, hexadecimal, binary, and octal literals are often used to specify the concrete representation in memory whereas decimal literals are used to represent abstract values.
Also note that -(0x8000i16) which evaluates to -32768 (hex: 0x8000i16, which is the minimum value of i16) currently does not warn.
cc #22020
reincarnation of #23463
The text was updated successfully, but these errors were encountered: