Skip to content

Commit 56417b3

Browse files
committed
mir: Monomorphize LvalueTy's of projections.
1 parent f9c06ab commit 56417b3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/librustc/mir/tcx.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use mir::repr::*;
1717
use middle::subst::{Subst, Substs};
1818
use middle::ty::{self, AdtDef, Ty, TyCtxt};
19+
use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
1920
use rustc_front::hir;
2021

2122
#[derive(Copy, Clone, Debug)]
@@ -77,6 +78,29 @@ impl<'tcx> LvalueTy<'tcx> {
7778
}
7879
}
7980

81+
impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> {
82+
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
83+
match *self {
84+
LvalueTy::Ty { ty } => LvalueTy::Ty { ty: ty.fold_with(folder) },
85+
LvalueTy::Downcast { adt_def, substs, variant_index } => {
86+
let substs = substs.fold_with(folder);
87+
LvalueTy::Downcast {
88+
adt_def: adt_def,
89+
substs: folder.tcx().mk_substs(substs),
90+
variant_index: variant_index
91+
}
92+
}
93+
}
94+
}
95+
96+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
97+
match *self {
98+
LvalueTy::Ty { ty } => ty.visit_with(visitor),
99+
LvalueTy::Downcast { substs, .. } => substs.visit_with(visitor)
100+
}
101+
}
102+
}
103+
80104
impl<'tcx> Mir<'tcx> {
81105
pub fn operand_ty(&self,
82106
tcx: &TyCtxt<'tcx>,

src/librustc_trans/trans/mir/lvalue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
114114
mir::Lvalue::Projection(ref projection) => {
115115
let tr_base = self.trans_lvalue(bcx, &projection.base);
116116
let projected_ty = tr_base.ty.projection_ty(tcx, &projection.elem);
117+
let projected_ty = bcx.monomorphize(&projected_ty);
117118
let (llprojected, llextra) = match projection.elem {
118119
mir::ProjectionElem::Deref => {
119120
let base_ty = tr_base.ty.to_ty(tcx);

0 commit comments

Comments
 (0)