about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-11 21:12:43 -0700
committerbors <bors@rust-lang.org>2013-03-11 21:12:43 -0700
commit9b9ffd5b4196d409dd76c224442ee0fee91fd9e4 (patch)
tree7539a8b5ccee75ed63ea57e822ddde4f8033f650 /src/libsyntax/print
parent48cb9a8ac0b95408a142ea7bc9767414eba2cbb3 (diff)
parent1df0a0ba0f04e15d74307088dd3c952dd61f2183 (diff)
downloadrust-9b9ffd5b4196d409dd76c224442ee0fee91fd9e4.tar.gz
rust-9b9ffd5b4196d409dd76c224442ee0fee91fd9e4.zip
auto merge of #5304 : jld/rust/const-adjustments, r=graydon
These changes make const translation use adjustments (autodereference, autoreference, bare-fn-to-closure), like normal code does, replacing some ad-hoc logic that wasn't always right.

As a convenient side-effect, explicit dereference (both of pointers and of newtypes) is also supported in const expressions.

There is also a “bonus fix” for a bug in the pretty-printer exposed by one of the added tests.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 49899fdeec4..62f593f15c1 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1192,6 +1192,11 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
       ast::expr_addr_of(m, expr) => {
         word(s.s, ~"&");
         print_mutability(s, m);
+        // Avoid `& &e` => `&&e`.
+        match (m, &expr.node) {
+            (ast::m_imm, &ast::expr_addr_of(*)) => space(s.s),
+            _ => { }
+        }
         print_expr(s, expr);
       }
       ast::expr_lit(lit) => print_literal(s, lit),