mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Support nested use closures
This commit is contained in:
parent
4cbca777ea
commit
38b4746d82
@ -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
|
||||
|
20
tests/ui/ergonomic-clones/closure/nested.rs
Normal file
20
tests/ui/ergonomic-clones/closure/nested.rs
Normal 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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user