1
Fork 0

Normalize associated types in with_field_tys

This commit is contained in:
Niko Matsakis 2015-01-07 13:53:54 -05:00
parent 9e4e8823c7
commit 4dd368b90a
3 changed files with 31 additions and 6 deletions

View file

@ -107,7 +107,7 @@ pub struct CrateAnalysis<'tcx> {
pub glob_map: Option<GlobMap>,
}
#[derive(Copy, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct field<'tcx> {
pub name: ast::Name,
pub mt: mt<'tcx>
@ -7212,6 +7212,12 @@ impl<'tcx> HasProjectionTypes for FnSig<'tcx> {
}
}
impl<'tcx> HasProjectionTypes for field<'tcx> {
fn has_projection_types(&self) -> bool {
self.mt.ty.has_projection_types()
}
}
impl<'tcx> HasProjectionTypes for BareFnTy<'tcx> {
fn has_projection_types(&self) -> bool {
self.sig.has_projection_types()
@ -7311,3 +7317,11 @@ impl<'tcx> Repr<'tcx> for UnboxedClosureUpvar<'tcx> {
self.ty.repr(tcx))
}
}
impl<'tcx> Repr<'tcx> for field<'tcx> {
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
format!("field({},{})",
self.name.repr(tcx),
self.mt.repr(tcx))
}
}

View file

@ -273,6 +273,15 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TraitRef<'tcx> {
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::field<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::field<'tcx> {
ty::field {
name: self.name,
mt: self.mt.fold_with(folder),
}
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::Region {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Region {
folder.fold_region(*self)

View file

@ -50,6 +50,7 @@ use trans::debuginfo;
use trans::glue;
use trans::machine;
use trans::meth;
use trans::monomorphize;
use trans::inline;
use trans::tvec;
use trans::type_of;
@ -1318,7 +1319,9 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
{
match ty.sty {
ty::ty_struct(did, substs) => {
op(0, struct_fields(tcx, did, substs).index(&FullRange))
let fields = struct_fields(tcx, did, substs);
let fields = monomorphize::normalize_associated_type(tcx, &fields);
op(0, fields.index(&FullRange))
}
ty::ty_tup(ref v) => {
@ -1340,10 +1343,9 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
def::DefVariant(enum_id, variant_id, _) => {
let variant_info = ty::enum_variant_with_id(
tcx, enum_id, variant_id);
op(variant_info.disr_val,
struct_fields(tcx,
variant_id,
substs).index(&FullRange))
let fields = struct_fields(tcx, variant_id, substs);
let fields = monomorphize::normalize_associated_type(tcx, &fields);
op(variant_info.disr_val, fields.index(&FullRange))
}
_ => {
tcx.sess.bug("resolve didn't map this expr to a \