From: bors Date: Sat, 23 Nov 2019 01:13:41 +0000 (+0000) Subject: Auto merge of #66507 - ecstatic-morse:const-if-match, r=oli-obk X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=6d523ee501a1ae30428d22ce4fc3c1f720e896e6;p=rust.git Auto merge of #66507 - ecstatic-morse:const-if-match, r=oli-obk Enable `if` and `match` in constants behind a feature flag This PR is an initial implementation of #49146. It introduces a `const_if_match` feature flag and does the following if it is enabled: - Allows `Downcast` projections, `SwitchInt` terminators and `FakeRead`s for matched places through the MIR const-checker. - Allows `if` and `match` expressions through the HIR const-checker. - Stops converting `&&` to `&` and `||` to `|` in `const` and `static` items. As a result, the following operations are now allowed in a const context behind the feature flag: - `if` and `match` - short circuiting logic operators (`&&` and `||`) - the `assert` and `debug_assert` macros (if the `const_panic` feature flag is also enabled) However, the following operations remain forbidden: - `while`, `loop` and `for` (see #52000) - the `?` operator (calls `From::from` on its error variant) - the `assert_eq` and `assert_ne` macros, along with their `debug` variants (calls `fmt::Debug`) This PR is possible now that we use dataflow for const qualification (see #64470 and #66385). r? @oli-obk cc @rust-lang/wg-const-eval @eddyb --- 6d523ee501a1ae30428d22ce4fc3c1f720e896e6