Add feature gates for for
and ?
in consts
This commit is contained in:
parent
a985d8e6c7
commit
dbd126901a
8 changed files with 91 additions and 4 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue