about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@mozilla.com>2014-06-06 11:59:32 -0700
committerCameron Zwarich <zwarich@mozilla.com>2014-06-06 11:59:32 -0700
commit0339b27e6db07e50bf71edc5eb78133a418a5949 (patch)
treef80ce3f9f982e9e3a2b2c9e3bdca0e04253b3aa7
parentd123188b20222c8fc5fbc386bd15100b6f3c80ed (diff)
downloadrust-0339b27e6db07e50bf71edc5eb78133a418a5949.tar.gz
rust-0339b27e6db07e50bf71edc5eb78133a418a5949.zip
Fix mem_categorization to treat an AutoObject adjustment as an rvalue.
Currently mem_categorization categorizes an AutoObject adjustment the
same as the original expression. This can cause two moves to be
generated for the same underlying expression. Currently this isn't a
problem in practice, since check_loans doesn't rely on ExprUseVisitor.
-rw-r--r--src/librustc/middle/mem_categorization.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 1d2ed72f70e..240212699e4 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -390,12 +390,10 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
             Some(adjustment) => {
                 match *adjustment {
                     ty::AutoObject(..) => {
-                        // Implicity casts a concrete object to trait object
-                        // so just patch up the type
+                        // Implicity cast a concrete object to trait object.
+                        // Result is an rvalue.
                         let expr_ty = if_ok!(self.expr_ty_adjusted(expr));
-                        let mut expr_cmt = (*if_ok!(self.cat_expr_unadjusted(expr))).clone();
-                        expr_cmt.ty = expr_ty;
-                        Ok(Rc::new(expr_cmt))
+                        Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty))
                     }
 
                     ty::AutoAddEnv(..) => {