File tree 4 files changed +69
-1
lines changed
compiler/rustc_ast_pretty/src/pprust/state
tests/pretty/postfix-match
4 files changed +69
-1
lines changed Original file line number Diff line number Diff line change @@ -488,7 +488,7 @@ impl<'a> State<'a> {
488
488
self . space ( ) ;
489
489
}
490
490
MatchKind :: Postfix => {
491
- self . print_expr_as_cond ( expr) ;
491
+ self . print_expr_maybe_paren ( expr, parser :: PREC_POSTFIX , fixup ) ;
492
492
self . word_nbsp ( ".match" ) ;
493
493
}
494
494
}
Original file line number Diff line number Diff line change
1
+ # ![feature(prelude_import)]
2
+ # ![no_std]
3
+ # ![feature(postfix_match)]
4
+ # [prelude_import]
5
+ use ::std::prelude::rust_2015::*;
6
+ # [macro_use]
7
+ extern crate std;
8
+
9
+ use std::ops::Add;
10
+
11
+ //@ pretty-mode:expanded
12
+ //@ pp-exact:precedence.pp
13
+
14
+ macro_rules! repro { ($e :expr) => { $e .match { _ => {} } }; }
15
+
16
+ struct Struct {}
17
+
18
+ impl Add<Struct> for usize {
19
+ type Output = ();
20
+ fn add(self, _: Struct) -> () { () }
21
+ }
22
+ pub fn main() {
23
+ let a;
24
+ (
25
+ { 1 } + 1).match {
26
+ _ => {}
27
+ };
28
+ (4 as usize).match { _ => {} };
29
+ (return).match { _ => {} };
30
+ (a = 42).match { _ => {} };
31
+ (|| {}).match { _ => {} };
32
+ (42..101).match { _ => {} };
33
+ (1 + Struct {}).match { _ => {} };
34
+ }
Original file line number Diff line number Diff line change
1
+ #![ feature( postfix_match) ]
2
+
3
+ use std:: ops:: Add ;
4
+
5
+ //@ pretty-mode:expanded
6
+ //@ pp-exact:precedence.pp
7
+
8
+ macro_rules! repro {
9
+ ( $e: expr) => {
10
+ $e. match {
11
+ _ => { }
12
+ }
13
+ } ;
14
+ }
15
+
16
+ struct Struct { }
17
+
18
+ impl Add < Struct > for usize {
19
+ type Output = ( ) ;
20
+ fn add ( self , _: Struct ) -> ( ) {
21
+ ( )
22
+ }
23
+ }
24
+ pub fn main ( ) {
25
+ let a;
26
+
27
+ repro ! ( { 1 } + 1 ) ;
28
+ repro ! ( 4 as usize ) ;
29
+ repro ! ( return ) ;
30
+ repro ! ( a = 42 ) ;
31
+ repro ! ( || { } ) ;
32
+ repro ! ( 42 ..101 ) ;
33
+ repro ! ( 1 + Struct { } ) ;
34
+ }
File renamed without changes.
You can’t perform that action at this time.
0 commit comments