File tree Expand file tree Collapse file tree 5 files changed +54
-10
lines changed Expand file tree Collapse file tree 5 files changed +54
-10
lines changed Original file line number Diff line number Diff line change @@ -4143,20 +4143,20 @@ impl<'a> Parser<'a> {
41434143 ( optional_unboxed_closure_kind, args)
41444144 }
41454145 } ;
4146- let output = if self . eat ( & token:: RARROW ) {
4147- self . parse_ty ( true )
4146+ let ( style , output) = if self . token == token :: RARROW {
4147+ self . parse_ret_ty ( )
41484148 } else {
4149- P ( Ty {
4149+ ( Return , P ( Ty {
41504150 id : ast:: DUMMY_NODE_ID ,
41514151 node : TyInfer ,
41524152 span : self . span ,
4153- } )
4153+ } ) )
41544154 } ;
41554155
41564156 ( P ( FnDecl {
41574157 inputs : inputs_captures,
41584158 output : output,
4159- cf : Return ,
4159+ cf : style ,
41604160 variadic : false
41614161 } ) , optional_unboxed_closure_kind)
41624162 }
@@ -4169,20 +4169,20 @@ impl<'a> Parser<'a> {
41694169 seq_sep_trailing_allowed ( token:: COMMA ) ,
41704170 |p| p. parse_fn_block_arg ( ) ) ;
41714171
4172- let output = if self . eat ( & token:: RARROW ) {
4173- self . parse_ty ( true )
4172+ let ( style , output) = if self . token == token :: RARROW {
4173+ self . parse_ret_ty ( )
41744174 } else {
4175- P ( Ty {
4175+ ( Return , P ( Ty {
41764176 id : ast:: DUMMY_NODE_ID ,
41774177 node : TyInfer ,
41784178 span : self . span ,
4179- } )
4179+ } ) )
41804180 } ;
41814181
41824182 P ( FnDecl {
41834183 inputs : inputs,
41844184 output : output,
4185- cf : Return ,
4185+ cf : style ,
41864186 variadic : false
41874187 } )
41884188 }
Original file line number Diff line number Diff line change @@ -13,5 +13,8 @@ fn foo(f: || -> !) {}
1313fn main( ) {
1414 // Type inference didn't use to be able to handle this:
1515 foo ( || fail ! ( ) ) ;
16+ foo( || -> ! fail ! ( ) ) ;
1617 foo( || 22 ) ; //~ ERROR mismatched types
18+ foo( || -> ! 22 ) ; //~ ERROR mismatched types
19+ let x = || -> ! 1 ; //~ ERROR mismatched types
1720}
Original file line number Diff line number Diff line change 1+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ deny( unreachable_code) ]
12+
13+ fn main ( ) {
14+ let x: || -> ! = || fail ! ( ) ;
15+ x ( ) ;
16+ println ! ( "Foo bar" ) ; //~ ERROR: unreachable statement
17+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ allow( dead_code) ]
12+
13+ fn f ( x: || -> !) -> ! {
14+ x ( ) ;
15+ }
16+
17+ fn main ( ) {
18+ let x: || -> ! = || fail ! ( ) ;
19+ let _y: || -> ! = || x ( ) ;
20+ }
Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ fn bar<'b>() {
7878
7979 let a = A ;
8080 a. foo:: <<' a >||>( ) ;
81+
82+ // issue #13490
83+ let _ = || -> ! loop { } ;
84+ let _ = proc ( ) -> ! loop { } ;
8185}
8286
8387struct B < T > ;
You can’t perform that action at this time.
0 commit comments