diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-15 16:16:48 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-18 14:56:00 -0500 |
| commit | b98c3bd4d2e03f801435165fe8fa75cbf59c0582 (patch) | |
| tree | 60213bb2f1aaa1e2f205d7b8fb82613193514705 | |
| parent | 9a962a7bdc9a794fbaa1e96ae951c22dd31eac86 (diff) | |
| download | rust-b98c3bd4d2e03f801435165fe8fa75cbf59c0582.tar.gz rust-b98c3bd4d2e03f801435165fe8fa75cbf59c0582.zip | |
Tell expr_use_visitor that user unops are by value
| -rw-r--r-- | src/librustc/middle/expr_use_visitor.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index aacb994e5a4..901944cd016 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -576,8 +576,14 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { self.walk_block(&**blk); } - ast::ExprUnary(_, ref lhs) => { - if !self.walk_overloaded_operator(expr, &**lhs, Vec::new(), PassArgs::ByRef) { + ast::ExprUnary(op, ref lhs) => { + let pass_args = if ast_util::is_by_value_unop(op) { + PassArgs::ByValue + } else { + PassArgs::ByRef + }; + + if !self.walk_overloaded_operator(expr, &**lhs, Vec::new(), pass_args) { self.consume_expr(&**lhs); } } @@ -937,7 +943,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { match pass_args { PassArgs::ByValue => { self.consume_expr(receiver); - self.consume_expr(rhs[0]); + for &arg in rhs.iter() { + self.consume_expr(arg); + } return true; }, |
