File tree Expand file tree Collapse file tree 3 files changed +47
-10
lines changed Expand file tree Collapse file tree 3 files changed +47
-10
lines changed Original file line number Diff line number Diff line change 12
12
13
13
// Predicates on exprs and stmts that the pretty-printer and parser use
14
14
15
- use ast:: { self , BlockCheckMode } ;
15
+ use ast;
16
16
17
17
/// Does this expression require a semicolon to be treated
18
18
/// as a statement? The negation of this: 'can this expression
@@ -35,13 +35,6 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
35
35
}
36
36
}
37
37
38
- pub fn expr_is_simple_block ( e : & ast:: Expr ) -> bool {
39
- match e. node {
40
- ast:: ExprKind :: Block ( ref block) => block. rules == BlockCheckMode :: Default ,
41
- _ => false ,
42
- }
43
- }
44
-
45
38
/// this statement requires a semicolon after it.
46
39
/// note that in one case (`stmt_semi`), we've already
47
40
/// seen the semicolon, and thus don't need another.
Original file line number Diff line number Diff line change @@ -3209,8 +3209,7 @@ impl<'a> Parser<'a> {
3209
3209
self . expect ( & token:: FatArrow ) ?;
3210
3210
let expr = self . parse_expr_res ( RESTRICTION_STMT_EXPR , None ) ?;
3211
3211
3212
- let require_comma =
3213
- !classify:: expr_is_simple_block ( & expr)
3212
+ let require_comma = classify:: expr_requires_semi_to_be_stmt ( & expr)
3214
3213
&& self . token != token:: CloseDelim ( token:: Brace ) ;
3215
3214
3216
3215
if require_comma {
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 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
+ fn main ( ) {
12
+ let x = 1 ;
13
+
14
+ match x {
15
+ 1 => loop { break ; } ,
16
+ 2 => while true { break ; } ,
17
+ 3 => if true { ( ) } ,
18
+ 4 => if true { ( ) } else { ( ) } ,
19
+ 5 => match ( ) { ( ) => ( ) } ,
20
+ 6 => { ( ) } ,
21
+ 7 => unsafe { ( ) } ,
22
+ _ => ( ) ,
23
+ }
24
+
25
+ match x {
26
+ 1 => loop { break ; }
27
+ 2 => while true { break ; }
28
+ 3 => if true { ( ) }
29
+ 4 => if true { ( ) } else { ( ) }
30
+ 5 => match ( ) { ( ) => ( ) }
31
+ 6 => { ( ) }
32
+ 7 => unsafe { ( ) }
33
+ _ => ( )
34
+ }
35
+
36
+ let r: & i32 = & x;
37
+
38
+ match r {
39
+ // Absence of comma should not cause confusion between a pattern
40
+ // and a bitwise and.
41
+ & 1 => if true { ( ) } else { ( ) }
42
+ & 2 => ( ) ,
43
+ _ =>( )
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments