about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-01 20:31:29 +0000
committerbors <bors@rust-lang.org>2018-09-01 20:31:29 +0000
commit28bcffead74d5e17c6cb1f7de432e37f93a6b50c (patch)
tree1abf601a008600ac3a23c22c1ce003c571dee816 /src/libsyntax/print
parentf39f218ec33d93e8a1b0ac4282f62ee35e02c18a (diff)
parent7a083ca25f14833d704d2efba5ca9b431f6c65ad (diff)
downloadrust-28bcffead74d5e17c6cb1f7de432e37f93a6b50c.tar.gz
rust-28bcffead74d5e17c6cb1f7de432e37f93a6b50c.zip
Auto merge of #53815 - F001:if-let-guard, r=petrochenkov
refactor match guard

This is the first step to implement RFC 2294: if-let-guard. Tracking issue: https://github.com/rust-lang/rust/issues/51114

The second step should be introducing another variant `IfLet` in the Guard enum. I separated them into 2 PRs for the convenience of reviewers.

r? @petrochenkov
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index e78e1afe3a4..85d29a5be89 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -2702,10 +2702,14 @@ impl<'a> State<'a> {
         self.print_outer_attributes(&arm.attrs)?;
         self.print_pats(&arm.pats)?;
         self.s.space()?;
-        if let Some(ref e) = arm.guard {
-            self.word_space("if")?;
-            self.print_expr(e)?;
-            self.s.space()?;
+        if let Some(ref g) = arm.guard {
+            match g {
+                ast::Guard::If(ref e) => {
+                    self.word_space("if")?;
+                    self.print_expr(e)?;
+                    self.s.space()?;
+                }
+            }
         }
         self.word_space("=>")?;