]> git.lizzy.rs Git - rust.git/commitdiff
Allow `Downcast` projections in `qualify_min_const_fn`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Tue, 19 Nov 2019 20:22:39 +0000 (12:22 -0800)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Fri, 22 Nov 2019 00:55:13 +0000 (16:55 -0800)
src/librustc_mir/transform/qualify_min_const_fn.rs

index c5fa9df528cc6641c2af092cc15876369f1147eb..2bc44d2e5c142d3ee7ae901b1b73b61a682cc4bd 100644 (file)
@@ -266,9 +266,10 @@ fn check_place(
     while let &[ref proj_base @ .., elem] = cursor {
         cursor = proj_base;
         match elem {
-            ProjectionElem::Downcast(..) => {
-                return Err((span, "`match` or `if let` in `const fn` is unstable".into()));
-            }
+            ProjectionElem::Downcast(..) if !tcx.features().const_if_match
+                => return Err((span, "`match` or `if let` in `const fn` is unstable".into())),
+            ProjectionElem::Downcast(_symbol, _variant_index) => {}
+
             ProjectionElem::Field(..) => {
                 let base_ty = Place::ty_from(&place.base, &proj_base, body, tcx).ty;
                 if let Some(def) = base_ty.ty_adt_def() {