Skip to content

Commit 957ee5c

Browse files
committed
Add subst helper for inheriting FnSpace from another subst
1 parent 1f34086 commit 957ee5c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustc/middle/subst.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ impl<'tcx> Substs<'tcx> {
160160
Substs { types: types, regions: regions }
161161
}
162162

163+
pub fn with_method_from_subst(self, other: &Substs<'tcx>) -> Substs<'tcx> {
164+
let Substs { types, regions } = self;
165+
let types = types.with_vec(FnSpace, other.types.get_slice(FnSpace).to_vec());
166+
let regions = regions.map(|r| {
167+
r.with_vec(FnSpace, other.regions().get_slice(FnSpace).to_vec())
168+
});
169+
Substs { types: types, regions: regions }
170+
}
171+
163172
/// Creates a trait-ref out of this substs, ignoring the FnSpace substs
164173
pub fn to_trait_ref(&self, tcx: &TyCtxt<'tcx>, trait_id: DefId)
165174
-> ty::TraitRef<'tcx> {

0 commit comments

Comments
 (0)