Add subst helper for inheriting FnSpace from another subst
This commit is contained in:
parent
1f34086e94
commit
957ee5ce34
1 changed files with 9 additions and 0 deletions
|
|
@ -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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue