-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
If expressions not evaluated for constants #37948
Comments
Your first example is evaluated at runtime, the second is evaluated at compile time. Rust doesn't currently support evaluating conditionals at compile time (support for calling functions is in the works but that doesn't cover conditionals). |
Just to clarify, I understand that one is evaluated at runtime, and the other at compile time. The reason for submitting this issue is to point out the inconsistency. That is, if if expressions are expressions, I think they should be usable just like any other expression. For example if the expression |
@JinShil Got it. That kind of issue usually goes in the rust-lang/rfcs repo (see rust-lang/rfcs#322, specifically). |
miri will make this possible, and much more. |
Yes, @Stebalien is right here. Thanks @JinShil , but we should track this in the RFCs repo (and already are) |
This works fine:
If assume, therefore, that this should work as well...
...but it fails with
The text was updated successfully, but these errors were encountered: