File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
compiler/rustc_parse/src/parser
tests/ui/ergonomic-clones/closure Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,10 @@ impl<'a> Parser<'a> {
209209 let check_pub = def == & Defaultness :: Final ;
210210 let mut def_ = || mem:: replace ( def, Defaultness :: Final ) ;
211211
212- let info = if self . eat_keyword_case ( exp ! ( Use ) , case) {
212+ let info = if !self
213+ . look_ahead ( 1 , |t| [ token:: OrOr , token:: BinOp ( token:: BinOpToken :: Or ) ] . contains ( & t. kind ) )
214+ && self . eat_keyword_case ( exp ! ( Use ) , case)
215+ {
213216 self . parse_use_item ( ) ?
214217 } else if self . check_fn_front_matter ( check_pub, case) {
215218 // FUNCTION ITEM
Original file line number Diff line number Diff line change 1+ //@ run-pass
2+
3+ #![ feature( ergonomic_clones) ]
4+
5+ use std:: marker:: UseCloned ;
6+
7+ #[ derive( Clone ) ]
8+ struct Foo ;
9+
10+ impl UseCloned for Foo { }
11+
12+ fn work ( _: Box < Foo > ) { }
13+ fn foo < F : FnOnce ( ) > ( _: F ) { }
14+
15+ pub fn main ( ) {
16+ let a = Box :: new ( Foo ) ;
17+ foo ( use || { foo ( use || { work ( a) } ) } ) ;
18+ let x = use || { use || { Foo } } ;
19+ let _y = x ( ) ;
20+ }
You can’t perform that action at this time.
0 commit comments