about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2015-11-11 00:07:34 +0200
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2015-11-13 22:47:02 +0200
commitcd1585ffb38a4ac911ce510fee92ac6f8ea86a5e (patch)
tree9e882fc7d907321261cb748cfb71e5361db9ae92 /src
parentc1bfd0ca6b6aedd4fa29e3dddf927f31051f3ea6 (diff)
downloadrust-cd1585ffb38a4ac911ce510fee92ac6f8ea86a5e.tar.gz
rust-cd1585ffb38a4ac911ce510fee92ac6f8ea86a5e.zip
rustc_mir: don't miss the autoref when doing an unsize
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/hair/cx/expr.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs
index 56ec0881811..c546a264be1 100644
--- a/src/librustc_mir/hair/cx/expr.rs
+++ b/src/librustc_mir/hair/cx/expr.rs
@@ -386,14 +386,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
                     };
                 }
 
-                if let Some(target) = adj.unsize {
-                    expr = Expr {
-                        temp_lifetime: temp_lifetime,
-                        ty: target,
-                        span: self.span,
-                        kind: ExprKind::Unsize { source: expr.to_ref() },
-                    };
-                } else if let Some(autoref) = adj.autoref {
+                if let Some(autoref) = adj.autoref {
                     let adjusted_ty = expr.ty.adjust_for_autoref(cx.tcx, Some(autoref));
                     match autoref {
                         ty::adjustment::AutoPtr(r, m) => {
@@ -433,6 +426,15 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
                         }
                     }
                 }
+
+                if let Some(target) = adj.unsize {
+                    expr = Expr {
+                        temp_lifetime: temp_lifetime,
+                        ty: target,
+                        span: self.span,
+                        kind: ExprKind::Unsize { source: expr.to_ref() },
+                    };
+                }
             }
         }