diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2025-02-21 17:38:30 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2025-03-06 17:58:34 -0300 |
| commit | 65d65e5e7eac02bfbb9f4053b7ec0db8f4c0f183 (patch) | |
| tree | f9283d91594ae348a3ed8d6ecd35705df6c9977c | |
| parent | 4e6407ab947314480f3b978a20f9b0685ad59f78 (diff) | |
| download | rust-65d65e5e7eac02bfbb9f4053b7ec0db8f4c0f183.tar.gz rust-65d65e5e7eac02bfbb9f4053b7ec0db8f4c0f183.zip | |
Parse and allow const use closures
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 6 | ||||
| -rw-r--r-- | tests/ui/ergonomic-clones/closure/const-closure.rs | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 7dabc28c645..4ec8d9e5e49 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -813,9 +813,9 @@ impl<'a> Parser<'a> { self.is_keyword_ahead(0, &[kw::Const]) && self.look_ahead(1, |t| match &t.kind { // async closures do not work with const closures, so we do not parse that here. - token::Ident(kw::Move | kw::Static, IdentIsRaw::No) | token::OrOr | token::Or => { - true - } + token::Ident(kw::Move | kw::Use | kw::Static, IdentIsRaw::No) + | token::OrOr + | token::Or => true, _ => false, }) } diff --git a/tests/ui/ergonomic-clones/closure/const-closure.rs b/tests/ui/ergonomic-clones/closure/const-closure.rs new file mode 100644 index 00000000000..6b4de824df9 --- /dev/null +++ b/tests/ui/ergonomic-clones/closure/const-closure.rs @@ -0,0 +1,11 @@ +//@ check-pass + +#![feature(const_closures)] +#![feature(ergonomic_clones)] +#![allow(incomplete_features)] + +const fn foo() { + let cl = const use || {}; +} + +fn main() {} |
