Skip to content

Commit b98c3bd

Browse files
author
Jorge Aparicio
committed
Tell expr_use_visitor that user unops are by value
1 parent 9a962a7 commit b98c3bd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/librustc/middle/expr_use_visitor.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,14 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
576576
self.walk_block(&**blk);
577577
}
578578

579-
ast::ExprUnary(_, ref lhs) => {
580-
if !self.walk_overloaded_operator(expr, &**lhs, Vec::new(), PassArgs::ByRef) {
579+
ast::ExprUnary(op, ref lhs) => {
580+
let pass_args = if ast_util::is_by_value_unop(op) {
581+
PassArgs::ByValue
582+
} else {
583+
PassArgs::ByRef
584+
};
585+
586+
if !self.walk_overloaded_operator(expr, &**lhs, Vec::new(), pass_args) {
581587
self.consume_expr(&**lhs);
582588
}
583589
}
@@ -937,7 +943,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
937943
match pass_args {
938944
PassArgs::ByValue => {
939945
self.consume_expr(receiver);
940-
self.consume_expr(rhs[0]);
946+
for &arg in rhs.iter() {
947+
self.consume_expr(arg);
948+
}
941949

942950
return true;
943951
},

0 commit comments

Comments
 (0)