From dbd126901ac7d6ee886e0a234e630b1fbfec9afd Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 18 Jul 2021 03:34:50 +0200 Subject: Add feature gates for `for` and `?` in consts --- compiler/rustc_passes/src/check_const.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_passes/src/check_const.rs') diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index 6ee54cfe37f..f6a93f5e02d 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -40,13 +40,14 @@ impl NonConstExpr { use hir::MatchSource::*; let gates: &[_] = match self { - // A `for` loop's desugaring contains a call to `IntoIterator::into_iter`, - // so they are not yet allowed. - // Likewise, `?` desugars to a call to `Try::into_result`. - Self::Loop(ForLoop) | Self::Match(ForLoopDesugar | TryDesugar | AwaitDesugar) => { + Self::Match(AwaitDesugar) => { return None; } + Self::Loop(ForLoop) | Self::Match(ForLoopDesugar) => &[sym::const_for], + + Self::Match(TryDesugar) => &[sym::const_try], + Self::Match(IfLetGuardDesugar) => bug!("`if let` guard outside a `match` expression"), // All other expressions are allowed. -- cgit 1.4.1-3-g733a5