move method to function so it can be used in map iterators without borrowing self

上级 73d7f1d4
......@@ -285,11 +285,6 @@ pub fn load_mir(&self, def_id: DefId) -> EvalResult<'tcx, MirRef<'tcx>> {
}
}
pub fn monomorphize_field_ty(&self, f: ty::FieldDef<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
let substituted = &f.ty(self.tcx, substs);
self.tcx.normalize_associated_type(&substituted)
}
pub fn monomorphize(&self, ty: Ty<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
let substituted = ty.subst(self.tcx, substs);
self.tcx.normalize_associated_type(&substituted)
......@@ -1511,8 +1506,8 @@ fn unsize_into(
let iter = src_fields.zip(dst_fields).enumerate();
for (i, (src_f, dst_f)) in iter {
let src_fty = self.monomorphize_field_ty(src_f, substs_a);
let dst_fty = self.monomorphize_field_ty(dst_f, substs_b);
let src_fty = monomorphize_field_ty(self.tcx, src_f, substs_a);
let dst_fty = monomorphize_field_ty(self.tcx, dst_f, substs_b);
if self.type_size(dst_fty) == 0 {
continue;
}
......@@ -1729,3 +1724,9 @@ fn size(self) -> Size {
}
}
}
pub fn monomorphize_field_ty<'a, 'tcx:'a >(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: ty::FieldDef<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
let substituted = &f.ty(tcx, substs);
tcx.normalize_associated_type(&substituted)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册