Add subst helper for inheriting FnSpace from another subst

This commit is contained in:
Aaron Turon 2015-12-28 13:34:01 -08:00
parent 1f34086e94
commit 957ee5ce34

View file

@ -160,6 +160,15 @@ impl<'tcx> Substs<'tcx> {
Substs { types: types, regions: regions }
}
pub fn with_method_from_subst(self, other: &Substs<'tcx>) -> Substs<'tcx> {
let Substs { types, regions } = self;
let types = types.with_vec(FnSpace, other.types.get_slice(FnSpace).to_vec());
let regions = regions.map(|r| {
r.with_vec(FnSpace, other.regions().get_slice(FnSpace).to_vec())
});
Substs { types: types, regions: regions }
}
/// Creates a trait-ref out of this substs, ignoring the FnSpace substs
pub fn to_trait_ref(&self, tcx: &TyCtxt<'tcx>, trait_id: DefId)
-> ty::TraitRef<'tcx> {