-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement float literals in valtree #98825
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
Implement float literals in valtree #98825
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
Not having floats in valtrees was somewhat deliberate since their equality is not very well-behaved. |
pub fn func<const F: f64>() {} | ||
|
||
fn main() { | ||
let _ = func::<14.0>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to accept this program? Obviously it shouldn't ICE, but IMO it should be rejected.
Interesting. Thanks for the info @RalfJung... in that case, how should we fix this ICE? 🤔 The code seems to assume we can always turn a const lit into a val tree..? |
(Alternatively, we could just provide some other error kind in |
My expectation was that types in constants are limited to "structural types" in some sense, and the type checker would bug out early when a non-structural type is used. And structural types are exactly those for which we can always create a valtree. |
Ah.. so ideally we shouldn't be able to use floats in a const generic to begin with... hmm yeah I guess we'll see what the others say |
jup, seems like this was an oversight in We don't want to accept floats as const parameters. The only possible equality we could use for them would by bitwise equality and that seems bad for 2 reasons:
|
@lcnr, soooo apparently we use |
Yea, I think adding a |
|
…-obk Deny float const params even when `adt_const_params` is enabled Supersedes rust-lang#98825 Fixes rust-lang#98813 r? `@oli-obk`
…-obk Deny float const params even when `adt_const_params` is enabled Supersedes rust-lang#98825 Fixes rust-lang#98813 r? ``@oli-obk``
Fixes #98813
cc: @rust-lang/wg-const-eval