diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-17 20:41:34 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-21 14:20:00 -0800 |
| commit | a98d20a260883739f5c31d67fc0d5918863742d1 (patch) | |
| tree | 153dd84c8505890e0494c519702d3b67ca4ce5e7 | |
| parent | e969fb2176afa6b82f44256b62c777193b972742 (diff) | |
| download | rust-a98d20a260883739f5c31d67fc0d5918863742d1.tar.gz rust-a98d20a260883739f5c31d67fc0d5918863742d1.zip | |
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.
| -rw-r--r-- | src/librustc_mir/transform/check_consts/ops.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc_mir/transform/check_consts/ops.rs b/src/librustc_mir/transform/check_consts/ops.rs index 950f48f03cd..acad56be604 100644 --- a/src/librustc_mir/transform/check_consts/ops.rs +++ b/src/librustc_mir/transform/check_consts/ops.rs @@ -52,7 +52,11 @@ pub trait NonConstOp: std::fmt::Debug { /// A `Downcast` projection. #[derive(Debug)] pub struct Downcast; -impl NonConstOp for Downcast {} +impl NonConstOp for Downcast { + fn feature_gate(tcx: TyCtxt<'_>) -> Option<bool> { + Some(tcx.features().const_if_match) + } +} /// A function call where the callee is a pointer. #[derive(Debug)] |
