Support nested use closures
This commit is contained in:
parent
4cbca777ea
commit
38b4746d82
2 changed files with 23 additions and 1 deletions
|
@ -209,7 +209,9 @@ impl<'a> Parser<'a> {
|
||||||
let check_pub = def == &Defaultness::Final;
|
let check_pub = def == &Defaultness::Final;
|
||||||
let mut def_ = || mem::replace(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()?
|
self.parse_use_item()?
|
||||||
} else if self.check_fn_front_matter(check_pub, case) {
|
} else if self.check_fn_front_matter(check_pub, case) {
|
||||||
// FUNCTION ITEM
|
// 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…
Add table
Add a link
Reference in a new issue