-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Redundant type specification in const definitions #37950
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This problem is discussed in rfcs repo. rust-lang/rfcs#1349 |
I think it would be very bad if the type of a const would depend on where its used inside the crate (or even worse where its used outside of the crate). |
@est31 That's not their point, but rather that the initializer expression is already fully typed. Unlike functions, global constants and statics have their values exposed, so the type being deduced wouldn't be too far of a stretch - it is, however, not possible to implement at the moment. |
@eddyb allowing they types of constants to be derived when the initializer expression is fully typed would still mean that there is an "inconsistency" to what let does. I agree that in this particular example it is silly to have to specify the type though. |
Yes, this is being tracked by rust-lang/rfcs#1349. Thanks @JinShil ! |
The following const expression appears unambiguous...
...but to get it to compile, the type must be redundantly specified
Fixing this seems in line with the Rust 2017 Roadmap item, explicit types on statics and constants
Interestingly, this works fine...
...so, the grammar appears inconsistent.
The text was updated successfully, but these errors were encountered: