Rollup merge of #145604 - compiler-errors:static-closure, r=fmease

Gate static closures behind a parser feature

I'd like to gate `static ||` closures behind a feature gate, since we shouldn't allow people to take advantage of this syntax if it's currently unstable. Right now, since it's only rejected after ast lowering, it's accessible to macros.

Let's crater this to see if we can claw it back without breaking anyone's code.
This commit is contained in:
Jacob Pratt
2025-08-21 17:57:52 -04:00
committed by GitHub
10 changed files with 67 additions and 24 deletions

View File

@@ -2409,8 +2409,12 @@ impl<'a> Parser<'a> {
let constness = self.parse_closure_constness();
let movability =
if self.eat_keyword(exp!(Static)) { Movability::Static } else { Movability::Movable };
let movability = if self.eat_keyword(exp!(Static)) {
self.psess.gated_spans.gate(sym::coroutines, self.prev_token.span);
Movability::Static
} else {
Movability::Movable
};
let coroutine_kind = if self.token_uninterpolated_span().at_least_rust_2018() {
self.parse_coroutine_kind(Case::Sensitive)