Skip to content

Commit 80d129a

Browse files
committed
Parenthesize unary move exprs in prettyprinter
Closes #3220
1 parent 5eea7d6 commit 80d129a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,12 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
12341234
print_block(s, blk);
12351235
}
12361236
ast::expr_copy(e) => { word_space(s, ~"copy"); print_expr(s, e); }
1237-
ast::expr_unary_move(e) => { word_space(s, ~"move"); print_expr(s, e); }
1237+
ast::expr_unary_move(e) => {
1238+
popen(s);
1239+
word_space(s, ~"move");
1240+
print_expr(s, e);
1241+
pclose(s);
1242+
}
12381243
ast::expr_move(lhs, rhs) => {
12391244
print_expr(s, lhs);
12401245
space(s.s);

src/test/run-pass/issue-3220.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
struct thing { x: int; new () { self.x = 0; } drop { } }
2+
impl thing { fn f(self) {} }
3+
4+
fn main() {
5+
let z = thing();
6+
(move z).f();
7+
}

0 commit comments

Comments
 (0)