Gate const closures even when they appear in macros

This commit is contained in:
Michael Goulet 2023-03-11 21:29:15 +00:00
parent bd4355500a
commit c3159b851a
5 changed files with 29 additions and 15 deletions

View file

@ -1196,9 +1196,13 @@ impl<'a> Parser<'a> {
self.parse_constness_(case, false)
}
/// Parses constness for closures
fn parse_closure_constness(&mut self, case: Case) -> Const {
self.parse_constness_(case, true)
/// Parses constness for closures (case sensitive, feature-gated)
fn parse_closure_constness(&mut self) -> Const {
let constness = self.parse_constness_(Case::Sensitive, true);
if let Const::Yes(span) = constness {
self.sess.gated_spans.gate(sym::const_closures, span);
}
constness
}
fn parse_constness_(&mut self, case: Case, is_closure: bool) -> Const {