about summary refs log tree commit diff
path: root/src/test/pretty
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-30 13:01:10 +0000
committerbors <bors@rust-lang.org>2014-07-30 13:01:10 +0000
commit3ab170ffc5e45d31eef85db8fd7a3b68764f77c2 (patch)
tree8146c564ee7c93820cb78da85b9cd9f1d51cc081 /src/test/pretty
parent692077b6431460b96beb0ccf4f38299618d51db2 (diff)
parente841a88b9298b0d1fef93192d8e163b44645fc73 (diff)
downloadrust-3ab170ffc5e45d31eef85db8fd7a3b68764f77c2.tar.gz
rust-3ab170ffc5e45d31eef85db8fd7a3b68764f77c2.zip
auto merge of #16037 : erickt/rust/quote_arm, r=acrichto
This adds support for `quote_arm!(cx, $pat => $expr)`, and `macro_rules!(($a:arm) => (...))`. It also fixes a bug in pretty printing, where this would generate invalid code:

```
match { 5i } {
    1 => 2,
    _ => 3,
}
```

It would generate this code:

```
match { 5i } {
    1 => 2
    _ => 3
}
```

Finally, it adds a couple helper methods to `ExtCtxt`.
Diffstat (limited to 'src/test/pretty')
-rw-r--r--src/test/pretty/match-block-expr.rs16
-rw-r--r--src/test/pretty/match-naked-expr-medium.rs2
-rw-r--r--src/test/pretty/match-naked-expr.rs2
3 files changed, 18 insertions, 2 deletions
diff --git a/src/test/pretty/match-block-expr.rs b/src/test/pretty/match-block-expr.rs
new file mode 100644
index 00000000000..44771a29bb4
--- /dev/null
+++ b/src/test/pretty/match-block-expr.rs
@@ -0,0 +1,16 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// pp-exact
+
+fn main() {
+    let x = match { 5i } { 1 => 5i, 2 => 6, _ => 7, };
+    assert_eq!(x , 7);
+}
diff --git a/src/test/pretty/match-naked-expr-medium.rs b/src/test/pretty/match-naked-expr-medium.rs
index c03ad499478..d2f8157ef62 100644
--- a/src/test/pretty/match-naked-expr-medium.rs
+++ b/src/test/pretty/match-naked-expr-medium.rs
@@ -19,6 +19,6 @@ fn main() {
              "long".to_string(), "string".to_string()],
             None =>
             ["none".to_string(), "a".to_string(), "a".to_string(),
-             "a".to_string(), "a".to_string()]
+             "a".to_string(), "a".to_string()],
         };
 }
diff --git a/src/test/pretty/match-naked-expr.rs b/src/test/pretty/match-naked-expr.rs
index 67c389f7e1f..6b4f579f9c5 100644
--- a/src/test/pretty/match-naked-expr.rs
+++ b/src/test/pretty/match-naked-expr.rs
@@ -15,6 +15,6 @@ fn main() {
     let _y =
         match x {
             Some(_) => "some(_)".to_string(),
-            None => "none".to_string()
+            None => "none".to_string(),
         };
 }