Skip to content

Commit 0339b27

Browse files
author
Cameron Zwarich
committed
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.
1 parent d123188 commit 0339b27

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/librustc/middle/mem_categorization.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,10 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
390390
Some(adjustment) => {
391391
match *adjustment {
392392
ty::AutoObject(..) => {
393-
// Implicity casts a concrete object to trait object
394-
// so just patch up the type
393+
// Implicity cast a concrete object to trait object.
394+
// Result is an rvalue.
395395
let expr_ty = if_ok!(self.expr_ty_adjusted(expr));
396-
let mut expr_cmt = (*if_ok!(self.cat_expr_unadjusted(expr))).clone();
397-
expr_cmt.ty = expr_ty;
398-
Ok(Rc::new(expr_cmt))
396+
Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty))
399397
}
400398

401399
ty::AutoAddEnv(..) => {

0 commit comments

Comments
 (0)