From cd1585ffb38a4ac911ce510fee92ac6f8ea86a5e Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 11 Nov 2015 00:07:34 +0200 Subject: [PATCH] rustc_mir: don't miss the autoref when doing an unsize --- src/librustc_mir/hair/cx/expr.rs | 18 ++++++++++-------- 1 file 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() }, + }; + } } }