-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Global const expr with macro causes compiler panic #29093
Comments
So, first const X: i32 = match Some(0) { _ => 10 }; The compiler panic doesn't require a macro, this will ICE in exactly same way: pub const PACKET_BUFFER_SIZE : usize = match Some(10) {
Some(x) => 1,
None => 1,
}; It seems that any binding inside the match will ICE instead of just giving the 'unsupported expression type in const expression' error. |
@cristicbz BTW, How can I achieve my first intend? |
The problem is you can't get the value out of an |
@cristicbz Thank you for your helpful comment :) |
…ixes rust-lang#31577, fixes rust-lang#29093, and fixes rust-lang#40012.
…, r=arielb1 Fixed ICEs with pattern matching in const expression Fixed 2 ICEs with when pattern matching inside a constant expression. Both of these ICEs now resolve to an appropriate compiler error. 1. ICE was caused by a compiler bug to implement discriminant const qualify. I removed this intentionally thrown bug and changed it to a FIXME as the unimplemented expression type is handled as a compiler error elsewhere. 2. ICE was caused during a drop check when checking if a variable lifetime outlives the current scope if there was no parent scope . I've changed it to stop checking if there is no parent scope for the current scope. It is valid syntax for a const variable to be assigned a match expression with no enclosing scope. The ICE seemed to mainly be used as a defensive check for bugs elsewhere. Fixes #38199. Fixes #31577. Fixes #29093. Fixes #40012.
I would like to have compile-time evaluation of my const values
from the environment variables.
I wonder whether I had some grammar mistakes, however the compiler panics.
This occurs all stable, beta, and nightly versions (from play.rust-lang.org).
I tried this code:
I expected to see this happen:
compiles with environment variables, statically evaluated.
Instead, this happened:
compiler panic.
Meta
http://puu.sh/kM1Yo/036518bf32.png
The text was updated successfully, but these errors were encountered: