Support nested use closures

This commit is contained in:
Santiago Pastorino 2025-02-10 18:09:31 -03:00
parent 4cbca777ea
commit 38b4746d82
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF
2 changed files with 23 additions and 1 deletions

View File

@ -209,7 +209,9 @@ impl<'a> Parser<'a> {
let check_pub = def == &Defaultness::Final;
let mut def_ = || mem::replace(def, Defaultness::Final);
let info = if self.eat_keyword_case(exp!(Use), case) {
let info = if !self.look_ahead(1, |t| [token::OrOr, token::Or].contains(&t.kind))
&& self.eat_keyword_case(exp!(Use), case)
{
self.parse_use_item()?
} else if self.check_fn_front_matter(check_pub, case) {
// FUNCTION ITEM

View File

@ -0,0 +1,20 @@
//@ run-pass
#![feature(ergonomic_clones)]
use std::clone::UseCloned;
#[derive(Clone)]
struct Foo;
impl UseCloned for Foo {}
fn work(_: Box<Foo>) {}
fn foo<F:FnOnce()>(_: F) {}
pub fn main() {
let a = Box::new(Foo);
foo(use || { foo(use || { work(a) }) });
let x = use || { use || { Foo } };
let _y = x();
}