Skip to content

Commit cd1585f

Browse files
committed
rustc_mir: don't miss the autoref when doing an unsize
1 parent c1bfd0c commit cd1585f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/librustc_mir/hair/cx/expr.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
386386
};
387387
}
388388

389-
if let Some(target) = adj.unsize {
390-
expr = Expr {
391-
temp_lifetime: temp_lifetime,
392-
ty: target,
393-
span: self.span,
394-
kind: ExprKind::Unsize { source: expr.to_ref() },
395-
};
396-
} else if let Some(autoref) = adj.autoref {
389+
if let Some(autoref) = adj.autoref {
397390
let adjusted_ty = expr.ty.adjust_for_autoref(cx.tcx, Some(autoref));
398391
match autoref {
399392
ty::adjustment::AutoPtr(r, m) => {
@@ -433,6 +426,15 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
433426
}
434427
}
435428
}
429+
430+
if let Some(target) = adj.unsize {
431+
expr = Expr {
432+
temp_lifetime: temp_lifetime,
433+
ty: target,
434+
span: self.span,
435+
kind: ExprKind::Unsize { source: expr.to_ref() },
436+
};
437+
}
436438
}
437439
}
438440

0 commit comments

Comments
 (0)