Skip to content

Commit a98d20a

Browse files
Allow Downcast projections if const_if_match enabled
These are generated when matching on enum variants to extract the value within. We should have no problem evaluating these, but care should be taken that we aren't accidentally allowing some other operation.
1 parent e969fb2 commit a98d20a

File tree

1 file changed

+5
-1
lines changed
  • src/librustc_mir/transform/check_consts

1 file changed

+5
-1
lines changed

src/librustc_mir/transform/check_consts/ops.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ pub trait NonConstOp: std::fmt::Debug {
5252
/// A `Downcast` projection.
5353
#[derive(Debug)]
5454
pub struct Downcast;
55-
impl NonConstOp for Downcast {}
55+
impl NonConstOp for Downcast {
56+
fn feature_gate(tcx: TyCtxt<'_>) -> Option<bool> {
57+
Some(tcx.features().const_if_match)
58+
}
59+
}
5660

5761
/// A function call where the callee is a pointer.
5862
#[derive(Debug)]

0 commit comments

Comments
 (0)