mir: Monomorphize LvalueTy's of projections.
This commit is contained in:
parent
f9c06abc21
commit
56417b3732
@ -16,6 +16,7 @@
|
||||
use mir::repr::*;
|
||||
use middle::subst::{Subst, Substs};
|
||||
use middle::ty::{self, AdtDef, Ty, TyCtxt};
|
||||
use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use rustc_front::hir;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@ -77,6 +78,29 @@ impl<'tcx> LvalueTy<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> {
|
||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
match *self {
|
||||
LvalueTy::Ty { ty } => LvalueTy::Ty { ty: ty.fold_with(folder) },
|
||||
LvalueTy::Downcast { adt_def, substs, variant_index } => {
|
||||
let substs = substs.fold_with(folder);
|
||||
LvalueTy::Downcast {
|
||||
adt_def: adt_def,
|
||||
substs: folder.tcx().mk_substs(substs),
|
||||
variant_index: variant_index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||
match *self {
|
||||
LvalueTy::Ty { ty } => ty.visit_with(visitor),
|
||||
LvalueTy::Downcast { substs, .. } => substs.visit_with(visitor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Mir<'tcx> {
|
||||
pub fn operand_ty(&self,
|
||||
tcx: &TyCtxt<'tcx>,
|
||||
|
@ -114,6 +114,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
mir::Lvalue::Projection(ref projection) => {
|
||||
let tr_base = self.trans_lvalue(bcx, &projection.base);
|
||||
let projected_ty = tr_base.ty.projection_ty(tcx, &projection.elem);
|
||||
let projected_ty = bcx.monomorphize(&projected_ty);
|
||||
let (llprojected, llextra) = match projection.elem {
|
||||
mir::ProjectionElem::Deref => {
|
||||
let base_ty = tr_base.ty.to_ty(tcx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user