about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2015-12-28 13:34:01 -0800
committerAaron Turon <aturon@mozilla.com>2016-03-14 15:04:35 -0700
commit957ee5ce347999ef2c1acfdb63a76643c61f6516 (patch)
treed616ca34154b419235cafc431a4e2790f16caf91
parent1f34086e947139d498847dce49ba437748f17c2d (diff)
downloadrust-957ee5ce347999ef2c1acfdb63a76643c61f6516.tar.gz
rust-957ee5ce347999ef2c1acfdb63a76643c61f6516.zip
Add subst helper for inheriting FnSpace from another subst
-rw-r--r--src/librustc/middle/subst.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs
index 02dfeb80b92..9f8e2a22133 100644
--- a/src/librustc/middle/subst.rs
+++ b/src/librustc/middle/subst.rs
@@ -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> {