Implement float literals in valtree#98825
Implement float literals in valtree#98825compiler-errors wants to merge 1 commit intorust-lang:masterfrom
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.
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