File tree 5 files changed +54
-10
lines changed
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> {
4143
4143
( optional_unboxed_closure_kind, args)
4144
4144
}
4145
4145
} ;
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 ( )
4148
4148
} else {
4149
- P ( Ty {
4149
+ ( Return , P ( Ty {
4150
4150
id : ast:: DUMMY_NODE_ID ,
4151
4151
node : TyInfer ,
4152
4152
span : self . span ,
4153
- } )
4153
+ } ) )
4154
4154
} ;
4155
4155
4156
4156
( P ( FnDecl {
4157
4157
inputs : inputs_captures,
4158
4158
output : output,
4159
- cf : Return ,
4159
+ cf : style ,
4160
4160
variadic : false
4161
4161
} ) , optional_unboxed_closure_kind)
4162
4162
}
@@ -4169,20 +4169,20 @@ impl<'a> Parser<'a> {
4169
4169
seq_sep_trailing_allowed ( token:: COMMA ) ,
4170
4170
|p| p. parse_fn_block_arg ( ) ) ;
4171
4171
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 ( )
4174
4174
} else {
4175
- P ( Ty {
4175
+ ( Return , P ( Ty {
4176
4176
id : ast:: DUMMY_NODE_ID ,
4177
4177
node : TyInfer ,
4178
4178
span : self . span ,
4179
- } )
4179
+ } ) )
4180
4180
} ;
4181
4181
4182
4182
P ( FnDecl {
4183
4183
inputs : inputs,
4184
4184
output : output,
4185
- cf : Return ,
4185
+ cf : style ,
4186
4186
variadic : false
4187
4187
} )
4188
4188
}
Original file line number Diff line number Diff line change @@ -13,5 +13,8 @@ fn foo(f: || -> !) {}
13
13
fn main( ) {
14
14
// Type inference didn't use to be able to handle this:
15
15
foo ( || fail ! ( ) ) ;
16
+ foo( || -> ! fail ! ( ) ) ;
16
17
foo( || 22 ) ; //~ ERROR mismatched types
18
+ foo( || -> ! 22 ) ; //~ ERROR mismatched types
19
+ let x = || -> ! 1 ; //~ ERROR mismatched types
17
20
}
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>() {
78
78
79
79
let a = A ;
80
80
a. foo:: <<' a >||>( ) ;
81
+
82
+ // issue #13490
83
+ let _ = || -> ! loop { } ;
84
+ let _ = proc ( ) -> ! loop { } ;
81
85
}
82
86
83
87
struct B < T > ;
You can’t perform that action at this time.
0 commit comments