replace UserTypeAnnotation::AdtDef with TypeOf

This commit is contained in:
Niko Matsakis 2018-10-17 11:48:41 -04:00
parent e94959b936
commit a0a3b4c058
5 changed files with 3 additions and 29 deletions

View File

@ -601,10 +601,6 @@ fn hash_stable<W: StableHasherResult>(&self,
def_id.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
mir::UserTypeAnnotation::AdtDef(ref def_id, ref substs) => {
def_id.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
}
}
}

View File

@ -2429,18 +2429,12 @@ pub enum UserTypeAnnotation<'tcx> {
/// The canonical type is the result of `type_of(def_id)` with the
/// given substitutions applied.
TypeOf(DefId, CanonicalUserSubsts<'tcx>),
/// The canonical type is the given ADT with the given
/// substitutions applied (in this case, `user_self_ty` had better
/// be `None`).
AdtDef(&'tcx AdtDef, CanonicalUserSubsts<'tcx>),
}
EnumTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for UserTypeAnnotation<'tcx> {
(UserTypeAnnotation::Ty)(ty),
(UserTypeAnnotation::TypeOf)(def, substs),
(UserTypeAnnotation::AdtDef)(def, substs),
}
}

View File

@ -132,22 +132,6 @@ pub(super) fn relate_type_and_user_type<'tcx>(
Ok(ty)
}
UserTypeAnnotation::AdtDef(adt_def, canonical_substs) => {
let (
UserSubsts {
substs,
user_self_ty,
},
_,
) = infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonical_substs);
// We don't extract adt-defs with a self-type.
assert!(user_self_ty.is_none());
let ty = infcx.tcx.mk_adt(adt_def, substs);
type_relating.relate(&ty, &a)?;
Ok(ty)
}
}
}

View File

@ -295,7 +295,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
let substs = cx.tables().node_substs(fun.hir_id);
let user_ty = cx.tables().user_substs(fun.hir_id)
.map(|user_substs| UserTypeAnnotation::AdtDef(adt_def, user_substs));
.map(|user_substs| UserTypeAnnotation::TypeOf(adt_def.did, user_substs));
let field_refs = args.iter()
.enumerate()

View File

@ -23,7 +23,7 @@ fn user_substs_applied_to_adt(
adt_def: &'tcx AdtDef,
) -> Option<UserTypeAnnotation<'tcx>> {
let user_substs = self.tables().user_substs(hir_id)?;
Some(UserTypeAnnotation::AdtDef(adt_def, user_substs))
Some(UserTypeAnnotation::TypeOf(adt_def.did, user_substs))
}
/// Looks up the type associated with this hir-id and applies the
@ -35,7 +35,7 @@ fn user_substs_applied_to_ty_of_hir_id(
) -> Option<UserTypeAnnotation<'tcx>> {
let user_substs = self.tables().user_substs(hir_id)?;
match &self.tables().node_id_to_type(hir_id).sty {
ty::Adt(adt_def, _) => Some(UserTypeAnnotation::AdtDef(adt_def, user_substs)),
ty::Adt(adt_def, _) => Some(UserTypeAnnotation::TypeOf(adt_def.did, user_substs)),
ty::FnDef(def_id, _) => Some(UserTypeAnnotation::TypeOf(*def_id, user_substs)),
sty => bug!(
"sty: {:?} should not have user-substs {:?} recorded ",