]> git.lizzy.rs Git - rust.git/commitdiff
rustc: fix fallout of adding the `'tcx` lifetime to `Ty`.
authorEduard Burtescu <edy.burt@gmail.com>
Mon, 29 Sep 2014 19:11:30 +0000 (22:11 +0300)
committerEduard Burtescu <edy.burt@gmail.com>
Wed, 19 Nov 2014 04:24:34 +0000 (06:24 +0200)
86 files changed:
src/librustc/lint/builtin.rs
src/librustc/lint/context.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tyencode.rs
src/librustc/middle/astencode.rs
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/gather_loans/gather_moves.rs
src/librustc/middle/borrowck/gather_loans/lifetime.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/borrowck/gather_loans/move_error.rs
src/librustc/middle/borrowck/gather_loans/restrictions.rs
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/check_match.rs
src/librustc/middle/check_rvalues.rs
src/librustc/middle/check_static.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/intrinsicck.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/privacy.rs
src/librustc/middle/subst.rs
src/librustc/middle/traits/coherence.rs
src/librustc/middle/traits/fulfill.rs
src/librustc/middle/traits/mod.rs
src/librustc/middle/traits/select.rs
src/librustc/middle/traits/util.rs
src/librustc/middle/ty.rs
src/librustc/middle/ty_fold.rs
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/check/_match.rs
src/librustc/middle/typeck/check/demand.rs
src/librustc/middle/typeck/check/method/confirm.rs
src/librustc/middle/typeck/check/method/mod.rs
src/librustc/middle/typeck/check/method/probe.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/regionmanip.rs
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/check/wf.rs
src/librustc/middle/typeck/check/writeback.rs
src/librustc/middle/typeck/coherence/mod.rs
src/librustc/middle/typeck/collect.rs
src/librustc/middle/typeck/infer/coercion.rs
src/librustc/middle/typeck/infer/combine.rs
src/librustc/middle/typeck/infer/equate.rs
src/librustc/middle/typeck/infer/error_reporting.rs
src/librustc/middle/typeck/infer/glb.rs
src/librustc/middle/typeck/infer/higher_ranked/mod.rs
src/librustc/middle/typeck/infer/lattice.rs
src/librustc/middle/typeck/infer/lub.rs
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/resolve.rs
src/librustc/middle/typeck/infer/skolemize.rs
src/librustc/middle/typeck/infer/sub.rs
src/librustc/middle/typeck/infer/type_variable.rs
src/librustc/middle/typeck/infer/unify.rs
src/librustc/middle/typeck/mod.rs
src/librustc/middle/typeck/variance.rs
src/librustc/util/ppaux.rs
src/librustc_trans/back/link.rs
src/librustc_trans/driver/driver.rs
src/librustc_trans/driver/pretty.rs
src/librustc_trans/test.rs
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/adt.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/callee.rs
src/librustc_trans/trans/cleanup.rs
src/librustc_trans/trans/closure.rs
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/context.rs
src/librustc_trans/trans/datum.rs
src/librustc_trans/trans/debuginfo.rs
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/foreign.rs
src/librustc_trans/trans/glue.rs
src/librustc_trans/trans/intrinsic.rs
src/librustc_trans/trans/meth.rs
src/librustc_trans/trans/monomorphize.rs
src/librustc_trans/trans/tvec.rs
src/librustc_trans/trans/type_of.rs

index 126d4c00f2867ea40636acffa63a47859d69834e..e805868274ab2dd1d1ae7e92e820289b65c5907c 100644 (file)
@@ -474,7 +474,8 @@ fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
 pub struct BoxPointers;
 
 impl BoxPointers {
-    fn check_heap_type(&self, cx: &Context, span: Span, ty: Ty) {
+    fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
+                                 span: Span, ty: Ty<'tcx>) {
         let mut n_uniq = 0i;
         ty::fold_ty(cx.tcx, ty, |t| {
             match ty::get(t).sty {
index a519683b351bb030819a87aacbba260eb34a9635..83f14d3a0db54868a2da890a1b9f6a15fab1ed8c 100644 (file)
@@ -546,19 +546,19 @@ fn visit_ids(&mut self, f: |&mut ast_util::IdVisitor<Context>|) {
 impl<'a, 'tcx> AstConv<'tcx> for Context<'a, 'tcx>{
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         ty::lookup_item_type(self.tcx, id)
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         ty::lookup_trait_def(self.tcx, id)
     }
 
-    fn ty_infer(&self, _span: Span) -> Ty {
+    fn ty_infer(&self, _span: Span) -> Ty<'tcx> {
         infer::new_infer_ctxt(self.tcx).next_ty_var()
     }
 
-    fn associated_types_of_trait_are_valid(&self, _: Ty, _: ast::DefId)
+    fn associated_types_of_trait_are_valid(&self, _: Ty<'tcx>, _: ast::DefId)
                                            -> bool {
         // FIXME(pcwalton): This is wrong.
         true
@@ -566,10 +566,10 @@ fn associated_types_of_trait_are_valid(&self, _: Ty, _: ast::DefId)
 
     fn associated_type_binding(&self,
                                _: Span,
-                               _: Option<Ty>,
+                               _: Option<Ty<'tcx>>,
                                trait_id: ast::DefId,
                                associated_type_id: ast::DefId)
-                               -> Ty {
+                               -> Ty<'tcx> {
         // FIXME(pcwalton): This is wrong.
         let trait_def = self.get_trait_def(trait_id);
         let index = ty::associated_type_parameter_index(self.tcx,
index 50c4178601f2f9c9df2c1a0d68d1f2ffc60e4de4..20e3f27f2ae18d2418af1a7622478c784cb42ce4 100644 (file)
@@ -123,8 +123,8 @@ pub fn get_enum_variant_defs(cstore: &cstore::CStore, enum_id: ast::DefId)
     decoder::get_enum_variant_defs(&*cstore.intr, &*cdata, enum_id.node)
 }
 
-pub fn get_enum_variants(tcx: &ty::ctxt, def: ast::DefId)
-                      -> Vec<Rc<ty::VariantInfo>> {
+pub fn get_enum_variants<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
+                               -> Vec<Rc<ty::VariantInfo<'tcx>>> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_enum_variants(cstore.intr.clone(), &*cdata, def.node, tcx)
@@ -137,8 +137,8 @@ pub fn get_impl_items(cstore: &cstore::CStore, impl_def_id: ast::DefId)
     decoder::get_impl_items(&*cdata, impl_def_id.node)
 }
 
-pub fn get_impl_or_trait_item(tcx: &ty::ctxt, def: ast::DefId)
-                              -> ty::ImplOrTraitItem {
+pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
+                                    -> ty::ImplOrTraitItem<'tcx> {
     let cdata = tcx.sess.cstore.get_crate_data(def.krate);
     decoder::get_impl_or_trait_item(tcx.sess.cstore.intr.clone(),
                                     &*cdata,
@@ -166,15 +166,17 @@ pub fn get_item_variances(cstore: &cstore::CStore,
     decoder::get_item_variances(&*cdata, def.node)
 }
 
-pub fn get_provided_trait_methods(tcx: &ty::ctxt,
-                                  def: ast::DefId)
-                               -> Vec<Rc<ty::Method>> {
+pub fn get_provided_trait_methods<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                        def: ast::DefId)
+                                        -> Vec<Rc<ty::Method<'tcx>>> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_provided_trait_methods(cstore.intr.clone(), &*cdata, def.node, tcx)
 }
 
-pub fn get_supertraits(tcx: &ty::ctxt, def: ast::DefId) -> Vec<Rc<ty::TraitRef>> {
+pub fn get_supertraits<'tcx>(tcx: &ty::ctxt<'tcx>,
+                             def: ast::DefId)
+                             -> Vec<Rc<ty::TraitRef<'tcx>>> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_supertraits(&*cdata, def.node, tcx)
@@ -213,22 +215,22 @@ pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: ast::DefId) -> HashM
     decoder::get_struct_field_attrs(&*cdata)
 }
 
-pub fn get_type(tcx: &ty::ctxt,
-                def: ast::DefId)
-             -> ty::Polytype {
+pub fn get_type<'tcx>(tcx: &ty::ctxt<'tcx>,
+                      def: ast::DefId)
+                      -> ty::Polytype<'tcx> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_type(&*cdata, def.node, tcx)
 }
 
-pub fn get_trait_def(tcx: &ty::ctxt, def: ast::DefId) -> ty::TraitDef {
+pub fn get_trait_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> ty::TraitDef<'tcx> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_trait_def(&*cdata, def.node, tcx)
 }
 
-pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
-                      def: ast::DefId) -> ty::Polytype {
+pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
+                            def: ast::DefId) -> ty::Polytype<'tcx> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(class_id.krate);
     let all_items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
@@ -255,17 +257,18 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
 
 // Given a def_id for an impl, return the trait it implements,
 // if there is one.
-pub fn get_impl_trait(tcx: &ty::ctxt,
-                      def: ast::DefId) -> Option<Rc<ty::TraitRef>> {
+pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
+                            def: ast::DefId)
+                            -> Option<Rc<ty::TraitRef<'tcx>>> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_impl_trait(&*cdata, def.node, tcx)
 }
 
 // Given a def_id for an impl, return information about its vtables
-pub fn get_impl_vtables(tcx: &ty::ctxt,
-                        def: ast::DefId)
-                        -> typeck::vtable_res {
+pub fn get_impl_vtables<'tcx>(tcx: &ty::ctxt<'tcx>,
+                              def: ast::DefId)
+                              -> typeck::vtable_res<'tcx> {
     let cstore = &tcx.sess.cstore;
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_impl_vtables(&*cdata, def.node, tcx)
index b45f57eae96713a19cbb9a302d791aee239c42cb..ffb847db1893302deba89a79907d64e0c323cc2a 100644 (file)
@@ -224,39 +224,44 @@ fn variant_disr_val(d: rbml::Doc) -> Option<ty::Disr> {
     })
 }
 
-fn doc_type(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> Ty {
+fn doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
     let tp = reader::get_doc(doc, tag_items_data_item_type);
     parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
                   |_, did| translate_def_id(cdata, did))
 }
 
-fn doc_method_fty(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::BareFnTy {
+fn doc_method_fty<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>,
+                        cdata: Cmd) -> ty::BareFnTy<'tcx> {
     let tp = reader::get_doc(doc, tag_item_method_fty);
     parse_bare_fn_ty_data(tp.data, cdata.cnum, tp.start, tcx,
                           |_, did| translate_def_id(cdata, did))
 }
 
-pub fn item_type(_item_id: ast::DefId, item: rbml::Doc,
-                 tcx: &ty::ctxt, cdata: Cmd) -> Ty {
+pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
+                       tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
     doc_type(item, tcx, cdata)
 }
 
-fn doc_trait_ref(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::TraitRef {
+fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
+                       -> ty::TraitRef<'tcx> {
     parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
                          |_, did| translate_def_id(cdata, did))
 }
 
-fn item_trait_ref(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::TraitRef {
+fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
+                        -> ty::TraitRef<'tcx> {
     let tp = reader::get_doc(doc, tag_item_trait_ref);
     doc_trait_ref(tp, tcx, cdata)
 }
 
-fn doc_bounds(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::ParamBounds {
+fn doc_bounds<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
+                    -> ty::ParamBounds<'tcx> {
     parse_bounds_data(doc.data, cdata.cnum, doc.start, tcx,
                       |_, did| translate_def_id(cdata, did))
 }
 
-fn trait_def_bounds(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::ParamBounds {
+fn trait_def_bounds<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
+                          -> ty::ParamBounds<'tcx> {
     let d = reader::get_doc(doc, tag_trait_def_bounds);
     doc_bounds(d, tcx, cdata)
 }
@@ -353,9 +358,9 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
     }
 }
 
-pub fn get_trait_def(cdata: Cmd,
-                     item_id: ast::NodeId,
-                     tcx: &ty::ctxt) -> ty::TraitDef
+pub fn get_trait_def<'tcx>(cdata: Cmd,
+                           item_id: ast::NodeId,
+                           tcx: &ty::ctxt<'tcx>) -> ty::TraitDef<'tcx>
 {
     let item_doc = lookup_item(item_id, cdata.data());
     let generics = doc_generics(item_doc, tcx, cdata, tag_item_generics);
@@ -368,8 +373,8 @@ pub fn get_trait_def(cdata: Cmd,
     }
 }
 
-pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
-    -> ty::Polytype {
+pub fn get_type<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
+    -> ty::Polytype<'tcx> {
 
     let item = lookup_item(id, cdata.data());
 
@@ -403,9 +408,10 @@ pub fn get_repr_attrs(cdata: Cmd, id: ast::NodeId) -> Vec<attr::ReprAttr> {
     }
 }
 
-pub fn get_impl_trait(cdata: Cmd,
-                      id: ast::NodeId,
-                      tcx: &ty::ctxt) -> Option<Rc<ty::TraitRef>>
+pub fn get_impl_trait<'tcx>(cdata: Cmd,
+                            id: ast::NodeId,
+                            tcx: &ty::ctxt<'tcx>)
+                            -> Option<Rc<ty::TraitRef<'tcx>>>
 {
     let item_doc = lookup_item(id, cdata.data());
     reader::maybe_get_doc(item_doc, tag_item_trait_ref).map(|tp| {
@@ -413,10 +419,10 @@ pub fn get_impl_trait(cdata: Cmd,
     })
 }
 
-pub fn get_impl_vtables(cdata: Cmd,
-                        id: ast::NodeId,
-                        tcx: &ty::ctxt)
-                        -> typeck::vtable_res
+pub fn get_impl_vtables<'tcx>(cdata: Cmd,
+                              id: ast::NodeId,
+                              tcx: &ty::ctxt<'tcx>)
+                              -> typeck::vtable_res<'tcx>
 {
     let item_doc = lookup_item(id, cdata.data());
     let vtables_doc = reader::get_doc(item_doc, tag_item_impl_vtables);
@@ -682,8 +688,8 @@ pub fn get_enum_variant_defs(intr: &IdentInterner,
     }).collect()
 }
 
-pub fn get_enum_variants(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId,
-                     tcx: &ty::ctxt) -> Vec<Rc<ty::VariantInfo>> {
+pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId,
+                               tcx: &ty::ctxt<'tcx>) -> Vec<Rc<ty::VariantInfo<'tcx>>> {
     let data = cdata.data();
     let items = reader::get_doc(rbml::Doc::new(data), tag_items);
     let item = find_item(id, items);
@@ -786,11 +792,11 @@ pub fn get_trait_item_name_and_kind(intr: Rc<IdentInterner>,
     }
 }
 
-pub fn get_impl_or_trait_item(intr: Rc<IdentInterner>,
-                              cdata: Cmd,
-                              id: ast::NodeId,
-                              tcx: &ty::ctxt)
-                              -> ty::ImplOrTraitItem {
+pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
+                                    cdata: Cmd,
+                                    id: ast::NodeId,
+                                    tcx: &ty::ctxt<'tcx>)
+                                    -> ty::ImplOrTraitItem<'tcx> {
     let method_doc = lookup_item(id, cdata.data());
 
     let def_id = item_def_id(method_doc, cdata);
@@ -860,11 +866,11 @@ pub fn get_item_variances(cdata: Cmd, id: ast::NodeId) -> ty::ItemVariances {
     Decodable::decode(&mut decoder).unwrap()
 }
 
-pub fn get_provided_trait_methods(intr: Rc<IdentInterner>,
-                                  cdata: Cmd,
-                                  id: ast::NodeId,
-                                  tcx: &ty::ctxt)
-                                  -> Vec<Rc<ty::Method>> {
+pub fn get_provided_trait_methods<'tcx>(intr: Rc<IdentInterner>,
+                                        cdata: Cmd,
+                                        id: ast::NodeId,
+                                        tcx: &ty::ctxt<'tcx>)
+                                        -> Vec<Rc<ty::Method<'tcx>>> {
     let data = cdata.data();
     let item = lookup_item(id, data);
     let mut result = Vec::new();
@@ -892,8 +898,8 @@ pub fn get_provided_trait_methods(intr: Rc<IdentInterner>,
 }
 
 /// Returns the supertraits of the given trait.
-pub fn get_supertraits(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
-                    -> Vec<Rc<ty::TraitRef>> {
+pub fn get_supertraits<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
+                             -> Vec<Rc<ty::TraitRef<'tcx>>> {
     let mut results = Vec::new();
     let item_doc = lookup_item(id, cdata.data());
     reader::tagged_docs(item_doc, tag_item_super_trait_ref, |trait_doc| {
@@ -1388,11 +1394,11 @@ pub fn is_typedef(cdata: Cmd, id: ast::NodeId) -> bool {
     }
 }
 
-fn doc_generics(base_doc: rbml::Doc,
-                tcx: &ty::ctxt,
-                cdata: Cmd,
-                tag: uint)
-                -> ty::Generics
+fn doc_generics<'tcx>(base_doc: rbml::Doc,
+                      tcx: &ty::ctxt<'tcx>,
+                      cdata: Cmd,
+                      tag: uint)
+                      -> ty::Generics<'tcx>
 {
     let doc = reader::get_doc(base_doc, tag);
 
index a1e4cd97dac22c583084401f0119df8cd7d2db27..7e4d2621f1837ab4dee232b4640e4a882ac20640 100644 (file)
@@ -82,7 +82,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
     pub link_meta: &'a LinkMeta,
     pub cstore: &'a cstore::CStore,
     pub encode_inlined_item: RefCell<EncodeInlinedItem<'a>>,
-    pub type_abbrevs: tyencode::abbrev_map,
+    pub type_abbrevs: tyencode::abbrev_map<'tcx>,
     pub reachable: &'a NodeSet,
 }
 
@@ -104,10 +104,10 @@ struct entry<T> {
     pos: u64
 }
 
-fn encode_trait_ref(rbml_w: &mut Encoder,
-                    ecx: &EncodeContext,
-                    trait_ref: &ty::TraitRef,
-                    tag: uint) {
+fn encode_trait_ref<'a, 'tcx>(rbml_w: &mut Encoder,
+                              ecx: &EncodeContext<'a, 'tcx>,
+                              trait_ref: &ty::TraitRef<'tcx>,
+                              tag: uint) {
     let ty_str_ctxt = &tyencode::ctxt {
         diag: ecx.diag,
         ds: def_to_string,
@@ -140,9 +140,9 @@ fn encode_item_variances(rbml_w: &mut Encoder,
     rbml_w.end_tag();
 }
 
-fn encode_bounds_and_type(rbml_w: &mut Encoder,
-                          ecx: &EncodeContext,
-                          pty: &ty::Polytype) {
+fn encode_bounds_and_type<'a, 'tcx>(rbml_w: &mut Encoder,
+                                    ecx: &EncodeContext<'a, 'tcx>,
+                                    pty: &ty::Polytype<'tcx>) {
     encode_generics(rbml_w, ecx, &pty.generics, tag_item_generics);
     encode_type(ecx, rbml_w, pty.ty);
 }
@@ -158,9 +158,9 @@ fn encode_variant_id(rbml_w: &mut Encoder, vid: DefId) {
     rbml_w.end_tag();
 }
 
-pub fn write_closure_type(ecx: &EncodeContext,
-                          rbml_w: &mut Encoder,
-                          closure_type: &ty::ClosureTy) {
+pub fn write_closure_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
+                                    rbml_w: &mut Encoder,
+                                    closure_type: &ty::ClosureTy<'tcx>) {
     let ty_str_ctxt = &tyencode::ctxt {
         diag: ecx.diag,
         ds: def_to_string,
@@ -170,9 +170,9 @@ pub fn write_closure_type(ecx: &EncodeContext,
     tyencode::enc_closure_ty(rbml_w.writer, ty_str_ctxt, closure_type);
 }
 
-pub fn write_type(ecx: &EncodeContext,
-                  rbml_w: &mut Encoder,
-                  typ: Ty) {
+pub fn write_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
+                            rbml_w: &mut Encoder,
+                            typ: Ty<'tcx>) {
     let ty_str_ctxt = &tyencode::ctxt {
         diag: ecx.diag,
         ds: def_to_string,
@@ -182,9 +182,9 @@ pub fn write_type(ecx: &EncodeContext,
     tyencode::enc_ty(rbml_w.writer, ty_str_ctxt, typ);
 }
 
-pub fn write_trait_ref(ecx: &EncodeContext,
-                       rbml_w: &mut Encoder,
-                       trait_ref: &ty::TraitRef) {
+pub fn write_trait_ref<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
+                                 rbml_w: &mut Encoder,
+                                trait_ref: &ty::TraitRef<'tcx>) {
     let ty_str_ctxt = &tyencode::ctxt {
         diag: ecx.diag,
         ds: def_to_string,
@@ -206,10 +206,10 @@ pub fn write_region(ecx: &EncodeContext,
     tyencode::enc_region(rbml_w.writer, ty_str_ctxt, r);
 }
 
-fn encode_bounds(rbml_w: &mut Encoder,
-                 ecx: &EncodeContext,
-                 bounds: &ty::ParamBounds,
-                 tag: uint) {
+fn encode_bounds<'a, 'tcx>(rbml_w: &mut Encoder,
+                           ecx: &EncodeContext<'a, 'tcx>,
+                           bounds: &ty::ParamBounds<'tcx>,
+                           tag: uint) {
     rbml_w.start_tag(tag);
 
     let ty_str_ctxt = &tyencode::ctxt { diag: ecx.diag,
@@ -221,9 +221,9 @@ fn encode_bounds(rbml_w: &mut Encoder,
     rbml_w.end_tag();
 }
 
-fn encode_type(ecx: &EncodeContext,
-               rbml_w: &mut Encoder,
-               typ: Ty) {
+fn encode_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
+                         rbml_w: &mut Encoder,
+                         typ: Ty<'tcx>) {
     rbml_w.start_tag(tag_items_data_item_type);
     write_type(ecx, rbml_w, typ);
     rbml_w.end_tag();
@@ -237,9 +237,9 @@ fn encode_region(ecx: &EncodeContext,
     rbml_w.end_tag();
 }
 
-fn encode_method_fty(ecx: &EncodeContext,
-                     rbml_w: &mut Encoder,
-                     typ: &ty::BareFnTy) {
+fn encode_method_fty<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
+                               rbml_w: &mut Encoder,
+                               typ: &ty::BareFnTy<'tcx>) {
     rbml_w.start_tag(tag_item_method_fty);
 
     let ty_str_ctxt = &tyencode::ctxt {
@@ -781,10 +781,10 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
     rbml_w.end_tag();
 }
 
-fn encode_generics(rbml_w: &mut Encoder,
-                   ecx: &EncodeContext,
-                   generics: &ty::Generics,
-                   tag: uint)
+fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
+                             ecx: &EncodeContext<'a, 'tcx>,
+                             generics: &ty::Generics<'tcx>,
+                             tag: uint)
 {
     rbml_w.start_tag(tag);
 
@@ -828,9 +828,9 @@ fn encode_generics(rbml_w: &mut Encoder,
     rbml_w.end_tag();
 }
 
-fn encode_method_ty_fields(ecx: &EncodeContext,
-                           rbml_w: &mut Encoder,
-                           method_ty: &ty::Method) {
+fn encode_method_ty_fields<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
+                                     rbml_w: &mut Encoder,
+                                     method_ty: &ty::Method<'tcx>) {
     encode_def_id(rbml_w, method_ty.def_id);
     encode_name(rbml_w, method_ty.name);
     encode_generics(rbml_w, ecx, &method_ty.generics,
@@ -847,13 +847,13 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
     encode_provided_source(rbml_w, method_ty.provided_source);
 }
 
-fn encode_info_for_method(ecx: &EncodeContext,
-                          rbml_w: &mut Encoder,
-                          m: &ty::Method,
-                          impl_path: PathElems,
-                          is_default_impl: bool,
-                          parent_id: NodeId,
-                          ast_item_opt: Option<&ast::ImplItem>) {
+fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
+                                    rbml_w: &mut Encoder,
+                                    m: &ty::Method<'tcx>,
+                                    impl_path: PathElems,
+                                    is_default_impl: bool,
+                                    parent_id: NodeId,
+                                    ast_item_opt: Option<&ast::ImplItem>) {
 
     debug!("encode_info_for_method: {} {}", m.def_id,
            token::get_name(m.name));
@@ -2167,7 +2167,7 @@ struct Stats {
 }
 
 // Get the encoded string for a type
-pub fn encoded_ty(tcx: &ty::ctxt, t: Ty) -> String {
+pub fn encoded_ty<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> String {
     let mut wr = SeekableMemWriter::new();
     tyencode::enc_ty(&mut wr, &tyencode::ctxt {
         diag: tcx.sess.diagnostic(),
index 6215f7ea77448dbb80e7f561924a37f300438051..34b57c5b437ed3e26bdbcb60d905683cd39464f9 100644 (file)
@@ -139,18 +139,18 @@ fn data_log_string(data: &[u8], pos: uint) -> String {
     buf
 }
 
-pub fn parse_ty_closure_data(data: &[u8],
-                             crate_num: ast::CrateNum,
-                             pos: uint,
-                             tcx: &ty::ctxt,
-                             conv: conv_did)
-                             -> ty::ClosureTy {
+pub fn parse_ty_closure_data<'tcx>(data: &[u8],
+                                   crate_num: ast::CrateNum,
+                                   pos: uint,
+                                   tcx: &ty::ctxt<'tcx>,
+                                   conv: conv_did)
+                                   -> ty::ClosureTy<'tcx> {
     let mut st = parse_state_from_data(data, crate_num, pos, tcx);
     parse_closure_ty(&mut st, conv)
 }
 
-pub fn parse_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
-                     conv: conv_did) -> Ty {
+pub fn parse_ty_data<'tcx>(data: &[u8], crate_num: ast::CrateNum, pos: uint,
+                           tcx: &ty::ctxt<'tcx>, conv: conv_did) -> Ty<'tcx> {
     debug!("parse_ty_data {}", data_log_string(data, pos));
     let mut st = parse_state_from_data(data, crate_num, pos, tcx);
     parse_ty(&mut st, conv)
@@ -163,30 +163,32 @@ pub fn parse_region_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx:
     parse_region(&mut st, conv)
 }
 
-pub fn parse_bare_fn_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
-                             conv: conv_did) -> ty::BareFnTy {
+pub fn parse_bare_fn_ty_data<'tcx>(data: &[u8], crate_num: ast::CrateNum, pos: uint,
+                                   tcx: &ty::ctxt<'tcx>, conv: conv_did)
+                                   -> ty::BareFnTy<'tcx> {
     debug!("parse_bare_fn_ty_data {}", data_log_string(data, pos));
     let mut st = parse_state_from_data(data, crate_num, pos, tcx);
     parse_bare_fn_ty(&mut st, conv)
 }
 
-pub fn parse_trait_ref_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
-                            conv: conv_did) -> ty::TraitRef {
+pub fn parse_trait_ref_data<'tcx>(data: &[u8], crate_num: ast::CrateNum, pos: uint,
+                                  tcx: &ty::ctxt<'tcx>, conv: conv_did)
+                                  -> ty::TraitRef<'tcx> {
     debug!("parse_trait_ref_data {}", data_log_string(data, pos));
     let mut st = parse_state_from_data(data, crate_num, pos, tcx);
     parse_trait_ref(&mut st, conv)
 }
 
-pub fn parse_substs_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
-                         conv: conv_did) -> subst::Substs {
+pub fn parse_substs_data<'tcx>(data: &[u8], crate_num: ast::CrateNum, pos: uint,
+                               tcx: &ty::ctxt<'tcx>, conv: conv_did) -> subst::Substs<'tcx> {
     debug!("parse_substs_data {}", data_log_string(data, pos));
     let mut st = parse_state_from_data(data, crate_num, pos, tcx);
     parse_substs(&mut st, conv)
 }
 
-pub fn parse_bounds_data(data: &[u8], crate_num: ast::CrateNum,
-                         pos: uint, tcx: &ty::ctxt, conv: conv_did)
-                         -> ty::ParamBounds {
+pub fn parse_bounds_data<'tcx>(data: &[u8], crate_num: ast::CrateNum,
+                               pos: uint, tcx: &ty::ctxt<'tcx>, conv: conv_did)
+                               -> ty::ParamBounds<'tcx> {
     let mut st = parse_state_from_data(data, crate_num, pos, tcx);
     parse_bounds(&mut st, conv)
 }
@@ -229,9 +231,9 @@ fn parse_trait_store(st: &mut PState, conv: conv_did) -> ty::TraitStore {
     }
 }
 
-fn parse_vec_per_param_space<T>(st: &mut PState,
-                                f: |&mut PState| -> T)
-                                -> VecPerParamSpace<T>
+fn parse_vec_per_param_space<'a, 'tcx, T>(st: &mut PState<'a, 'tcx>,
+                                          f: |&mut PState<'a, 'tcx>| -> T)
+                                          -> VecPerParamSpace<T>
 {
     let mut r = VecPerParamSpace::empty();
     for &space in subst::ParamSpace::all().iter() {
@@ -244,7 +246,8 @@ fn parse_vec_per_param_space<T>(st: &mut PState,
     r
 }
 
-fn parse_substs(st: &mut PState, conv: conv_did) -> subst::Substs {
+fn parse_substs<'a, 'tcx>(st: &mut PState<'a, 'tcx>,
+                          conv: conv_did) -> subst::Substs<'tcx> {
     let regions =
         parse_region_substs(st, |x,y| conv(x,y));
 
@@ -334,7 +337,8 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
     }
 }
 
-fn parse_opt<T>(st: &mut PState, f: |&mut PState| -> T) -> Option<T> {
+fn parse_opt<'a, 'tcx, T>(st: &mut PState<'a, 'tcx>, f: |&mut PState<'a, 'tcx>| -> T)
+                          -> Option<T> {
     match next(st) {
       'n' => None,
       's' => Some(f(st)),
@@ -353,13 +357,14 @@ fn parse_str(st: &mut PState, term: char) -> String {
     result
 }
 
-fn parse_trait_ref(st: &mut PState, conv: conv_did) -> ty::TraitRef {
+fn parse_trait_ref<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
+                             -> ty::TraitRef<'tcx> {
     let def = parse_def(st, NominalType, |x,y| conv(x,y));
     let substs = parse_substs(st, |x,y| conv(x,y));
     ty::TraitRef {def_id: def, substs: substs}
 }
 
-fn parse_ty(st: &mut PState, conv: conv_did) -> Ty {
+fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
     match next(st) {
       'b' => return ty::mk_bool(),
       'i' => return ty::mk_int(),
@@ -486,7 +491,7 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
     }
 }
 
-fn parse_mt(st: &mut PState, conv: conv_did) -> ty::mt {
+fn parse_mt<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> ty::mt<'tcx> {
     let m = parse_mutability(st);
     ty::mt { ty: parse_ty(st, |x,y| conv(x,y)), mutbl: m }
 }
@@ -548,7 +553,8 @@ fn parse_onceness(c: char) -> ast::Onceness {
     }
 }
 
-fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy {
+fn parse_closure_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>,
+                              conv: conv_did) -> ty::ClosureTy<'tcx> {
     let fn_style = parse_fn_style(next(st));
     let onceness = parse_onceness(next(st));
     let store = parse_trait_store(st, |x,y| conv(x,y));
@@ -565,7 +571,8 @@ fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy {
     }
 }
 
-fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {
+fn parse_bare_fn_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>,
+                              conv: conv_did) -> ty::BareFnTy<'tcx> {
     let fn_style = parse_fn_style(next(st));
     let abi = parse_abi_set(st);
     let sig = parse_sig(st, |x,y| conv(x,y));
@@ -576,7 +583,7 @@ fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {
     }
 }
 
-fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig {
+fn parse_sig<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> ty::FnSig<'tcx> {
     assert_eq!(next(st), '[');
     let mut inputs = Vec::new();
     while peek(st) != ']' {
@@ -626,15 +633,16 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId {
     ast::DefId { krate: crate_num, node: def_num }
 }
 
-pub fn parse_type_param_def_data(data: &[u8], start: uint,
-                                 crate_num: ast::CrateNum, tcx: &ty::ctxt,
-                                 conv: conv_did) -> ty::TypeParameterDef
+pub fn parse_type_param_def_data<'tcx>(data: &[u8], start: uint,
+                                       crate_num: ast::CrateNum, tcx: &ty::ctxt<'tcx>,
+                                       conv: conv_did) -> ty::TypeParameterDef<'tcx>
 {
     let mut st = parse_state_from_data(data, crate_num, start, tcx);
     parse_type_param_def(&mut st, conv)
 }
 
-fn parse_type_param_def(st: &mut PState, conv: conv_did) -> ty::TypeParameterDef {
+fn parse_type_param_def<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
+                                  -> ty::TypeParameterDef<'tcx> {
     let name = parse_name(st, ':');
     let def_id = parse_def(st, NominalType, |x,y| conv(x,y));
     let space = parse_param_space(st);
@@ -692,7 +700,8 @@ fn parse_builtin_bounds(st: &mut PState, _conv: conv_did) -> ty::BuiltinBounds {
     }
 }
 
-fn parse_bounds(st: &mut PState, conv: conv_did) -> ty::ParamBounds {
+fn parse_bounds<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
+                          -> ty::ParamBounds<'tcx> {
     let builtin_bounds = parse_builtin_bounds(st, |x,y| conv(x,y));
 
     let mut param_bounds = ty::ParamBounds {
index 7c929a1fbcdd4f4843649bb88faa66426573d14a..2a445e17b203b6fc0b5d5caddbc904218fedf68c 100644 (file)
@@ -36,19 +36,19 @@ pub struct ctxt<'a, 'tcx: 'a> {
     pub ds: fn(ast::DefId) -> String,
     // The type context.
     pub tcx: &'a ty::ctxt<'tcx>,
-    pub abbrevs: &'a abbrev_map
+    pub abbrevs: &'a abbrev_map<'tcx>
 }
 
-// Compact string representation for ty.t values. API ty_str & parse_from_str.
+// Compact string representation for Ty values. API ty_str & parse_from_str.
 // Extra parameters are for converting to/from def_ids in the string rep.
 // Whatever format you choose should not contain pipe characters.
 pub struct ty_abbrev {
     s: String
 }
 
-pub type abbrev_map = RefCell<FnvHashMap<Ty, ty_abbrev>>;
+pub type abbrev_map<'tcx> = RefCell<FnvHashMap<Ty<'tcx>, ty_abbrev>>;
 
-pub fn enc_ty(w: &mut SeekableMemWriter, cx: &ctxt, t: Ty) {
+pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
     match cx.abbrevs.borrow_mut().get(&t) {
         Some(a) => { w.write(a.s.as_bytes()); return; }
         None => {}
@@ -79,7 +79,8 @@ fn enc_mutability(w: &mut SeekableMemWriter, mt: ast::Mutability) {
     }
 }
 
-fn enc_mt(w: &mut SeekableMemWriter, cx: &ctxt, mt: ty::mt) {
+fn enc_mt<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                    mt: ty::mt<'tcx>) {
     enc_mutability(w, mt.mutbl);
     enc_ty(w, cx, mt.ty);
 }
@@ -94,10 +95,10 @@ fn enc_opt<T>(w: &mut SeekableMemWriter, t: Option<T>, enc_f: |&mut SeekableMemW
     }
 }
 
-fn enc_vec_per_param_space<T>(w: &mut SeekableMemWriter,
-                              cx: &ctxt,
-                              v: &VecPerParamSpace<T>,
-                              op: |&mut SeekableMemWriter, &ctxt, &T|) {
+fn enc_vec_per_param_space<'a, 'tcx, T>(w: &mut SeekableMemWriter,
+                                        cx: &ctxt<'a, 'tcx>,
+                                        v: &VecPerParamSpace<T>,
+                                        op: |&mut SeekableMemWriter, &ctxt<'a, 'tcx>, &T|) {
     for &space in subst::ParamSpace::all().iter() {
         mywrite!(w, "[");
         for t in v.get_slice(space).iter() {
@@ -107,7 +108,8 @@ fn enc_vec_per_param_space<T>(w: &mut SeekableMemWriter,
     }
 }
 
-pub fn enc_substs(w: &mut SeekableMemWriter, cx: &ctxt, substs: &subst::Substs) {
+pub fn enc_substs<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                            substs: &subst::Substs<'tcx>) {
     enc_region_substs(w, cx, &substs.regions);
     enc_vec_per_param_space(w, cx, &substs.types,
                             |w, cx, &ty| enc_ty(w, cx, ty));
@@ -180,7 +182,8 @@ fn enc_bound_region(w: &mut SeekableMemWriter, cx: &ctxt, br: ty::BoundRegion) {
     }
 }
 
-pub fn enc_trait_ref(w: &mut SeekableMemWriter, cx: &ctxt, s: &ty::TraitRef) {
+pub fn enc_trait_ref<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                               s: &ty::TraitRef<'tcx>) {
     mywrite!(w, "{}|", (cx.ds)(s.def_id));
     enc_substs(w, cx, &s.substs);
 }
@@ -196,7 +199,8 @@ pub fn enc_trait_store(w: &mut SeekableMemWriter, cx: &ctxt, s: ty::TraitStore)
     }
 }
 
-fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) {
+fn enc_sty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                     st: &ty::sty<'tcx>) {
     match *st {
         ty::ty_bool => mywrite!(w, "b"),
         ty::ty_char => mywrite!(w, "c"),
@@ -314,13 +318,15 @@ fn enc_onceness(w: &mut SeekableMemWriter, o: ast::Onceness) {
     }
 }
 
-pub fn enc_bare_fn_ty(w: &mut SeekableMemWriter, cx: &ctxt, ft: &ty::BareFnTy) {
+pub fn enc_bare_fn_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                                ft: &ty::BareFnTy<'tcx>) {
     enc_fn_style(w, ft.fn_style);
     enc_abi(w, ft.abi);
     enc_fn_sig(w, cx, &ft.sig);
 }
 
-pub fn enc_closure_ty(w: &mut SeekableMemWriter, cx: &ctxt, ft: &ty::ClosureTy) {
+pub fn enc_closure_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                                ft: &ty::ClosureTy<'tcx>) {
     enc_fn_style(w, ft.fn_style);
     enc_onceness(w, ft.onceness);
     enc_trait_store(w, cx, ft.store);
@@ -329,7 +335,8 @@ pub fn enc_closure_ty(w: &mut SeekableMemWriter, cx: &ctxt, ft: &ty::ClosureTy)
     enc_abi(w, ft.abi);
 }
 
-fn enc_fn_sig(w: &mut SeekableMemWriter, cx: &ctxt, fsig: &ty::FnSig) {
+fn enc_fn_sig<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                        fsig: &ty::FnSig<'tcx>) {
     mywrite!(w, "[");
     for ty in fsig.inputs.iter() {
         enc_ty(w, cx, *ty);
@@ -368,7 +375,8 @@ pub fn enc_existential_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::Exi
     enc_builtin_bounds(w, cx, &bs.builtin_bounds);
 }
 
-pub fn enc_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::ParamBounds) {
+pub fn enc_bounds<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                            bs: &ty::ParamBounds<'tcx>) {
     enc_builtin_bounds(w, cx, &bs.builtin_bounds);
 
     for &r in bs.region_bounds.iter() {
@@ -384,7 +392,8 @@ pub fn enc_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::ParamBounds) {
     mywrite!(w, ".");
 }
 
-pub fn enc_type_param_def(w: &mut SeekableMemWriter, cx: &ctxt, v: &ty::TypeParameterDef) {
+pub fn enc_type_param_def<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
+                                    v: &ty::TypeParameterDef<'tcx>) {
     mywrite!(w, "{}:{}|{}|{}|",
              token::get_name(v.name), (cx.ds)(v.def_id),
              v.space.to_uint(), v.index);
index cd65334d6645f91361f2aa102b23541b1bae0b62..3cebb7236b64001e2d80c80e5b65f426c99db9df 100644 (file)
@@ -577,15 +577,15 @@ fn tr(&self, dcx: &DecodeContext) -> ty::UpvarBorrow {
 // ______________________________________________________________________
 // Encoding and decoding of MethodCallee
 
-trait read_method_callee_helper {
-    fn read_method_callee(&mut self, dcx: &DecodeContext)
-        -> (typeck::ExprAdjustment, MethodCallee);
+trait read_method_callee_helper<'tcx> {
+    fn read_method_callee<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+        -> (typeck::ExprAdjustment, MethodCallee<'tcx>);
 }
 
-fn encode_method_callee(ecx: &e::EncodeContext,
-                        rbml_w: &mut Encoder,
-                        adjustment: typeck::ExprAdjustment,
-                        method: &MethodCallee) {
+fn encode_method_callee<'a, 'tcx>(ecx: &e::EncodeContext<'a, 'tcx>,
+                                  rbml_w: &mut Encoder,
+                                  adjustment: typeck::ExprAdjustment,
+                                  method: &MethodCallee<'tcx>) {
     use serialize::Encoder;
 
     rbml_w.emit_struct("MethodCallee", 4, |rbml_w| {
@@ -604,9 +604,9 @@ fn encode_method_callee(ecx: &e::EncodeContext,
     }).unwrap();
 }
 
-impl<'a> read_method_callee_helper for reader::Decoder<'a> {
-    fn read_method_callee(&mut self, dcx: &DecodeContext)
-        -> (typeck::ExprAdjustment, MethodCallee) {
+impl<'a, 'tcx> read_method_callee_helper<'tcx> for reader::Decoder<'a> {
+    fn read_method_callee<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+        -> (typeck::ExprAdjustment, MethodCallee<'tcx>) {
 
         self.read_struct("MethodCallee", 4, |this| {
             let adjustment = this.read_struct_field("adjustment", 0, |this| {
@@ -627,8 +627,8 @@ fn read_method_callee(&mut self, dcx: &DecodeContext)
     }
 }
 
-impl tr for MethodOrigin {
-    fn tr(&self, dcx: &DecodeContext) -> MethodOrigin {
+impl<'tcx> tr for MethodOrigin<'tcx> {
+    fn tr(&self, dcx: &DecodeContext) -> MethodOrigin<'tcx> {
         match *self {
             typeck::MethodStatic(did) => typeck::MethodStatic(did.tr(dcx)),
             typeck::MethodStaticUnboxedClosure(did) => {
@@ -683,26 +683,26 @@ pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder,
     }).unwrap()
 }
 
-pub trait vtable_decoder_helpers {
+pub trait vtable_decoder_helpers<'tcx> {
     fn read_vec_per_param_space<T>(&mut self,
                                    f: |&mut Self| -> T)
                                    -> VecPerParamSpace<T>;
     fn read_vtable_res_with_key(&mut self,
-                                tcx: &ty::ctxt,
+                                tcx: &ty::ctxt<'tcx>,
                                 cdata: &cstore::crate_metadata)
-                                -> (typeck::ExprAdjustment, typeck::vtable_res);
+                                -> (typeck::ExprAdjustment, typeck::vtable_res<'tcx>);
     fn read_vtable_res(&mut self,
-                       tcx: &ty::ctxt, cdata: &cstore::crate_metadata)
-                      -> typeck::vtable_res;
+                       tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
+                      -> typeck::vtable_res<'tcx>;
     fn read_vtable_param_res(&mut self,
-                       tcx: &ty::ctxt, cdata: &cstore::crate_metadata)
-                      -> typeck::vtable_param_res;
+                       tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
+                      -> typeck::vtable_param_res<'tcx>;
     fn read_vtable_origin(&mut self,
-                          tcx: &ty::ctxt, cdata: &cstore::crate_metadata)
-                          -> typeck::vtable_origin;
+                          tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
+                          -> typeck::vtable_origin<'tcx>;
 }
 
-impl<'a> vtable_decoder_helpers for reader::Decoder<'a> {
+impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
     fn read_vec_per_param_space<T>(&mut self,
                                    f: |&mut reader::Decoder<'a>| -> T)
                                    -> VecPerParamSpace<T>
@@ -715,9 +715,9 @@ fn read_vec_per_param_space<T>(&mut self,
     }
 
     fn read_vtable_res_with_key(&mut self,
-                                tcx: &ty::ctxt,
+                                tcx: &ty::ctxt<'tcx>,
                                 cdata: &cstore::crate_metadata)
-                                -> (typeck::ExprAdjustment, typeck::vtable_res) {
+                                -> (typeck::ExprAdjustment, typeck::vtable_res<'tcx>) {
         self.read_struct("VtableWithKey", 2, |this| {
             let adjustment = this.read_struct_field("adjustment", 0, |this| {
                 Decodable::decode(this)
@@ -729,24 +729,24 @@ fn read_vtable_res_with_key(&mut self,
     }
 
     fn read_vtable_res(&mut self,
-                       tcx: &ty::ctxt,
+                       tcx: &ty::ctxt<'tcx>,
                        cdata: &cstore::crate_metadata)
-                       -> typeck::vtable_res
+                       -> typeck::vtable_res<'tcx>
     {
         self.read_vec_per_param_space(
             |this| this.read_vtable_param_res(tcx, cdata))
     }
 
     fn read_vtable_param_res(&mut self,
-                             tcx: &ty::ctxt, cdata: &cstore::crate_metadata)
-                      -> typeck::vtable_param_res {
+                             tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
+                      -> typeck::vtable_param_res<'tcx> {
         self.read_to_vec(|this| Ok(this.read_vtable_origin(tcx, cdata)))
              .unwrap().into_iter().collect()
     }
 
     fn read_vtable_origin(&mut self,
-                          tcx: &ty::ctxt, cdata: &cstore::crate_metadata)
-        -> typeck::vtable_origin {
+                          tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
+        -> typeck::vtable_origin<'tcx> {
         self.read_enum("vtable_origin", |this| {
             this.read_enum_variant(&["vtable_static",
                                      "vtable_param",
@@ -824,43 +824,46 @@ fn ty_str_ctxt<'a>(&'a self) -> tyencode::ctxt<'a, 'tcx> {
     }
 }
 
-trait rbml_writer_helpers {
-    fn emit_closure_type(&mut self,
-                         ecx: &e::EncodeContext,
-                         closure_type: &ty::ClosureTy);
-    fn emit_method_origin(&mut self,
-                          ecx: &e::EncodeContext,
-                          method_origin: &typeck::MethodOrigin);
-    fn emit_ty(&mut self, ecx: &e::EncodeContext, ty: Ty);
-    fn emit_tys(&mut self, ecx: &e::EncodeContext, tys: &[Ty]);
-    fn emit_type_param_def(&mut self,
-                           ecx: &e::EncodeContext,
-                           type_param_def: &ty::TypeParameterDef);
-    fn emit_trait_ref(&mut self, ecx: &e::EncodeContext, ty: &ty::TraitRef);
-    fn emit_polytype(&mut self,
-                     ecx: &e::EncodeContext,
-                     pty: ty::Polytype);
-    fn emit_substs(&mut self, ecx: &e::EncodeContext, substs: &subst::Substs);
+trait rbml_writer_helpers<'tcx> {
+    fn emit_closure_type<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                             closure_type: &ty::ClosureTy<'tcx>);
+    fn emit_method_origin<'a>(&mut self,
+                              ecx: &e::EncodeContext<'a, 'tcx>,
+                              method_origin: &typeck::MethodOrigin<'tcx>);
+    fn emit_ty<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, ty: Ty<'tcx>);
+    fn emit_tys<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, tys: &[Ty<'tcx>]);
+    fn emit_type_param_def<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                               type_param_def: &ty::TypeParameterDef<'tcx>);
+    fn emit_trait_ref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                          ty: &ty::TraitRef<'tcx>);
+    fn emit_polytype<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                         pty: ty::Polytype<'tcx>);
+    fn emit_substs<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                       substs: &subst::Substs<'tcx>);
     fn emit_existential_bounds(&mut self, ecx: &e::EncodeContext, bounds: &ty::ExistentialBounds);
     fn emit_builtin_bounds(&mut self, ecx: &e::EncodeContext, bounds: &ty::BuiltinBounds);
-    fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustment);
-    fn emit_autoref(&mut self, ecx: &e::EncodeContext, autoref: &ty::AutoRef);
-    fn emit_auto_deref_ref(&mut self, ecx: &e::EncodeContext, auto_deref_ref: &ty::AutoDerefRef);
-    fn emit_unsize_kind(&mut self, ecx: &e::EncodeContext, uk: &ty::UnsizeKind);
-}
-
-impl<'a> rbml_writer_helpers for Encoder<'a> {
-    fn emit_closure_type(&mut self,
-                         ecx: &e::EncodeContext,
-                         closure_type: &ty::ClosureTy) {
+    fn emit_auto_adjustment<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                                adj: &ty::AutoAdjustment<'tcx>);
+    fn emit_autoref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                        autoref: &ty::AutoRef<'tcx>);
+    fn emit_auto_deref_ref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                               auto_deref_ref: &ty::AutoDerefRef<'tcx>);
+    fn emit_unsize_kind<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                            uk: &ty::UnsizeKind<'tcx>);
+}
+
+impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
+    fn emit_closure_type<'a>(&mut self,
+                             ecx: &e::EncodeContext<'a, 'tcx>,
+                             closure_type: &ty::ClosureTy<'tcx>) {
         self.emit_opaque(|this| {
             Ok(e::write_closure_type(ecx, this, closure_type))
         });
     }
 
-    fn emit_method_origin(&mut self,
-                          ecx: &e::EncodeContext,
-                          method_origin: &typeck::MethodOrigin)
+    fn emit_method_origin<'a>(&mut self,
+                              ecx: &e::EncodeContext<'a, 'tcx>,
+                              method_origin: &typeck::MethodOrigin<'tcx>)
     {
         use serialize::Encoder;
 
@@ -915,23 +918,21 @@ fn emit_method_origin(&mut self,
         });
     }
 
-    fn emit_ty(&mut self, ecx: &e::EncodeContext, ty: Ty) {
+    fn emit_ty<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, ty: Ty<'tcx>) {
         self.emit_opaque(|this| Ok(e::write_type(ecx, this, ty)));
     }
 
-    fn emit_tys(&mut self, ecx: &e::EncodeContext, tys: &[Ty]) {
+    fn emit_tys<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, tys: &[Ty<'tcx>]) {
         self.emit_from_vec(tys, |this, ty| Ok(this.emit_ty(ecx, *ty)));
     }
 
-    fn emit_trait_ref(&mut self,
-                      ecx: &e::EncodeContext,
-                      trait_ref: &ty::TraitRef) {
+    fn emit_trait_ref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                          trait_ref: &ty::TraitRef<'tcx>) {
         self.emit_opaque(|this| Ok(e::write_trait_ref(ecx, this, trait_ref)));
     }
 
-    fn emit_type_param_def(&mut self,
-                           ecx: &e::EncodeContext,
-                           type_param_def: &ty::TypeParameterDef) {
+    fn emit_type_param_def<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                               type_param_def: &ty::TypeParameterDef<'tcx>) {
         self.emit_opaque(|this| {
             Ok(tyencode::enc_type_param_def(this.writer,
                                          &ecx.ty_str_ctxt(),
@@ -939,9 +940,9 @@ fn emit_type_param_def(&mut self,
         });
     }
 
-    fn emit_polytype(&mut self,
-                 ecx: &e::EncodeContext,
-                 pty: ty::Polytype) {
+    fn emit_polytype<'a>(&mut self,
+                         ecx: &e::EncodeContext<'a, 'tcx>,
+                         pty: ty::Polytype<'tcx>) {
         use serialize::Encoder;
 
         self.emit_struct("Polytype", 2, |this| {
@@ -977,13 +978,15 @@ fn emit_builtin_bounds(&mut self, ecx: &e::EncodeContext, bounds: &ty::BuiltinBo
                                                                 bounds)));
     }
 
-    fn emit_substs(&mut self, ecx: &e::EncodeContext, substs: &subst::Substs) {
+    fn emit_substs<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                       substs: &subst::Substs<'tcx>) {
         self.emit_opaque(|this| Ok(tyencode::enc_substs(this.writer,
                                                            &ecx.ty_str_ctxt(),
                                                            substs)));
     }
 
-    fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustment) {
+    fn emit_auto_adjustment<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                                adj: &ty::AutoAdjustment<'tcx>) {
         use serialize::Encoder;
 
         self.emit_enum("AutoAdjustment", |this| {
@@ -1004,7 +1007,8 @@ fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustm
         });
     }
 
-    fn emit_autoref(&mut self, ecx: &e::EncodeContext, autoref: &ty::AutoRef) {
+    fn emit_autoref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                        autoref: &ty::AutoRef<'tcx>) {
         use serialize::Encoder;
 
         self.emit_enum("AutoRef", |this| {
@@ -1053,7 +1057,8 @@ fn emit_autoref(&mut self, ecx: &e::EncodeContext, autoref: &ty::AutoRef) {
         });
     }
 
-    fn emit_auto_deref_ref(&mut self, ecx: &e::EncodeContext, auto_deref_ref: &ty::AutoDerefRef) {
+    fn emit_auto_deref_ref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                               auto_deref_ref: &ty::AutoDerefRef<'tcx>) {
         use serialize::Encoder;
 
         self.emit_struct("AutoDerefRef", 2, |this| {
@@ -1069,7 +1074,8 @@ fn emit_auto_deref_ref(&mut self, ecx: &e::EncodeContext, auto_deref_ref: &ty::A
         });
     }
 
-    fn emit_unsize_kind(&mut self, ecx: &e::EncodeContext, uk: &ty::UnsizeKind) {
+    fn emit_unsize_kind<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
+                            uk: &ty::UnsizeKind<'tcx>) {
         use serialize::Encoder;
 
         self.emit_enum("UnsizeKind", |this| {
@@ -1325,23 +1331,31 @@ fn opt_child(&self, tag: c::astencode_tag) -> Option<rbml::Doc<'a>> {
     }
 }
 
-trait rbml_decoder_decoder_helpers {
-    fn read_method_origin(&mut self, dcx: &DecodeContext) -> typeck::MethodOrigin;
-    fn read_ty(&mut self, dcx: &DecodeContext) -> Ty;
-    fn read_tys(&mut self, dcx: &DecodeContext) -> Vec<Ty>;
-    fn read_trait_ref(&mut self, dcx: &DecodeContext) -> Rc<ty::TraitRef>;
-    fn read_type_param_def(&mut self, dcx: &DecodeContext)
-                           -> ty::TypeParameterDef;
-    fn read_polytype(&mut self, dcx: &DecodeContext)
-                     -> ty::Polytype;
-    fn read_existential_bounds(&mut self, dcx: &DecodeContext) -> ty::ExistentialBounds;
-    fn read_substs(&mut self, dcx: &DecodeContext) -> subst::Substs;
-    fn read_auto_adjustment(&mut self, dcx: &DecodeContext) -> ty::AutoAdjustment;
-    fn read_unboxed_closure(&mut self, dcx: &DecodeContext)
-                            -> ty::UnboxedClosure;
-    fn read_auto_deref_ref(&mut self, dcx: &DecodeContext) -> ty::AutoDerefRef;
-    fn read_autoref(&mut self, dcx: &DecodeContext) -> ty::AutoRef;
-    fn read_unsize_kind(&mut self, dcx: &DecodeContext) -> ty::UnsizeKind;
+trait rbml_decoder_decoder_helpers<'tcx> {
+    fn read_method_origin<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                  -> typeck::MethodOrigin<'tcx>;
+    fn read_ty<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Ty<'tcx>;
+    fn read_tys<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Vec<Ty<'tcx>>;
+    fn read_trait_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                              -> Rc<ty::TraitRef<'tcx>>;
+    fn read_type_param_def<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                   -> ty::TypeParameterDef<'tcx>;
+    fn read_polytype<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                             -> ty::Polytype<'tcx>;
+    fn read_existential_bounds<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                       -> ty::ExistentialBounds;
+    fn read_substs<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                           -> subst::Substs<'tcx>;
+    fn read_auto_adjustment<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                    -> ty::AutoAdjustment<'tcx>;
+    fn read_unboxed_closure<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                    -> ty::UnboxedClosure<'tcx>;
+    fn read_auto_deref_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                   -> ty::AutoDerefRef<'tcx>;
+    fn read_autoref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                            -> ty::AutoRef<'tcx>;
+    fn read_unsize_kind<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                -> ty::UnsizeKind<'tcx>;
     fn convert_def_id(&mut self,
                       dcx: &DecodeContext,
                       source: DefIdSource,
@@ -1351,18 +1365,18 @@ fn convert_def_id(&mut self,
     // Versions of the type reading functions that don't need the full
     // DecodeContext.
     fn read_ty_nodcx(&mut self,
-                     tcx: &ty::ctxt, cdata: &cstore::crate_metadata) -> Ty;
+                     tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata) -> Ty<'tcx>;
     fn read_tys_nodcx(&mut self,
-                      tcx: &ty::ctxt,
-                      cdata: &cstore::crate_metadata) -> Vec<Ty>;
-    fn read_substs_nodcx(&mut self, tcx: &ty::ctxt,
+                      tcx: &ty::ctxt<'tcx>,
+                      cdata: &cstore::crate_metadata) -> Vec<Ty<'tcx>>;
+    fn read_substs_nodcx(&mut self, tcx: &ty::ctxt<'tcx>,
                          cdata: &cstore::crate_metadata)
-                         -> subst::Substs;
+                         -> subst::Substs<'tcx>;
 }
 
-impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
+impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
     fn read_ty_nodcx(&mut self,
-                     tcx: &ty::ctxt, cdata: &cstore::crate_metadata) -> Ty {
+                     tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata) -> Ty<'tcx> {
         self.read_opaque(|_, doc| {
             Ok(tydecode::parse_ty_data(
                 doc.data,
@@ -1374,8 +1388,8 @@ fn read_ty_nodcx(&mut self,
     }
 
     fn read_tys_nodcx(&mut self,
-                      tcx: &ty::ctxt,
-                      cdata: &cstore::crate_metadata) -> Vec<Ty> {
+                      tcx: &ty::ctxt<'tcx>,
+                      cdata: &cstore::crate_metadata) -> Vec<Ty<'tcx>> {
         self.read_to_vec(|this| Ok(this.read_ty_nodcx(tcx, cdata)) )
             .unwrap()
             .into_iter()
@@ -1383,9 +1397,9 @@ fn read_tys_nodcx(&mut self,
     }
 
     fn read_substs_nodcx(&mut self,
-                         tcx: &ty::ctxt,
+                         tcx: &ty::ctxt<'tcx>,
                          cdata: &cstore::crate_metadata)
-                         -> subst::Substs
+                         -> subst::Substs<'tcx>
     {
         self.read_opaque(|_, doc| {
             Ok(tydecode::parse_substs_data(
@@ -1397,8 +1411,8 @@ fn read_substs_nodcx(&mut self,
         }).unwrap()
     }
 
-    fn read_method_origin(&mut self, dcx: &DecodeContext)
-                          -> typeck::MethodOrigin
+    fn read_method_origin<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                  -> typeck::MethodOrigin<'tcx>
     {
         self.read_enum("MethodOrigin", |this| {
             let variants = &["MethodStatic", "MethodStaticUnboxedClosure",
@@ -1468,7 +1482,7 @@ fn read_method_origin(&mut self, dcx: &DecodeContext)
     }
 
 
-    fn read_ty(&mut self, dcx: &DecodeContext) -> Ty {
+    fn read_ty<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Ty<'tcx> {
         // Note: regions types embed local node ids.  In principle, we
         // should translate these node ids into the new decode
         // context.  However, we do not bother, because region types
@@ -1496,11 +1510,13 @@ fn type_string(doc: rbml::Doc) -> String {
         }
     }
 
-    fn read_tys(&mut self, dcx: &DecodeContext) -> Vec<Ty> {
+    fn read_tys<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                        -> Vec<Ty<'tcx>> {
         self.read_to_vec(|this| Ok(this.read_ty(dcx))).unwrap().into_iter().collect()
     }
 
-    fn read_trait_ref(&mut self, dcx: &DecodeContext) -> Rc<ty::TraitRef> {
+    fn read_trait_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                              -> Rc<ty::TraitRef<'tcx>> {
         Rc::new(self.read_opaque(|this, doc| {
             let ty = tydecode::parse_trait_ref_data(
                 doc.data,
@@ -1512,8 +1528,8 @@ fn read_trait_ref(&mut self, dcx: &DecodeContext) -> Rc<ty::TraitRef> {
         }).unwrap())
     }
 
-    fn read_type_param_def(&mut self, dcx: &DecodeContext)
-                           -> ty::TypeParameterDef {
+    fn read_type_param_def<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                   -> ty::TypeParameterDef<'tcx> {
         self.read_opaque(|this, doc| {
             Ok(tydecode::parse_type_param_def_data(
                 doc.data,
@@ -1524,8 +1540,8 @@ fn read_type_param_def(&mut self, dcx: &DecodeContext)
         }).unwrap()
     }
 
-    fn read_polytype(&mut self, dcx: &DecodeContext)
-                                   -> ty::Polytype {
+    fn read_polytype<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                             -> ty::Polytype<'tcx> {
         self.read_struct("Polytype", 2, |this| {
             Ok(ty::Polytype {
                 generics: this.read_struct_field("generics", 0, |this| {
@@ -1552,7 +1568,8 @@ fn read_polytype(&mut self, dcx: &DecodeContext)
         }).unwrap()
     }
 
-    fn read_existential_bounds(&mut self, dcx: &DecodeContext) -> ty::ExistentialBounds
+    fn read_existential_bounds<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                       -> ty::ExistentialBounds
     {
         self.read_opaque(|this, doc| {
             Ok(tydecode::parse_existential_bounds_data(doc.data,
@@ -1563,7 +1580,8 @@ fn read_existential_bounds(&mut self, dcx: &DecodeContext) -> ty::ExistentialBou
         }).unwrap()
     }
 
-    fn read_substs(&mut self, dcx: &DecodeContext) -> subst::Substs {
+    fn read_substs<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                           -> subst::Substs<'tcx> {
         self.read_opaque(|this, doc| {
             Ok(tydecode::parse_substs_data(doc.data,
                                         dcx.cdata.cnum,
@@ -1573,7 +1591,8 @@ fn read_substs(&mut self, dcx: &DecodeContext) -> subst::Substs {
         }).unwrap()
     }
 
-    fn read_auto_adjustment(&mut self, dcx: &DecodeContext) -> ty::AutoAdjustment {
+    fn read_auto_adjustment<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                    -> ty::AutoAdjustment<'tcx> {
         self.read_enum("AutoAdjustment", |this| {
             let variants = ["AutoAddEnv", "AutoDerefRef"];
             this.read_enum_variant(&variants, |this, i| {
@@ -1597,7 +1616,8 @@ fn read_auto_adjustment(&mut self, dcx: &DecodeContext) -> ty::AutoAdjustment {
         }).unwrap()
     }
 
-    fn read_auto_deref_ref(&mut self, dcx: &DecodeContext) -> ty::AutoDerefRef {
+    fn read_auto_deref_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                   -> ty::AutoDerefRef<'tcx> {
         self.read_struct("AutoDerefRef", 2, |this| {
             Ok(ty::AutoDerefRef {
                 autoderefs: this.read_struct_field("autoderefs", 0, |this| {
@@ -1616,7 +1636,7 @@ fn read_auto_deref_ref(&mut self, dcx: &DecodeContext) -> ty::AutoDerefRef {
         }).unwrap()
     }
 
-    fn read_autoref(&mut self, dcx: &DecodeContext) -> ty::AutoRef {
+    fn read_autoref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> ty::AutoRef<'tcx> {
         self.read_enum("AutoRef", |this| {
             let variants = ["AutoPtr",
                             "AutoUnsize",
@@ -1674,7 +1694,8 @@ fn read_autoref(&mut self, dcx: &DecodeContext) -> ty::AutoRef {
         }).unwrap()
     }
 
-    fn read_unsize_kind(&mut self, dcx: &DecodeContext) -> ty::UnsizeKind {
+    fn read_unsize_kind<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                -> ty::UnsizeKind<'tcx> {
         self.read_enum("UnsizeKind", |this| {
             let variants = &["UnsizeLength", "UnsizeStruct", "UnsizeVtable"];
             this.read_enum_variant(variants, |this, i| {
@@ -1716,8 +1737,8 @@ fn read_unsize_kind(&mut self, dcx: &DecodeContext) -> ty::UnsizeKind {
         }).unwrap()
     }
 
-    fn read_unboxed_closure(&mut self, dcx: &DecodeContext)
-                            -> ty::UnboxedClosure {
+    fn read_unboxed_closure<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
+                                    -> ty::UnboxedClosure<'tcx> {
         let closure_type = self.read_opaque(|this, doc| {
             Ok(tydecode::parse_ty_closure_data(
                 doc.data,
index c7fe1ce73194636c7e859f1da6df69eefccb101a..d91d666511dd5fe40fe82cd49d44cbf17b881f7a 100644 (file)
@@ -86,11 +86,11 @@ struct CheckLoanCtxt<'a, 'tcx: 'a> {
     all_loans: &'a [Loan],
 }
 
-impl<'a, 'tcx> euv::Delegate for CheckLoanCtxt<'a, 'tcx> {
+impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
     fn consume(&mut self,
                consume_id: ast::NodeId,
                consume_span: Span,
-               cmt: mc::cmt,
+               cmt: mc::cmt<'tcx>,
                mode: euv::ConsumeMode) {
         debug!("consume(consume_id={}, cmt={}, mode={})",
                consume_id, cmt.repr(self.tcx()), mode);
@@ -100,7 +100,7 @@ fn consume(&mut self,
 
     fn consume_pat(&mut self,
                    consume_pat: &ast::Pat,
-                   cmt: mc::cmt,
+                   cmt: mc::cmt<'tcx>,
                    mode: euv::ConsumeMode) {
         debug!("consume_pat(consume_pat={}, cmt={}, mode={})",
                consume_pat.repr(self.tcx()),
@@ -113,7 +113,7 @@ fn consume_pat(&mut self,
     fn borrow(&mut self,
               borrow_id: ast::NodeId,
               borrow_span: Span,
-              cmt: mc::cmt,
+              cmt: mc::cmt<'tcx>,
               loan_region: ty::Region,
               bk: ty::BorrowKind,
               loan_cause: euv::LoanCause)
@@ -140,7 +140,7 @@ fn borrow(&mut self,
     fn mutate(&mut self,
               assignment_id: ast::NodeId,
               assignment_span: Span,
-              assignee_cmt: mc::cmt,
+              assignee_cmt: mc::cmt<'tcx>,
               mode: euv::MutateMode)
     {
         debug!("mutate(assignment_id={}, assignee_cmt={})",
@@ -737,7 +737,7 @@ fn check_if_assigned_path_is_moved(&self,
     fn check_assignment(&self,
                         assignment_id: ast::NodeId,
                         assignment_span: Span,
-                        assignee_cmt: mc::cmt,
+                        assignee_cmt: mc::cmt<'tcx>,
                         mode: euv::MutateMode) {
         debug!("check_assignment(assignee_cmt={})", assignee_cmt.repr(self.tcx()));
 
@@ -820,8 +820,8 @@ fn check_assignment(&self,
         }
         return;
 
-        fn mark_variable_as_used_mut(this: &CheckLoanCtxt,
-                                     mut cmt: mc::cmt) {
+        fn mark_variable_as_used_mut<'a, 'tcx>(this: &CheckLoanCtxt<'a, 'tcx>,
+                                               mut cmt: mc::cmt<'tcx>) {
             //! If the mutability of the `cmt` being written is inherited
             //! from a local variable, liveness will
             //! not have been able to detect that this variable's mutability
@@ -868,9 +868,9 @@ fn mark_variable_as_used_mut(this: &CheckLoanCtxt,
             }
         }
 
-        fn check_for_aliasable_mutable_writes(this: &CheckLoanCtxt,
-                                              span: Span,
-                                              cmt: mc::cmt) -> bool {
+        fn check_for_aliasable_mutable_writes<'a, 'tcx>(this: &CheckLoanCtxt<'a, 'tcx>,
+                                                        span: Span,
+                                                        cmt: mc::cmt<'tcx>) -> bool {
             //! Safety checks related to writes to aliasable, mutable locations
 
             let guarantor = cmt.guarantor();
@@ -889,10 +889,10 @@ fn check_for_aliasable_mutable_writes(this: &CheckLoanCtxt,
             return true; // no errors reported
         }
 
-        fn check_for_aliasability_violation(this: &CheckLoanCtxt,
-                                            span: Span,
-                                            cmt: mc::cmt)
-                                            -> bool {
+        fn check_for_aliasability_violation<'a, 'tcx>(this: &CheckLoanCtxt<'a, 'tcx>,
+                                                      span: Span,
+                                                      cmt: mc::cmt<'tcx>)
+                                                      -> bool {
             match cmt.freely_aliasable(this.tcx()) {
                 None => {
                     return true;
index a1c02b85e8f51cd085764f98fbac2e09597a192f..2ca42a42a0255c5b8ddf95616e143587c20124f3 100644 (file)
 
 use std::rc::Rc;
 
-struct GatherMoveInfo {
+struct GatherMoveInfo<'tcx> {
     id: ast::NodeId,
     kind: MoveKind,
-    cmt: mc::cmt,
+    cmt: mc::cmt<'tcx>,
     span_path_opt: Option<MoveSpanAndPath>
 }
 
@@ -41,12 +41,12 @@ pub fn gather_decl(bccx: &BorrowckCtxt,
     move_data.add_move(bccx.tcx, loan_path, decl_id, Declared);
 }
 
-pub fn gather_move_from_expr(bccx: &BorrowckCtxt,
-                             move_data: &MoveData,
-                             move_error_collector: &MoveErrorCollector,
-                             move_expr_id: ast::NodeId,
-                             cmt: mc::cmt,
-                             move_reason: euv::MoveReason) {
+pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                       move_data: &MoveData,
+                                       move_error_collector: &MoveErrorCollector<'tcx>,
+                                       move_expr_id: ast::NodeId,
+                                       cmt: mc::cmt<'tcx>,
+                                       move_reason: euv::MoveReason) {
     let kind = match move_reason {
         euv::DirectRefMove | euv::PatBindingMove => MoveExpr,
         euv::CaptureMove => Captured
@@ -60,11 +60,11 @@ pub fn gather_move_from_expr(bccx: &BorrowckCtxt,
     gather_move(bccx, move_data, move_error_collector, move_info);
 }
 
-pub fn gather_move_from_pat(bccx: &BorrowckCtxt,
-                            move_data: &MoveData,
-                            move_error_collector: &MoveErrorCollector,
-                            move_pat: &ast::Pat,
-                            cmt: mc::cmt) {
+pub fn gather_move_from_pat<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                      move_data: &MoveData,
+                                      move_error_collector: &MoveErrorCollector<'tcx>,
+                                      move_pat: &ast::Pat,
+                                      cmt: mc::cmt<'tcx>) {
     let pat_span_path_opt = match move_pat.node {
         ast::PatIdent(_, ref path1, _) => {
             Some(MoveSpanAndPath{span: move_pat.span,
@@ -81,10 +81,10 @@ pub fn gather_move_from_pat(bccx: &BorrowckCtxt,
     gather_move(bccx, move_data, move_error_collector, move_info);
 }
 
-fn gather_move(bccx: &BorrowckCtxt,
-               move_data: &MoveData,
-               move_error_collector: &MoveErrorCollector,
-               move_info: GatherMoveInfo) {
+fn gather_move<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                         move_data: &MoveData,
+                         move_error_collector: &MoveErrorCollector<'tcx>,
+                         move_info: GatherMoveInfo<'tcx>) {
     debug!("gather_move(move_id={}, cmt={})",
            move_info.id, move_info.cmt.repr(bccx.tcx));
 
@@ -127,8 +127,9 @@ pub fn gather_assignment(bccx: &BorrowckCtxt,
                              mode);
 }
 
-fn check_and_get_illegal_move_origin(bccx: &BorrowckCtxt,
-                                     cmt: &mc::cmt) -> Option<mc::cmt> {
+fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                               cmt: &mc::cmt<'tcx>)
+                                               -> Option<mc::cmt<'tcx>> {
     match cmt.cat {
         mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
         mc::cat_deref(_, _, mc::Implicit(..)) |
index 41fe77d5197fd5b6325b2ab102eb364c78c59abb..99795fb3009021720934c7caef47718835430df5 100644 (file)
 
 type R = Result<(),()>;
 
-pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
-                          item_scope_id: ast::NodeId,
-                          span: Span,
-                          cause: euv::LoanCause,
-                          cmt: mc::cmt,
-                          loan_region: ty::Region,
-                          _: ty::BorrowKind)
-                          -> Result<(),()> {
+pub fn guarantee_lifetime<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                    item_scope_id: ast::NodeId,
+                                    span: Span,
+                                    cause: euv::LoanCause,
+                                    cmt: mc::cmt<'tcx>,
+                                    loan_region: ty::Region,
+                                    _: ty::BorrowKind)
+                                    -> Result<(),()> {
     debug!("guarantee_lifetime(cmt={}, loan_region={})",
            cmt.repr(bccx.tcx), loan_region.repr(bccx.tcx));
     let ctxt = GuaranteeLifetimeContext {bccx: bccx,
@@ -54,12 +54,12 @@ struct GuaranteeLifetimeContext<'a, 'tcx: 'a> {
     span: Span,
     cause: euv::LoanCause,
     loan_region: ty::Region,
-    cmt_original: mc::cmt
+    cmt_original: mc::cmt<'tcx>
 }
 
 impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
 
-    fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
+    fn check(&self, cmt: &mc::cmt<'tcx>, discr_scope: Option<ast::NodeId>) -> R {
         //! Main routine. Walks down `cmt` until we find the "guarantor".
         debug!("guarantee_lifetime.check(cmt={}, loan_region={})",
                cmt.repr(self.bccx.tcx),
index 7d893a0533a370ab994a1c2f519bba316b149f57..6bb511b2077c9659334036b271060ffa9c8a2bd6 100644 (file)
@@ -60,16 +60,16 @@ pub fn gather_loans_in_fn(bccx: &BorrowckCtxt,
 struct GatherLoanCtxt<'a, 'tcx: 'a> {
     bccx: &'a BorrowckCtxt<'a, 'tcx>,
     move_data: move_data::MoveData,
-    move_error_collector: move_error::MoveErrorCollector,
+    move_error_collector: move_error::MoveErrorCollector<'tcx>,
     all_loans: Vec<Loan>,
     item_ub: ast::NodeId,
 }
 
-impl<'a, 'tcx> euv::Delegate for GatherLoanCtxt<'a, 'tcx> {
+impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
     fn consume(&mut self,
                consume_id: ast::NodeId,
                _consume_span: Span,
-               cmt: mc::cmt,
+               cmt: mc::cmt<'tcx>,
                mode: euv::ConsumeMode) {
         debug!("consume(consume_id={}, cmt={}, mode={})",
                consume_id, cmt.repr(self.tcx()), mode);
@@ -86,7 +86,7 @@ fn consume(&mut self,
 
     fn consume_pat(&mut self,
                    consume_pat: &ast::Pat,
-                   cmt: mc::cmt,
+                   cmt: mc::cmt<'tcx>,
                    mode: euv::ConsumeMode) {
         debug!("consume_pat(consume_pat={}, cmt={}, mode={})",
                consume_pat.repr(self.tcx()),
@@ -106,7 +106,7 @@ fn consume_pat(&mut self,
     fn borrow(&mut self,
               borrow_id: ast::NodeId,
               borrow_span: Span,
-              cmt: mc::cmt,
+              cmt: mc::cmt<'tcx>,
               loan_region: ty::Region,
               bk: ty::BorrowKind,
               loan_cause: euv::LoanCause)
@@ -127,7 +127,7 @@ fn borrow(&mut self,
     fn mutate(&mut self,
               assignment_id: ast::NodeId,
               assignment_span: Span,
-              assignee_cmt: mc::cmt,
+              assignee_cmt: mc::cmt<'tcx>,
               mode: euv::MutateMode)
     {
         debug!("mutate(assignment_id={}, assignee_cmt={})",
@@ -153,12 +153,12 @@ fn decl_without_init(&mut self, id: ast::NodeId, span: Span) {
 }
 
 /// Implements the A-* rules in doc.rs.
-fn check_aliasability(bccx: &BorrowckCtxt,
-                      borrow_span: Span,
-                      loan_cause: euv::LoanCause,
-                      cmt: mc::cmt,
-                      req_kind: ty::BorrowKind)
-                      -> Result<(),()> {
+fn check_aliasability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                borrow_span: Span,
+                                loan_cause: euv::LoanCause,
+                                cmt: mc::cmt<'tcx>,
+                                req_kind: ty::BorrowKind)
+                                -> Result<(),()> {
 
     match (cmt.freely_aliasable(bccx.tcx), req_kind) {
         (None, _) => {
@@ -206,7 +206,7 @@ pub fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.bccx.tcx }
     fn guarantee_valid(&mut self,
                        borrow_id: ast::NodeId,
                        borrow_span: Span,
-                       cmt: mc::cmt,
+                       cmt: mc::cmt<'tcx>,
                        req_kind: ty::BorrowKind,
                        loan_region: ty::Region,
                        cause: euv::LoanCause) {
@@ -349,12 +349,12 @@ fn guarantee_valid(&mut self,
             //    }
         // }
 
-        fn check_mutability(bccx: &BorrowckCtxt,
-                            borrow_span: Span,
-                            cause: euv::LoanCause,
-                            cmt: mc::cmt,
-                            req_kind: ty::BorrowKind)
-                            -> Result<(),()> {
+        fn check_mutability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                      borrow_span: Span,
+                                      cause: euv::LoanCause,
+                                      cmt: mc::cmt<'tcx>,
+                                      req_kind: ty::BorrowKind)
+                                      -> Result<(),()> {
             //! Implements the M-* rules in doc.rs.
 
             match req_kind {
index ab6ff08c9d4e8c65fd4e6b025cc6506899b26a60..a8440507949f41497d808a35b9ceb3a2b75de0bb 100644 (file)
 use syntax::print::pprust;
 use util::ppaux::UserString;
 
-pub struct MoveErrorCollector {
-    errors: RefCell<Vec<MoveError>>
+pub struct MoveErrorCollector<'tcx> {
+    errors: RefCell<Vec<MoveError<'tcx>>>
 }
 
-impl MoveErrorCollector {
-    pub fn new() -> MoveErrorCollector {
+impl<'tcx> MoveErrorCollector<'tcx> {
+    pub fn new() -> MoveErrorCollector<'tcx> {
         MoveErrorCollector {
             errors: RefCell::new(Vec::new())
         }
     }
 
-    pub fn add_error(&self, error: MoveError) {
+    pub fn add_error(&self, error: MoveError<'tcx>) {
         self.errors.borrow_mut().push(error);
     }
 
-    pub fn report_potential_errors(&self, bccx: &BorrowckCtxt) {
+    pub fn report_potential_errors<'a>(&self, bccx: &BorrowckCtxt<'a, 'tcx>) {
         report_move_errors(bccx, self.errors.borrow().deref())
     }
 }
 
-pub struct MoveError {
-    move_from: mc::cmt,
+pub struct MoveError<'tcx> {
+    move_from: mc::cmt<'tcx>,
     move_to: Option<MoveSpanAndPath>
 }
 
-impl MoveError {
-    pub fn with_move_info(move_from: mc::cmt,
+impl<'tcx> MoveError<'tcx> {
+    pub fn with_move_info(move_from: mc::cmt<'tcx>,
                           move_to: Option<MoveSpanAndPath>)
-                          -> MoveError {
+                          -> MoveError<'tcx> {
         MoveError {
             move_from: move_from,
             move_to: move_to,
@@ -60,12 +60,13 @@ pub struct MoveSpanAndPath {
     pub ident: ast::Ident
 }
 
-pub struct GroupedMoveErrors {
-    move_from: mc::cmt,
+pub struct GroupedMoveErrors<'tcx> {
+    move_from: mc::cmt<'tcx>,
     move_to_places: Vec<MoveSpanAndPath>
 }
 
-fn report_move_errors(bccx: &BorrowckCtxt, errors: &Vec<MoveError>) {
+fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                errors: &Vec<MoveError<'tcx>>) {
     let grouped_errors = group_errors_with_same_origin(errors);
     for error in grouped_errors.iter() {
         report_cannot_move_out_of(bccx, error.move_from.clone());
@@ -78,16 +79,16 @@ fn report_move_errors(bccx: &BorrowckCtxt, errors: &Vec<MoveError>) {
     }
 }
 
-fn group_errors_with_same_origin(errors: &Vec<MoveError>)
-                                 -> Vec<GroupedMoveErrors> {
+fn group_errors_with_same_origin<'tcx>(errors: &Vec<MoveError<'tcx>>)
+                                       -> Vec<GroupedMoveErrors<'tcx>> {
     let mut grouped_errors = Vec::new();
     for error in errors.iter() {
         append_to_grouped_errors(&mut grouped_errors, error)
     }
     return grouped_errors;
 
-    fn append_to_grouped_errors(grouped_errors: &mut Vec<GroupedMoveErrors>,
-                                error: &MoveError) {
+    fn append_to_grouped_errors<'tcx>(grouped_errors: &mut Vec<GroupedMoveErrors<'tcx>>,
+                                      error: &MoveError<'tcx>) {
         let move_from_id = error.move_from.id;
         debug!("append_to_grouped_errors(move_from_id={})", move_from_id);
         let move_to = if error.move_to.is_some() {
@@ -110,7 +111,8 @@ fn append_to_grouped_errors(grouped_errors: &mut Vec<GroupedMoveErrors>,
     }
 }
 
-fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) {
+fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                       move_from: mc::cmt<'tcx>) {
     match move_from.cat {
         mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
         mc::cat_deref(_, _, mc::Implicit(..)) |
index 1c8f1effcf6d493eb6fe3f3e278ee9bbbd0311a3..9b9a5e61393f888fe43448b9f284b67ea6c08f5b 100644 (file)
@@ -29,11 +29,12 @@ pub enum RestrictionResult {
     SafeIf(Rc<LoanPath>, Vec<Rc<LoanPath>>)
 }
 
-pub fn compute_restrictions(bccx: &BorrowckCtxt,
-                            span: Span,
-                            cause: euv::LoanCause,
-                            cmt: mc::cmt,
-                            loan_region: ty::Region) -> RestrictionResult {
+pub fn compute_restrictions<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
+                                      span: Span,
+                                      cause: euv::LoanCause,
+                                      cmt: mc::cmt<'tcx>,
+                                      loan_region: ty::Region)
+                                      -> RestrictionResult {
     let ctxt = RestrictionsContext {
         bccx: bccx,
         span: span,
@@ -56,7 +57,7 @@ struct RestrictionsContext<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
     fn restrict(&self,
-                cmt: mc::cmt) -> RestrictionResult {
+                cmt: mc::cmt<'tcx>) -> RestrictionResult {
         debug!("restrict(cmt={})", cmt.repr(self.bccx.tcx));
 
         match cmt.cat.clone() {
index 45bab842bca1086dc9b54c11570b8f1a53a89ea4..dff70b92031a94c1d88a33cf9f65960903443f16 100644 (file)
@@ -247,7 +247,7 @@ struct BorrowStats {
     guaranteed_paths: uint
 }
 
-pub type BckResult<T> = Result<T, BckError>;
+pub type BckResult<'tcx, T> = Result<T, BckError<'tcx>>;
 
 ///////////////////////////////////////////////////////////////////////////
 // Loans and loan paths
@@ -405,10 +405,10 @@ pub enum bckerr_code {
 // Combination of an error code and the categorization of the expression
 // that caused it
 #[deriving(PartialEq)]
-pub struct BckError {
+pub struct BckError<'tcx> {
     span: Span,
     cause: euv::LoanCause,
-    cmt: mc::cmt,
+    cmt: mc::cmt<'tcx>,
     code: bckerr_code
 }
 
@@ -436,7 +436,7 @@ pub fn mc(&self) -> mc::MemCategorizationContext<'a, ty::ctxt<'tcx>> {
         mc::MemCategorizationContext::new(self.tcx)
     }
 
-    pub fn cat_expr(&self, expr: &ast::Expr) -> mc::cmt {
+    pub fn cat_expr(&self, expr: &ast::Expr) -> mc::cmt<'tcx> {
         match self.mc().cat_expr(expr) {
             Ok(c) => c,
             Err(()) => {
@@ -445,7 +445,7 @@ pub fn cat_expr(&self, expr: &ast::Expr) -> mc::cmt {
         }
     }
 
-    pub fn report(&self, err: BckError) {
+    pub fn report(&self, err: BckError<'tcx>) {
         self.span_err(
             err.span,
             self.bckerr_to_string(&err).as_slice());
@@ -586,8 +586,9 @@ pub fn report_use_of_moved_value(&self,
             }
         }
 
-        fn move_suggestion(tcx: &ty::ctxt, ty: Ty, default_msgs: (&'static str, &'static str))
-                          -> (&'static str, &'static str) {
+        fn move_suggestion<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>,
+                                 default_msgs: (&'static str, &'static str))
+                                 -> (&'static str, &'static str) {
             match ty::get(ty).sty {
                 ty::ty_closure(box ty::ClosureTy {
                         store: ty::RegionTraitStore(..),
@@ -631,7 +632,7 @@ pub fn span_help(&self, s: Span, m: &str) {
         self.tcx.sess.span_help(s, m);
     }
 
-    pub fn bckerr_to_string(&self, err: &BckError) -> String {
+    pub fn bckerr_to_string(&self, err: &BckError<'tcx>) -> String {
         match err.code {
             err_mutbl => {
                 let descr = match err.cmt.note {
@@ -766,7 +767,7 @@ pub fn report_aliasability_violation(&self,
         }
     }
 
-    pub fn note_and_explain_bckerr(&self, err: BckError) {
+    pub fn note_and_explain_bckerr(&self, err: BckError<'tcx>) {
         let code = err.code;
         match code {
             err_mutbl(..) => {
@@ -893,7 +894,7 @@ pub fn loan_path_to_string(&self, loan_path: &LoanPath) -> String {
         result
     }
 
-    pub fn cmt_to_string(&self, cmt: &mc::cmt_) -> String {
+    pub fn cmt_to_string(&self, cmt: &mc::cmt_<'tcx>) -> String {
         self.mc().cmt_to_string(cmt)
     }
 }
@@ -924,7 +925,7 @@ fn initial_value(&self) -> bool {
     }
 }
 
-impl Repr for Loan {
+impl<'tcx> Repr<'tcx> for Loan {
     fn repr(&self, tcx: &ty::ctxt) -> String {
         format!("Loan_{}({}, {}, {}-{}, {})",
                  self.index,
@@ -936,7 +937,7 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl Repr for LoanPath {
+impl<'tcx> Repr<'tcx> for LoanPath {
     fn repr(&self, tcx: &ty::ctxt) -> String {
         match self {
             &LpVar(id) => {
index bb118dcb349fff6aab8aa3525b9b430e01dea282..c161bf6b34877218535bf56f038fc890bee3348c 100644 (file)
@@ -1024,7 +1024,7 @@ struct MutationChecker<'a, 'tcx: 'a> {
     cx: &'a MatchCheckCtxt<'a, 'tcx>,
 }
 
-impl<'a, 'tcx> Delegate for MutationChecker<'a, 'tcx> {
+impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
     fn consume(&mut self, _: NodeId, _: Span, _: cmt, _: ConsumeMode) {}
     fn consume_pat(&mut self, _: &Pat, _: cmt, _: ConsumeMode) {}
     fn borrow(&mut self,
index cd7c4b15494a997ed05470e87e274278ba05359c..dbba9288cbbc4cb0d9874655cdd272453a78be2b 100644 (file)
@@ -45,11 +45,11 @@ fn visit_fn(&mut self,
     }
 }
 
-impl<'a, 'tcx> euv::Delegate for RvalueContext<'a, 'tcx> {
+impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContext<'a, 'tcx> {
     fn consume(&mut self,
                _: ast::NodeId,
                span: Span,
-               cmt: mc::cmt,
+               cmt: mc::cmt<'tcx>,
                _: euv::ConsumeMode) {
         debug!("consume; cmt: {}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
         if !ty::type_is_sized(self.tcx, cmt.ty) {
index 636898187e49e63a58e4383abb397dad7c74547d..dab6339ad533758a9eafb445fc818c4125305c31 100644 (file)
@@ -53,7 +53,7 @@ struct CheckStaticVisitor<'a, 'tcx: 'a> {
     checker: &'a mut GlobalChecker,
 }
 
-struct GlobalVisitor<'a, 'b, 't: 'b>(euv::ExprUseVisitor<'a, 'b, ty::ctxt<'t>>);
+struct GlobalVisitor<'a, 'b, 'tcx: 'b>(euv::ExprUseVisitor<'a, 'b, 'tcx, ty::ctxt<'tcx>>);
 struct GlobalChecker {
     static_consumptions: NodeSet,
     const_borrows: NodeSet,
@@ -256,7 +256,7 @@ fn visit_item(&mut self, item: &ast::Item) {
     }
 }
 
-impl euv::Delegate for GlobalChecker {
+impl<'tcx> euv::Delegate<'tcx> for GlobalChecker {
     fn consume(&mut self,
                consume_id: ast::NodeId,
                _consume_span: Span,
index 494d678ea382621109fcec37f58c9aacbeca695e..e86fb18259c79dac36abe6cc15d29acfc804a182 100644 (file)
 
 /// This trait defines the callbacks you can expect to receive when
 /// employing the ExprUseVisitor.
-pub trait Delegate {
+pub trait Delegate<'tcx> {
     // The value found at `cmt` is either copied or moved, depending
     // on mode.
     fn consume(&mut self,
                consume_id: ast::NodeId,
                consume_span: Span,
-               cmt: mc::cmt,
+               cmt: mc::cmt<'tcx>,
                mode: ConsumeMode);
 
     // The value found at `cmt` is either copied or moved via the
     // pattern binding `consume_pat`, depending on mode.
     fn consume_pat(&mut self,
                    consume_pat: &ast::Pat,
-                   cmt: mc::cmt,
+                   cmt: mc::cmt<'tcx>,
                    mode: ConsumeMode);
 
     // The value found at `borrow` is being borrowed at the point
@@ -61,7 +61,7 @@ fn consume_pat(&mut self,
     fn borrow(&mut self,
               borrow_id: ast::NodeId,
               borrow_span: Span,
-              cmt: mc::cmt,
+              cmt: mc::cmt<'tcx>,
               loan_region: ty::Region,
               bk: ty::BorrowKind,
               loan_cause: LoanCause);
@@ -75,7 +75,7 @@ fn decl_without_init(&mut self,
     fn mutate(&mut self,
               assignment_id: ast::NodeId,
               assignment_span: Span,
-              assignee_cmt: mc::cmt,
+              assignee_cmt: mc::cmt<'tcx>,
               mode: MutateMode);
 }
 
@@ -201,10 +201,10 @@ fn from_method_origin(tcx: &ty::ctxt, origin: &MethodOrigin)
 // supplies types from the tree. After type checking is complete, you
 // can just use the tcx as the typer.
 
-pub struct ExprUseVisitor<'d,'t,TYPER:'t> {
+pub struct ExprUseVisitor<'d,'t,'tcx,TYPER:'t> {
     typer: &'t TYPER,
     mc: mc::MemCategorizationContext<'t,TYPER>,
-    delegate: &'d mut Delegate+'d,
+    delegate: &'d mut Delegate<'tcx>+'d,
 }
 
 // If the TYPER results in an error, it's because the type check
@@ -223,10 +223,10 @@ macro_rules! return_if_err(
     )
 )
 
-impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
-    pub fn new(delegate: &'d mut Delegate,
+impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
+    pub fn new(delegate: &'d mut Delegate<'tcx>,
                typer: &'t TYPER)
-               -> ExprUseVisitor<'d,'t,TYPER> {
+               -> ExprUseVisitor<'d,'t,'tcx,TYPER> {
         ExprUseVisitor { typer: typer,
                          mc: mc::MemCategorizationContext::new(typer),
                          delegate: delegate }
@@ -262,7 +262,7 @@ fn tcx(&self) -> &'t ty::ctxt<'tcx> {
     fn delegate_consume(&mut self,
                         consume_id: ast::NodeId,
                         consume_span: Span,
-                        cmt: mc::cmt) {
+                        cmt: mc::cmt<'tcx>) {
         let mode = copy_or_move(self.tcx(), cmt.ty, DirectRefMove);
         self.delegate.consume(consume_id, consume_span, cmt, mode);
     }
@@ -823,7 +823,7 @@ fn walk_overloaded_operator(&mut self,
         return true;
     }
 
-    fn walk_arm(&mut self, discr_cmt: mc::cmt, arm: &ast::Arm) {
+    fn walk_arm(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &ast::Arm) {
         for pat in arm.pats.iter() {
             self.walk_pat(discr_cmt.clone(), &**pat);
         }
@@ -835,7 +835,7 @@ fn walk_arm(&mut self, discr_cmt: mc::cmt, arm: &ast::Arm) {
         self.consume_expr(&*arm.body);
     }
 
-    fn walk_pat(&mut self, cmt_discr: mc::cmt, pat: &ast::Pat) {
+    fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &ast::Pat) {
         debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(self.tcx()),
                pat.repr(self.tcx()));
         let mc = &self.mc;
@@ -990,7 +990,7 @@ fn cat_captured_var(&mut self,
                         closure_id: ast::NodeId,
                         closure_span: Span,
                         upvar_def: def::Def)
-                        -> mc::McResult<mc::cmt> {
+                        -> mc::McResult<mc::cmt<'tcx>> {
         // Create the cmt for the variable being borrowed, from the
         // caller's perspective
         let var_id = upvar_def.def_id().node;
@@ -999,7 +999,8 @@ fn cat_captured_var(&mut self,
     }
 }
 
-fn copy_or_move(tcx: &ty::ctxt, ty: Ty, move_reason: MoveReason) -> ConsumeMode {
+fn copy_or_move<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>,
+                      move_reason: MoveReason) -> ConsumeMode {
     if ty::type_moves_by_default(tcx, ty) { Move(move_reason) } else { Copy }
 }
 
index 913995a33251413df25be419d9631f3be3e920bb..1880a8fce8426ff91268c6d142d16d8e80ede27e 100644 (file)
@@ -23,8 +23,8 @@
 use syntax::visit::Visitor;
 use syntax::visit;
 
-fn type_size_is_affected_by_type_parameters(tcx: &ty::ctxt, typ: Ty)
-                                            -> bool {
+fn type_size_is_affected_by_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>, typ: Ty<'tcx>)
+                                                  -> bool {
     let mut result = false;
     ty::maybe_walk_ty(typ, |typ| {
         match ty::get(typ).sty {
@@ -96,7 +96,7 @@ fn def_id_is_transmute(&self, def_id: DefId) -> bool {
         }
     }
 
-    fn check_transmute(&self, span: Span, from: Ty, to: Ty, id: ast::NodeId) {
+    fn check_transmute(&self, span: Span, from: Ty<'tcx>, to: Ty<'tcx>, id: ast::NodeId) {
         if type_size_is_affected_by_type_parameters(self.tcx, from) {
             span_err!(self.tcx.sess, span, E0139,
                       "cannot transmute from a type that contains type parameters");
index 5f416fc98c902b0a06737e2d42050be58cdeaef5..320cdae826ccb21d4507010d952a01564815eafc 100644 (file)
@@ -1518,7 +1518,7 @@ fn check_fn(_v: &Liveness,
 }
 
 impl<'a, 'tcx> Liveness<'a, 'tcx> {
-    fn fn_ret(&self, id: NodeId) -> ty::FnOutput {
+    fn fn_ret(&self, id: NodeId) -> ty::FnOutput<'tcx> {
         let fn_ty = ty::node_id_to_type(self.ir.tcx, id);
         match ty::get(fn_ty).sty {
             ty::ty_unboxed_closure(closure_def_id, _, _) =>
index 572059e99fc63d86e1efd25ddf650dc29385db8e..cf1e58d17c78864e21c3baf3415afc4b232f11c7 100644 (file)
 use std::rc::Rc;
 
 #[deriving(Clone, PartialEq, Show)]
-pub enum categorization {
-    cat_rvalue(ty::Region),            // temporary val, argument is its scope
+pub enum categorization<'tcx> {
+    cat_rvalue(ty::Region),                    // temporary val, argument is its scope
     cat_static_item,
-    cat_upvar(Upvar),                  // upvar referenced by closure env
-    cat_local(ast::NodeId),            // local variable
-    cat_deref(cmt, uint, PointerKind), // deref of a ptr
-    cat_interior(cmt, InteriorKind),   // something interior: field, tuple, etc
-    cat_downcast(cmt),                 // selects a particular enum variant (*1)
+    cat_upvar(Upvar),                          // upvar referenced by closure env
+    cat_local(ast::NodeId),                    // local variable
+    cat_deref(cmt<'tcx>, uint, PointerKind),   // deref of a ptr
+    cat_interior(cmt<'tcx>, InteriorKind),     // something interior: field, tuple, etc
+    cat_downcast(cmt<'tcx>),                   // selects a particular enum variant (*1)
 
     // (*1) downcast is only required if the enum has more than one variant
 }
@@ -175,16 +175,16 @@ pub enum Note {
 // (`@T`). So use `cmt.ty` to find the type of the value in a consistent
 // fashion. For more details, see the method `cat_pattern`
 #[deriving(Clone, PartialEq, Show)]
-pub struct cmt_ {
-    pub id: ast::NodeId,          // id of expr/pat producing this value
+pub struct cmt_<'tcx> {
+    pub id: ast::NodeId,           // id of expr/pat producing this value
     pub span: Span,                // span of same expr/pat
-    pub cat: categorization,       // categorization of expr
+    pub cat: categorization<'tcx>, // categorization of expr
     pub mutbl: MutabilityCategory, // mutability of expr as lvalue
-    pub ty: Ty,                    // type of the expr (*see WARNING above*)
+    pub ty: Ty<'tcx>,              // type of the expr (*see WARNING above*)
     pub note: Note,                // Note about the provenance of this cmt
 }
 
-pub type cmt = Rc<cmt_>;
+pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
 
 // We pun on *T to mean both actual deref of a ptr as well
 // as accessing of components:
@@ -232,7 +232,7 @@ pub fn opt_deref_kind(t: Ty) -> Option<deref_kind> {
     }
 }
 
-pub fn deref_kind(tcx: &ty::ctxt, t: Ty) -> deref_kind {
+pub fn deref_kind<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> deref_kind {
     debug!("deref_kind {}", ty_to_string(tcx, t));
     match opt_deref_kind(t) {
       Some(k) => k,
@@ -285,16 +285,16 @@ pub struct MemCategorizationContext<'t,TYPER:'t> {
  */
 pub trait Typer<'tcx> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
-    fn node_ty(&self, id: ast::NodeId) -> McResult<Ty>;
-    fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<Ty>;
-    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>>;
+    fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>>;
+    fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<Ty<'tcx>>;
+    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>>;
     fn is_method_call(&self, id: ast::NodeId) -> bool;
     fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<ast::NodeId>;
     fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> ty::UpvarBorrow;
     fn capture_mode(&self, closure_expr_id: ast::NodeId)
                     -> ast::CaptureClause;
     fn unboxed_closures<'a>(&'a self)
-                        -> &'a RefCell<DefIdMap<ty::UnboxedClosure>>;
+                        -> &'a RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>>;
 }
 
 impl MutabilityCategory {
@@ -393,26 +393,26 @@ fn tcx(&self) -> &'t ty::ctxt<'tcx> {
         self.typer.tcx()
     }
 
-    fn expr_ty(&self, expr: &ast::Expr) -> McResult<Ty> {
+    fn expr_ty(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>> {
         self.typer.node_ty(expr.id)
     }
 
-    fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty> {
+    fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>> {
         let unadjusted_ty = if_ok!(self.expr_ty(expr));
         Ok(ty::adjust_ty(self.tcx(), expr.span, expr.id, unadjusted_ty,
                          self.typer.adjustments().borrow().get(&expr.id),
                          |method_call| self.typer.node_method_ty(method_call)))
     }
 
-    fn node_ty(&self, id: ast::NodeId) -> McResult<Ty> {
+    fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>> {
         self.typer.node_ty(id)
     }
 
-    fn pat_ty(&self, pat: &ast::Pat) -> McResult<Ty> {
+    fn pat_ty(&self, pat: &ast::Pat) -> McResult<Ty<'tcx>> {
         self.typer.node_ty(pat.id)
     }
 
-    pub fn cat_expr(&self, expr: &ast::Expr) -> McResult<cmt> {
+    pub fn cat_expr(&self, expr: &ast::Expr) -> McResult<cmt<'tcx>> {
         match self.typer.adjustments().borrow().get(&expr.id) {
             None => {
                 // No adjustments.
@@ -455,7 +455,7 @@ pub fn cat_expr(&self, expr: &ast::Expr) -> McResult<cmt> {
     pub fn cat_expr_autoderefd(&self,
                                expr: &ast::Expr,
                                autoderefs: uint)
-                               -> McResult<cmt> {
+                               -> McResult<cmt<'tcx>> {
         let mut cmt = if_ok!(self.cat_expr_unadjusted(expr));
         debug!("cat_expr_autoderefd: autoderefs={}, cmt={}",
                autoderefs,
@@ -466,7 +466,7 @@ pub fn cat_expr_autoderefd(&self,
         return Ok(cmt);
     }
 
-    pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt> {
+    pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt<'tcx>> {
         debug!("cat_expr: id={} expr={}", expr.id, expr.repr(self.tcx()));
 
         let expr_ty = if_ok!(self.expr_ty(expr));
@@ -546,9 +546,9 @@ pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt> {
     pub fn cat_def(&self,
                    id: ast::NodeId,
                    span: Span,
-                   expr_ty: Ty,
+                   expr_ty: Ty<'tcx>,
                    def: def::Def)
-                   -> McResult<cmt> {
+                   -> McResult<cmt<'tcx>> {
         debug!("cat_def: id={} expr={} def={}",
                id, expr_ty.repr(self.tcx()), def);
 
@@ -644,7 +644,7 @@ fn cat_upvar(&self,
                  kind: ty::UnboxedClosureKind,
                  mode: ast::CaptureClause,
                  is_unboxed: bool)
-                 -> McResult<cmt> {
+                 -> McResult<cmt<'tcx>> {
         // An upvar can have up to 3 components.  The base is a
         // `cat_upvar`.  Next, we add a deref through the implicit
         // environment pointer with an anonymous free region 'env and
@@ -804,8 +804,8 @@ fn cat_upvar(&self,
     pub fn cat_rvalue_node(&self,
                            id: ast::NodeId,
                            span: Span,
-                           expr_ty: Ty)
-                           -> cmt {
+                           expr_ty: Ty<'tcx>)
+                           -> cmt<'tcx> {
         match self.typer.temporary_scope(id) {
             Some(scope) => {
                 match ty::get(expr_ty).sty {
@@ -823,7 +823,7 @@ pub fn cat_rvalue(&self,
                       cmt_id: ast::NodeId,
                       span: Span,
                       temp_scope: ty::Region,
-                      expr_ty: Ty) -> cmt {
+                      expr_ty: Ty<'tcx>) -> cmt<'tcx> {
         Rc::new(cmt_ {
             id:cmt_id,
             span:span,
@@ -836,10 +836,10 @@ pub fn cat_rvalue(&self,
 
     pub fn cat_field<N:ast_node>(&self,
                                  node: &N,
-                                 base_cmt: cmt,
+                                 base_cmt: cmt<'tcx>,
                                  f_name: ast::Name,
-                                 f_ty: Ty)
-                                 -> cmt {
+                                 f_ty: Ty<'tcx>)
+                                 -> cmt<'tcx> {
         Rc::new(cmt_ {
             id: node.id(),
             span: node.span(),
@@ -852,10 +852,10 @@ pub fn cat_field<N:ast_node>(&self,
 
     pub fn cat_tup_field<N:ast_node>(&self,
                                      node: &N,
-                                     base_cmt: cmt,
+                                     base_cmt: cmt<'tcx>,
                                      f_idx: uint,
-                                     f_ty: Ty)
-                                     -> cmt {
+                                     f_ty: Ty<'tcx>)
+                                     -> cmt<'tcx> {
         Rc::new(cmt_ {
             id: node.id(),
             span: node.span(),
@@ -868,10 +868,10 @@ pub fn cat_tup_field<N:ast_node>(&self,
 
     fn cat_deref<N:ast_node>(&self,
                              node: &N,
-                             base_cmt: cmt,
+                             base_cmt: cmt<'tcx>,
                              deref_cnt: uint,
                              implicit: bool)
-                             -> cmt {
+                             -> cmt<'tcx> {
         let adjustment = match self.typer.adjustments().borrow().get(&node.id()) {
             Some(adj) if ty::adjust_is_object(adj) => typeck::AutoObject,
             _ if deref_cnt != 0 => typeck::AutoDeref(deref_cnt),
@@ -907,11 +907,11 @@ fn cat_deref<N:ast_node>(&self,
 
     fn cat_deref_common<N:ast_node>(&self,
                                     node: &N,
-                                    base_cmt: cmt,
+                                    base_cmt: cmt<'tcx>,
                                     deref_cnt: uint,
-                                    deref_ty: Ty,
+                                    deref_ty: Ty<'tcx>,
                                     implicit: bool)
-                                    -> cmt {
+                                    -> cmt<'tcx> {
         let (m, cat) = match deref_kind(self.tcx(), base_cmt.ty) {
             deref_ptr(ptr) => {
                 let ptr = if implicit {
@@ -944,8 +944,8 @@ fn cat_deref_common<N:ast_node>(&self,
 
     pub fn cat_index<N:ast_node>(&self,
                                  elt: &N,
-                                 mut base_cmt: cmt)
-                                 -> cmt {
+                                 mut base_cmt: cmt<'tcx>)
+                                 -> cmt<'tcx> {
         //! Creates a cmt for an indexing operation (`[]`).
         //!
         //! One subtle aspect of indexing that may not be
@@ -988,11 +988,11 @@ pub fn cat_index<N:ast_node>(&self,
         let m = base_cmt.mutbl.inherit();
         return interior(elt, base_cmt.clone(), base_cmt.ty, m, element_ty);
 
-        fn interior<N: ast_node>(elt: &N,
-                                 of_cmt: cmt,
-                                 vec_ty: Ty,
-                                 mutbl: MutabilityCategory,
-                                 element_ty: Ty) -> cmt
+        fn interior<'tcx, N: ast_node>(elt: &N,
+                                       of_cmt: cmt<'tcx>,
+                                       vec_ty: Ty<'tcx>,
+                                       mutbl: MutabilityCategory,
+                                       element_ty: Ty<'tcx>) -> cmt<'tcx>
         {
             Rc::new(cmt_ {
                 id:elt.id(),
@@ -1009,8 +1009,8 @@ fn interior<N: ast_node>(elt: &N,
     // underlying vec.
     fn deref_vec<N:ast_node>(&self,
                              elt: &N,
-                             base_cmt: cmt)
-                             -> cmt {
+                             base_cmt: cmt<'tcx>)
+                             -> cmt<'tcx> {
         match deref_kind(self.tcx(), base_cmt.ty) {
             deref_ptr(ptr) => {
                 // for unique ptrs, we inherit mutability from the
@@ -1038,9 +1038,9 @@ fn deref_vec<N:ast_node>(&self,
     }
 
     pub fn cat_slice_pattern(&self,
-                             vec_cmt: cmt,
+                             vec_cmt: cmt<'tcx>,
                              slice_pat: &ast::Pat)
-                             -> McResult<(cmt, ast::Mutability, ty::Region)> {
+                             -> McResult<(cmt<'tcx>, ast::Mutability, ty::Region)> {
         /*!
          * Given a pattern P like: `[_, ..Q, _]`, where `vec_cmt` is
          * the cmt for `P`, `slice_pat` is the pattern `Q`, returns:
@@ -1085,10 +1085,10 @@ fn vec_slice_info(tcx: &ty::ctxt,
 
     pub fn cat_imm_interior<N:ast_node>(&self,
                                         node: &N,
-                                        base_cmt: cmt,
-                                        interior_ty: Ty,
+                                        base_cmt: cmt<'tcx>,
+                                        interior_ty: Ty<'tcx>,
                                         interior: InteriorKind)
-                                        -> cmt {
+                                        -> cmt<'tcx> {
         Rc::new(cmt_ {
             id: node.id(),
             span: node.span(),
@@ -1101,9 +1101,9 @@ pub fn cat_imm_interior<N:ast_node>(&self,
 
     pub fn cat_downcast<N:ast_node>(&self,
                                     node: &N,
-                                    base_cmt: cmt,
-                                    downcast_ty: Ty)
-                                    -> cmt {
+                                    base_cmt: cmt<'tcx>,
+                                    downcast_ty: Ty<'tcx>)
+                                    -> cmt<'tcx> {
         Rc::new(cmt_ {
             id: node.id(),
             span: node.span(),
@@ -1115,10 +1115,10 @@ pub fn cat_downcast<N:ast_node>(&self,
     }
 
     pub fn cat_pattern(&self,
-                       cmt: cmt,
+                       cmt: cmt<'tcx>,
                        pat: &ast::Pat,
                        op: |&MemCategorizationContext<TYPER>,
-                            cmt,
+                            cmt<'tcx>,
                             &ast::Pat|)
                        -> McResult<()> {
         // Here, `cmt` is the categorization for the value being
@@ -1291,7 +1291,7 @@ pub fn cat_pattern(&self,
         Ok(())
     }
 
-    pub fn cmt_to_string(&self, cmt: &cmt_) -> String {
+    pub fn cmt_to_string(&self, cmt: &cmt_<'tcx>) -> String {
         fn upvar_to_string(upvar: &Upvar, is_copy: bool) -> String {
             if upvar.is_unboxed {
                 let kind = match upvar.kind {
@@ -1376,8 +1376,8 @@ pub enum AliasableReason {
     AliasableStaticMut(InteriorSafety),
 }
 
-impl cmt_ {
-    pub fn guarantor(&self) -> cmt {
+impl<'tcx> cmt_<'tcx> {
+    pub fn guarantor(&self) -> cmt<'tcx> {
         //! Returns `self` after stripping away any owned pointer derefs or
         //! interior content. The return value is basically the `cmt` which
         //! determines how long the value in `self` remains live.
@@ -1400,7 +1400,8 @@ pub fn guarantor(&self) -> cmt {
         }
     }
 
-    pub fn freely_aliasable(&self, ctxt: &ty::ctxt) -> Option<AliasableReason> {
+    pub fn freely_aliasable(&self, ctxt: &ty::ctxt<'tcx>)
+                            -> Option<AliasableReason> {
         /*!
          * Returns `Some(_)` if this lvalue represents a freely aliasable
          * pointer type.
@@ -1455,7 +1456,7 @@ pub fn freely_aliasable(&self, ctxt: &ty::ctxt) -> Option<AliasableReason> {
 
     // Digs down through one or two layers of deref and grabs the cmt
     // for the upvar if a note indicates there is one.
-    pub fn upvar(&self) -> Option<cmt> {
+    pub fn upvar(&self) -> Option<cmt<'tcx>> {
         match self.note {
             NoteClosureEnv(..) | NoteUpvarRef(..) => {
                 Some(match self.cat {
@@ -1474,8 +1475,8 @@ pub fn upvar(&self) -> Option<cmt> {
     }
 }
 
-impl Repr for cmt_ {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for cmt_<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("{{{} id:{} m:{} ty:{}}}",
                 self.cat.repr(tcx),
                 self.id,
@@ -1484,8 +1485,8 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl Repr for categorization {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for categorization<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             cat_static_item |
             cat_rvalue(..) |
@@ -1519,7 +1520,7 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
     }
 }
 
-impl Repr for InteriorKind {
+impl<'tcx> Repr<'tcx> for InteriorKind {
     fn repr(&self, _tcx: &ty::ctxt) -> String {
         match *self {
             InteriorField(NamedField(fld)) => {
index 0b097c63710ad8b24e9992b8cdbdd90830af85d0..c334d98daadea5f81fe29eac6ae6905d2f5a5df3 100644 (file)
@@ -32,7 +32,7 @@
 use syntax::visit;
 use syntax::visit::Visitor;
 
-type Context<'a> = (&'a MethodMap, &'a resolve::ExportMap2);
+type Context<'a, 'tcx> = (&'a MethodMap<'tcx>, &'a resolve::ExportMap2);
 
 /// A set of AST nodes exported by the crate.
 pub type ExportedItems = NodeSet;
index 7222806e4844207f2d1b4284f868610daea48edc..acfce00b360bacc42d21bee6a8fba6ee57fd428b 100644 (file)
@@ -31,8 +31,8 @@
  * `ParamSpace`).
  */
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub struct Substs {
-    pub types: VecPerParamSpace<Ty>,
+pub struct Substs<'tcx> {
+    pub types: VecPerParamSpace<Ty<'tcx>>,
     pub regions: RegionSubsts,
 }
 
@@ -46,45 +46,45 @@ pub enum RegionSubsts {
     NonerasedRegions(VecPerParamSpace<ty::Region>)
 }
 
-impl Substs {
-    pub fn new(t: VecPerParamSpace<Ty>,
+impl<'tcx> Substs<'tcx> {
+    pub fn new(t: VecPerParamSpace<Ty<'tcx>>,
                r: VecPerParamSpace<ty::Region>)
-               -> Substs
+               -> Substs<'tcx>
     {
         Substs { types: t, regions: NonerasedRegions(r) }
     }
 
-    pub fn new_type(t: Vec<Ty>,
+    pub fn new_type(t: Vec<Ty<'tcx>>,
                     r: Vec<ty::Region>)
-                    -> Substs
+                    -> Substs<'tcx>
     {
         Substs::new(VecPerParamSpace::new(t, Vec::new(), Vec::new(), Vec::new()),
                     VecPerParamSpace::new(r, Vec::new(), Vec::new(), Vec::new()))
     }
 
-    pub fn new_trait(t: Vec<Ty>,
+    pub fn new_trait(t: Vec<Ty<'tcx>>,
                      r: Vec<ty::Region>,
-                     a: Vec<Ty>,
-                     s: Ty)
-                    -> Substs
+                     a: Vec<Ty<'tcx>>,
+                     s: Ty<'tcx>)
+                    -> Substs<'tcx>
     {
         Substs::new(VecPerParamSpace::new(t, vec!(s), a, Vec::new()),
                     VecPerParamSpace::new(r, Vec::new(), Vec::new(), Vec::new()))
     }
 
-    pub fn erased(t: VecPerParamSpace<Ty>) -> Substs
+    pub fn erased(t: VecPerParamSpace<Ty<'tcx>>) -> Substs<'tcx>
     {
         Substs { types: t, regions: ErasedRegions }
     }
 
-    pub fn empty() -> Substs {
+    pub fn empty() -> Substs<'tcx> {
         Substs {
             types: VecPerParamSpace::empty(),
             regions: NonerasedRegions(VecPerParamSpace::empty()),
         }
     }
 
-    pub fn trans_empty() -> Substs {
+    pub fn trans_empty() -> Substs<'tcx> {
         Substs {
             types: VecPerParamSpace::empty(),
             regions: ErasedRegions
@@ -111,18 +111,18 @@ pub fn has_regions_escaping_depth(&self, depth: uint) -> bool {
         }
     }
 
-    pub fn self_ty(&self) -> Option<Ty> {
+pub fn self_ty(&self) -> Option<Ty<'tcx>> {
         self.types.get_self().map(|&t| t)
     }
 
-    pub fn with_self_ty(&self, self_ty: Ty) -> Substs {
+    pub fn with_self_ty(&self, self_ty: Ty<'tcx>) -> Substs<'tcx> {
         assert!(self.self_ty().is_none());
         let mut s = (*self).clone();
         s.types.push(SelfSpace, self_ty);
         s
     }
 
-    pub fn erase_regions(self) -> Substs {
+    pub fn erase_regions(self) -> Substs<'tcx> {
         let Substs { types, regions: _ } = self;
         Substs { types: types, regions: ErasedRegions }
     }
@@ -154,9 +154,9 @@ pub fn mut_regions<'a>(&'a mut self) -> &'a mut VecPerParamSpace<ty::Region> {
     }
 
     pub fn with_method(self,
-                       m_types: Vec<Ty>,
+                       m_types: Vec<Ty<'tcx>>,
                        m_regions: Vec<ty::Region>)
-                       -> Substs
+                       -> Substs<'tcx>
     {
         let Substs { types, regions } = self;
         let types = types.with_vec(FnSpace, m_types);
@@ -536,21 +536,21 @@ fn next(&mut self) -> Option<(ParamSpace, uint, &'a T)> {
 // `foo`. Or use `foo.subst_spanned(tcx, substs, Some(span))` when
 // there is more information available (for better errors).
 
-pub trait Subst {
-    fn subst(&self, tcx: &ty::ctxt, substs: &Substs) -> Self {
+pub trait Subst<'tcx> {
+    fn subst(&self, tcx: &ty::ctxt<'tcx>, substs: &Substs<'tcx>) -> Self {
         self.subst_spanned(tcx, substs, None)
     }
 
-    fn subst_spanned(&self, tcx: &ty::ctxt,
-                     substs: &Substs,
+    fn subst_spanned(&self, tcx: &ty::ctxt<'tcx>,
+                     substs: &Substs<'tcx>,
                      span: Option<Span>)
                      -> Self;
 }
 
-impl<T:TypeFoldable> Subst for T {
+impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T {
     fn subst_spanned(&self,
-                     tcx: &ty::ctxt,
-                     substs: &Substs,
+                     tcx: &ty::ctxt<'tcx>,
+                     substs: &Substs<'tcx>,
                      span: Option<Span>)
                      -> T
     {
@@ -569,13 +569,13 @@ fn subst_spanned(&self,
 
 struct SubstFolder<'a, 'tcx: 'a> {
     tcx: &'a ty::ctxt<'tcx>,
-    substs: &'a Substs,
+    substs: &'a Substs<'tcx>,
 
     // The location for which the substitution is performed, if available.
     span: Option<Span>,
 
     // The root type that is being substituted, if available.
-    root_ty: Option<Ty>,
+    root_ty: Option<Ty<'tcx>>,
 
     // Depth of type stack
     ty_stack_depth: uint,
@@ -629,7 +629,7 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
         }
     }
 
-    fn fold_ty(&mut self, t: Ty) -> Ty {
+    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
         if !ty::type_needs_subst(t) {
             return t;
         }
@@ -661,7 +661,7 @@ fn fold_ty(&mut self, t: Ty) -> Ty {
 }
 
 impl<'a,'tcx> SubstFolder<'a,'tcx> {
-    fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty) -> Ty {
+    fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> {
         // Look up the type in the substitutions. It really should be in there.
         let opt_ty = self.substs.types.opt_get(p.space, p.idx);
         let ty = match opt_ty {
@@ -684,7 +684,7 @@ fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty) -> Ty {
         self.shift_regions_through_binders(ty)
     }
 
-    fn shift_regions_through_binders(&self, ty: Ty) -> Ty {
+    fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
         /*!
          * It is sometimes necessary to adjust the debruijn indices
          * during substitution. This occurs when we are substituting a
index fa469dc734759ae2622499e74b74bc87693559a0..ebd7c68877347f2748218e0fc7bb663cc6cc8e9a 100644 (file)
@@ -76,7 +76,7 @@ pub fn impl_is_local(tcx: &ty::ctxt,
     trait_ref.input_types().iter().any(|&t| ty_is_local(tcx, t))
 }
 
-pub fn ty_is_local(tcx: &ty::ctxt, ty: Ty) -> bool {
+pub fn ty_is_local<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     debug!("ty_is_local({})", ty.repr(tcx));
 
     match ty::get(ty).sty {
index ff5d80c8a16a21fa9d5c86bb8be57aa52ecdb17e..5b8edacb28d67e775484c55fcc2aeda262011132 100644 (file)
  * method `select_all_or_error` can be used to report any remaining
  * ambiguous cases as errors.
  */
-pub struct FulfillmentContext {
+pub struct FulfillmentContext<'tcx> {
     // A list of all obligations that have been registered with this
     // fulfillment context.
-    trait_obligations: Vec<Obligation>,
+    trait_obligations: Vec<Obligation<'tcx>>,
 
     // Remembers the count of trait obligations that we have already
     // attempted to select. This is used to avoid repeating work
@@ -42,8 +42,8 @@ pub struct FulfillmentContext {
     attempted_mark: uint,
 }
 
-impl FulfillmentContext {
-    pub fn new() -> FulfillmentContext {
+impl<'tcx> FulfillmentContext<'tcx> {
+    pub fn new() -> FulfillmentContext<'tcx> {
         FulfillmentContext {
             trait_obligations: Vec::new(),
             attempted_mark: 0,
@@ -51,19 +51,19 @@ pub fn new() -> FulfillmentContext {
     }
 
     pub fn register_obligation(&mut self,
-                               tcx: &ty::ctxt,
-                               obligation: Obligation)
+                               tcx: &ty::ctxt<'tcx>,
+                               obligation: Obligation<'tcx>)
     {
         debug!("register_obligation({})", obligation.repr(tcx));
         assert!(!obligation.trait_ref.has_escaping_regions());
         self.trait_obligations.push(obligation);
     }
 
-    pub fn select_all_or_error<'a,'tcx>(&mut self,
-                                        infcx: &InferCtxt<'a,'tcx>,
-                                        param_env: &ty::ParameterEnvironment,
-                                        typer: &Typer<'tcx>)
-                                        -> Result<(),Vec<FulfillmentError>>
+    pub fn select_all_or_error<'a>(&mut self,
+                                   infcx: &InferCtxt<'a,'tcx>,
+                                   param_env: &ty::ParameterEnvironment<'tcx>,
+                                   typer: &Typer<'tcx>)
+                                   -> Result<(),Vec<FulfillmentError<'tcx>>>
     {
         try!(self.select_where_possible(infcx, param_env, typer));
 
@@ -81,11 +81,11 @@ pub fn select_all_or_error<'a,'tcx>(&mut self,
         }
     }
 
-    pub fn select_new_obligations<'a,'tcx>(&mut self,
-                                           infcx: &InferCtxt<'a,'tcx>,
-                                           param_env: &ty::ParameterEnvironment,
-                                           typer: &Typer<'tcx>)
-                                           -> Result<(),Vec<FulfillmentError>>
+    pub fn select_new_obligations<'a>(&mut self,
+                                      infcx: &InferCtxt<'a,'tcx>,
+                                      param_env: &ty::ParameterEnvironment<'tcx>,
+                                      typer: &Typer<'tcx>)
+                                      -> Result<(),Vec<FulfillmentError<'tcx>>>
     {
         /*!
          * Attempts to select obligations that were registered since
@@ -99,20 +99,20 @@ pub fn select_new_obligations<'a,'tcx>(&mut self,
         self.select(&mut selcx, true)
     }
 
-    pub fn select_where_possible<'a,'tcx>(&mut self,
-                                          infcx: &InferCtxt<'a,'tcx>,
-                                          param_env: &ty::ParameterEnvironment,
-                                          typer: &Typer<'tcx>)
-                                          -> Result<(),Vec<FulfillmentError>>
+    pub fn select_where_possible<'a>(&mut self,
+                                     infcx: &InferCtxt<'a,'tcx>,
+                                     param_env: &ty::ParameterEnvironment<'tcx>,
+                                     typer: &Typer<'tcx>)
+                                     -> Result<(),Vec<FulfillmentError<'tcx>>>
     {
         let mut selcx = SelectionContext::new(infcx, param_env, typer);
         self.select(&mut selcx, false)
     }
 
-    fn select(&mut self,
-              selcx: &mut SelectionContext,
-              only_new_obligations: bool)
-              -> Result<(),Vec<FulfillmentError>>
+    fn select<'a>(&mut self,
+                  selcx: &mut SelectionContext<'a, 'tcx>,
+                  only_new_obligations: bool)
+                  -> Result<(),Vec<FulfillmentError<'tcx>>>
     {
         /*!
          * Attempts to select obligations using `selcx`. If
index d821c447eb8ac87c3a2a382bcc3f132e52ddda89..c5eacf35da92fd6e09bed8d9b46d2836fe8f25d4 100644 (file)
  * scope. The eventual result is usually a `Selection` (defined below).
  */
 #[deriving(Clone)]
-pub struct Obligation {
-    pub cause: ObligationCause,
+pub struct Obligation<'tcx> {
+    pub cause: ObligationCause<'tcx>,
     pub recursion_depth: uint,
-    pub trait_ref: Rc<ty::TraitRef>,
+    pub trait_ref: Rc<ty::TraitRef<'tcx>>,
 }
 
 /**
  * Why did we incur this obligation? Used for error reporting.
  */
 #[deriving(Clone)]
-pub struct ObligationCause {
+pub struct ObligationCause<'tcx> {
     pub span: Span,
-    pub code: ObligationCauseCode
+    pub code: ObligationCauseCode<'tcx>
 }
 
 #[deriving(Clone)]
-pub enum ObligationCauseCode {
+pub enum ObligationCauseCode<'tcx> {
     /// Not well classified or should be obvious from span.
     MiscObligation,
 
@@ -75,7 +75,7 @@ pub enum ObligationCauseCode {
     ItemObligation(ast::DefId),
 
     /// Obligation incurred due to an object cast.
-    ObjectCastObligation(/* Object type */ Ty),
+    ObjectCastObligation(/* Object type */ Ty<'tcx>),
 
     /// To implement drop, type must be sendable.
     DropTrait,
@@ -99,25 +99,25 @@ pub enum ObligationCauseCode {
 #[deriving(Clone,Show)]
 pub struct ErrorReported;
 
-pub type Obligations = subst::VecPerParamSpace<Obligation>;
+pub type Obligations<'tcx> = subst::VecPerParamSpace<Obligation<'tcx>>;
 
-pub type Selection = Vtable<Obligation>;
+pub type Selection<'tcx> = Vtable<'tcx, Obligation<'tcx>>;
 
 #[deriving(Clone,Show)]
-pub enum SelectionError {
+pub enum SelectionError<'tcx> {
     Unimplemented,
     Overflow,
-    OutputTypeParameterMismatch(Rc<ty::TraitRef>, ty::type_err)
+    OutputTypeParameterMismatch(Rc<ty::TraitRef<'tcx>>, ty::type_err<'tcx>)
 }
 
-pub struct FulfillmentError {
-    pub obligation: Obligation,
-    pub code: FulfillmentErrorCode
+pub struct FulfillmentError<'tcx> {
+    pub obligation: Obligation<'tcx>,
+    pub code: FulfillmentErrorCode<'tcx>
 }
 
 #[deriving(Clone)]
-pub enum FulfillmentErrorCode {
-    CodeSelectionError(SelectionError),
+pub enum FulfillmentErrorCode<'tcx> {
+    CodeSelectionError(SelectionError<'tcx>),
     CodeAmbiguity,
 }
 
@@ -130,7 +130,7 @@ pub enum FulfillmentErrorCode {
  *   to inconclusive type inference.
  * - `Err(e)`: error `e` occurred
  */
-pub type SelectionResult<T> = Result<Option<T>, SelectionError>;
+pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
 
 /**
  * Given the successful resolution of an obligation, the `Vtable`
@@ -173,19 +173,19 @@ pub enum FulfillmentErrorCode {
  * See explanation on `VtableImplData`.
  */
 #[deriving(Show,Clone)]
-pub enum Vtable<N> {
+pub enum Vtable<'tcx, N> {
     /// Vtable identifying a particular impl.
-    VtableImpl(VtableImplData<N>),
+    VtableImpl(VtableImplData<'tcx, N>),
 
     /// Vtable automatically generated for an unboxed closure. The def
     /// ID is the ID of the closure expression. This is a `VtableImpl`
     /// in spirit, but the impl is generated by the compiler and does
     /// not appear in the source.
-    VtableUnboxedClosure(ast::DefId, subst::Substs),
+    VtableUnboxedClosure(ast::DefId, subst::Substs<'tcx>),
 
     /// Successful resolution to an obligation provided by the caller
     /// for some type parameter.
-    VtableParam(VtableParamData),
+    VtableParam(VtableParamData<'tcx>),
 
     /// Successful resolution for a builtin trait.
     VtableBuiltin(VtableBuiltinData<N>),
@@ -204,9 +204,9 @@ pub enum Vtable<N> {
  * impl, and nested obligations are satisfied later.
  */
 #[deriving(Clone)]
-pub struct VtableImplData<N> {
+pub struct VtableImplData<'tcx, N> {
     pub impl_def_id: ast::DefId,
-    pub substs: subst::Substs,
+    pub substs: subst::Substs<'tcx>,
     pub nested: subst::VecPerParamSpace<N>
 }
 
@@ -221,18 +221,19 @@ pub struct VtableBuiltinData<N> {
  * on an instance of `T`, the vtable would be of type `VtableParam`.
  */
 #[deriving(PartialEq,Eq,Clone)]
-pub struct VtableParamData {
+pub struct VtableParamData<'tcx> {
     // In the above example, this would `Eq`
-    pub bound: Rc<ty::TraitRef>,
+    pub bound: Rc<ty::TraitRef<'tcx>>,
 }
 
 pub fn select_inherent_impl<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
-                                     param_env: &ty::ParameterEnvironment,
+                                     param_env: &ty::ParameterEnvironment<'tcx>,
                                      typer: &Typer<'tcx>,
-                                     cause: ObligationCause,
+                                     cause: ObligationCause<'tcx>,
                                      impl_def_id: ast::DefId,
-                                     self_ty: Ty)
-                                     -> SelectionResult<VtableImplData<Obligation>>
+                                     self_ty: Ty<'tcx>)
+                                     -> SelectionResult<'tcx,
+                                            VtableImplData<'tcx, Obligation<'tcx>>>
 {
     /*!
      * Matches the self type of the inherent impl `impl_def_id`
@@ -281,11 +282,11 @@ pub fn overlapping_impls(infcx: &InferCtxt,
     coherence::impl_can_satisfy(infcx, impl2_def_id, impl1_def_id)
 }
 
-pub fn obligations_for_generics(tcx: &ty::ctxt,
-                                cause: ObligationCause,
-                                generic_bounds: &ty::GenericBounds,
-                                type_substs: &subst::VecPerParamSpace<Ty>)
-                                -> subst::VecPerParamSpace<Obligation>
+pub fn obligations_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                      cause: ObligationCause<'tcx>,
+                                      generic_bounds: &ty::GenericBounds<'tcx>,
+                                      type_substs: &subst::VecPerParamSpace<Ty<'tcx>>)
+                                      -> subst::VecPerParamSpace<Obligation<'tcx>>
 {
     /*!
      * Given generic bounds from an impl like:
@@ -305,46 +306,48 @@ pub fn obligations_for_generics(tcx: &ty::ctxt,
     util::obligations_for_generics(tcx, cause, 0, generic_bounds, type_substs)
 }
 
-pub fn obligation_for_builtin_bound(tcx: &ty::ctxt,
-                                    cause: ObligationCause,
-                                    source_ty: Ty,
-                                    builtin_bound: ty::BuiltinBound)
-                                    -> Result<Obligation, ErrorReported>
+pub fn obligation_for_builtin_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                          cause: ObligationCause<'tcx>,
+                                          source_ty: Ty<'tcx>,
+                                          builtin_bound: ty::BuiltinBound)
+                                          -> Result<Obligation<'tcx>, ErrorReported>
 {
     util::obligation_for_builtin_bound(tcx, cause, builtin_bound, 0, source_ty)
 }
 
-impl Obligation {
-    pub fn new(cause: ObligationCause, trait_ref: Rc<ty::TraitRef>) -> Obligation {
+impl<'tcx> Obligation<'tcx> {
+    pub fn new(cause: ObligationCause<'tcx>, trait_ref: Rc<ty::TraitRef<'tcx>>)
+               -> Obligation<'tcx> {
         Obligation { cause: cause,
                      recursion_depth: 0,
                      trait_ref: trait_ref }
     }
 
-    pub fn misc(span: Span, trait_ref: Rc<ty::TraitRef>) -> Obligation {
+    pub fn misc(span: Span, trait_ref: Rc<ty::TraitRef<'tcx>>) -> Obligation<'tcx> {
         Obligation::new(ObligationCause::misc(span), trait_ref)
     }
 
-    pub fn self_ty(&self) -> Ty {
+    pub fn self_ty(&self) -> Ty<'tcx> {
         self.trait_ref.self_ty()
     }
 }
 
-impl ObligationCause {
-    pub fn new(span: Span, code: ObligationCauseCode) -> ObligationCause {
+impl<'tcx> ObligationCause<'tcx> {
+    pub fn new(span: Span, code: ObligationCauseCode<'tcx>)
+               -> ObligationCause<'tcx> {
         ObligationCause { span: span, code: code }
     }
 
-    pub fn misc(span: Span) -> ObligationCause {
+    pub fn misc(span: Span) -> ObligationCause<'tcx> {
         ObligationCause { span: span, code: MiscObligation }
     }
 
-    pub fn dummy() -> ObligationCause {
+    pub fn dummy() -> ObligationCause<'tcx> {
         ObligationCause { span: DUMMY_SP, code: MiscObligation }
     }
 }
 
-impl<N> Vtable<N> {
+impl<'tcx, N> Vtable<'tcx, N> {
     pub fn iter_nested(&self) -> Items<N> {
         match *self {
             VtableImpl(ref i) => i.iter_nested(),
@@ -354,7 +357,7 @@ pub fn iter_nested(&self) -> Items<N> {
         }
     }
 
-    pub fn map_nested<M>(&self, op: |&N| -> M) -> Vtable<M> {
+    pub fn map_nested<M>(&self, op: |&N| -> M) -> Vtable<'tcx, M> {
         match *self {
             VtableImpl(ref i) => VtableImpl(i.map_nested(op)),
             VtableUnboxedClosure(d, ref s) => VtableUnboxedClosure(d, s.clone()),
@@ -363,7 +366,7 @@ pub fn map_nested<M>(&self, op: |&N| -> M) -> Vtable<M> {
         }
     }
 
-    pub fn map_move_nested<M>(self, op: |N| -> M) -> Vtable<M> {
+    pub fn map_move_nested<M>(self, op: |N| -> M) -> Vtable<'tcx, M> {
         match self {
             VtableImpl(i) => VtableImpl(i.map_move_nested(op)),
             VtableUnboxedClosure(d, s) => VtableUnboxedClosure(d, s),
@@ -373,14 +376,14 @@ pub fn map_move_nested<M>(self, op: |N| -> M) -> Vtable<M> {
     }
 }
 
-impl<N> VtableImplData<N> {
+impl<'tcx, N> VtableImplData<'tcx, N> {
     pub fn iter_nested(&self) -> Items<N> {
         self.nested.iter()
     }
 
     pub fn map_nested<M>(&self,
                          op: |&N| -> M)
-                         -> VtableImplData<M>
+                         -> VtableImplData<'tcx, M>
     {
         VtableImplData {
             impl_def_id: self.impl_def_id,
@@ -389,7 +392,8 @@ pub fn map_nested<M>(&self,
         }
     }
 
-    pub fn map_move_nested<M>(self, op: |N| -> M) -> VtableImplData<M> {
+    pub fn map_move_nested<M>(self, op: |N| -> M)
+                              -> VtableImplData<'tcx, M> {
         let VtableImplData { impl_def_id, substs, nested } = self;
         VtableImplData {
             impl_def_id: impl_def_id,
@@ -420,9 +424,9 @@ pub fn map_move_nested<M>(self, op: |N| -> M) -> VtableBuiltinData<M> {
     }
 }
 
-impl FulfillmentError {
-    fn new(obligation: Obligation, code: FulfillmentErrorCode)
-           -> FulfillmentError
+impl<'tcx> FulfillmentError<'tcx> {
+    fn new(obligation: Obligation<'tcx>, code: FulfillmentErrorCode<'tcx>)
+           -> FulfillmentError<'tcx>
     {
         FulfillmentError { obligation: obligation, code: code }
     }
index 6ff405f19fb9021203707bde2c4b83a724d33019..217830bcb4e63b22dbaafc39a9374632fff5872a 100644 (file)
@@ -42,7 +42,7 @@
 
 pub struct SelectionContext<'cx, 'tcx:'cx> {
     infcx: &'cx InferCtxt<'cx, 'tcx>,
-    param_env: &'cx ty::ParameterEnvironment,
+    param_env: &'cx ty::ParameterEnvironment<'tcx>,
     typer: &'cx Typer<'tcx>+'cx,
 
     /// Skolemizer used specifically for skolemizing entries on the
@@ -70,18 +70,19 @@ pub struct SelectionContext<'cx, 'tcx:'cx> {
 }
 
 // A stack that walks back up the stack frame.
-struct ObligationStack<'prev> {
-    obligation: &'prev Obligation,
+struct ObligationStack<'prev, 'tcx: 'prev> {
+    obligation: &'prev Obligation<'tcx>,
 
     /// Trait ref from `obligation` but skolemized with the
     /// selection-context's skolemizer. Used to check for recursion.
-    skol_trait_ref: Rc<ty::TraitRef>,
+    skol_trait_ref: Rc<ty::TraitRef<'tcx>>,
 
-    previous: Option<&'prev ObligationStack<'prev>>
+    previous: Option<&'prev ObligationStack<'prev, 'tcx>>
 }
 
-pub struct SelectionCache {
-    hashmap: RefCell<HashMap<Rc<ty::TraitRef>, SelectionResult<Candidate>>>,
+pub struct SelectionCache<'tcx> {
+    hashmap: RefCell<HashMap<Rc<ty::TraitRef<'tcx>>,
+                             SelectionResult<'tcx, Candidate<'tcx>>>>,
 }
 
 pub enum MethodMatchResult {
@@ -128,21 +129,21 @@ pub enum MethodMatchedData {
  * parameters) that would have to be inferred from the impl.
  */
 #[deriving(PartialEq,Eq,Show,Clone)]
-enum Candidate {
+enum Candidate<'tcx> {
     BuiltinCandidate(ty::BuiltinBound),
-    ParamCandidate(VtableParamData),
+    ParamCandidate(VtableParamData<'tcx>),
     ImplCandidate(ast::DefId),
-    UnboxedClosureCandidate(/* closure */ ast::DefId, Substs),
+    UnboxedClosureCandidate(/* closure */ ast::DefId, Substs<'tcx>),
     ErrorCandidate,
 }
 
-struct CandidateSet {
-    vec: Vec<Candidate>,
+struct CandidateSet<'tcx> {
+    vec: Vec<Candidate<'tcx>>,
     ambiguous: bool
 }
 
-enum BuiltinBoundConditions {
-    If(Vec<Ty>),
+enum BuiltinBoundConditions<'tcx> {
+    If(Vec<Ty<'tcx>>),
     ParameterBuiltin,
     AmbiguousBuiltin
 }
@@ -156,7 +157,7 @@ enum EvaluationResult {
 
 impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
     pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>,
-               param_env: &'cx ty::ParameterEnvironment,
+               param_env: &'cx ty::ParameterEnvironment<'tcx>,
                typer: &'cx Typer<'tcx>)
                -> SelectionContext<'cx, 'tcx> {
         SelectionContext {
@@ -169,7 +170,7 @@ pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>,
     }
 
     pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>,
-                      param_env: &'cx ty::ParameterEnvironment,
+                      param_env: &'cx ty::ParameterEnvironment<'tcx>,
                       typer: &'cx Typer<'tcx>)
                       -> SelectionContext<'cx, 'tcx> {
         SelectionContext {
@@ -200,7 +201,8 @@ pub fn tcx(&self) -> &'cx ty::ctxt<'tcx> {
     //    is `Vec<Foo>:Iterable<Bar>`, but the impl specifies
     //    `impl<T> Iterable<T> for Vec<T>`, than an error would result.
 
-    pub fn select(&mut self, obligation: &Obligation) -> SelectionResult<Selection> {
+    pub fn select(&mut self, obligation: &Obligation<'tcx>)
+                  -> SelectionResult<'tcx, Selection<'tcx>> {
         /*!
          * Evaluates whether the obligation can be satisfied. Returns
          * an indication of whether the obligation can be satisfied
@@ -220,9 +222,9 @@ pub fn select(&mut self, obligation: &Obligation) -> SelectionResult<Selection>
 
     pub fn select_inherent_impl(&mut self,
                                 impl_def_id: ast::DefId,
-                                obligation_cause: ObligationCause,
-                                obligation_self_ty: Ty)
-                                -> SelectionResult<VtableImplData<Obligation>>
+                                obligation_cause: ObligationCause<'tcx>,
+                                obligation_self_ty: Ty<'tcx>)
+                                -> SelectionResult<'tcx, VtableImplData<'tcx, Obligation<'tcx>>>
     {
         debug!("select_inherent_impl(impl_def_id={}, obligation_self_ty={})",
                impl_def_id.repr(self.tcx()),
@@ -252,7 +254,7 @@ pub fn select_inherent_impl(&mut self,
     // we can be sure it does not.
 
     pub fn evaluate_obligation(&mut self,
-                               obligation: &Obligation)
+                               obligation: &Obligation<'tcx>)
                                -> bool
     {
         /*!
@@ -268,11 +270,11 @@ pub fn evaluate_obligation(&mut self,
         self.evaluate_stack(&stack).may_apply()
     }
 
-    fn evaluate_builtin_bound_recursively(&mut self,
-                                          bound: ty::BuiltinBound,
-                                          previous_stack: &ObligationStack,
-                                          ty: Ty)
-                                          -> EvaluationResult
+    fn evaluate_builtin_bound_recursively<'o>(&mut self,
+                                              bound: ty::BuiltinBound,
+                                              previous_stack: &ObligationStack<'o, 'tcx>,
+                                              ty: Ty<'tcx>)
+                                              -> EvaluationResult
     {
         let obligation =
             util::obligation_for_builtin_bound(
@@ -292,10 +294,10 @@ fn evaluate_builtin_bound_recursively(&mut self,
         }
     }
 
-    fn evaluate_obligation_recursively(&mut self,
-                                       previous_stack: Option<&ObligationStack>,
-                                       obligation: &Obligation)
-                                       -> EvaluationResult
+    fn evaluate_obligation_recursively<'o>(&mut self,
+                                           previous_stack: Option<&ObligationStack<'o, 'tcx>>,
+                                           obligation: &Obligation<'tcx>)
+                                           -> EvaluationResult
     {
         debug!("evaluate_obligation_recursively({})",
                obligation.repr(self.tcx()));
@@ -308,9 +310,9 @@ fn evaluate_obligation_recursively(&mut self,
         result
     }
 
-    fn evaluate_stack(&mut self,
-                      stack: &ObligationStack)
-                      -> EvaluationResult
+    fn evaluate_stack<'o>(&mut self,
+                          stack: &ObligationStack<'o, 'tcx>)
+                          -> EvaluationResult
     {
         // In intercrate mode, whenever any of the types are unbound,
         // there can always be an impl. Even if there are no impls in
@@ -387,7 +389,7 @@ fn evaluate_stack(&mut self,
 
     pub fn evaluate_impl(&mut self,
                          impl_def_id: ast::DefId,
-                         obligation: &Obligation)
+                         obligation: &Obligation<'tcx>)
                          -> bool
     {
         /*!
@@ -434,9 +436,9 @@ pub fn evaluate_impl(&mut self,
     // the algorithm.
 
     pub fn evaluate_method_obligation(&mut self,
-                                      rcvr_ty: Ty,
-                                      xform_self_ty: Ty,
-                                      obligation: &Obligation)
+                                      rcvr_ty: Ty<'tcx>,
+                                      xform_self_ty: Ty<'tcx>,
+                                      obligation: &Obligation<'tcx>)
                                       -> MethodMatchResult
     {
         /*!
@@ -562,9 +564,9 @@ pub fn evaluate_method_obligation(&mut self,
     }
 
     pub fn confirm_method_match(&mut self,
-                                rcvr_ty: Ty,
-                                xform_self_ty: Ty,
-                                obligation: &Obligation,
+                                rcvr_ty: Ty<'tcx>,
+                                xform_self_ty: Ty<'tcx>,
+                                obligation: &Obligation<'tcx>,
                                 data: MethodMatchedData)
     {
         /*!
@@ -596,9 +598,9 @@ pub fn confirm_method_match(&mut self,
     }
 
     fn match_method_precise(&mut self,
-                            rcvr_ty: Ty,
-                            xform_self_ty: Ty,
-                            obligation: &Obligation)
+                            rcvr_ty: Ty<'tcx>,
+                            xform_self_ty: Ty<'tcx>,
+                            obligation: &Obligation<'tcx>)
                             -> Result<(),()>
     {
         /*!
@@ -622,9 +624,9 @@ fn match_method_precise(&mut self,
     }
 
     fn assemble_method_candidates_from_impls(&mut self,
-                                             rcvr_ty: Ty,
-                                             xform_self_ty: Ty,
-                                             obligation: &Obligation)
+                                             rcvr_ty: Ty<'tcx>,
+                                             xform_self_ty: Ty<'tcx>,
+                                             obligation: &Obligation<'tcx>)
                                              -> Vec<ast::DefId>
     {
         /*!
@@ -650,10 +652,10 @@ fn assemble_method_candidates_from_impls(&mut self,
 
     fn match_method_coerce(&mut self,
                            impl_def_id: ast::DefId,
-                           rcvr_ty: Ty,
-                           xform_self_ty: Ty,
-                           obligation: &Obligation)
-                           -> Result<Substs, ()>
+                           rcvr_ty: Ty<'tcx>,
+                           xform_self_ty: Ty<'tcx>,
+                           obligation: &Obligation<'tcx>)
+                           -> Result<Substs<'tcx>, ()>
     {
         /*!
          * Applies the *coercive match* procedure described in
@@ -683,9 +685,9 @@ fn match_method_coerce(&mut self,
 
     fn winnow_method_impl(&mut self,
                           impl_def_id: ast::DefId,
-                          rcvr_ty: Ty,
-                          xform_self_ty: Ty,
-                          obligation: &Obligation)
+                          rcvr_ty: Ty<'tcx>,
+                          xform_self_ty: Ty<'tcx>,
+                          obligation: &Obligation<'tcx>)
                           -> bool
     {
         /*!
@@ -724,9 +726,9 @@ fn winnow_method_impl(&mut self,
     // caller obligations, and so forth and assembling a list of
     // candidates. See `doc.rs` and the `Candidate` type for more details.
 
-    fn candidate_from_obligation(&mut self,
-                                 stack: &ObligationStack)
-                                 -> SelectionResult<Candidate>
+    fn candidate_from_obligation<'o>(&mut self,
+                                     stack: &ObligationStack<'o, 'tcx>)
+                                     -> SelectionResult<'tcx, Candidate<'tcx>>
     {
         // Watch out for overflow. This intentionally bypasses (and does
         // not update) the cache.
@@ -767,9 +769,9 @@ fn candidate_from_obligation(&mut self,
         candidate
     }
 
-    fn candidate_from_obligation_no_cache(&mut self,
-                                          stack: &ObligationStack)
-                                          -> SelectionResult<Candidate>
+    fn candidate_from_obligation_no_cache<'o>(&mut self,
+                                              stack: &ObligationStack<'o, 'tcx>)
+                                              -> SelectionResult<'tcx, Candidate<'tcx>>
     {
         if ty::type_is_error(stack.obligation.self_ty()) {
             return Ok(Some(ErrorCandidate));
@@ -863,8 +865,8 @@ fn candidate_from_obligation_no_cache(&mut self,
     }
 
     fn pick_candidate_cache(&self,
-                            cache_skol_trait_ref: &Rc<ty::TraitRef>)
-                            -> &SelectionCache
+                            cache_skol_trait_ref: &Rc<ty::TraitRef<'tcx>>)
+                            -> &SelectionCache<'tcx>
     {
         // High-level idea: we have to decide whether to consult the
         // cache that is specific to this scope, or to consult the
@@ -910,8 +912,8 @@ fn pick_candidate_cache(&self,
     }
 
     fn check_candidate_cache(&mut self,
-                             cache_skol_trait_ref: Rc<ty::TraitRef>)
-                             -> Option<SelectionResult<Candidate>>
+                             cache_skol_trait_ref: Rc<ty::TraitRef<'tcx>>)
+                             -> Option<SelectionResult<'tcx, Candidate<'tcx>>>
     {
         let cache = self.pick_candidate_cache(&cache_skol_trait_ref);
         let hashmap = cache.hashmap.borrow();
@@ -919,17 +921,17 @@ fn check_candidate_cache(&mut self,
     }
 
     fn insert_candidate_cache(&mut self,
-                              cache_skol_trait_ref: Rc<ty::TraitRef>,
-                              candidate: SelectionResult<Candidate>)
+                              cache_skol_trait_ref: Rc<ty::TraitRef<'tcx>>,
+                              candidate: SelectionResult<'tcx, Candidate<'tcx>>)
     {
         let cache = self.pick_candidate_cache(&cache_skol_trait_ref);
         let mut hashmap = cache.hashmap.borrow_mut();
         hashmap.insert(cache_skol_trait_ref, candidate);
     }
 
-    fn assemble_candidates(&mut self,
-                           stack: &ObligationStack)
-                           -> Result<CandidateSet, SelectionError>
+    fn assemble_candidates<'o>(&mut self,
+                               stack: &ObligationStack<'o, 'tcx>)
+                               -> Result<CandidateSet<'tcx>, SelectionError<'tcx>>
     {
         // Check for overflow.
 
@@ -961,9 +963,9 @@ fn assemble_candidates(&mut self,
     }
 
     fn assemble_candidates_from_caller_bounds(&mut self,
-                                              obligation: &Obligation,
-                                              candidates: &mut CandidateSet)
-                                              -> Result<(),SelectionError>
+                                              obligation: &Obligation<'tcx>,
+                                              candidates: &mut CandidateSet<'tcx>)
+                                              -> Result<(),SelectionError<'tcx>>
     {
         /*!
          * Given an obligation like `<SomeTrait for T>`, search the obligations
@@ -1001,9 +1003,9 @@ fn assemble_candidates_from_caller_bounds(&mut self,
     }
 
     fn assemble_unboxed_candidates(&mut self,
-                                   obligation: &Obligation,
-                                   candidates: &mut CandidateSet)
-                                   -> Result<(),SelectionError>
+                                   obligation: &Obligation<'tcx>,
+                                   candidates: &mut CandidateSet<'tcx>)
+                                   -> Result<(),SelectionError<'tcx>>
     {
         /*!
          * Check for the artificial impl that the compiler will create
@@ -1059,9 +1061,9 @@ fn assemble_unboxed_candidates(&mut self,
     }
 
     fn assemble_candidates_from_impls(&mut self,
-                                      obligation: &Obligation,
-                                      candidates: &mut CandidateSet)
-                                      -> Result<(), SelectionError>
+                                      obligation: &Obligation<'tcx>,
+                                      candidates: &mut CandidateSet<'tcx>)
+                                      -> Result<(), SelectionError<'tcx>>
     {
         /*!
          * Search for impls that might apply to `obligation`.
@@ -1090,10 +1092,10 @@ fn assemble_candidates_from_impls(&mut self,
     // attempt to evaluate recursive bounds to see if they are
     // satisfied.
 
-    fn winnow_candidate(&mut self,
-                        stack: &ObligationStack,
-                        candidate: &Candidate)
-                        -> EvaluationResult
+    fn winnow_candidate<'o>(&mut self,
+                            stack: &ObligationStack<'o, 'tcx>,
+                            candidate: &Candidate<'tcx>)
+                            -> EvaluationResult
     {
         /*!
          * Further evaluate `candidate` to decide whether all type parameters match
@@ -1111,10 +1113,10 @@ fn winnow_candidate(&mut self,
         })
     }
 
-    fn winnow_selection(&mut self,
-                        stack: Option<&ObligationStack>,
-                        selection: Selection)
-                        -> EvaluationResult
+    fn winnow_selection<'o>(&mut self,
+                            stack: Option<&ObligationStack<'o, 'tcx>>,
+                            selection: Selection<'tcx>)
+                            -> EvaluationResult
     {
         let mut result = EvaluatedToOk;
         for obligation in selection.iter_nested() {
@@ -1127,11 +1129,11 @@ fn winnow_selection(&mut self,
         result
     }
 
-    fn candidate_should_be_dropped_in_favor_of(&mut self,
-                                               stack: &ObligationStack,
-                                               candidate_i: &Candidate,
-                                               candidate_j: &Candidate)
-                                               -> bool
+    fn candidate_should_be_dropped_in_favor_of<'o>(&mut self,
+                                                   stack: &ObligationStack<'o, 'tcx>,
+                                                   candidate_i: &Candidate<'tcx>,
+                                                   candidate_j: &Candidate<'tcx>)
+                                                   -> bool
     {
         /*!
          * Returns true if `candidate_i` should be dropped in favor of `candidate_j`.
@@ -1194,11 +1196,11 @@ fn candidate_should_be_dropped_in_favor_of(&mut self,
     // those will hopefully change to library-defined traits in the
     // future.
 
-    fn assemble_builtin_bound_candidates(&mut self,
-                                         bound: ty::BuiltinBound,
-                                         stack: &ObligationStack,
-                                         candidates: &mut CandidateSet)
-                                         -> Result<(),SelectionError>
+    fn assemble_builtin_bound_candidates<'o>(&mut self,
+                                             bound: ty::BuiltinBound,
+                                             stack: &ObligationStack<'o, 'tcx>,
+                                             candidates: &mut CandidateSet<'tcx>)
+                                             -> Result<(),SelectionError<'tcx>>
     {
         // FIXME -- To be more like a normal impl, we should just
         // ignore the nested cases here, and instead generate nested
@@ -1227,8 +1229,8 @@ fn assemble_builtin_bound_candidates(&mut self,
 
     fn builtin_bound(&mut self,
                      bound: ty::BuiltinBound,
-                     self_ty: Ty)
-                     -> Result<BuiltinBoundConditions,SelectionError>
+                     self_ty: Ty<'tcx>)
+                     -> Result<BuiltinBoundConditions<'tcx>,SelectionError<'tcx>>
     {
         let self_ty = self.infcx.shallow_resolve(self_ty);
         return match ty::get(self_ty).sty {
@@ -1505,11 +1507,11 @@ fn builtin_bound(&mut self,
             }
         };
 
-        fn nominal(this: &mut SelectionContext,
-                   bound: ty::BuiltinBound,
-                   def_id: ast::DefId,
-                   types: Vec<Ty>)
-                   -> Result<BuiltinBoundConditions,SelectionError>
+        fn nominal<'cx, 'tcx>(this: &mut SelectionContext<'cx, 'tcx>,
+                              bound: ty::BuiltinBound,
+                              def_id: ast::DefId,
+                              types: Vec<Ty<'tcx>>)
+                              -> Result<BuiltinBoundConditions<'tcx>,SelectionError<'tcx>>
         {
             // First check for markers and other nonsense.
             let tcx = this.tcx();
@@ -1564,9 +1566,9 @@ fn nominal(this: &mut SelectionContext,
     // type error.  See `doc.rs` for more details.
 
     fn confirm_candidate(&mut self,
-                         obligation: &Obligation,
-                         candidate: Candidate)
-                         -> Result<Selection,SelectionError>
+                         obligation: &Obligation<'tcx>,
+                         candidate: Candidate<'tcx>)
+                         -> Result<Selection<'tcx>,SelectionError<'tcx>>
     {
         debug!("confirm_candidate({}, {})",
                obligation.repr(self.tcx()),
@@ -1598,9 +1600,10 @@ fn confirm_candidate(&mut self,
     }
 
     fn confirm_param_candidate(&mut self,
-                               obligation: &Obligation,
-                               param: VtableParamData)
-                               -> Result<VtableParamData,SelectionError>
+                               obligation: &Obligation<'tcx>,
+                               param: VtableParamData<'tcx>)
+                               -> Result<VtableParamData<'tcx>,
+                                         SelectionError<'tcx>>
     {
         debug!("confirm_param_candidate({},{})",
                obligation.repr(self.tcx()),
@@ -1613,9 +1616,10 @@ fn confirm_param_candidate(&mut self,
     }
 
     fn confirm_builtin_candidate(&mut self,
-                                 obligation: &Obligation,
+                                 obligation: &Obligation<'tcx>,
                                  bound: ty::BuiltinBound)
-                                 -> Result<VtableBuiltinData<Obligation>,SelectionError>
+                                 -> Result<VtableBuiltinData<Obligation<'tcx>>,
+                                           SelectionError<'tcx>>
     {
         debug!("confirm_builtin_candidate({})",
                obligation.repr(self.tcx()));
@@ -1633,10 +1637,10 @@ fn confirm_builtin_candidate(&mut self,
     }
 
     fn vtable_builtin_data(&mut self,
-                           obligation: &Obligation,
+                           obligation: &Obligation<'tcx>,
                            bound: ty::BuiltinBound,
-                           nested: Vec<Ty>)
-                           -> VtableBuiltinData<Obligation>
+                           nested: Vec<Ty<'tcx>>)
+                           -> VtableBuiltinData<Obligation<'tcx>>
     {
         let obligations = nested.iter().map(|&t| {
             util::obligation_for_builtin_bound(
@@ -1656,9 +1660,10 @@ fn vtable_builtin_data(&mut self,
     }
 
     fn confirm_impl_candidate(&mut self,
-                              obligation: &Obligation,
+                              obligation: &Obligation<'tcx>,
                               impl_def_id: ast::DefId)
-                              -> Result<VtableImplData<Obligation>,SelectionError>
+                              -> Result<VtableImplData<'tcx, Obligation<'tcx>>,
+                                        SelectionError<'tcx>>
     {
         debug!("confirm_impl_candidate({},{})",
                obligation.repr(self.tcx()),
@@ -1672,10 +1677,10 @@ fn confirm_impl_candidate(&mut self,
 
     fn vtable_impl(&mut self,
                    impl_def_id: ast::DefId,
-                   substs: Substs,
-                   cause: ObligationCause,
+                   substs: Substs<'tcx>,
+                   cause: ObligationCause<'tcx>,
                    recursion_depth: uint)
-                   -> VtableImplData<Obligation>
+                   -> VtableImplData<'tcx, Obligation<'tcx>>
     {
         let impl_obligations =
             self.impl_obligations(cause,
@@ -1688,10 +1693,10 @@ fn vtable_impl(&mut self,
     }
 
     fn confirm_unboxed_closure_candidate(&mut self,
-                                         obligation: &Obligation,
+                                         obligation: &Obligation<'tcx>,
                                          closure_def_id: ast::DefId,
-                                         substs: &Substs)
-                                         -> Result<(),SelectionError>
+                                         substs: &Substs<'tcx>)
+                                         -> Result<(),SelectionError<'tcx>>
     {
         debug!("confirm_unboxed_closure_candidate({},{},{})",
                obligation.repr(self.tcx()),
@@ -1739,8 +1744,8 @@ fn confirm_unboxed_closure_candidate(&mut self,
 
     fn rematch_impl(&mut self,
                     impl_def_id: ast::DefId,
-                    obligation: &Obligation)
-                    -> Substs
+                    obligation: &Obligation<'tcx>)
+                    -> Substs<'tcx>
     {
         match self.match_impl(impl_def_id, obligation) {
             Ok(substs) => {
@@ -1758,8 +1763,8 @@ fn rematch_impl(&mut self,
 
     fn match_impl(&mut self,
                   impl_def_id: ast::DefId,
-                  obligation: &Obligation)
-                  -> Result<Substs, ()>
+                  obligation: &Obligation<'tcx>)
+                  -> Result<Substs<'tcx>, ()>
     {
         let impl_trait_ref = ty::impl_trait_ref(self.tcx(),
                                                 impl_def_id).unwrap();
@@ -1808,8 +1813,8 @@ fn fast_reject_trait_refs(&mut self,
     }
 
     fn match_trait_refs(&mut self,
-                        obligation: &Obligation,
-                        trait_ref: Rc<ty::TraitRef>)
+                        obligation: &Obligation<'tcx>,
+                        trait_ref: Rc<ty::TraitRef<'tcx>>)
                         -> Result<(),()>
     {
         debug!("match_trait_refs: obligation={} trait_ref={}",
@@ -1829,8 +1834,8 @@ fn match_trait_refs(&mut self,
     fn match_inherent_impl(&mut self,
                            impl_def_id: ast::DefId,
                            obligation_cause: ObligationCause,
-                           obligation_self_ty: Ty)
-                           -> Result<Substs,()>
+                           obligation_self_ty: Ty<'tcx>)
+                           -> Result<Substs<'tcx>,()>
     {
         /*!
          * Determines whether the self type declared against
@@ -1878,10 +1883,10 @@ fn match_self_types(&mut self,
                         cause: ObligationCause,
 
                         // The self type provided by the impl/caller-obligation:
-                        provided_self_ty: Ty,
+                        provided_self_ty: Ty<'tcx>,
 
                         // The self type the obligation is for:
-                        required_self_ty: Ty)
+                        required_self_ty: Ty<'tcx>)
                         -> Result<(),()>
     {
         // FIXME(#5781) -- equating the types is stronger than
@@ -1908,10 +1913,10 @@ fn match_self_types(&mut self,
 
     fn confirm_impl_vtable(&mut self,
                            impl_def_id: ast::DefId,
-                           obligation_cause: ObligationCause,
-                           obligation_trait_ref: Rc<ty::TraitRef>,
-                           substs: &Substs)
-                           -> Result<(), SelectionError>
+                           obligation_cause: ObligationCause<'tcx>,
+                           obligation_trait_ref: Rc<ty::TraitRef<'tcx>>,
+                           substs: &Substs<'tcx>)
+                           -> Result<(), SelectionError<'tcx>>
     {
         /*!
          * Relates the output type parameters from an impl to the
@@ -1938,9 +1943,9 @@ fn confirm_impl_vtable(&mut self,
 
     fn confirm(&mut self,
                obligation_cause: ObligationCause,
-               obligation_trait_ref: Rc<ty::TraitRef>,
-               expected_trait_ref: Rc<ty::TraitRef>)
-               -> Result<(), SelectionError>
+               obligation_trait_ref: Rc<ty::TraitRef<'tcx>>,
+               expected_trait_ref: Rc<ty::TraitRef<'tcx>>)
+               -> Result<(), SelectionError<'tcx>>
     {
         /*!
          * After we have determined which impl applies, and with what
@@ -1984,9 +1989,9 @@ fn confirm(&mut self,
     // Miscellany
 
     fn push_stack<'o,'s:'o>(&mut self,
-                            previous_stack: Option<&'s ObligationStack<'s>>,
-                            obligation: &'o Obligation)
-                            -> ObligationStack<'o>
+                            previous_stack: Option<&'s ObligationStack<'s, 'tcx>>,
+                            obligation: &'o Obligation<'tcx>)
+                            -> ObligationStack<'o, 'tcx>
     {
         let skol_trait_ref = obligation.trait_ref.fold_with(&mut self.skolemizer);
 
@@ -2011,11 +2016,11 @@ fn all_impls(&self, trait_def_id: ast::DefId) -> Vec<ast::DefId> {
     }
 
     fn impl_obligations(&self,
-                        cause: ObligationCause,
+                        cause: ObligationCause<'tcx>,
                         recursion_depth: uint,
                         impl_def_id: ast::DefId,
-                        impl_substs: &Substs)
-                        -> VecPerParamSpace<Obligation>
+                        impl_substs: &Substs<'tcx>)
+                        -> VecPerParamSpace<Obligation<'tcx>>
     {
         let impl_generics = ty::lookup_item_type(self.tcx(), impl_def_id).generics;
         let bounds = impl_generics.to_bounds(self.tcx(), impl_substs);
@@ -2024,8 +2029,8 @@ fn impl_obligations(&self,
     }
 }
 
-impl Repr for Candidate {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for Candidate<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             ErrorCandidate => format!("ErrorCandidate"),
             BuiltinCandidate(b) => format!("BuiltinCandidate({})", b),
@@ -2038,22 +2043,22 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl SelectionCache {
-    pub fn new() -> SelectionCache {
+impl<'tcx> SelectionCache<'tcx> {
+    pub fn new() -> SelectionCache<'tcx> {
         SelectionCache {
             hashmap: RefCell::new(HashMap::new())
         }
     }
 }
 
-impl<'o> ObligationStack<'o> {
-    fn iter(&self) -> Option<&ObligationStack> {
+impl<'o, 'tcx> ObligationStack<'o, 'tcx> {
+    fn iter(&self) -> Option<&ObligationStack<'o, 'tcx>> {
         Some(self)
     }
 }
 
-impl<'o> Iterator<&'o ObligationStack<'o>> for Option<&'o ObligationStack<'o>> {
-    fn next(&mut self) -> Option<&'o ObligationStack<'o>> {
+impl<'o, 'tcx> Iterator<&'o ObligationStack<'o, 'tcx>> for Option<&'o ObligationStack<'o, 'tcx>> {
+    fn next(&mut self) -> Option<&'o ObligationStack<'o, 'tcx>> {
         match *self {
             Some(o) => {
                 *self = o.previous;
@@ -2066,8 +2071,8 @@ fn next(&mut self) -> Option<&'o ObligationStack<'o>> {
     }
 }
 
-impl<'o> Repr for ObligationStack<'o> {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'o, 'tcx> Repr<'tcx> for ObligationStack<'o, 'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("ObligationStack({})",
                 self.obligation.repr(tcx))
     }
index 41cdbc0948fd1ce579de5ccdca5e45ee650c713e..dfd436bdc4d306458f0b49869612690b66b6232f 100644 (file)
 
 pub struct Supertraits<'cx, 'tcx:'cx> {
     tcx: &'cx ty::ctxt<'tcx>,
-    stack: Vec<SupertraitEntry>,
-    visited: HashSet<Rc<ty::TraitRef>>,
+    stack: Vec<SupertraitEntry<'tcx>>,
+    visited: HashSet<Rc<ty::TraitRef<'tcx>>>,
 }
 
-struct SupertraitEntry {
+struct SupertraitEntry<'tcx> {
     position: uint,
-    supertraits: Vec<Rc<ty::TraitRef>>,
+    supertraits: Vec<Rc<ty::TraitRef<'tcx>>>,
 }
 
 pub fn supertraits<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
-                              trait_ref: Rc<ty::TraitRef>)
+                              trait_ref: Rc<ty::TraitRef<'tcx>>)
                               -> Supertraits<'cx, 'tcx>
 {
     /*!
@@ -61,7 +61,7 @@ pub fn supertraits<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
 }
 
 pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
-                                    bounds: &[Rc<ty::TraitRef>])
+                                    bounds: &[Rc<ty::TraitRef<'tcx>>])
                                     -> Supertraits<'cx, 'tcx>
 {
     let bounds = Vec::from_fn(bounds.len(), |i| bounds[i].clone());
@@ -76,7 +76,7 @@ pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
 }
 
 impl<'cx, 'tcx> Supertraits<'cx, 'tcx> {
-    fn push(&mut self, trait_ref: &ty::TraitRef) {
+    fn push(&mut self, trait_ref: &ty::TraitRef<'tcx>) {
         let ty::ParamBounds { builtin_bounds, mut trait_bounds, .. } =
             ty::bounds_for_trait_ref(self.tcx, trait_ref);
         for builtin_bound in builtin_bounds.iter() {
@@ -106,8 +106,8 @@ pub fn indices(&self) -> Vec<uint> {
     }
 }
 
-impl<'cx, 'tcx> Iterator<Rc<ty::TraitRef>> for Supertraits<'cx, 'tcx> {
-    fn next(&mut self) -> Option<Rc<ty::TraitRef>> {
+impl<'cx, 'tcx> Iterator<Rc<ty::TraitRef<'tcx>>> for Supertraits<'cx, 'tcx> {
+    fn next(&mut self) -> Option<Rc<ty::TraitRef<'tcx>>> {
         loop {
             // Extract next item from top-most stack frame, if any.
             let next_trait = match self.stack.last_mut() {
@@ -148,34 +148,34 @@ fn next(&mut self) -> Option<Rc<ty::TraitRef>> {
 // declared on the impl declaration e.g., `impl<A,B> for ~[(A,B)]`
 // would return ($0, $1) where $0 and $1 are freshly instantiated type
 // variables.
-pub fn fresh_substs_for_impl(infcx: &InferCtxt,
-                             span: Span,
-                             impl_def_id: ast::DefId)
-                             -> Substs
+pub fn fresh_substs_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
+                                       span: Span,
+                                       impl_def_id: ast::DefId)
+                                       -> Substs<'tcx>
 {
     let tcx = infcx.tcx;
     let impl_generics = ty::lookup_item_type(tcx, impl_def_id).generics;
     infcx.fresh_substs_for_generics(span, &impl_generics)
 }
 
-impl<N> fmt::Show for VtableImplData<N> {
+impl<'tcx, N> fmt::Show for VtableImplData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "VtableImpl({})", self.impl_def_id)
     }
 }
 
-impl fmt::Show for VtableParamData {
+impl<'tcx> fmt::Show for VtableParamData<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "VtableParam(...)")
     }
 }
 
-pub fn obligations_for_generics(tcx: &ty::ctxt,
-                                cause: ObligationCause,
-                                recursion_depth: uint,
-                                generic_bounds: &ty::GenericBounds,
-                                type_substs: &VecPerParamSpace<Ty>)
-                                -> VecPerParamSpace<Obligation>
+pub fn obligations_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                      cause: ObligationCause<'tcx>,
+                                      recursion_depth: uint,
+                                      generic_bounds: &ty::GenericBounds<'tcx>,
+                                      type_substs: &VecPerParamSpace<Ty<'tcx>>)
+                                      -> VecPerParamSpace<Obligation<'tcx>>
 {
     /*! See `super::obligations_for_generics` */
 
@@ -200,15 +200,15 @@ pub fn obligations_for_generics(tcx: &ty::ctxt,
     return obligations;
 }
 
-fn push_obligations_for_param_bounds(
-    tcx: &ty::ctxt,
-    cause: ObligationCause,
+fn push_obligations_for_param_bounds<'tcx>(
+    tcx: &ty::ctxt<'tcx>,
+    cause: ObligationCause<'tcx>,
     recursion_depth: uint,
     space: subst::ParamSpace,
     index: uint,
-    param_bounds: &ty::ParamBounds,
-    param_type_substs: &VecPerParamSpace<Ty>,
-    obligations: &mut VecPerParamSpace<Obligation>)
+    param_bounds: &ty::ParamBounds<'tcx>,
+    param_type_substs: &VecPerParamSpace<Ty<'tcx>>,
+    obligations: &mut VecPerParamSpace<Obligation<'tcx>>)
 {
     let param_ty = *param_type_substs.get(space, index);
     for builtin_bound in param_bounds.builtin_bounds.iter() {
@@ -232,11 +232,11 @@ fn push_obligations_for_param_bounds(
     }
 }
 
-pub fn trait_ref_for_builtin_bound(
-    tcx: &ty::ctxt,
+pub fn trait_ref_for_builtin_bound<'tcx>(
+    tcx: &ty::ctxt<'tcx>,
     builtin_bound: ty::BuiltinBound,
-    param_ty: Ty)
-    -> Option<Rc<ty::TraitRef>>
+    param_ty: Ty<'tcx>)
+    -> Option<Rc<ty::TraitRef<'tcx>>>
 {
     match tcx.lang_items.from_builtin_kind(builtin_bound) {
         Ok(def_id) => {
@@ -252,13 +252,13 @@ pub fn trait_ref_for_builtin_bound(
     }
 }
 
-pub fn obligation_for_builtin_bound(
-    tcx: &ty::ctxt,
-    cause: ObligationCause,
+pub fn obligation_for_builtin_bound<'tcx>(
+    tcx: &ty::ctxt<'tcx>,
+    cause: ObligationCause<'tcx>,
     builtin_bound: ty::BuiltinBound,
     recursion_depth: uint,
-    param_ty: Ty)
-    -> Result<Obligation, ErrorReported>
+    param_ty: Ty<'tcx>)
+    -> Result<Obligation<'tcx>, ErrorReported>
 {
     let trait_ref = trait_ref_for_builtin_bound(tcx, builtin_bound, param_ty);
     match trait_ref {
@@ -271,10 +271,10 @@ pub fn obligation_for_builtin_bound(
     }
 }
 
-pub fn search_trait_and_supertraits_from_bound(tcx: &ty::ctxt,
-                                               caller_bound: Rc<ty::TraitRef>,
-                                               test: |ast::DefId| -> bool)
-                                               -> Option<VtableParamData>
+pub fn search_trait_and_supertraits_from_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                                     caller_bound: Rc<ty::TraitRef<'tcx>>,
+                                                     test: |ast::DefId| -> bool)
+                                                     -> Option<VtableParamData<'tcx>>
 {
     /*!
      * Starting from a caller obligation `caller_bound` (which has
@@ -295,16 +295,16 @@ pub fn search_trait_and_supertraits_from_bound(tcx: &ty::ctxt,
     return None;
 }
 
-impl Repr for super::Obligation {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for super::Obligation<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("Obligation(trait_ref={},depth={})",
                 self.trait_ref.repr(tcx),
                 self.recursion_depth)
     }
 }
 
-impl<N:Repr> Repr for super::Vtable<N> {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::Vtable<'tcx, N> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             super::VtableImpl(ref v) =>
                 v.repr(tcx),
@@ -323,8 +323,8 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl<N:Repr> Repr for super::VtableImplData<N> {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableImplData<'tcx, N> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("VtableImpl(impl_def_id={}, substs={}, nested={})",
                 self.impl_def_id.repr(tcx),
                 self.substs.repr(tcx),
@@ -332,22 +332,22 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl<N:Repr> Repr for super::VtableBuiltinData<N> {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableBuiltinData<N> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("VtableBuiltin(nested={})",
                 self.nested.repr(tcx))
     }
 }
 
-impl Repr for super::VtableParamData {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for super::VtableParamData<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("VtableParam(bound={})",
                 self.bound.repr(tcx))
     }
 }
 
-impl Repr for super::SelectionError {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for super::SelectionError<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             super::Overflow =>
                 format!("Overflow"),
@@ -363,16 +363,16 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl Repr for super::FulfillmentError {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for super::FulfillmentError<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("FulfillmentError({},{})",
                 self.obligation.repr(tcx),
                 self.code.repr(tcx))
     }
 }
 
-impl Repr for super::FulfillmentErrorCode {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for super::FulfillmentErrorCode<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             super::CodeSelectionError(ref o) => o.repr(tcx),
             super::CodeAmbiguity => format!("Ambiguity")
@@ -380,7 +380,7 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl fmt::Show for super::FulfillmentErrorCode {
+impl<'tcx> fmt::Show for super::FulfillmentErrorCode<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             super::CodeSelectionError(ref e) => write!(f, "{}", e),
@@ -389,8 +389,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-impl Repr for ty::type_err {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::type_err<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         ty::type_err_to_str(tcx, self)
     }
 }
index 5c356e80c703f8f1ed82f5e290fd35c278622850..2aa50d90b09b129b40691fce2f17144957c974a0 100644 (file)
@@ -90,9 +90,9 @@
 // Data types
 
 #[deriving(PartialEq, Eq, Hash)]
-pub struct field {
+pub struct field<'tcx> {
     pub name: ast::Name,
-    pub mt: mt
+    pub mt: mt<'tcx>
 }
 
 #[deriving(Clone, Show)]
@@ -111,12 +111,12 @@ pub fn id(&self) -> ast::DefId {
 }
 
 #[deriving(Clone)]
-pub enum ImplOrTraitItem {
-    MethodTraitItem(Rc<Method>),
+pub enum ImplOrTraitItem<'tcx> {
+    MethodTraitItem(Rc<Method<'tcx>>),
     TypeTraitItem(Rc<AssociatedType>),
 }
 
-impl ImplOrTraitItem {
+impl<'tcx> ImplOrTraitItem<'tcx> {
     fn id(&self) -> ImplOrTraitItemId {
         match *self {
             MethodTraitItem(ref method) => MethodTraitItemId(method.def_id),
@@ -147,7 +147,7 @@ pub fn container(&self) -> ImplOrTraitItemContainer {
         }
     }
 
-    pub fn as_opt_method(&self) -> Option<Rc<Method>> {
+    pub fn as_opt_method(&self) -> Option<Rc<Method<'tcx>>> {
         match *self {
             MethodTraitItem(ref m) => Some((*m).clone()),
             TypeTraitItem(_) => None
@@ -171,10 +171,10 @@ pub fn def_id(&self) -> ast::DefId {
 }
 
 #[deriving(Clone, Show)]
-pub struct Method {
+pub struct Method<'tcx> {
     pub name: ast::Name,
-    pub generics: ty::Generics,
-    pub fty: BareFnTy,
+    pub generics: ty::Generics<'tcx>,
+    pub fty: BareFnTy<'tcx>,
     pub explicit_self: ExplicitSelfCategory,
     pub vis: ast::Visibility,
     pub def_id: ast::DefId,
@@ -184,16 +184,16 @@ pub struct Method {
     pub provided_source: Option<ast::DefId>
 }
 
-impl Method {
+impl<'tcx> Method<'tcx> {
     pub fn new(name: ast::Name,
-               generics: ty::Generics,
-               fty: BareFnTy,
+               generics: ty::Generics<'tcx>,
+               fty: BareFnTy<'tcx>,
                explicit_self: ExplicitSelfCategory,
                vis: ast::Visibility,
                def_id: ast::DefId,
                container: ImplOrTraitItemContainer,
                provided_source: Option<ast::DefId>)
-               -> Method {
+               -> Method<'tcx> {
        Method {
             name: name,
             generics: generics,
@@ -223,8 +223,8 @@ pub struct AssociatedType {
 }
 
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub struct mt {
-    pub ty: Ty,
+pub struct mt<'tcx> {
+    pub ty: Ty<'tcx>,
     pub mutbl: ast::Mutability,
 }
 
@@ -253,9 +253,9 @@ pub struct creader_cache_key {
     pub len: uint
 }
 
-pub enum ast_ty_to_ty_cache_entry {
+pub enum ast_ty_to_ty_cache_entry<'tcx> {
     atttce_unresolved,  /* not resolved yet */
-    atttce_resolved(Ty)  /* resolved to a type, irrespective of region */
+    atttce_resolved(Ty<'tcx>)  /* resolved to a type, irrespective of region */
 }
 
 #[deriving(Clone, PartialEq, Decodable, Encodable)]
@@ -273,44 +273,44 @@ pub enum Variance {
 }
 
 #[deriving(Clone, Show)]
-pub enum AutoAdjustment {
+pub enum AutoAdjustment<'tcx> {
     AdjustAddEnv(ty::TraitStore),
-    AdjustDerefRef(AutoDerefRef)
+    AdjustDerefRef(AutoDerefRef<'tcx>)
 }
 
 #[deriving(Clone, PartialEq, Show)]
-pub enum UnsizeKind {
+pub enum UnsizeKind<'tcx> {
     // [T, ..n] -> [T], the uint field is n.
     UnsizeLength(uint),
     // An unsize coercion applied to the tail field of a struct.
     // The uint is the index of the type parameter which is unsized.
-    UnsizeStruct(Box<UnsizeKind>, uint),
-    UnsizeVtable(TyTrait, /* the self type of the trait */ Ty)
+    UnsizeStruct(Box<UnsizeKind<'tcx>>, uint),
+    UnsizeVtable(TyTrait<'tcx>, /* the self type of the trait */ Ty<'tcx>)
 }
 
 #[deriving(Clone, Show)]
-pub struct AutoDerefRef {
+pub struct AutoDerefRef<'tcx> {
     pub autoderefs: uint,
-    pub autoref: Option<AutoRef>
+    pub autoref: Option<AutoRef<'tcx>>
 }
 
 #[deriving(Clone, PartialEq, Show)]
-pub enum AutoRef {
+pub enum AutoRef<'tcx> {
     /// Convert from T to &T
     /// The third field allows us to wrap other AutoRef adjustments.
-    AutoPtr(Region, ast::Mutability, Option<Box<AutoRef>>),
+    AutoPtr(Region, ast::Mutability, Option<Box<AutoRef<'tcx>>>),
 
     /// Convert [T, ..n] to [T] (or similar, depending on the kind)
-    AutoUnsize(UnsizeKind),
+    AutoUnsize(UnsizeKind<'tcx>),
 
     /// Convert Box<[T, ..n]> to Box<[T]> or something similar in a Box.
     /// With DST and Box a library type, this should be replaced by UnsizeStruct.
-    AutoUnsizeUniq(UnsizeKind),
+    AutoUnsizeUniq(UnsizeKind<'tcx>),
 
     /// Convert from T to *T
     /// Value to thin pointer
     /// The second field allows us to wrap other AutoRef adjustments.
-    AutoUnsafe(ast::Mutability, Option<Box<AutoRef>>),
+    AutoUnsafe(ast::Mutability, Option<Box<AutoRef<'tcx>>>),
 }
 
 // Ugly little helper function. The first bool in the returned tuple is true if
@@ -372,8 +372,8 @@ pub fn adjust_is_object(adj: &AutoAdjustment) -> bool {
 
 // If possible, returns the type expected from the given adjustment. This is not
 // possible if the adjustment depends on the type of the adjusted expression.
-pub fn type_of_adjust(cx: &ctxt, adj: &AutoAdjustment) -> Option<Ty> {
-    fn type_of_autoref(cx: &ctxt, autoref: &AutoRef) -> Option<Ty> {
+pub fn type_of_adjust<'tcx>(cx: &ctxt<'tcx>, adj: &AutoAdjustment<'tcx>) -> Option<Ty<'tcx>> {
+    fn type_of_autoref<'tcx>(cx: &ctxt<'tcx>, autoref: &AutoRef<'tcx>) -> Option<Ty<'tcx>> {
         match autoref {
             &AutoUnsize(ref k) => match k {
                 &UnsizeVtable(TyTrait { ref principal, bounds }, _) => {
@@ -415,13 +415,13 @@ fn type_of_autoref(cx: &ctxt, autoref: &AutoRef) -> Option<Ty> {
 
 /// A restriction that certain types must be the same size. The use of
 /// `transmute` gives rise to these restrictions.
-pub struct TransmuteRestriction {
+pub struct TransmuteRestriction<'tcx> {
     /// The span from whence the restriction comes.
     pub span: Span,
     /// The type being transmuted from.
-    pub from: Ty,
+    pub from: Ty<'tcx>,
     /// The type being transmuted to.
-    pub to: Ty,
+    pub to: Ty<'tcx>,
     /// NodeIf of the transmute intrinsic.
     pub id: ast::NodeId,
 }
@@ -431,11 +431,11 @@ pub struct TransmuteRestriction {
 /// later on.
 pub struct ctxt<'tcx> {
     /// The arena that types are allocated from.
-    type_arena: &'tcx TypedArena<TyS>,
+    type_arena: &'tcx TypedArena<TyS<'tcx>>,
 
     /// Specifically use a speedy hash algorithm for this hash map, it's used
     /// quite often.
-    // TODO(eddyb) use a FnvHashSet<InternedTy<'tcx>> when equivalent keys can
+    // FIXME(eddyb) use a FnvHashSet<InternedTy<'tcx>> when equivalent keys can
     // queried from a HashSet.
     interner: RefCell<FnvHashMap<InternedTy<'tcx>, Ty<'tcx>>>,
     pub sess: Session,
@@ -448,45 +448,45 @@ pub struct ctxt<'tcx> {
     /// Stores the types for various nodes in the AST.  Note that this table
     /// is not guaranteed to be populated until after typeck.  See
     /// typeck::check::fn_ctxt for details.
-    pub node_types: RefCell<NodeMap<Ty>>,
+    pub node_types: RefCell<NodeMap<Ty<'tcx>>>,
 
     /// Stores the type parameters which were substituted to obtain the type
     /// of this node.  This only applies to nodes that refer to entities
     /// parameterized by type parameters, such as generic fns, types, or
     /// other items.
-    pub item_substs: RefCell<NodeMap<ItemSubsts>>,
+    pub item_substs: RefCell<NodeMap<ItemSubsts<'tcx>>>,
 
     /// Maps from a trait item to the trait item "descriptor"
-    pub impl_or_trait_items: RefCell<DefIdMap<ImplOrTraitItem>>,
+    pub impl_or_trait_items: RefCell<DefIdMap<ImplOrTraitItem<'tcx>>>,
 
     /// Maps from a trait def-id to a list of the def-ids of its trait items
     pub trait_item_def_ids: RefCell<DefIdMap<Rc<Vec<ImplOrTraitItemId>>>>,
 
     /// A cache for the trait_items() routine
-    pub trait_items_cache: RefCell<DefIdMap<Rc<Vec<ImplOrTraitItem>>>>,
+    pub trait_items_cache: RefCell<DefIdMap<Rc<Vec<ImplOrTraitItem<'tcx>>>>>,
 
-    pub impl_trait_cache: RefCell<DefIdMap<Option<Rc<ty::TraitRef>>>>,
+    pub impl_trait_cache: RefCell<DefIdMap<Option<Rc<ty::TraitRef<'tcx>>>>>,
 
-    pub trait_refs: RefCell<NodeMap<Rc<TraitRef>>>,
-    pub trait_defs: RefCell<DefIdMap<Rc<TraitDef>>>,
+    pub trait_refs: RefCell<NodeMap<Rc<TraitRef<'tcx>>>>,
+    pub trait_defs: RefCell<DefIdMap<Rc<TraitDef<'tcx>>>>,
 
     /// Maps from node-id of a trait object cast (like `foo as
     /// Box<Trait>`) to the trait reference.
-    pub object_cast_map: typeck::ObjectCastMap,
+    pub object_cast_map: typeck::ObjectCastMap<'tcx>,
 
     pub map: ast_map::Map<'tcx>,
-    pub intrinsic_defs: RefCell<DefIdMap<Ty>>,
+    pub intrinsic_defs: RefCell<DefIdMap<Ty<'tcx>>>,
     pub freevars: RefCell<FreevarMap>,
-    pub tcache: RefCell<DefIdMap<Polytype>>,
-    pub rcache: RefCell<FnvHashMap<creader_cache_key, Ty>>,
-    pub short_names_cache: RefCell<FnvHashMap<Ty, String>>,
-    pub needs_unwind_cleanup_cache: RefCell<FnvHashMap<Ty, bool>>,
-    pub tc_cache: RefCell<FnvHashMap<Ty, TypeContents>>,
-    pub ast_ty_to_ty_cache: RefCell<NodeMap<ast_ty_to_ty_cache_entry>>,
-    pub enum_var_cache: RefCell<DefIdMap<Rc<Vec<Rc<VariantInfo>>>>>,
-    pub ty_param_defs: RefCell<NodeMap<TypeParameterDef>>,
-    pub adjustments: RefCell<NodeMap<AutoAdjustment>>,
-    pub normalized_cache: RefCell<FnvHashMap<Ty, Ty>>,
+    pub tcache: RefCell<DefIdMap<Polytype<'tcx>>>,
+    pub rcache: RefCell<FnvHashMap<creader_cache_key, Ty<'tcx>>>,
+    pub short_names_cache: RefCell<FnvHashMap<Ty<'tcx>, String>>,
+    pub needs_unwind_cleanup_cache: RefCell<FnvHashMap<Ty<'tcx>, bool>>,
+    pub tc_cache: RefCell<FnvHashMap<Ty<'tcx>, TypeContents>>,
+    pub ast_ty_to_ty_cache: RefCell<NodeMap<ast_ty_to_ty_cache_entry<'tcx>>>,
+    pub enum_var_cache: RefCell<DefIdMap<Rc<Vec<Rc<VariantInfo<'tcx>>>>>>,
+    pub ty_param_defs: RefCell<NodeMap<TypeParameterDef<'tcx>>>,
+    pub adjustments: RefCell<NodeMap<AutoAdjustment<'tcx>>>,
+    pub normalized_cache: RefCell<FnvHashMap<Ty<'tcx>, Ty<'tcx>>>,
     pub lang_items: middle::lang_items::LanguageItems,
     /// A mapping of fake provided method def_ids to the default implementation
     pub provided_method_sources: RefCell<DefIdMap<ast::DefId>>,
@@ -547,13 +547,13 @@ pub struct ctxt<'tcx> {
     pub extern_const_statics: RefCell<DefIdMap<ast::NodeId>>,
     pub extern_const_variants: RefCell<DefIdMap<ast::NodeId>>,
 
-    pub method_map: typeck::MethodMap,
+    pub method_map: typeck::MethodMap<'tcx>,
 
     pub dependency_formats: RefCell<dependency_format::Dependencies>,
 
     /// Records the type of each unboxed closure. The def ID is the ID of the
     /// expression defining the unboxed closure.
-    pub unboxed_closures: RefCell<DefIdMap<UnboxedClosure>>,
+    pub unboxed_closures: RefCell<DefIdMap<UnboxedClosure<'tcx>>>,
 
     pub node_lint_levels: RefCell<FnvHashMap<(ast::NodeId, lint::LintId),
                                               lint::LevelSource>>,
@@ -561,7 +561,7 @@ pub struct ctxt<'tcx> {
     /// The types that must be asserted to be the same size for `transmute`
     /// to be valid. We gather up these restrictions in the intrinsicck pass
     /// and check them in trans.
-    pub transmute_restrictions: RefCell<Vec<TransmuteRestriction>>,
+    pub transmute_restrictions: RefCell<Vec<TransmuteRestriction<'tcx>>>,
 
     /// Maps any item's def-id to its stability index.
     pub stability: RefCell<stability::Index>,
@@ -574,7 +574,7 @@ pub struct ctxt<'tcx> {
 
     /// Caches the results of trait selection. This cache is used
     /// for things that do not have to do with the parameters in scope.
-    pub selection_cache: traits::SelectionCache,
+    pub selection_cache: traits::SelectionCache<'tcx>,
 
     /// Caches the representation hints for struct definitions.
     pub repr_hint_cache: RefCell<DefIdMap<Rc<Vec<attr::ReprAttr>>>>,
@@ -599,8 +599,8 @@ pub struct ctxt<'tcx> {
 }
 
 #[deriving(Show)]
-pub struct TyS {
-    pub sty: sty,
+pub struct TyS<'tcx> {
+    pub sty: sty<'tcx>,
     pub flags: TypeFlags,
 
     // the maximal depth of any bound regions appearing in this type.
@@ -613,23 +613,23 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-impl PartialEq for TyS {
-    fn eq(&self, other: &TyS) -> bool {
+impl<'tcx> PartialEq for TyS<'tcx> {
+    fn eq(&self, other: &TyS<'tcx>) -> bool {
         (self as *const _) == (other as *const _)
     }
 }
-impl Eq for TyS {}
+impl<'tcx> Eq for TyS<'tcx> {}
 
-impl<S: Writer> Hash<S> for TyS {
+impl<'tcx, S: Writer> Hash<S> for TyS<'tcx> {
     fn hash(&self, s: &mut S) {
         (self as *const _).hash(s)
     }
 }
 
-pub type Ty<'tcx> = &'tcx TyS;
+pub type Ty<'tcx> = &'tcx TyS<'tcx>;
 
 /// An entry in the type interner.
-struct InternedTy<'tcx> {
+pub struct InternedTy<'tcx> {
     ty: Ty<'tcx>
 }
 
@@ -653,12 +653,12 @@ fn borrow_from<'a>(ty: &'a InternedTy<'tcx>) -> &'a sty<'tcx> {
     }
 }
 
-pub fn get(ty: Ty) -> Ty {
+pub fn get<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
     ty
 }
 
-fn tbox_has_flag(ty: Ty, flag: TypeFlags) -> bool {
-    ty.flags.intersects(flag)
+pub fn tbox_has_flag(tb: &TyS, flag: TypeFlags) -> bool {
+    tb.flags.intersects(flag)
 }
 pub fn type_has_params(ty: Ty) -> bool {
     tbox_has_flag(get(ty), HAS_PARAMS)
@@ -718,32 +718,32 @@ pub fn type_escapes_depth(ty: Ty, depth: uint) -> bool {
 }
 
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub struct BareFnTy {
+pub struct BareFnTy<'tcx> {
     pub fn_style: ast::FnStyle,
     pub abi: abi::Abi,
-    pub sig: FnSig,
+    pub sig: FnSig<'tcx>,
 }
 
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub struct ClosureTy {
+pub struct ClosureTy<'tcx> {
     pub fn_style: ast::FnStyle,
     pub onceness: ast::Onceness,
     pub store: TraitStore,
     pub bounds: ExistentialBounds,
-    pub sig: FnSig,
+    pub sig: FnSig<'tcx>,
     pub abi: abi::Abi,
 }
 
 #[deriving(Clone, PartialEq, Eq, Hash)]
-pub enum FnOutput {
-    FnConverging(Ty),
+pub enum FnOutput<'tcx> {
+    FnConverging(Ty<'tcx>),
     FnDiverging
 }
 
-impl FnOutput {
-    pub fn unwrap(&self) -> Ty {
-        match *self {
-            ty::FnConverging(ref t) => *t,
+impl<'tcx> FnOutput<'tcx> {
+    pub fn unwrap(self) -> Ty<'tcx> {
+        match self {
+            ty::FnConverging(t) => t,
             ty::FnDiverging => unreachable!()
         }
     }
@@ -762,9 +762,9 @@ pub fn unwrap(&self) -> Ty {
  * fn's arguments or the fn's return type.
  */
 #[deriving(Clone, PartialEq, Eq, Hash)]
-pub struct FnSig {
-    pub inputs: Vec<Ty>,
-    pub output: FnOutput,
+pub struct FnSig<'tcx> {
+    pub inputs: Vec<Ty<'tcx>>,
+    pub output: FnOutput<'tcx>,
     pub variadic: bool
 }
 
@@ -1025,7 +1025,7 @@ mod primitives {
 
     macro_rules! def_prim_ty(
         ($name:ident, $sty:expr) => (
-            pub static $name: TyS = TyS {
+            pub static $name: TyS<'static> = TyS {
                 sty: $sty,
                 flags: super::NO_TYPE_FLAGS,
                 region_depth: 0,
@@ -1048,7 +1048,7 @@ macro_rules! def_prim_ty(
     def_prim_ty!(TY_F32,    super::ty_float(ast::TyF32))
     def_prim_ty!(TY_F64,    super::ty_float(ast::TyF64))
 
-    pub static TY_ERR: TyS = TyS {
+    pub static TY_ERR: TyS<'static> = TyS {
         sty: super::ty_err,
         flags: super::HAS_TY_ERR,
         region_depth: 0,
@@ -1058,7 +1058,7 @@ macro_rules! def_prim_ty(
 // NB: If you change this, you'll probably want to change the corresponding
 // AST structure in libsyntax/ast.rs as well.
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub enum sty {
+pub enum sty<'tcx> {
     ty_bool,
     ty_char,
     ty_int(ast::IntTy),
@@ -1071,25 +1071,25 @@ pub enum sty {
     /// from the tcx, use the `NodeId` from the `ast::Ty` and look it up in
     /// the `ast_ty_to_ty_cache`. This is probably true for `ty_struct` as
     /// well.`
-    ty_enum(DefId, Substs),
-    ty_uniq(Ty),
+    ty_enum(DefId, Substs<'tcx>),
+    ty_uniq(Ty<'tcx>),
     ty_str,
-    ty_vec(Ty, Option<uint>), // Second field is length.
-    ty_ptr(mt),
-    ty_rptr(Region, mt),
-    ty_bare_fn(BareFnTy),
-    ty_closure(Box<ClosureTy>),
-    ty_trait(Box<TyTrait>),
-    ty_struct(DefId, Substs),
-    ty_unboxed_closure(DefId, Region, Substs),
-    ty_tup(Vec<Ty>),
+    ty_vec(Ty<'tcx>, Option<uint>), // Second field is length.
+    ty_ptr(mt<'tcx>),
+    ty_rptr(Region, mt<'tcx>),
+    ty_bare_fn(BareFnTy<'tcx>),
+    ty_closure(Box<ClosureTy<'tcx>>),
+    ty_trait(Box<TyTrait<'tcx>>),
+    ty_struct(DefId, Substs<'tcx>),
+    ty_unboxed_closure(DefId, Region, Substs<'tcx>),
+    ty_tup(Vec<Ty<'tcx>>),
 
     ty_param(ParamTy), // type parameter
-    ty_open(Ty), // A deref'ed fat pointer, i.e., a dynamically sized value
-                 // and its size. Only ever used in trans. It is not necessary
-                 // earlier since we don't need to distinguish a DST with its
-                 // size (e.g., in a deref) vs a DST with the size elsewhere (
-                 // e.g., in a field).
+    ty_open(Ty<'tcx>), // A deref'ed fat pointer, i.e., a dynamically sized value
+                       // and its size. Only ever used in trans. It is not necessary
+                       // earlier since we don't need to distinguish a DST with its
+                       // size (e.g., in a deref) vs a DST with the size elsewhere (
+                       // e.g., in a field).
 
     ty_infer(InferTy), // something used only during inference/typeck
     ty_err, // Also only used during inference/typeck, to represent
@@ -1098,9 +1098,9 @@ pub enum sty {
 }
 
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub struct TyTrait {
+pub struct TyTrait<'tcx> {
     // Principal trait reference.
-    pub principal: TraitRef, // would use Rc<TraitRef>, but it runs afoul of some static rules
+    pub principal: TraitRef<'tcx>, // would use Rc<TraitRef>, but it runs afoul of some static rules
     pub bounds: ExistentialBounds
 }
 
@@ -1122,9 +1122,9 @@ pub struct TyTrait {
  * U>` or higher-ranked object types.
  */
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub struct TraitRef {
+pub struct TraitRef<'tcx> {
     pub def_id: DefId,
-    pub substs: Substs,
+    pub substs: Substs<'tcx>,
 }
 
 /**
@@ -1166,7 +1166,7 @@ pub struct expected_found<T> {
 
 // Data structures used in type unification
 #[deriving(Clone, Show)]
-pub enum type_err {
+pub enum type_err<'tcx> {
     terr_mismatch,
     terr_fn_style_mismatch(expected_found<FnStyle>),
     terr_onceness_mismatch(expected_found<Onceness>),
@@ -1187,7 +1187,7 @@ pub enum type_err {
     terr_regions_insufficiently_polymorphic(BoundRegion, Region),
     terr_regions_overly_polymorphic(BoundRegion, Region),
     terr_trait_stores_differ(terr_vstore_kind, expected_found<TraitStore>),
-    terr_sorts(expected_found<Ty>),
+    terr_sorts(expected_found<Ty<'tcx>>),
     terr_integer_as_char,
     terr_int_mismatch(expected_found<IntVarValue>),
     terr_float_mismatch(expected_found<ast::FloatTy>),
@@ -1201,10 +1201,10 @@ pub enum type_err {
 /// Bounds suitable for a named type parameter like `A` in `fn foo<A>`
 /// as well as the existential type parameter in an object type.
 #[deriving(PartialEq, Eq, Hash, Clone, Show)]
-pub struct ParamBounds {
+pub struct ParamBounds<'tcx> {
     pub region_bounds: Vec<ty::Region>,
     pub builtin_bounds: BuiltinBounds,
-    pub trait_bounds: Vec<Rc<TraitRef>>
+    pub trait_bounds: Vec<Rc<TraitRef<'tcx>>>
 }
 
 /// Bounds suitable for an existentially quantified type parameter
@@ -1339,7 +1339,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-impl fmt::Show for FnSig {
+impl<'tcx> fmt::Show for FnSig<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         // grr, without tcx not much we can do.
         write!(f, "(...)")
@@ -1368,14 +1368,14 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[deriving(Clone, Show)]
-pub struct TypeParameterDef {
+pub struct TypeParameterDef<'tcx> {
     pub name: ast::Name,
     pub def_id: ast::DefId,
     pub space: subst::ParamSpace,
     pub index: uint,
     pub associated_with: Option<ast::DefId>,
-    pub bounds: ParamBounds,
-    pub default: Option<Ty>,
+    pub bounds: ParamBounds<'tcx>,
+    pub default: Option<Ty<'tcx>>,
 }
 
 #[deriving(Encodable, Decodable, Clone, Show)]
@@ -1390,13 +1390,13 @@ pub struct RegionParameterDef {
 /// Information about the type/lifetime parameters associated with an
 /// item or method. Analogous to ast::Generics.
 #[deriving(Clone, Show)]
-pub struct Generics {
-    pub types: VecPerParamSpace<TypeParameterDef>,
+pub struct Generics<'tcx> {
+    pub types: VecPerParamSpace<TypeParameterDef<'tcx>>,
     pub regions: VecPerParamSpace<RegionParameterDef>,
 }
 
-impl Generics {
-    pub fn empty() -> Generics {
+impl<'tcx> Generics<'tcx> {
+    pub fn empty() -> Generics<'tcx> {
         Generics { types: VecPerParamSpace::empty(),
                    regions: VecPerParamSpace::empty() }
     }
@@ -1409,7 +1409,8 @@ pub fn has_region_params(&self, space: subst::ParamSpace) -> bool {
         !self.regions.is_empty_in(space)
     }
 
-    pub fn to_bounds(&self, tcx: &ty::ctxt, substs: &Substs) -> GenericBounds {
+    pub fn to_bounds(&self, tcx: &ty::ctxt<'tcx>, substs: &Substs<'tcx>)
+                     -> GenericBounds<'tcx> {
         GenericBounds {
             types: self.types.map(|d| d.bounds.subst(tcx, substs)),
             regions: self.regions.map(|d| d.bounds.subst(tcx, substs)),
@@ -1439,13 +1440,13 @@ pub fn to_bounds(&self, tcx: &ty::ctxt, substs: &Substs) -> GenericBounds {
  * [uint:Bar<int>]]`.
  */
 #[deriving(Clone, Show)]
-pub struct GenericBounds {
-    pub types: VecPerParamSpace<ParamBounds>,
+pub struct GenericBounds<'tcx> {
+    pub types: VecPerParamSpace<ParamBounds<'tcx>>,
     pub regions: VecPerParamSpace<Vec<Region>>,
 }
 
-impl GenericBounds {
-    pub fn empty() -> GenericBounds {
+impl<'tcx> GenericBounds<'tcx> {
+    pub fn empty() -> GenericBounds<'tcx> {
         GenericBounds { types: VecPerParamSpace::empty(),
                         regions: VecPerParamSpace::empty() }
     }
@@ -1456,16 +1457,16 @@ pub fn has_escaping_regions(&self) -> bool {
     }
 }
 
-impl TraitRef {
-    pub fn new(def_id: ast::DefId, substs: Substs) -> TraitRef {
+impl<'tcx> TraitRef<'tcx> {
+    pub fn new(def_id: ast::DefId, substs: Substs<'tcx>) -> TraitRef<'tcx> {
         TraitRef { def_id: def_id, substs: substs }
     }
 
-    pub fn self_ty(&self) -> Ty {
+    pub fn self_ty(&self) -> Ty<'tcx> {
         self.substs.self_ty().unwrap()
     }
 
-    pub fn input_types(&self) -> &[Ty] {
+    pub fn input_types(&self) -> &[Ty<'tcx>] {
         // Select only the "input types" from a trait-reference. For
         // now this is all the types that appear in the
         // trait-reference, but it should eventually exclude
@@ -1494,16 +1495,16 @@ pub fn has_bound_regions(&self) -> bool {
 /// bound lifetime parameters are replaced with free ones, but in the
 /// future I hope to refine the representation of types so as to make
 /// more distinctions clearer.
-pub struct ParameterEnvironment {
+pub struct ParameterEnvironment<'tcx> {
     /// A substitution that can be applied to move from
     /// the "outer" view of a type or method to the "inner" view.
     /// In general, this means converting from bound parameters to
     /// free parameters. Since we currently represent bound/free type
     /// parameters in the same way, this only has an effect on regions.
-    pub free_substs: Substs,
+    pub free_substs: Substs<'tcx>,
 
     /// Bounds on the various type parameters
-    pub bounds: VecPerParamSpace<ParamBounds>,
+    pub bounds: VecPerParamSpace<ParamBounds<'tcx>>,
 
     /// Each type parameter has an implicit region bound that
     /// indicates it must outlive at least the function body (the user
@@ -1517,15 +1518,15 @@ pub struct ParameterEnvironment {
     ///
     /// Note: This effectively *duplicates* the `bounds` array for
     /// now.
-    pub caller_obligations: VecPerParamSpace<traits::Obligation>,
+    pub caller_obligations: VecPerParamSpace<traits::Obligation<'tcx>>,
 
     /// Caches the results of trait selection. This cache is used
     /// for things that have to do with the parameters in scope.
-    pub selection_cache: traits::SelectionCache,
+    pub selection_cache: traits::SelectionCache<'tcx>,
 }
 
-impl ParameterEnvironment {
-    pub fn for_item(cx: &ctxt, id: NodeId) -> ParameterEnvironment {
+impl<'tcx> ParameterEnvironment<'tcx> {
+    pub fn for_item(cx: &ctxt<'tcx>, id: NodeId) -> ParameterEnvironment<'tcx> {
         match cx.map.find(id) {
             Some(ast_map::NodeImplItem(ref impl_item)) => {
                 match **impl_item {
@@ -1635,37 +1636,37 @@ pub fn for_item(cx: &ctxt, id: NodeId) -> ParameterEnvironment {
 /// - `ty`: the base types, which may reference the parameters defined
 ///   in `generics`
 #[deriving(Clone, Show)]
-pub struct Polytype {
-    pub generics: Generics,
-    pub ty: Ty
+pub struct Polytype<'tcx> {
+    pub generics: Generics<'tcx>,
+    pub ty: Ty<'tcx>
 }
 
 /// As `Polytype` but for a trait ref.
-pub struct TraitDef {
+pub struct TraitDef<'tcx> {
     /// Generic type definitions. Note that `Self` is listed in here
     /// as having a single bound, the trait itself (e.g., in the trait
     /// `Eq`, there is a single bound `Self : Eq`). This is so that
     /// default methods get to assume that the `Self` parameters
     /// implements the trait.
-    pub generics: Generics,
+    pub generics: Generics<'tcx>,
 
     /// The "supertrait" bounds.
-    pub bounds: ParamBounds,
-    pub trait_ref: Rc<ty::TraitRef>,
+    pub bounds: ParamBounds<'tcx>,
+    pub trait_ref: Rc<ty::TraitRef<'tcx>>,
 }
 
 /// Records the substitutions used to translate the polytype for an
 /// item into the monotype of an item reference.
 #[deriving(Clone)]
-pub struct ItemSubsts {
-    pub substs: Substs,
+pub struct ItemSubsts<'tcx> {
+    pub substs: Substs<'tcx>,
 }
 
 /// Records information about each unboxed closure.
 #[deriving(Clone)]
-pub struct UnboxedClosure {
+pub struct UnboxedClosure<'tcx> {
     /// The type of the unboxed closure.
-    pub closure_type: ClosureTy,
+    pub closure_type: ClosureTy<'tcx>,
     /// The kind of unboxed closure this is.
     pub kind: UnboxedClosureKind,
 }
@@ -1696,7 +1697,7 @@ pub fn trait_did(&self, cx: &ctxt) -> ast::DefId {
 }
 
 pub fn mk_ctxt<'tcx>(s: Session,
-                     type_arena: &'tcx TypedArena<TyS>,
+                     type_arena: &'tcx TypedArena<TyS<'tcx>>,
                      dm: resolve::DefMap,
                      named_region_map: resolve_lifetime::NamedRegionMap,
                      map: ast_map::Map<'tcx>,
@@ -1768,7 +1769,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
 
 // Interns a type/name combination, stores the resulting box in cx.interner,
 // and returns the box as cast to an unsafe ptr (see comments for Ty above).
-pub fn mk_t(cx: &ctxt, st: sty) -> Ty {
+pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
     // Check for primitive types.
     match st {
         ty_err => return mk_err(),
@@ -1781,7 +1782,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> Ty {
     };
 
     match cx.interner.borrow().get(&st) {
-        Some(ty) => return ty,
+        Some(ty) => return *ty,
         _ => ()
     }
 
@@ -1795,7 +1796,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> Ty {
 
     cx.interner.borrow_mut().insert(InternedTy { ty: ty }, ty);
 
-    Ty { inner: ty }
+    ty
 }
 
 struct FlagComputation {
@@ -1981,53 +1982,54 @@ fn add_bounds(&mut self, bounds: &ExistentialBounds) {
 }
 
 #[inline]
-pub fn mk_prim_t(primitive: &'static TyS) -> Ty {
-    Ty { inner: primitive }
+pub fn mk_prim_t<'tcx>(primitive: &'tcx TyS<'static>) -> Ty<'tcx> {
+    // FIXME(#17596) Ty<'tcx> is incorrectly invariant w.r.t 'tcx.
+    unsafe { &*(primitive as *const _ as *const TyS<'tcx>) }
 }
 
 #[inline]
-pub fn mk_err() -> Ty { mk_prim_t(&primitives::TY_ERR) }
+pub fn mk_err<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_ERR) }
 
 #[inline]
-pub fn mk_bool() -> Ty { mk_prim_t(&primitives::TY_BOOL) }
+pub fn mk_bool<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_BOOL) }
 
 #[inline]
-pub fn mk_int() -> Ty { mk_prim_t(&primitives::TY_INT) }
+pub fn mk_int<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_INT) }
 
 #[inline]
-pub fn mk_i8() -> Ty { mk_prim_t(&primitives::TY_I8) }
+pub fn mk_i8<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_I8) }
 
 #[inline]
-pub fn mk_i16() -> Ty { mk_prim_t(&primitives::TY_I16) }
+pub fn mk_i16<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_I16) }
 
 #[inline]
-pub fn mk_i32() -> Ty { mk_prim_t(&primitives::TY_I32) }
+pub fn mk_i32<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_I32) }
 
 #[inline]
-pub fn mk_i64() -> Ty { mk_prim_t(&primitives::TY_I64) }
+pub fn mk_i64<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_I64) }
 
 #[inline]
-pub fn mk_f32() -> Ty { mk_prim_t(&primitives::TY_F32) }
+pub fn mk_f32<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_F32) }
 
 #[inline]
-pub fn mk_f64() -> Ty { mk_prim_t(&primitives::TY_F64) }
+pub fn mk_f64<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_F64) }
 
 #[inline]
-pub fn mk_uint() -> Ty { mk_prim_t(&primitives::TY_UINT) }
+pub fn mk_uint<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_UINT) }
 
 #[inline]
-pub fn mk_u8() -> Ty { mk_prim_t(&primitives::TY_U8) }
+pub fn mk_u8<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_U8) }
 
 #[inline]
-pub fn mk_u16() -> Ty { mk_prim_t(&primitives::TY_U16) }
+pub fn mk_u16<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_U16) }
 
 #[inline]
-pub fn mk_u32() -> Ty { mk_prim_t(&primitives::TY_U32) }
+pub fn mk_u32<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_U32) }
 
 #[inline]
-pub fn mk_u64() -> Ty { mk_prim_t(&primitives::TY_U64) }
+pub fn mk_u64<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_U64) }
 
-pub fn mk_mach_int(tm: ast::IntTy) -> Ty {
+pub fn mk_mach_int<'tcx>(tm: ast::IntTy) -> Ty<'tcx> {
     match tm {
         ast::TyI    => mk_int(),
         ast::TyI8   => mk_i8(),
@@ -2037,7 +2039,7 @@ pub fn mk_mach_int(tm: ast::IntTy) -> Ty {
     }
 }
 
-pub fn mk_mach_uint(tm: ast::UintTy) -> Ty {
+pub fn mk_mach_uint<'tcx>(tm: ast::UintTy) -> Ty<'tcx> {
     match tm {
         ast::TyU    => mk_uint(),
         ast::TyU8   => mk_u8(),
@@ -2047,7 +2049,7 @@ pub fn mk_mach_uint(tm: ast::UintTy) -> Ty {
     }
 }
 
-pub fn mk_mach_float(tm: ast::FloatTy) -> Ty {
+pub fn mk_mach_float<'tcx>(tm: ast::FloatTy) -> Ty<'tcx> {
     match tm {
         ast::TyF32  => mk_f32(),
         ast::TyF64  => mk_f64(),
@@ -2055,13 +2057,13 @@ pub fn mk_mach_float(tm: ast::FloatTy) -> Ty {
 }
 
 #[inline]
-pub fn mk_char() -> Ty { mk_prim_t(&primitives::TY_CHAR) }
+pub fn mk_char<'tcx>() -> Ty<'tcx> { mk_prim_t(&primitives::TY_CHAR) }
 
-pub fn mk_str(cx: &ctxt) -> Ty {
+pub fn mk_str<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
     mk_t(cx, ty_str)
 }
 
-pub fn mk_str_slice(cx: &ctxt, r: Region, m: ast::Mutability) -> Ty {
+pub fn mk_str_slice<'tcx>(cx: &ctxt<'tcx>, r: Region, m: ast::Mutability) -> Ty<'tcx> {
     mk_rptr(cx, r,
             mt {
                 ty: mk_t(cx, ty_str),
@@ -2069,41 +2071,43 @@ pub fn mk_str_slice(cx: &ctxt, r: Region, m: ast::Mutability) -> Ty {
             })
 }
 
-pub fn mk_enum(cx: &ctxt, did: ast::DefId, substs: Substs) -> Ty {
+pub fn mk_enum<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId, substs: Substs<'tcx>) -> Ty<'tcx> {
     // take a copy of substs so that we own the vectors inside
     mk_t(cx, ty_enum(did, substs))
 }
 
-pub fn mk_uniq(cx: &ctxt, ty: Ty) -> Ty { mk_t(cx, ty_uniq(ty)) }
+pub fn mk_uniq<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { mk_t(cx, ty_uniq(ty)) }
 
-pub fn mk_ptr(cx: &ctxt, tm: mt) -> Ty { mk_t(cx, ty_ptr(tm)) }
+pub fn mk_ptr<'tcx>(cx: &ctxt<'tcx>, tm: mt<'tcx>) -> Ty<'tcx> { mk_t(cx, ty_ptr(tm)) }
 
-pub fn mk_rptr(cx: &ctxt, r: Region, tm: mt) -> Ty { mk_t(cx, ty_rptr(r, tm)) }
+pub fn mk_rptr<'tcx>(cx: &ctxt<'tcx>, r: Region, tm: mt<'tcx>) -> Ty<'tcx> {
+    mk_t(cx, ty_rptr(r, tm))
+}
 
-pub fn mk_mut_rptr(cx: &ctxt, r: Region, ty: Ty) -> Ty {
+pub fn mk_mut_rptr<'tcx>(cx: &ctxt<'tcx>, r: Region, ty: Ty<'tcx>) -> Ty<'tcx> {
     mk_rptr(cx, r, mt {ty: ty, mutbl: ast::MutMutable})
 }
-pub fn mk_imm_rptr(cx: &ctxt, r: Region, ty: Ty) -> Ty {
+pub fn mk_imm_rptr<'tcx>(cx: &ctxt<'tcx>, r: Region, ty: Ty<'tcx>) -> Ty<'tcx> {
     mk_rptr(cx, r, mt {ty: ty, mutbl: ast::MutImmutable})
 }
 
-pub fn mk_mut_ptr(cx: &ctxt, ty: Ty) -> Ty {
+pub fn mk_mut_ptr<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     mk_ptr(cx, mt {ty: ty, mutbl: ast::MutMutable})
 }
 
-pub fn mk_imm_ptr(cx: &ctxt, ty: Ty) -> Ty {
+pub fn mk_imm_ptr<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     mk_ptr(cx, mt {ty: ty, mutbl: ast::MutImmutable})
 }
 
-pub fn mk_nil_ptr(cx: &ctxt) -> Ty {
+pub fn mk_nil_ptr<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
     mk_ptr(cx, mt {ty: mk_nil(cx), mutbl: ast::MutImmutable})
 }
 
-pub fn mk_vec(cx: &ctxt, ty: Ty, sz: Option<uint>) -> Ty {
+pub fn mk_vec<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, sz: Option<uint>) -> Ty<'tcx> {
     mk_t(cx, ty_vec(ty, sz))
 }
 
-pub fn mk_slice(cx: &ctxt, r: Region, tm: mt) -> Ty {
+pub fn mk_slice<'tcx>(cx: &ctxt<'tcx>, r: Region, tm: mt<'tcx>) -> Ty<'tcx> {
     mk_rptr(cx, r,
             mt {
                 ty: mk_vec(cx, tm.ty, None),
@@ -2111,25 +2115,25 @@ pub fn mk_slice(cx: &ctxt, r: Region, tm: mt) -> Ty {
             })
 }
 
-pub fn mk_tup(cx: &ctxt, ts: Vec<Ty>) -> Ty {
+pub fn mk_tup<'tcx>(cx: &ctxt<'tcx>, ts: Vec<Ty<'tcx>>) -> Ty<'tcx> {
     mk_t(cx, ty_tup(ts))
 }
 
-pub fn mk_nil(cx: &ctxt) -> Ty {
+pub fn mk_nil<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
     mk_tup(cx, Vec::new())
 }
 
-pub fn mk_closure(cx: &ctxt, fty: ClosureTy) -> Ty {
+pub fn mk_closure<'tcx>(cx: &ctxt<'tcx>, fty: ClosureTy<'tcx>) -> Ty<'tcx> {
     mk_t(cx, ty_closure(box fty))
 }
 
-pub fn mk_bare_fn(cx: &ctxt, fty: BareFnTy) -> Ty {
+pub fn mk_bare_fn<'tcx>(cx: &ctxt<'tcx>, fty: BareFnTy<'tcx>) -> Ty<'tcx> {
     mk_t(cx, ty_bare_fn(fty))
 }
 
-pub fn mk_ctor_fn(cx: &ctxt,
-                  input_tys: &[Ty],
-                  output: Ty) -> Ty {
+pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
+                        input_tys: &[Ty<'tcx>],
+                        output: Ty<'tcx>) -> Ty<'tcx> {
     let input_args = input_tys.iter().map(|ty| *ty).collect();
     mk_bare_fn(cx,
                BareFnTy {
@@ -2144,10 +2148,10 @@ pub fn mk_ctor_fn(cx: &ctxt,
 }
 
 
-pub fn mk_trait(cx: &ctxt,
-                principal: ty::TraitRef,
-                bounds: ExistentialBounds)
-                -> Ty {
+pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
+                      principal: ty::TraitRef<'tcx>,
+                      bounds: ExistentialBounds)
+                      -> Ty<'tcx> {
     // take a copy of substs so that we own the vectors inside
     let inner = box TyTrait {
         principal: principal,
@@ -2156,43 +2160,54 @@ pub fn mk_trait(cx: &ctxt,
     mk_t(cx, ty_trait(inner))
 }
 
-pub fn mk_struct(cx: &ctxt, struct_id: ast::DefId, substs: Substs) -> Ty {
+pub fn mk_struct<'tcx>(cx: &ctxt<'tcx>, struct_id: ast::DefId,
+                       substs: Substs<'tcx>) -> Ty<'tcx> {
     // take a copy of substs so that we own the vectors inside
     mk_t(cx, ty_struct(struct_id, substs))
 }
 
-pub fn mk_unboxed_closure(cx: &ctxt, closure_id: ast::DefId, region: Region, substs: Substs)
-                          -> Ty {
+pub fn mk_unboxed_closure<'tcx>(cx: &ctxt<'tcx>, closure_id: ast::DefId,
+                                region: Region, substs: Substs<'tcx>)
+                                -> Ty<'tcx> {
     mk_t(cx, ty_unboxed_closure(closure_id, region, substs))
 }
 
-pub fn mk_var(cx: &ctxt, v: TyVid) -> Ty { mk_infer(cx, TyVar(v)) }
+pub fn mk_var<'tcx>(cx: &ctxt<'tcx>, v: TyVid) -> Ty<'tcx> {
+    mk_infer(cx, TyVar(v))
+}
 
-pub fn mk_int_var(cx: &ctxt, v: IntVid) -> Ty { mk_infer(cx, IntVar(v)) }
+pub fn mk_int_var<'tcx>(cx: &ctxt<'tcx>, v: IntVid) -> Ty<'tcx> {
+    mk_infer(cx, IntVar(v))
+}
 
-pub fn mk_float_var(cx: &ctxt, v: FloatVid) -> Ty { mk_infer(cx, FloatVar(v)) }
+pub fn mk_float_var<'tcx>(cx: &ctxt<'tcx>, v: FloatVid) -> Ty<'tcx> {
+    mk_infer(cx, FloatVar(v))
+}
 
-pub fn mk_infer(cx: &ctxt, it: InferTy) -> Ty { mk_t(cx, ty_infer(it)) }
+pub fn mk_infer<'tcx>(cx: &ctxt<'tcx>, it: InferTy) -> Ty<'tcx> {
+    mk_t(cx, ty_infer(it))
+}
 
-pub fn mk_param(cx: &ctxt, space: subst::ParamSpace, n: uint, k: DefId) -> Ty {
+pub fn mk_param<'tcx>(cx: &ctxt<'tcx>, space: subst::ParamSpace,
+                      n: uint, k: DefId) -> Ty<'tcx> {
     mk_t(cx, ty_param(ParamTy { space: space, idx: n, def_id: k }))
 }
 
-pub fn mk_self_type(cx: &ctxt, did: ast::DefId) -> Ty {
+pub fn mk_self_type<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId) -> Ty<'tcx> {
     mk_param(cx, subst::SelfSpace, 0, did)
 }
 
-pub fn mk_param_from_def(cx: &ctxt, def: &TypeParameterDef) -> Ty {
+pub fn mk_param_from_def<'tcx>(cx: &ctxt<'tcx>, def: &TypeParameterDef) -> Ty<'tcx> {
     mk_param(cx, def.space, def.index, def.def_id)
 }
 
-pub fn mk_open(cx: &ctxt, ty: Ty) -> Ty { mk_t(cx, ty_open(ty)) }
+pub fn mk_open<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { mk_t(cx, ty_open(ty)) }
 
-pub fn walk_ty(ty: Ty, f: |Ty|) {
+pub fn walk_ty<'tcx>(ty: Ty<'tcx>, f: |Ty<'tcx>|) {
     maybe_walk_ty(ty, |ty| { f(ty); true });
 }
 
-pub fn maybe_walk_ty(ty: Ty, f: |Ty| -> bool) {
+pub fn maybe_walk_ty<'tcx>(ty: Ty<'tcx>, f: |Ty<'tcx>| -> bool) {
     if !f(ty) {
         return;
     }
@@ -2232,7 +2247,9 @@ pub fn maybe_walk_ty(ty: Ty, f: |Ty| -> bool) {
 }
 
 // Folds types from the bottom up.
-pub fn fold_ty(cx: &ctxt, t0: Ty, fldop: |Ty| -> Ty) -> Ty {
+pub fn fold_ty<'tcx>(cx: &ctxt<'tcx>, t0: Ty<'tcx>,
+                     fldop: |Ty<'tcx>| -> Ty<'tcx>)
+                     -> Ty<'tcx> {
     let mut f = ty_fold::BottomUpFolder {tcx: cx, fldop: fldop};
     f.fold_ty(t0)
 }
@@ -2253,7 +2270,7 @@ pub fn for_def(def: &TypeParameterDef) -> ParamTy {
         ParamTy::new(def.space, def.index, def.def_id)
     }
 
-    pub fn to_ty(self, tcx: &ty::ctxt) -> Ty {
+    pub fn to_ty<'tcx>(self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
         ty::mk_param(tcx, self.space, self.idx, self.def_id)
     }
 
@@ -2262,8 +2279,8 @@ pub fn is_self(&self) -> bool {
     }
 }
 
-impl ItemSubsts {
-    pub fn empty() -> ItemSubsts {
+impl<'tcx> ItemSubsts<'tcx> {
+    pub fn empty() -> ItemSubsts<'tcx> {
         ItemSubsts { substs: Substs::empty() }
     }
 
@@ -2272,8 +2289,8 @@ pub fn is_noop(&self) -> bool {
     }
 }
 
-impl ParamBounds {
-    pub fn empty() -> ParamBounds {
+impl<'tcx> ParamBounds<'tcx> {
+    pub fn empty() -> ParamBounds<'tcx> {
         ParamBounds {
             builtin_bounds: empty_builtin_bounds(),
             trait_bounds: Vec::new(),
@@ -2356,7 +2373,7 @@ pub fn type_is_simd(cx: &ctxt, ty: Ty) -> bool {
     }
 }
 
-pub fn sequence_element_type(cx: &ctxt, ty: Ty) -> Ty {
+pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     match get(ty).sty {
         ty_vec(ty, _) => ty,
         ty_str => mk_mach_uint(ast::TyU8),
@@ -2366,7 +2383,7 @@ pub fn sequence_element_type(cx: &ctxt, ty: Ty) -> Ty {
     }
 }
 
-pub fn simd_type(cx: &ctxt, ty: Ty) -> Ty {
+pub fn simd_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     match get(ty).sty {
         ty_struct(did, ref substs) => {
             let fields = lookup_struct_fields(cx, did);
@@ -2410,7 +2427,7 @@ pub fn type_is_unique(ty: Ty) -> bool {
     }
 }
 
-pub fn type_is_fat_ptr(cx: &ctxt, ty: Ty) -> bool {
+pub fn type_is_fat_ptr<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     match get(ty).sty {
         ty_ptr(mt{ty, ..}) | ty_rptr(_, mt{ty, ..})
         | ty_uniq(ty) if !type_is_sized(cx, ty) => true,
@@ -2441,7 +2458,7 @@ pub fn type_is_floating_point(ty: Ty) -> bool {
     }
 }
 
-pub fn type_needs_drop(cx: &ctxt, ty: Ty) -> bool {
+pub fn type_needs_drop<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     type_contents(cx, ty).needs_drop(cx)
 }
 
@@ -2449,12 +2466,13 @@ pub fn type_needs_drop(cx: &ctxt, ty: Ty) -> bool {
 // task can free them all at once later. Currently only things
 // that only contain scalars and shared boxes can avoid unwind
 // cleanups.
-pub fn type_needs_unwind_cleanup(cx: &ctxt, ty: Ty) -> bool {
+pub fn type_needs_unwind_cleanup<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     return memoized(&cx.needs_unwind_cleanup_cache, ty, |ty| {
         type_needs_unwind_cleanup_(cx, ty, &mut FnvHashSet::new())
     });
 
-    fn type_needs_unwind_cleanup_(cx: &ctxt, ty: Ty, tycache: &mut FnvHashSet<Ty>) -> bool {
+    fn type_needs_unwind_cleanup_<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>,
+                                        tycache: &mut FnvHashSet<Ty<'tcx>>) -> bool {
         // Prevent infinite recursion
         if !tycache.insert(ty) {
             return false;
@@ -2670,18 +2688,18 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-pub fn type_interior_is_unsafe(cx: &ctxt, ty: Ty) -> bool {
+pub fn type_interior_is_unsafe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     type_contents(cx, ty).interior_unsafe()
 }
 
-pub fn type_contents(cx: &ctxt, ty: Ty) -> TypeContents {
+pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
     return memoized(&cx.tc_cache, ty, |ty| {
         tc_ty(cx, ty, &mut FnvHashMap::new())
     });
 
-    fn tc_ty(cx: &ctxt,
-             ty: Ty,
-             cache: &mut FnvHashMap<Ty, TypeContents>) -> TypeContents
+    fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
+                   ty: Ty<'tcx>,
+                   cache: &mut FnvHashMap<Ty<'tcx>, TypeContents>) -> TypeContents
     {
         // Subtle: Note that we are *not* using cx.tc_cache here but rather a
         // private cache for this walk.  This is needed in the case of cyclic
@@ -2886,9 +2904,9 @@ fn tc_ty(cx: &ctxt,
         result
     }
 
-    fn tc_mt(cx: &ctxt,
-             mt: mt,
-             cache: &mut FnvHashMap<Ty, TypeContents>) -> TypeContents
+    fn tc_mt<'tcx>(cx: &ctxt<'tcx>,
+                   mt: mt<'tcx>,
+                   cache: &mut FnvHashMap<Ty<'tcx>, TypeContents>) -> TypeContents
     {
         let mc = TC::ReachesMutable.when(mt.mutbl == MutMutable);
         mc | tc_ty(cx, mt.ty, cache)
@@ -2956,10 +2974,10 @@ fn object_contents(cx: &ctxt,
         kind_bounds_to_contents(cx, bounds.builtin_bounds, &[])
     }
 
-    fn kind_bounds_to_contents(cx: &ctxt,
-                               bounds: BuiltinBounds,
-                               traits: &[Rc<TraitRef>])
-                               -> TypeContents {
+    fn kind_bounds_to_contents<'tcx>(cx: &ctxt<'tcx>,
+                                     bounds: BuiltinBounds,
+                                     traits: &[Rc<TraitRef<'tcx>>])
+                                     -> TypeContents {
         let _i = indenter();
         let mut tc = TC::All;
         each_inherited_builtin_bound(cx, bounds, traits, |bound| {
@@ -2973,10 +2991,10 @@ fn kind_bounds_to_contents(cx: &ctxt,
 
         // Iterates over all builtin bounds on the type parameter def, including
         // those inherited from traits with builtin-kind-supertraits.
-        fn each_inherited_builtin_bound(cx: &ctxt,
-                                        bounds: BuiltinBounds,
-                                        traits: &[Rc<TraitRef>],
-                                        f: |BuiltinBound|) {
+        fn each_inherited_builtin_bound<'tcx>(cx: &ctxt<'tcx>,
+                                              bounds: BuiltinBounds,
+                                              traits: &[Rc<TraitRef<'tcx>>],
+                                              f: |BuiltinBound|) {
             for bound in bounds.iter() {
                 f(bound);
             }
@@ -2992,18 +3010,18 @@ fn each_inherited_builtin_bound(cx: &ctxt,
     }
 }
 
-pub fn type_moves_by_default(cx: &ctxt, ty: Ty) -> bool {
+pub fn type_moves_by_default<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     type_contents(cx, ty).moves_by_default(cx)
 }
 
-pub fn is_ffi_safe(cx: &ctxt, ty: Ty) -> bool {
+pub fn is_ffi_safe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     !type_contents(cx, ty).intersects(TC::ReachesFfiUnsafe)
 }
 
 // True if instantiating an instance of `r_ty` requires an instance of `r_ty`.
-pub fn is_instantiable(cx: &ctxt, r_ty: Ty) -> bool {
-    fn type_requires(cx: &ctxt, seen: &mut Vec<DefId>,
-                     r_ty: Ty, ty: Ty) -> bool {
+pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
+    fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
+                           r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
         debug!("type_requires({}, {})?",
                ::util::ppaux::ty_to_string(cx, r_ty),
                ::util::ppaux::ty_to_string(cx, ty));
@@ -3020,8 +3038,8 @@ fn type_requires(cx: &ctxt, seen: &mut Vec<DefId>,
         return r;
     }
 
-    fn subtypes_require(cx: &ctxt, seen: &mut Vec<DefId>,
-                        r_ty: Ty, ty: Ty) -> bool {
+    fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
+                              r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
         debug!("subtypes_require({}, {})?",
                ::util::ppaux::ty_to_string(cx, r_ty),
                ::util::ppaux::ty_to_string(cx, ty));
@@ -3130,17 +3148,21 @@ pub enum Representability {
 
 /// Check whether a type is representable. This means it cannot contain unboxed
 /// structural recursion. This check is needed for structs and enums.
-pub fn is_type_representable(cx: &ctxt, sp: Span, ty: Ty) -> Representability {
+pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
+                                   -> Representability {
 
     // Iterate until something non-representable is found
-    fn find_nonrepresentable<It: Iterator<Ty>>(cx: &ctxt, sp: Span, seen: &mut Vec<Ty>,
-                                              mut iter: It) -> Representability {
+    fn find_nonrepresentable<'tcx, It: Iterator<Ty<'tcx>>>(cx: &ctxt<'tcx>, sp: Span,
+                                                           seen: &mut Vec<Ty<'tcx>>,
+                                                           mut iter: It)
+                                                           -> Representability {
         iter.fold(Representable,
                   |r, ty| cmp::max(r, is_type_structurally_recursive(cx, sp, seen, ty)))
     }
 
-    fn are_inner_types_recursive(cx: &ctxt, sp: Span,
-                                 seen: &mut Vec<Ty>, ty: Ty) -> Representability {
+    fn are_inner_types_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
+                                       seen: &mut Vec<Ty<'tcx>>, ty: Ty<'tcx>)
+                                       -> Representability {
         match get(ty).sty {
             ty_tup(ref ts) => {
                 find_nonrepresentable(cx, sp, seen, ts.iter().map(|ty| *ty))
@@ -3179,7 +3201,7 @@ fn same_struct_or_enum_def_id(ty: Ty, did: DefId) -> bool {
         }
     }
 
-    fn same_type(a: Ty, b: Ty) -> bool {
+    fn same_type<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
         match (&get(a).sty, &get(b).sty) {
             (&ty_struct(did_a, ref substs_a), &ty_struct(did_b, ref substs_b)) |
             (&ty_enum(did_a, ref substs_a), &ty_enum(did_b, ref substs_b)) => {
@@ -3202,8 +3224,9 @@ fn same_type(a: Ty, b: Ty) -> bool {
 
     // Does the type `ty` directly (without indirection through a pointer)
     // contain any types on stack `seen`?
-    fn is_type_structurally_recursive(cx: &ctxt, sp: Span, seen: &mut Vec<Ty>,
-                                      ty: Ty) -> Representability {
+    fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
+                                            seen: &mut Vec<Ty<'tcx>>,
+                                            ty: Ty<'tcx>) -> Representability {
         debug!("is_type_structurally_recursive: {}",
                ::util::ppaux::ty_to_string(cx, ty));
 
@@ -3283,7 +3306,7 @@ pub fn type_is_trait(ty: Ty) -> bool {
     type_trait_info(ty).is_some()
 }
 
-pub fn type_trait_info(ty: Ty) -> Option<&'static TyTrait> {
+pub fn type_trait_info<'tcx>(ty: Ty<'tcx>) -> Option<&'tcx TyTrait<'tcx>> {
     match get(ty).sty {
         ty_uniq(ty) | ty_rptr(_, mt { ty, ..}) | ty_ptr(mt { ty, ..}) => match get(ty).sty {
             ty_trait(ref t) => Some(&**t),
@@ -3357,11 +3380,11 @@ pub fn type_is_machine(ty: Ty) -> bool {
 }
 
 // Is the type's representation size known at compile time?
-pub fn type_is_sized(cx: &ctxt, ty: Ty) -> bool {
+pub fn type_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     type_contents(cx, ty).is_sized(cx)
 }
 
-pub fn lltype_is_sized(cx: &ctxt, ty: Ty) -> bool {
+pub fn lltype_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     match get(ty).sty {
         ty_open(_) => true,
         _ => type_contents(cx, ty).is_sized(cx)
@@ -3371,7 +3394,7 @@ pub fn lltype_is_sized(cx: &ctxt, ty: Ty) -> bool {
 // Return the smallest part of ty which is unsized. Fails if ty is sized.
 // 'Smallest' here means component of the static representation of the type; not
 // the size of an object at runtime.
-pub fn unsized_part_of_type(cx: &ctxt, ty: Ty) -> Ty {
+pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     match get(ty).sty {
         ty_str | ty_trait(..) | ty_vec(..) => ty,
         ty_struct(def_id, ref substs) => {
@@ -3410,7 +3433,7 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: Ty) -> bool {
 //
 // The parameter `explicit` indicates if this is an *explicit* dereference.
 // Some types---notably unsafe ptrs---can only be dereferenced explicitly.
-pub fn deref(ty: Ty, explicit: bool) -> Option<mt> {
+pub fn deref<'tcx>(ty: Ty<'tcx>, explicit: bool) -> Option<mt<'tcx>> {
     match get(ty).sty {
         ty_uniq(ty) => {
             Some(mt {
@@ -3424,7 +3447,7 @@ pub fn deref(ty: Ty, explicit: bool) -> Option<mt> {
     }
 }
 
-pub fn deref_or_dont(ty: Ty) -> Ty {
+pub fn deref_or_dont<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
     match get(ty).sty {
         ty_uniq(ty) => ty,
         ty_rptr(_, mt) | ty_ptr(mt) => mt.ty,
@@ -3432,7 +3455,7 @@ pub fn deref_or_dont(ty: Ty) -> Ty {
     }
 }
 
-pub fn close_type(cx: &ctxt, ty: Ty) -> Ty {
+pub fn close_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     match get(ty).sty {
         ty_open(ty) => mk_rptr(cx, ReStatic, mt {ty: ty, mutbl:ast::MutImmutable}),
         _ => cx.sess.bug(format!("Trying to close a non-open type {}",
@@ -3440,7 +3463,7 @@ pub fn close_type(cx: &ctxt, ty: Ty) -> Ty {
     }
 }
 
-pub fn type_content(ty: Ty) -> Ty {
+pub fn type_content<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
     match get(ty).sty {
         ty_uniq(ty) => ty,
         ty_rptr(_, mt) |ty_ptr(mt) => mt.ty,
@@ -3449,7 +3472,7 @@ pub fn type_content(ty: Ty) -> Ty {
 }
 
 // Extract the unsized type in an open type (or just return ty if it is not open).
-pub fn unopen_type(ty: Ty) -> Ty {
+pub fn unopen_type<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
     match get(ty).sty {
         ty_open(ty) => ty,
         _ => ty
@@ -3457,7 +3480,7 @@ pub fn unopen_type(ty: Ty) -> Ty {
 }
 
 // Returns the type of ty[i]
-pub fn index(ty: Ty) -> Option<Ty> {
+pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
     match get(ty).sty {
         ty_vec(ty, _) => Some(ty),
         _ => None
@@ -3467,7 +3490,7 @@ pub fn index(ty: Ty) -> Option<Ty> {
 // Returns the type of elements contained within an 'array-like' type.
 // This is exactly the same as the above, except it supports strings,
 // which can't actually be indexed.
-pub fn array_element_ty(ty: Ty) -> Option<Ty> {
+pub fn array_element_ty<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
     match get(ty).sty {
         ty_vec(ty, _) => Some(ty),
         ty_str => Some(mk_u8()),
@@ -3475,7 +3498,8 @@ pub fn array_element_ty(ty: Ty) -> Option<Ty> {
     }
 }
 
-pub fn node_id_to_trait_ref(cx: &ctxt, id: ast::NodeId) -> Rc<ty::TraitRef> {
+pub fn node_id_to_trait_ref<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId)
+                                  -> Rc<ty::TraitRef<'tcx>> {
     match cx.trait_refs.borrow().get(&id) {
         Some(ty) => ty.clone(),
         None => cx.sess.bug(
@@ -3484,11 +3508,11 @@ pub fn node_id_to_trait_ref(cx: &ctxt, id: ast::NodeId) -> Rc<ty::TraitRef> {
     }
 }
 
-pub fn try_node_id_to_type(cx: &ctxt, id: ast::NodeId) -> Option<Ty> {
+pub fn try_node_id_to_type<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> Option<Ty<'tcx>> {
     cx.node_types.borrow().get(&id).cloned()
 }
 
-pub fn node_id_to_type(cx: &ctxt, id: ast::NodeId) -> Ty {
+pub fn node_id_to_type<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> Ty<'tcx> {
     match try_node_id_to_type(cx, id) {
        Some(ty) => ty,
        None => cx.sess.bug(
@@ -3497,14 +3521,14 @@ pub fn node_id_to_type(cx: &ctxt, id: ast::NodeId) -> Ty {
     }
 }
 
-pub fn node_id_to_type_opt(cx: &ctxt, id: ast::NodeId) -> Option<Ty> {
+pub fn node_id_to_type_opt<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> Option<Ty<'tcx>> {
     match cx.node_types.borrow().get(&id) {
        Some(&ty) => Some(ty),
        None => None
     }
 }
 
-pub fn node_id_item_substs(cx: &ctxt, id: ast::NodeId) -> ItemSubsts {
+pub fn node_id_item_substs<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> ItemSubsts<'tcx> {
     match cx.item_substs.borrow().get(&id) {
       None => ItemSubsts::empty(),
       Some(ts) => ts.clone(),
@@ -3521,7 +3545,7 @@ pub fn fn_is_variadic(fty: Ty) -> bool {
     }
 }
 
-pub fn ty_fn_sig(fty: Ty) -> FnSig {
+pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> FnSig<'tcx> {
     match get(fty).sty {
         ty_bare_fn(ref f) => f.sig.clone(),
         ty_closure(ref f) => f.sig.clone(),
@@ -3541,7 +3565,7 @@ pub fn ty_fn_abi(fty: Ty) -> abi::Abi {
 }
 
 // Type accessors for substructures of types
-pub fn ty_fn_args(fty: Ty) -> Vec<Ty> {
+pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> Vec<Ty<'tcx>> {
     match get(fty).sty {
         ty_bare_fn(ref f) => f.sig.inputs.clone(),
         ty_closure(ref f) => f.sig.inputs.clone(),
@@ -3565,7 +3589,7 @@ pub fn ty_closure_store(fty: Ty) -> TraitStore {
     }
 }
 
-pub fn ty_fn_ret(fty: Ty) -> FnOutput {
+pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> FnOutput<'tcx> {
     match get(fty).sty {
         ty_bare_fn(ref f) => f.sig.output,
         ty_closure(ref f) => f.sig.output,
@@ -3607,7 +3631,7 @@ pub fn free_region_from_def(free_id: ast::NodeId, def: &RegionParameterDef)
 
 // Returns the type of a pattern as a monotype. Like @expr_ty, this function
 // doesn't provide type parameter substitutions.
-pub fn pat_ty(cx: &ctxt, pat: &ast::Pat) -> Ty {
+pub fn pat_ty<'tcx>(cx: &ctxt<'tcx>, pat: &ast::Pat) -> Ty<'tcx> {
     return node_id_to_type(cx, pat.id);
 }
 
@@ -3622,15 +3646,15 @@ pub fn pat_ty(cx: &ctxt, pat: &ast::Pat) -> Ty {
 // NB (2): This type doesn't provide type parameter substitutions; e.g. if you
 // ask for the type of "id" in "id(3)", it will return "fn(&int) -> int"
 // instead of "fn(ty) -> T with T = int".
-pub fn expr_ty(cx: &ctxt, expr: &ast::Expr) -> Ty {
+pub fn expr_ty<'tcx>(cx: &ctxt<'tcx>, expr: &ast::Expr) -> Ty<'tcx> {
     return node_id_to_type(cx, expr.id);
 }
 
-pub fn expr_ty_opt(cx: &ctxt, expr: &ast::Expr) -> Option<Ty> {
+pub fn expr_ty_opt<'tcx>(cx: &ctxt<'tcx>, expr: &ast::Expr) -> Option<Ty<'tcx>> {
     return node_id_to_type_opt(cx, expr.id);
 }
 
-pub fn expr_ty_adjusted(cx: &ctxt, expr: &ast::Expr) -> Ty {
+pub fn expr_ty_adjusted<'tcx>(cx: &ctxt<'tcx>, expr: &ast::Expr) -> Ty<'tcx> {
     /*!
      *
      * Returns the type of `expr`, considering any `AutoAdjustment`
@@ -3689,13 +3713,13 @@ pub fn local_var_name_str(cx: &ctxt, id: NodeId) -> InternedString {
     }
 }
 
-pub fn adjust_ty(cx: &ctxt,
-                 span: Span,
-                 expr_id: ast::NodeId,
-                 unadjusted_ty: Ty,
-                 adjustment: Option<&AutoAdjustment>,
-                 method_type: |typeck::MethodCall| -> Option<Ty>)
-                 -> Ty {
+pub fn adjust_ty<'tcx>(cx: &ctxt<'tcx>,
+                       span: Span,
+                       expr_id: ast::NodeId,
+                       unadjusted_ty: Ty<'tcx>,
+                       adjustment: Option<&AutoAdjustment<'tcx>>,
+                       method_type: |typeck::MethodCall| -> Option<Ty<'tcx>>)
+                       -> Ty<'tcx> {
     /*! See `expr_ty_adjusted` */
 
     match get(unadjusted_ty).sty {
@@ -3769,11 +3793,11 @@ pub fn adjust_ty(cx: &ctxt,
     };
 }
 
-pub fn adjust_ty_for_autoref(cx: &ctxt,
-                             span: Span,
-                             ty: Ty,
-                             autoref: Option<&AutoRef>)
-                             -> Ty
+pub fn adjust_ty_for_autoref<'tcx>(cx: &ctxt<'tcx>,
+                                   span: Span,
+                                   ty: Ty<'tcx>,
+                                   autoref: Option<&AutoRef<'tcx>>)
+                                   -> Ty<'tcx>
 {
     match autoref {
         None => ty,
@@ -3805,11 +3829,11 @@ pub fn adjust_ty_for_autoref(cx: &ctxt,
 
 // Take a sized type and a sizing adjustment and produce an unsized version of
 // the type.
-pub fn unsize_ty(cx: &ctxt,
-                 ty: Ty,
-                 kind: &UnsizeKind,
-                 span: Span)
-                 -> Ty {
+pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
+                       ty: Ty<'tcx>,
+                       kind: &UnsizeKind<'tcx>,
+                       span: Span)
+                       -> Ty<'tcx> {
     match kind {
         &UnsizeLength(len) => match get(ty).sty {
             ty_vec(ty, Some(n)) => {
@@ -4070,7 +4094,7 @@ pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem])
     trait_items.iter().position(|m| m.name() == id)
 }
 
-pub fn ty_sort_string(cx: &ctxt, ty: Ty) -> String {
+pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String {
     match get(ty).sty {
         ty_bool | ty_char | ty_int(_) |
         ty_uint(_) | ty_float(_) | ty_str => {
@@ -4111,7 +4135,7 @@ pub fn ty_sort_string(cx: &ctxt, ty: Ty) -> String {
     }
 }
 
-pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
+pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
     /*!
      *
      * Explains the source of a type err in a short,
@@ -4293,7 +4317,8 @@ pub fn provided_source(cx: &ctxt, id: ast::DefId) -> Option<ast::DefId> {
     cx.provided_method_sources.borrow().get(&id).map(|x| *x)
 }
 
-pub fn provided_trait_methods(cx: &ctxt, id: ast::DefId) -> Vec<Rc<Method>> {
+pub fn provided_trait_methods<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
+                                    -> Vec<Rc<Method<'tcx>>> {
     if is_local(id) {
         match cx.map.find(id.node) {
             Some(ast_map::NodeItem(item)) => {
@@ -4362,14 +4387,14 @@ fn lookup_locally_or_in_crate_store<V:Clone>(
     v
 }
 
-pub fn trait_item(cx: &ctxt, trait_did: ast::DefId, idx: uint)
-                  -> ImplOrTraitItem {
+pub fn trait_item<'tcx>(cx: &ctxt<'tcx>, trait_did: ast::DefId, idx: uint)
+                        -> ImplOrTraitItem<'tcx> {
     let method_def_id = (*ty::trait_item_def_ids(cx, trait_did))[idx].def_id();
     impl_or_trait_item(cx, method_def_id)
 }
 
-pub fn trait_items(cx: &ctxt, trait_did: ast::DefId)
-                   -> Rc<Vec<ImplOrTraitItem>> {
+pub fn trait_items<'tcx>(cx: &ctxt<'tcx>, trait_did: ast::DefId)
+                         -> Rc<Vec<ImplOrTraitItem<'tcx>>> {
     let mut trait_items = cx.trait_items_cache.borrow_mut();
     match trait_items.get(&trait_did).cloned() {
         Some(trait_items) => trait_items,
@@ -4385,7 +4410,8 @@ pub fn trait_items(cx: &ctxt, trait_did: ast::DefId)
     }
 }
 
-pub fn impl_or_trait_item(cx: &ctxt, id: ast::DefId) -> ImplOrTraitItem {
+pub fn impl_or_trait_item<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
+                                -> ImplOrTraitItem<'tcx> {
     lookup_locally_or_in_crate_store("impl_or_trait_items",
                                      id,
                                      &mut *cx.impl_or_trait_items
@@ -4457,7 +4483,8 @@ pub fn trait_item_def_ids(cx: &ctxt, id: ast::DefId)
     })
 }
 
-pub fn impl_trait_ref(cx: &ctxt, id: ast::DefId) -> Option<Rc<TraitRef>> {
+pub fn impl_trait_ref<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
+                            -> Option<Rc<TraitRef<'tcx>>> {
     memoized(&cx.impl_trait_cache, id, |id: ast::DefId| {
         if id.krate == ast::LOCAL_CRATE {
             debug!("(impl_trait_ref) searching for trait impl {}", id);
@@ -4522,24 +4549,24 @@ pub fn ty_to_def_id(ty: Ty) -> Option<ast::DefId> {
 
 // Enum information
 #[deriving(Clone)]
-pub struct VariantInfo {
-    pub args: Vec<Ty>,
+pub struct VariantInfo<'tcx> {
+    pub args: Vec<Ty<'tcx>>,
     pub arg_names: Option<Vec<ast::Ident>>,
-    pub ctor_ty: Option<Ty>,
+    pub ctor_ty: Option<Ty<'tcx>>,
     pub name: ast::Name,
     pub id: ast::DefId,
     pub disr_val: Disr,
     pub vis: Visibility
 }
 
-impl VariantInfo {
+impl<'tcx> VariantInfo<'tcx> {
 
     /// Creates a new VariantInfo from the corresponding ast representation.
     ///
     /// Does not do any caching of the value in the type context.
-    pub fn from_ast_variant(cx: &ctxt,
+    pub fn from_ast_variant(cx: &ctxt<'tcx>,
                             ast_variant: &ast::Variant,
-                            discriminant: Disr) -> VariantInfo {
+                            discriminant: Disr) -> VariantInfo<'tcx> {
         let ctor_ty = node_id_to_type(cx, ast_variant.node.id);
 
         match ast_variant.node.kind {
@@ -4590,10 +4617,10 @@ pub fn from_ast_variant(cx: &ctxt,
     }
 }
 
-pub fn substd_enum_variants(cx: &ctxt,
-                            id: ast::DefId,
-                            substs: &Substs)
-                         -> Vec<Rc<VariantInfo>> {
+pub fn substd_enum_variants<'tcx>(cx: &ctxt<'tcx>,
+                                  id: ast::DefId,
+                                  substs: &Substs<'tcx>)
+                                  -> Vec<Rc<VariantInfo<'tcx>>> {
     enum_variants(cx, id).iter().map(|variant_info| {
         let substd_args = variant_info.args.iter()
             .map(|aty| aty.subst(cx, substs)).collect::<Vec<_>>();
@@ -4669,7 +4696,8 @@ pub fn type_is_empty(cx: &ctxt, ty: Ty) -> bool {
      }
 }
 
-pub fn enum_variants(cx: &ctxt, id: ast::DefId) -> Rc<Vec<Rc<VariantInfo>>> {
+pub fn enum_variants<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
+                           -> Rc<Vec<Rc<VariantInfo<'tcx>>>> {
     memoized(&cx.enum_var_cache, id, |id: ast::DefId| {
         if ast::LOCAL_CRATE != id.krate {
             Rc::new(csearch::get_enum_variants(cx, id))
@@ -4732,10 +4760,10 @@ pub fn enum_variants(cx: &ctxt, id: ast::DefId) -> Rc<Vec<Rc<VariantInfo>>> {
 }
 
 // Returns information about the enum variant with the given ID:
-pub fn enum_variant_with_id(cx: &ctxt,
-                            enum_id: ast::DefId,
-                            variant_id: ast::DefId)
-                         -> Rc<VariantInfo> {
+pub fn enum_variant_with_id<'tcx>(cx: &ctxt<'tcx>,
+                                  enum_id: ast::DefId,
+                                  variant_id: ast::DefId)
+                                  -> Rc<VariantInfo<'tcx>> {
     enum_variants(cx, enum_id).iter()
                               .find(|variant| variant.id == variant_id)
                               .expect("enum_variant_with_id(): no variant exists with that ID")
@@ -4745,16 +4773,17 @@ pub fn enum_variant_with_id(cx: &ctxt,
 
 // If the given item is in an external crate, looks up its type and adds it to
 // the type cache. Returns the type parameters and type.
-pub fn lookup_item_type(cx: &ctxt,
-                        did: ast::DefId)
-                     -> Polytype {
+pub fn lookup_item_type<'tcx>(cx: &ctxt<'tcx>,
+                              did: ast::DefId)
+                              -> Polytype<'tcx> {
     lookup_locally_or_in_crate_store(
         "tcache", did, &mut *cx.tcache.borrow_mut(),
         || csearch::get_type(cx, did))
 }
 
 /// Given the did of a trait, returns its canonical trait ref.
-pub fn lookup_trait_def(cx: &ctxt, did: DefId) -> Rc<ty::TraitDef> {
+pub fn lookup_trait_def<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId)
+                              -> Rc<ty::TraitDef<'tcx>> {
     memoized(&cx.trait_defs, did, |did: DefId| {
         assert!(did.krate != ast::LOCAL_CRATE);
         Rc::new(csearch::get_trait_def(cx, did))
@@ -4763,9 +4792,9 @@ pub fn lookup_trait_def(cx: &ctxt, did: DefId) -> Rc<ty::TraitDef> {
 
 /// Given a reference to a trait, returns the bounds declared on the
 /// trait, with appropriate substitutions applied.
-pub fn bounds_for_trait_ref(tcx: &ctxt,
-                            trait_ref: &TraitRef)
-                            -> ty::ParamBounds
+pub fn bounds_for_trait_ref<'tcx>(tcx: &ctxt<'tcx>,
+                                  trait_ref: &TraitRef<'tcx>)
+                                  -> ty::ParamBounds<'tcx>
 {
     let trait_def = lookup_trait_def(tcx, trait_ref.def_id);
 
@@ -4926,11 +4955,11 @@ pub fn lookup_repr_hints(tcx: &ctxt, did: DefId) -> Rc<Vec<attr::ReprAttr>> {
 
 // Look up a field ID, whether or not it's local
 // Takes a list of type substs in case the struct is generic
-pub fn lookup_field_type(tcx: &ctxt,
-                         struct_id: DefId,
-                         id: DefId,
-                         substs: &Substs)
-                      -> Ty {
+pub fn lookup_field_type<'tcx>(tcx: &ctxt<'tcx>,
+                               struct_id: DefId,
+                               id: DefId,
+                               substs: &Substs<'tcx>)
+                               -> Ty<'tcx> {
     let ty = if id.krate == ast::LOCAL_CRATE {
         node_id_to_type(tcx, id.node)
     } else {
@@ -4969,8 +4998,8 @@ pub fn is_tuple_struct(cx: &ctxt, did: ast::DefId) -> bool {
 
 // Returns a list of fields corresponding to the struct's items. trans uses
 // this. Takes a list of substs with which to instantiate field types.
-pub fn struct_fields(cx: &ctxt, did: ast::DefId, substs: &Substs)
-                     -> Vec<field> {
+pub fn struct_fields<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId, substs: &Substs<'tcx>)
+                           -> Vec<field<'tcx>> {
     lookup_struct_fields(cx, did).iter().map(|f| {
        field {
             name: f.name,
@@ -4984,7 +5013,7 @@ pub fn struct_fields(cx: &ctxt, did: ast::DefId, substs: &Substs)
 
 // Returns a list of fields corresponding to the tuple's items. trans uses
 // this.
-pub fn tup_fields(v: &[Ty]) -> Vec<field> {
+pub fn tup_fields<'tcx>(v: &[Ty<'tcx>]) -> Vec<field<'tcx>> {
     v.iter().enumerate().map(|(i, &f)| {
        field {
             name: token::intern(i.to_string().as_slice()),
@@ -4996,15 +5025,15 @@ pub fn tup_fields(v: &[Ty]) -> Vec<field> {
     }).collect()
 }
 
-pub struct UnboxedClosureUpvar {
+pub struct UnboxedClosureUpvar<'tcx> {
     pub def: def::Def,
     pub span: Span,
-    pub ty: Ty,
+    pub ty: Ty<'tcx>,
 }
 
 // Returns a list of `UnboxedClosureUpvar`s for each upvar.
-pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Substs)
-                              -> Vec<UnboxedClosureUpvar> {
+pub fn unboxed_closure_upvars<'tcx>(tcx: &ctxt<'tcx>, closure_id: ast::DefId, substs: &Substs<'tcx>)
+                                    -> Vec<UnboxedClosureUpvar<'tcx>> {
     // Presently an unboxed closure type cannot "escape" out of a
     // function, so we will only encounter ones that originated in the
     // local crate or were inlined into it along with some function.
@@ -5039,7 +5068,7 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Subst
     }
 }
 
-pub fn is_binopable(cx: &ctxt, ty: Ty, op: ast::BinOp) -> bool {
+pub fn is_binopable<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, op: ast::BinOp) -> bool {
     #![allow(non_upper_case_globals)]
     static tycat_other: int = 0;
     static tycat_bool: int = 1;
@@ -5081,7 +5110,7 @@ fn opcat(op: ast::BinOp) -> int {
         }
     }
 
-    fn tycat(cx: &ctxt, ty: Ty) -> int {
+    fn tycat<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> int {
         if type_is_simd(cx, ty) {
             return tycat(cx, simd_type(cx, ty))
         }
@@ -5112,7 +5141,7 @@ fn tycat(cx: &ctxt, ty: Ty) -> int {
 }
 
 /// Returns an equivalent type with all the typedefs and self regions removed.
-pub fn normalize_ty(cx: &ctxt, ty: Ty) -> Ty {
+pub fn normalize_ty<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     let u = TypeNormalizer(cx).fold_ty(ty);
     return u;
 
@@ -5121,7 +5150,7 @@ pub fn normalize_ty(cx: &ctxt, ty: Ty) -> Ty {
     impl<'a, 'tcx> TypeFolder<'tcx> for TypeNormalizer<'a, 'tcx> {
         fn tcx(&self) -> &ctxt<'tcx> { let TypeNormalizer(c) = *self; c }
 
-        fn fold_ty(&mut self, ty: Ty) -> Ty {
+        fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
             match self.tcx().normalized_cache.borrow().get(&ty).cloned() {
                 None => {}
                 Some(u) => return u
@@ -5137,15 +5166,15 @@ fn fold_region(&mut self, _: ty::Region) -> ty::Region {
         }
 
         fn fold_substs(&mut self,
-                       substs: &subst::Substs)
-                       -> subst::Substs {
+                       substs: &subst::Substs<'tcx>)
+                       -> subst::Substs<'tcx> {
             subst::Substs { regions: subst::ErasedRegions,
                             types: substs.types.fold_with(self) }
         }
 
         fn fold_fn_sig(&mut self,
-                       sig: &ty::FnSig)
-                       -> ty::FnSig {
+                       sig: &ty::FnSig<'tcx>)
+                       -> ty::FnSig<'tcx> {
             // The binder-id is only relevant to bound regions, which
             // are erased at trans time.
             ty::FnSig {
@@ -5203,10 +5232,10 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
 // Here, the supertraits are the transitive closure of the supertrait
 // relation on the supertraits from each bounded trait's constraint
 // list.
-pub fn each_bound_trait_and_supertraits(tcx: &ctxt,
-                                        bounds: &[Rc<TraitRef>],
-                                        f: |Rc<TraitRef>| -> bool)
-                                        -> bool
+pub fn each_bound_trait_and_supertraits<'tcx>(tcx: &ctxt<'tcx>,
+                                              bounds: &[Rc<TraitRef<'tcx>>],
+                                              f: |Rc<TraitRef<'tcx>>| -> bool)
+                                              -> bool
 {
     for bound_trait_ref in traits::transitive_bounds(tcx, bounds) {
         if !f(bound_trait_ref) {
@@ -5216,11 +5245,11 @@ pub fn each_bound_trait_and_supertraits(tcx: &ctxt,
     return true;
 }
 
-pub fn required_region_bounds(tcx: &ctxt,
-                              region_bounds: &[ty::Region],
-                              builtin_bounds: BuiltinBounds,
-                              trait_bounds: &[Rc<TraitRef>])
-                              -> Vec<ty::Region>
+pub fn required_region_bounds<'tcx>(tcx: &ctxt<'tcx>,
+                                    region_bounds: &[ty::Region],
+                                    builtin_bounds: BuiltinBounds,
+                                    trait_bounds: &[Rc<TraitRef<'tcx>>])
+                                    -> Vec<ty::Region>
 {
     /*!
      * Given a type which must meet the builtin bounds and trait
@@ -5271,7 +5300,7 @@ fn push_region_bounds(region_bounds: &[ty::Region],
     }
 }
 
-pub fn get_tydesc_ty(tcx: &ctxt) -> Result<Ty, String> {
+pub fn get_tydesc_ty<'tcx>(tcx: &ctxt<'tcx>) -> Result<Ty<'tcx>, String> {
     tcx.lang_items.require(TyDescStructLangItem).map(|tydesc_lang_item| {
         tcx.intrinsic_defs.borrow().get(&tydesc_lang_item).cloned()
             .expect("Failed to resolve TyDesc")
@@ -5614,7 +5643,7 @@ pub fn to_string(self) -> &'static str {
     }
 }
 
-pub fn empty_parameter_environment() -> ParameterEnvironment {
+pub fn empty_parameter_environment<'tcx>() -> ParameterEnvironment<'tcx> {
     /*!
      * Construct a parameter environment suitable for static contexts
      * or other contexts where there are no free type/lifetime
@@ -5628,12 +5657,12 @@ pub fn empty_parameter_environment() -> ParameterEnvironment {
                                selection_cache: traits::SelectionCache::new(), }
 }
 
-pub fn construct_parameter_environment(
-    tcx: &ctxt,
+pub fn construct_parameter_environment<'tcx>(
+    tcx: &ctxt<'tcx>,
     span: Span,
-    generics: &ty::Generics,
+    generics: &ty::Generics<'tcx>,
     free_id: ast::NodeId)
-    -> ParameterEnvironment
+    -> ParameterEnvironment<'tcx>
 {
     /*! See `ParameterEnvironment` struct def'n for details */
 
@@ -5708,10 +5737,10 @@ fn push_region_params(regions: &mut VecPerParamSpace<ty::Region>,
         }
     }
 
-    fn push_types_from_defs(tcx: &ty::ctxt,
-                            types: &mut subst::VecPerParamSpace<Ty>,
-                            space: subst::ParamSpace,
-                            defs: &[TypeParameterDef]) {
+    fn push_types_from_defs<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                  types: &mut subst::VecPerParamSpace<Ty<'tcx>>,
+                                  space: subst::ParamSpace,
+                                  defs: &[TypeParameterDef<'tcx>]) {
         for (i, def) in defs.iter().enumerate() {
             debug!("construct_parameter_environment(): push_types_from_defs: \
                     space={} def={} index={}",
@@ -5723,10 +5752,10 @@ fn push_types_from_defs(tcx: &ty::ctxt,
         }
     }
 
-    fn record_region_bounds(tcx: &ty::ctxt,
-                            space: subst::ParamSpace,
-                            free_substs: &Substs,
-                            bound_sets: &[Vec<ty::Region>]) {
+    fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                  space: subst::ParamSpace,
+                                  free_substs: &Substs<'tcx>,
+                                  bound_sets: &[Vec<ty::Region>]) {
         for (subst_region, bound_set) in
             free_substs.regions().get_slice(space).iter().zip(
                 bound_sets.iter())
@@ -5796,15 +5825,15 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self
     }
 
-    fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty> {
+    fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
         Ok(ty::node_id_to_type(self, id))
     }
 
-    fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<Ty> {
+    fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<Ty<'tcx>> {
         self.method_map.borrow().get(&method_call).map(|method| method.ty)
     }
 
-    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
+    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
         &self.adjustments
     }
 
@@ -5826,7 +5855,7 @@ fn capture_mode(&self, closure_expr_id: ast::NodeId)
     }
 
     fn unboxed_closures<'a>(&'a self)
-                        -> &'a RefCell<DefIdMap<UnboxedClosure>> {
+                        -> &'a RefCell<DefIdMap<UnboxedClosure<'tcx>>> {
         &self.unboxed_closures
     }
 }
@@ -5920,7 +5949,7 @@ pub fn with_freevars<T>(tcx: &ty::ctxt, fid: ast::NodeId, f: |&[Freevar]| -> T)
     }
 }
 
-impl AutoAdjustment {
+impl<'tcx> AutoAdjustment<'tcx> {
     pub fn is_identity(&self) -> bool {
         match *self {
             AdjustAddEnv(..) => false,
@@ -5929,18 +5958,18 @@ pub fn is_identity(&self) -> bool {
     }
 }
 
-impl AutoDerefRef {
+impl<'tcx> AutoDerefRef<'tcx> {
     pub fn is_identity(&self) -> bool {
         self.autoderefs == 0 && self.autoref.is_none()
     }
 }
 
-pub fn liberate_late_bound_regions<HR>(
-    tcx: &ty::ctxt,
+pub fn liberate_late_bound_regions<'tcx, HR>(
+    tcx: &ty::ctxt<'tcx>,
     scope_id: ast::NodeId,
     value: &HR)
     -> HR
-    where HR : HigherRankedFoldable
+    where HR : HigherRankedFoldable<'tcx>
 {
     /*!
      * Replace any late-bound regions bound in `value` with free variants
@@ -5952,11 +5981,11 @@ pub fn liberate_late_bound_regions<HR>(
         |br, _| ty::ReFree(ty::FreeRegion{scope_id: scope_id, bound_region: br})).0
 }
 
-pub fn erase_late_bound_regions<HR>(
-    tcx: &ty::ctxt,
+pub fn erase_late_bound_regions<'tcx, HR>(
+    tcx: &ty::ctxt<'tcx>,
     value: &HR)
     -> HR
-    where HR : HigherRankedFoldable
+    where HR : HigherRankedFoldable<'tcx>
 {
     /*!
      * Replace any late-bound regions bound in `value` with `'static`.
@@ -5967,12 +5996,12 @@ pub fn erase_late_bound_regions<HR>(
     replace_late_bound_regions(tcx, value, |_, _| ty::ReStatic).0
 }
 
-pub fn replace_late_bound_regions<HR>(
-    tcx: &ty::ctxt,
+pub fn replace_late_bound_regions<'tcx, HR>(
+    tcx: &ty::ctxt<'tcx>,
     value: &HR,
     mapf: |BoundRegion, DebruijnIndex| -> ty::Region)
     -> (HR, FnvHashMap<ty::BoundRegion,ty::Region>)
-    where HR : HigherRankedFoldable
+    where HR : HigherRankedFoldable<'tcx>
 {
     /*!
      * Replaces the late-bound-regions in `value` that are bound by `value`.
index e09cf55437c389e00719f6d26919e5705119c1c6..7c6148459d18f9d0b0a59a217800b124f642b6d9 100644 (file)
@@ -50,8 +50,8 @@
 
 /// The TypeFoldable trait is implemented for every type that can be folded.
 /// Basically, every type that has a corresponding method in TypeFolder.
-pub trait TypeFoldable {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
+pub trait TypeFoldable<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
 }
 
 /// The TypeFolder trait defines the actual *folding*. There is a
@@ -73,50 +73,50 @@ fn enter_region_binder(&mut self) { }
     /// track the Debruijn index nesting level.
     fn exit_region_binder(&mut self) { }
 
-    fn fold_ty(&mut self, t: Ty) -> Ty {
+    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
         super_fold_ty(self, t)
     }
 
-    fn fold_mt(&mut self, t: &ty::mt) -> ty::mt {
+    fn fold_mt(&mut self, t: &ty::mt<'tcx>) -> ty::mt<'tcx> {
         super_fold_mt(self, t)
     }
 
-    fn fold_trait_ref(&mut self, t: &ty::TraitRef) -> ty::TraitRef {
+    fn fold_trait_ref(&mut self, t: &ty::TraitRef<'tcx>) -> ty::TraitRef<'tcx> {
         super_fold_trait_ref(self, t)
     }
 
-    fn fold_sty(&mut self, sty: &ty::sty) -> ty::sty {
+    fn fold_sty(&mut self, sty: &ty::sty<'tcx>) -> ty::sty<'tcx> {
         super_fold_sty(self, sty)
     }
 
     fn fold_substs(&mut self,
-                   substs: &subst::Substs)
-                   -> subst::Substs {
+                   substs: &subst::Substs<'tcx>)
+                   -> subst::Substs<'tcx> {
         super_fold_substs(self, substs)
     }
 
     fn fold_fn_sig(&mut self,
-                sig: &ty::FnSig)
-                -> ty::FnSig {
+                sig: &ty::FnSig<'tcx>)
+                -> ty::FnSig<'tcx> {
         super_fold_fn_sig(self, sig)
     }
 
     fn fold_output(&mut self,
-                      output: &ty::FnOutput)
-                      -> ty::FnOutput {
+                      output: &ty::FnOutput<'tcx>)
+                      -> ty::FnOutput<'tcx> {
         super_fold_output(self, output)
     }
 
     fn fold_bare_fn_ty(&mut self,
-                       fty: &ty::BareFnTy)
-                       -> ty::BareFnTy
+                       fty: &ty::BareFnTy<'tcx>)
+                       -> ty::BareFnTy<'tcx>
     {
         super_fold_bare_fn_ty(self, fty)
     }
 
     fn fold_closure_ty(&mut self,
-                       fty: &ty::ClosureTy)
-                       -> ty::ClosureTy {
+                       fty: &ty::ClosureTy<'tcx>)
+                       -> ty::ClosureTy<'tcx> {
         super_fold_closure_ty(self, fty)
     }
 
@@ -133,15 +133,16 @@ fn fold_existential_bounds(&mut self, s: ty::ExistentialBounds)
         super_fold_existential_bounds(self, s)
     }
 
-    fn fold_autoref(&mut self, ar: &ty::AutoRef) -> ty::AutoRef {
+    fn fold_autoref(&mut self, ar: &ty::AutoRef<'tcx>) -> ty::AutoRef<'tcx> {
         super_fold_autoref(self, ar)
     }
 
-    fn fold_item_substs(&mut self, i: ty::ItemSubsts) -> ty::ItemSubsts {
+    fn fold_item_substs(&mut self, i: ty::ItemSubsts<'tcx>) -> ty::ItemSubsts<'tcx> {
         super_fold_item_substs(self, i)
     }
 
-    fn fold_obligation(&mut self, o: &traits::Obligation) -> traits::Obligation {
+    fn fold_obligation(&mut self, o: &traits::Obligation<'tcx>)
+                       -> traits::Obligation<'tcx> {
         super_fold_obligation(self, o)
     }
 }
@@ -157,38 +158,38 @@ fn fold_obligation(&mut self, o: &traits::Obligation) -> traits::Obligation {
 // can easily refactor the folding into the TypeFolder trait as
 // needed.
 
-impl TypeFoldable for () {
-    fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, _: &mut F) -> () {
+impl<'tcx> TypeFoldable<'tcx> for () {
+    fn fold_with<F:TypeFolder<'tcx>>(&self, _: &mut F) -> () {
         ()
     }
 }
 
-impl<T:TypeFoldable,U:TypeFoldable> TypeFoldable for (T, U) {
-    fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) {
+impl<'tcx, T:TypeFoldable<'tcx>, U:TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
+    fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) {
         (self.0.fold_with(folder), self.1.fold_with(folder))
     }
 }
 
-impl<T:TypeFoldable> TypeFoldable for Option<T> {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Option<T> {
+impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Option<T> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Option<T> {
         self.as_ref().map(|t| t.fold_with(folder))
     }
 }
 
-impl<T:TypeFoldable> TypeFoldable for Rc<T> {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Rc<T> {
+impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc<T> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Rc<T> {
         Rc::new((**self).fold_with(folder))
     }
 }
 
-impl<T:TypeFoldable> TypeFoldable for Vec<T> {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Vec<T> {
+impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Vec<T> {
         self.iter().map(|t| t.fold_with(folder)).collect()
     }
 }
 
-impl<T:TypeFoldable> TypeFoldable for ty::Binder<T> {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Binder<T> {
+impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Binder<T> {
         folder.enter_region_binder();
         let result = ty::bind(self.value.fold_with(folder));
         folder.exit_region_binder();
@@ -196,14 +197,14 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Binder<T>
     }
 }
 
-impl<T:TypeFoldable> TypeFoldable for OwnedSlice<T> {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> OwnedSlice<T> {
+impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice<T> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> OwnedSlice<T> {
         self.iter().map(|t| t.fold_with(folder)).collect()
     }
 }
 
-impl<T:TypeFoldable> TypeFoldable for VecPerParamSpace<T> {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> VecPerParamSpace<T> {
+impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> VecPerParamSpace<T> {
 
         // Things in the Fn space take place under an additional level
         // of region binding relative to the other spaces. This is
@@ -225,88 +226,88 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> VecPerParamSpa
     }
 }
 
-impl TypeFoldable for ty::TraitStore {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitStore {
+impl<'tcx> TypeFoldable<'tcx> for ty::TraitStore {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitStore {
         folder.fold_trait_store(*self)
     }
 }
 
-impl TypeFoldable for Ty {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Ty {
+impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Ty<'tcx> {
         folder.fold_ty(*self)
     }
 }
 
-impl TypeFoldable for ty::BareFnTy {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::BareFnTy {
+impl<'tcx> TypeFoldable<'tcx> for ty::BareFnTy<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::BareFnTy<'tcx> {
         folder.fold_bare_fn_ty(self)
     }
 }
 
-impl TypeFoldable for ty::ClosureTy {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureTy {
+impl<'tcx> TypeFoldable<'tcx> for ty::ClosureTy<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureTy<'tcx> {
         folder.fold_closure_ty(self)
     }
 }
 
-impl TypeFoldable for ty::mt {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::mt {
+impl<'tcx> TypeFoldable<'tcx> for ty::mt<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::mt<'tcx> {
         folder.fold_mt(self)
     }
 }
 
-impl TypeFoldable for ty::FnOutput {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnOutput {
+impl<'tcx> TypeFoldable<'tcx> for ty::FnOutput<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnOutput<'tcx> {
         folder.fold_output(self)
     }
 }
 
-impl TypeFoldable for ty::FnSig {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnSig {
+impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnSig<'tcx> {
         folder.fold_fn_sig(self)
     }
 }
 
-impl TypeFoldable for ty::sty {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::sty {
+impl<'tcx> TypeFoldable<'tcx> for ty::sty<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::sty<'tcx> {
         folder.fold_sty(self)
     }
 }
 
-impl TypeFoldable for ty::TraitRef {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitRef {
+impl<'tcx> TypeFoldable<'tcx> for ty::TraitRef<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitRef<'tcx> {
         folder.fold_trait_ref(self)
     }
 }
 
-impl TypeFoldable for ty::Region {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Region {
+impl<'tcx> TypeFoldable<'tcx> for ty::Region {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Region {
         folder.fold_region(*self)
     }
 }
 
-impl TypeFoldable for subst::Substs {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> subst::Substs {
+impl<'tcx> TypeFoldable<'tcx> for subst::Substs<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> subst::Substs<'tcx> {
         folder.fold_substs(self)
     }
 }
 
-impl TypeFoldable for ty::ItemSubsts {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ItemSubsts {
+impl<'tcx> TypeFoldable<'tcx> for ty::ItemSubsts<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ItemSubsts<'tcx> {
         ty::ItemSubsts {
             substs: self.substs.fold_with(folder),
         }
     }
 }
 
-impl TypeFoldable for ty::AutoRef {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::AutoRef {
+impl<'tcx> TypeFoldable<'tcx> for ty::AutoRef<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::AutoRef<'tcx> {
         folder.fold_autoref(self)
     }
 }
 
-impl TypeFoldable for typeck::MethodOrigin {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> typeck::MethodOrigin {
+impl<'tcx> TypeFoldable<'tcx> for typeck::MethodOrigin<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> typeck::MethodOrigin<'tcx> {
         match *self {
             typeck::MethodStatic(def_id) => {
                 typeck::MethodStatic(def_id)
@@ -332,8 +333,8 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> typeck::Method
     }
 }
 
-impl TypeFoldable for typeck::vtable_origin {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> typeck::vtable_origin {
+impl<'tcx> TypeFoldable<'tcx> for typeck::vtable_origin<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> typeck::vtable_origin<'tcx> {
         match *self {
             typeck::vtable_static(def_id, ref substs, ref origins) => {
                 let r_substs = substs.fold_with(folder);
@@ -353,20 +354,20 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> typeck::vtable
     }
 }
 
-impl TypeFoldable for ty::BuiltinBounds {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> ty::BuiltinBounds {
+impl<'tcx> TypeFoldable<'tcx> for ty::BuiltinBounds {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> ty::BuiltinBounds {
         *self
     }
 }
 
-impl TypeFoldable for ty::ExistentialBounds {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ExistentialBounds {
+impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialBounds {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ExistentialBounds {
         folder.fold_existential_bounds(*self)
     }
 }
 
-impl TypeFoldable for ty::ParamBounds {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ParamBounds {
+impl<'tcx> TypeFoldable<'tcx> for ty::ParamBounds<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ParamBounds<'tcx> {
         ty::ParamBounds {
             region_bounds: self.region_bounds.fold_with(folder),
             builtin_bounds: self.builtin_bounds.fold_with(folder),
@@ -375,8 +376,8 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ParamBound
     }
 }
 
-impl TypeFoldable for ty::TypeParameterDef {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeParameterDef {
+impl<'tcx> TypeFoldable<'tcx> for ty::TypeParameterDef<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeParameterDef<'tcx> {
         ty::TypeParameterDef {
             name: self.name,
             def_id: self.def_id,
@@ -389,8 +390,8 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeParame
     }
 }
 
-impl TypeFoldable for ty::RegionParameterDef {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::RegionParameterDef {
+impl<'tcx> TypeFoldable<'tcx> for ty::RegionParameterDef {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::RegionParameterDef {
         ty::RegionParameterDef {
             name: self.name,
             def_id: self.def_id,
@@ -401,8 +402,8 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::RegionPara
     }
 }
 
-impl TypeFoldable for ty::Generics {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Generics {
+impl<'tcx> TypeFoldable<'tcx> for ty::Generics<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Generics<'tcx> {
         ty::Generics {
             types: self.types.fold_with(folder),
             regions: self.regions.fold_with(folder),
@@ -410,8 +411,8 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Generics {
     }
 }
 
-impl TypeFoldable for ty::GenericBounds {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::GenericBounds {
+impl<'tcx> TypeFoldable<'tcx> for ty::GenericBounds<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::GenericBounds<'tcx> {
         ty::GenericBounds {
             types: self.types.fold_with(folder),
             regions: self.regions.fold_with(folder),
@@ -419,8 +420,8 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::GenericBou
     }
 }
 
-impl TypeFoldable for ty::UnsizeKind {
-    fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::UnsizeKind {
+impl<'tcx> TypeFoldable<'tcx> for ty::UnsizeKind<'tcx> {
+    fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::UnsizeKind<'tcx> {
         match *self {
             ty::UnsizeLength(len) => ty::UnsizeLength(len),
             ty::UnsizeStruct(box ref k, n) => ty::UnsizeStruct(box k.fold_with(folder), n),
@@ -436,14 +437,14 @@ fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::UnsizeKind
     }
 }
 
-impl TypeFoldable for traits::Obligation {
-    fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Obligation {
+impl<'tcx> TypeFoldable<'tcx> for traits::Obligation<'tcx> {
+    fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Obligation<'tcx> {
         folder.fold_obligation(self)
     }
 }
 
-impl<N:TypeFoldable> TypeFoldable for traits::VtableImplData<N> {
-    fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableImplData<N> {
+impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableImplData<'tcx, N> {
+    fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableImplData<'tcx, N> {
         traits::VtableImplData {
             impl_def_id: self.impl_def_id,
             substs: self.substs.fold_with(folder),
@@ -452,16 +453,16 @@ fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableI
     }
 }
 
-impl<N:TypeFoldable> TypeFoldable for traits::VtableBuiltinData<N> {
-    fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableBuiltinData<N> {
+impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableBuiltinData<N> {
+    fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableBuiltinData<N> {
         traits::VtableBuiltinData {
             nested: self.nested.fold_with(folder),
         }
     }
 }
 
-impl<N:TypeFoldable> TypeFoldable for traits::Vtable<N> {
-    fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<N> {
+impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N> {
+    fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<'tcx, N> {
         match *self {
             traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)),
             traits::VtableUnboxedClosure(d, ref s) => {
@@ -473,8 +474,8 @@ fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<
     }
 }
 
-impl TypeFoldable for traits::VtableParamData {
-    fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableParamData {
+impl<'tcx> TypeFoldable<'tcx> for traits::VtableParamData<'tcx> {
+    fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableParamData<'tcx> {
         traits::VtableParamData {
             bound: self.bound.fold_with(folder),
         }
@@ -487,15 +488,15 @@ fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableP
 // They should invoke `foo.fold_with()` to do recursive folding.
 
 pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                t: Ty)
-                                                -> Ty {
+                                                t: Ty<'tcx>)
+                                                -> Ty<'tcx> {
     let sty = ty::get(t).sty.fold_with(this);
     ty::mk_t(this.tcx(), sty)
 }
 
 pub fn super_fold_substs<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                    substs: &subst::Substs)
-                                                    -> subst::Substs {
+                                                    substs: &subst::Substs<'tcx>)
+                                                    -> subst::Substs<'tcx> {
     let regions = match substs.regions {
         subst::ErasedRegions => {
             subst::ErasedRegions
@@ -510,8 +511,8 @@ pub fn super_fold_substs<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_fn_sig<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                    sig: &ty::FnSig)
-                                                    -> ty::FnSig
+                                                    sig: &ty::FnSig<'tcx>)
+                                                    -> ty::FnSig<'tcx>
 {
     this.enter_region_binder();
     let result = super_fold_fn_sig_contents(this, sig);
@@ -520,8 +521,8 @@ pub fn super_fold_fn_sig<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_fn_sig_contents<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                             sig: &ty::FnSig)
-                                                             -> ty::FnSig
+                                                             sig: &ty::FnSig<'tcx>)
+                                                             -> ty::FnSig<'tcx>
 {
     ty::FnSig { inputs: sig.inputs.fold_with(this),
                 output: sig.output.fold_with(this),
@@ -529,8 +530,8 @@ pub fn super_fold_fn_sig_contents<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_output<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                    output: &ty::FnOutput)
-                                                    -> ty::FnOutput {
+                                                    output: &ty::FnOutput<'tcx>)
+                                                    -> ty::FnOutput<'tcx> {
     match *output {
         ty::FnConverging(ref ty) => ty::FnConverging(ty.fold_with(this)),
         ty::FnDiverging => ty::FnDiverging
@@ -538,8 +539,8 @@ pub fn super_fold_output<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_bare_fn_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                        fty: &ty::BareFnTy)
-                                                        -> ty::BareFnTy
+                                                        fty: &ty::BareFnTy<'tcx>)
+                                                        -> ty::BareFnTy<'tcx>
 {
     ty::BareFnTy { sig: fty.sig.fold_with(this),
                    abi: fty.abi,
@@ -547,8 +548,8 @@ pub fn super_fold_bare_fn_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_closure_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                        fty: &ty::ClosureTy)
-                                                        -> ty::ClosureTy
+                                                        fty: &ty::ClosureTy<'tcx>)
+                                                        -> ty::ClosureTy<'tcx>
 {
     ty::ClosureTy {
         store: fty.store.fold_with(this),
@@ -561,8 +562,8 @@ pub fn super_fold_closure_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_trait_ref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                       t: &ty::TraitRef)
-                                                       -> ty::TraitRef
+                                                       t: &ty::TraitRef<'tcx>)
+                                                       -> ty::TraitRef<'tcx>
 {
     this.enter_region_binder();
     let result = super_fold_trait_ref_contents(this, t);
@@ -571,8 +572,8 @@ pub fn super_fold_trait_ref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_trait_ref_contents<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                                t: &ty::TraitRef)
-                                                                -> ty::TraitRef
+                                                                t: &ty::TraitRef<'tcx>)
+                                                                -> ty::TraitRef<'tcx>
 {
     ty::TraitRef {
         def_id: t.def_id,
@@ -581,13 +582,15 @@ pub fn super_fold_trait_ref_contents<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                mt: &ty::mt) -> ty::mt {
+                                                mt: &ty::mt<'tcx>)
+                                                -> ty::mt<'tcx> {
     ty::mt {ty: mt.ty.fold_with(this),
             mutbl: mt.mutbl}
 }
 
 pub fn super_fold_sty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                 sty: &ty::sty) -> ty::sty {
+                                                 sty: &ty::sty<'tcx>)
+                                                 -> ty::sty<'tcx> {
     match *sty {
         ty::ty_uniq(typ) => {
             ty::ty_uniq(typ.fold_with(this))
@@ -658,8 +661,8 @@ pub fn super_fold_existential_bounds<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_autoref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                     autoref: &ty::AutoRef)
-                                                     -> ty::AutoRef
+                                                     autoref: &ty::AutoRef<'tcx>)
+                                                     -> ty::AutoRef<'tcx>
 {
     match *autoref {
         ty::AutoPtr(r, m, None) => ty::AutoPtr(this.fold_region(r), m, None),
@@ -676,8 +679,8 @@ pub fn super_fold_autoref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_item_substs<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
-                                                         substs: ty::ItemSubsts)
-                                                         -> ty::ItemSubsts
+                                                         substs: ty::ItemSubsts<'tcx>)
+                                                         -> ty::ItemSubsts<'tcx>
 {
     ty::ItemSubsts {
         substs: substs.substs.fold_with(this),
@@ -685,8 +688,8 @@ pub fn super_fold_item_substs<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
 }
 
 pub fn super_fold_obligation<'tcx, T:TypeFolder<'tcx>>(this: &mut T,
-                                                       obligation: &traits::Obligation)
-                                                       -> traits::Obligation
+                                                       obligation: &traits::Obligation<'tcx>)
+                                                       -> traits::Obligation<'tcx>
 {
     traits::Obligation {
         cause: obligation.cause,
@@ -701,32 +704,32 @@ pub fn super_fold_obligation<'tcx, T:TypeFolder<'tcx>>(this: &mut T,
 /**
  * Designates a "binder" for late-bound regions.
  */
-pub trait HigherRankedFoldable : Repr {
+pub trait HigherRankedFoldable<'tcx>: Repr<'tcx> {
     /// Folds the contents of `self`, ignoring the region binder created
     /// by `self`.
-    fn fold_contents<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
+    fn fold_contents<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
 }
 
-impl HigherRankedFoldable for ty::FnSig {
-    fn fold_contents<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnSig {
+impl<'tcx> HigherRankedFoldable<'tcx> for ty::FnSig<'tcx> {
+    fn fold_contents<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnSig<'tcx> {
         super_fold_fn_sig_contents(folder, self)
     }
 }
 
-impl HigherRankedFoldable for ty::TraitRef {
-    fn fold_contents<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitRef {
+impl<'tcx> HigherRankedFoldable<'tcx> for ty::TraitRef<'tcx> {
+    fn fold_contents<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitRef<'tcx> {
         super_fold_trait_ref_contents(folder, self)
     }
 }
 
-impl<T:TypeFoldable+Repr> HigherRankedFoldable for ty::Binder<T> {
-    fn fold_contents<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Binder<T> {
+impl<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>> HigherRankedFoldable<'tcx> for ty::Binder<T> {
+    fn fold_contents<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Binder<T> {
         ty::bind(self.value.fold_with(folder))
     }
 }
 
-impl<T:HigherRankedFoldable> HigherRankedFoldable for Rc<T> {
-    fn fold_contents<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Rc<T> {
+impl<'tcx, T:HigherRankedFoldable<'tcx>> HigherRankedFoldable<'tcx> for Rc<T> {
+    fn fold_contents<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Rc<T> {
         Rc::new((**self).fold_contents(folder))
     }
 }
@@ -736,13 +739,13 @@ fn fold_contents<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Rc<T> {
 
 pub struct BottomUpFolder<'a, 'tcx: 'a> {
     pub tcx: &'a ty::ctxt<'tcx>,
-    pub fldop: |Ty|: 'a -> Ty,
+    pub fldop: |Ty<'tcx>|: 'a -> Ty<'tcx>,
 }
 
 impl<'a, 'tcx> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx }
 
-    fn fold_ty(&mut self, ty: Ty) -> Ty {
+    fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
         let t1 = super_fold_ty(self, ty);
         (self.fldop)(t1)
     }
@@ -816,7 +819,7 @@ pub struct RegionEraser<'a, 'tcx: 'a> {
     tcx: &'a ty::ctxt<'tcx>,
 }
 
-pub fn erase_regions<T:TypeFoldable>(tcx: &ty::ctxt, t: T) -> T {
+pub fn erase_regions<'tcx, T: TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>, t: T) -> T {
     let mut eraser = RegionEraser { tcx: tcx };
     t.fold_with(&mut eraser)
 }
@@ -852,7 +855,8 @@ pub fn shift_region(region: ty::Region, amount: uint) -> ty::Region {
     }
 }
 
-pub fn shift_regions<T:TypeFoldable+Repr>(tcx: &ty::ctxt, amount: uint, value: &T) -> T {
+pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>>(tcx: &ty::ctxt<'tcx>,
+                                                            amount: uint, value: &T) -> T {
     debug!("shift_regions(value={}, amount={})",
            value.repr(tcx), amount);
 
index b3e2c88ef63b40b7d69cd9f6513626bc63aeb451..8e04e8b1f79d844ec6de4183d63a925e5aed5672 100644 (file)
 
 pub trait AstConv<'tcx> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype;
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef>;
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx>;
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>>;
 
     /// What type should we use when a type is omitted?
-    fn ty_infer(&self, span: Span) -> Ty;
+    fn ty_infer(&self, span: Span) -> Ty<'tcx>;
 
     /// Returns true if associated types from the given trait and type are
     /// allowed to be used here and false otherwise.
     fn associated_types_of_trait_are_valid(&self,
-                                           ty: Ty,
+                                           ty: Ty<'tcx>,
                                            trait_id: ast::DefId)
                                            -> bool;
 
     /// Returns the binding of the given associated type for some type.
     fn associated_type_binding(&self,
                                span: Span,
-                               ty: Option<Ty>,
+                               ty: Option<Ty<'tcx>>,
                                trait_id: ast::DefId,
                                associated_type_id: ast::DefId)
-                               -> Ty;
+                               -> Ty<'tcx>;
 }
 
 pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime)
@@ -205,11 +205,11 @@ fn ast_path_substs_for_ty<'tcx,AC,RS>(
     this: &AC,
     rscope: &RS,
     decl_def_id: ast::DefId,
-    decl_generics: &ty::Generics,
-    self_ty: Option<Ty>,
-    associated_ty: Option<Ty>,
+    decl_generics: &ty::Generics<'tcx>,
+    self_ty: Option<Ty<'tcx>>,
+    associated_ty: Option<Ty<'tcx>>,
     path: &ast::Path)
-    -> Substs
+    -> Substs<'tcx>
     where AC: AstConv<'tcx>, RS: RegionScope
 {
     /*!
@@ -251,12 +251,12 @@ fn create_substs_for_ast_path<'tcx,AC,RS>(
     rscope: &RS,
     span: Span,
     decl_def_id: ast::DefId,
-    decl_generics: &ty::Generics,
-    self_ty: Option<Ty>,
-    types: Vec<Ty>,
+    decl_generics: &ty::Generics<'tcx>,
+    self_ty: Option<Ty<'tcx>>,
+    types: Vec<Ty<'tcx>>,
     regions: Vec<ty::Region>,
-    associated_ty: Option<Ty>)
-    -> Substs
+    associated_ty: Option<Ty<'tcx>>)
+    -> Substs<'tcx>
     where AC: AstConv<'tcx>, RS: RegionScope
 {
     let tcx = this.tcx();
@@ -377,7 +377,7 @@ fn create_substs_for_ast_path<'tcx,AC,RS>(
 fn convert_angle_bracketed_parameters<'tcx, AC, RS>(this: &AC,
                                                     rscope: &RS,
                                                     data: &ast::AngleBracketedParameterData)
-                                                    -> (Vec<ty::Region>, Vec<Ty>)
+                                                    -> (Vec<ty::Region>, Vec<Ty<'tcx>>)
     where AC: AstConv<'tcx>, RS: RegionScope
 {
     let regions: Vec<_> =
@@ -395,7 +395,7 @@ fn convert_angle_bracketed_parameters<'tcx, AC, RS>(this: &AC,
 
 fn convert_parenthesized_parameters<'tcx,AC>(this: &AC,
                                              data: &ast::ParenthesizedParameterData)
-                                             -> Vec<Ty>
+                                             -> Vec<Ty<'tcx>>
     where AC: AstConv<'tcx>
 {
     let binding_rscope = BindingRscope::new();
@@ -417,9 +417,9 @@ pub fn instantiate_poly_trait_ref<'tcx,AC,RS>(
     this: &AC,
     rscope: &RS,
     ast_trait_ref: &ast::PolyTraitRef,
-    self_ty: Option<Ty>,
-    associated_type: Option<Ty>)
-    -> Rc<ty::TraitRef>
+    self_ty: Option<Ty<'tcx>>,
+    associated_type: Option<Ty<'tcx>>)
+    -> Rc<ty::TraitRef<'tcx>>
     where AC: AstConv<'tcx>, RS: RegionScope
 {
     instantiate_trait_ref(this, rscope, &ast_trait_ref.trait_ref, self_ty, associated_type)
@@ -428,9 +428,9 @@ pub fn instantiate_poly_trait_ref<'tcx,AC,RS>(
 pub fn instantiate_trait_ref<'tcx,AC,RS>(this: &AC,
                                          rscope: &RS,
                                          ast_trait_ref: &ast::TraitRef,
-                                         self_ty: Option<Ty>,
-                                         associated_type: Option<Ty>)
-                                         -> Rc<ty::TraitRef>
+                                         self_ty: Option<Ty<'tcx>>,
+                                         associated_type: Option<Ty<'tcx>>)
+                                         -> Rc<ty::TraitRef<'tcx>>
                                          where AC: AstConv<'tcx>,
                                                RS: RegionScope
 {
@@ -462,10 +462,10 @@ fn ast_path_to_trait_ref<'tcx,AC,RS>(
     this: &AC,
     rscope: &RS,
     trait_def_id: ast::DefId,
-    self_ty: Option<Ty>,
-    associated_type: Option<Ty>,
+    self_ty: Option<Ty<'tcx>>,
+    associated_type: Option<Ty<'tcx>>,
     path: &ast::Path)
-    -> ty::TraitRef
+    -> ty::TraitRef<'tcx>
     where AC: AstConv<'tcx>, RS: RegionScope
 {
     let trait_def = this.get_trait_def(trait_def_id);
@@ -504,7 +504,7 @@ pub fn ast_path_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
     rscope: &RS,
     did: ast::DefId,
     path: &ast::Path)
-    -> TypeAndSubsts
+    -> TypeAndSubsts<'tcx>
 {
     let tcx = this.tcx();
     let ty::Polytype {
@@ -533,7 +533,7 @@ pub fn ast_path_to_ty_relaxed<'tcx,AC,RS>(
     rscope: &RS,
     did: ast::DefId,
     path: &ast::Path)
-    -> TypeAndSubsts
+    -> TypeAndSubsts<'tcx>
     where AC : AstConv<'tcx>, RS : RegionScope
 {
     let tcx = this.tcx();
@@ -589,7 +589,8 @@ fn check_path_args(tcx: &ty::ctxt,
     }
 }
 
-pub fn ast_ty_to_prim_ty(tcx: &ty::ctxt, ast_ty: &ast::Ty) -> Option<Ty> {
+pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
+                               -> Option<Ty<'tcx>> {
     match ast_ty.node {
         ast::TyPath(ref path, _, id) => {
             let a_def = match tcx.def_map.borrow().get(&id) {
@@ -641,7 +642,7 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
         this: &AC,
         rscope: &RS,
         ast_ty: &ast::Ty)
-        -> Option<Ty> {
+        -> Option<Ty<'tcx>> {
     match ast_ty_to_prim_ty(this.tcx(), ast_ty) {
         Some(typ) => return Some(typ),
         None => {}
@@ -697,8 +698,8 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
         a_seq_mutbl: ast::Mutability,
         a_seq_ty: &ast::Ty,
         region: ty::Region,
-        constr: |Ty| -> Ty)
-        -> Ty
+        constr: |Ty<'tcx>| -> Ty<'tcx>)
+        -> Ty<'tcx>
 {
     let tcx = this.tcx();
 
@@ -755,7 +756,7 @@ fn associated_ty_to_ty<'tcx,AC,RS>(this: &AC,
                                    for_ast_type: &ast::Ty,
                                    trait_type_id: ast::DefId,
                                    span: Span)
-                                   -> Ty
+                                   -> Ty<'tcx>
                                    where AC: AstConv<'tcx>, RS: RegionScope
 {
     debug!("associated_ty_to_ty(trait_path={}, for_ast_type={}, trait_type_id={})",
@@ -811,7 +812,7 @@ fn associated_ty_to_ty<'tcx,AC,RS>(this: &AC,
 // Parses the programmer's textual representation of a type into our
 // internal notion of a type.
 pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
-        this: &AC, rscope: &RS, ast_ty: &ast::Ty) -> Ty
+        this: &AC, rscope: &RS, ast_ty: &ast::Ty) -> Ty<'tcx>
 {
     debug!("ast_ty_to_ty(ast_ty={})",
            ast_ty.repr(this.tcx()));
@@ -1060,8 +1061,8 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
 
 pub fn ty_of_arg<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(this: &AC, rscope: &RS,
                                                            a: &ast::Arg,
-                                                           expected_ty: Option<Ty>)
-                                                           -> Ty {
+                                                           expected_ty: Option<Ty<'tcx>>)
+                                                           -> Ty<'tcx> {
     match a.ty.node {
         ast::TyInfer if expected_ty.is_some() => expected_ty.unwrap(),
         ast::TyInfer => this.ty_infer(a.ty.span),
@@ -1069,19 +1070,19 @@ pub fn ty_of_arg<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(this: &AC, rscope: &R
     }
 }
 
-struct SelfInfo<'a> {
-    untransformed_self_ty: Ty,
+struct SelfInfo<'a, 'tcx> {
+    untransformed_self_ty: Ty<'tcx>,
     explicit_self: &'a ast::ExplicitSelf,
 }
 
 pub fn ty_of_method<'tcx, AC: AstConv<'tcx>>(
                     this: &AC,
                     fn_style: ast::FnStyle,
-                    untransformed_self_ty: Ty,
+                    untransformed_self_ty: Ty<'tcx>,
                     explicit_self: &ast::ExplicitSelf,
                     decl: &ast::FnDecl,
                     abi: abi::Abi)
-                    -> (ty::BareFnTy, ty::ExplicitSelfCategory) {
+                    -> (ty::BareFnTy<'tcx>, ty::ExplicitSelfCategory) {
     let self_info = Some(SelfInfo {
         untransformed_self_ty: untransformed_self_ty,
         explicit_self: explicit_self,
@@ -1096,18 +1097,18 @@ pub fn ty_of_method<'tcx, AC: AstConv<'tcx>>(
 }
 
 pub fn ty_of_bare_fn<'tcx, AC: AstConv<'tcx>>(this: &AC, fn_style: ast::FnStyle, abi: abi::Abi,
-                                              decl: &ast::FnDecl) -> ty::BareFnTy {
+                                              decl: &ast::FnDecl) -> ty::BareFnTy<'tcx> {
     let (bare_fn_ty, _) = ty_of_method_or_bare_fn(this, fn_style, abi, None, decl);
     bare_fn_ty
 }
 
-fn ty_of_method_or_bare_fn<'tcx, AC: AstConv<'tcx>>(
+fn ty_of_method_or_bare_fn<'a, 'tcx, AC: AstConv<'tcx>>(
                            this: &AC,
                            fn_style: ast::FnStyle,
                            abi: abi::Abi,
-                           opt_self_info: Option<SelfInfo>,
+                           opt_self_info: Option<SelfInfo<'a, 'tcx>>,
                            decl: &ast::FnDecl)
-                           -> (ty::BareFnTy,
+                           -> (ty::BareFnTy<'tcx>,
                                Option<ty::ExplicitSelfCategory>) {
     debug!("ty_of_method_or_bare_fn");
 
@@ -1229,11 +1230,11 @@ fn ty_of_method_or_bare_fn<'tcx, AC: AstConv<'tcx>>(
     }, explicit_self_category_result)
 }
 
-fn determine_explicit_self_category<'tcx, AC: AstConv<'tcx>,
+fn determine_explicit_self_category<'a, 'tcx, AC: AstConv<'tcx>,
                                     RS:RegionScope>(
                                     this: &AC,
                                     rscope: &RS,
-                                    self_info: &SelfInfo)
+                                    self_info: &SelfInfo<'a, 'tcx>)
                                     -> ty::ExplicitSelfCategory
 {
     return match self_info.explicit_self.node {
@@ -1319,8 +1320,8 @@ pub fn ty_of_closure<'tcx, AC: AstConv<'tcx>>(
     store: ty::TraitStore,
     decl: &ast::FnDecl,
     abi: abi::Abi,
-    expected_sig: Option<ty::FnSig>)
-    -> ty::ClosureTy
+    expected_sig: Option<ty::FnSig<'tcx>>)
+    -> ty::ClosureTy<'tcx>
 {
     debug!("ty_of_closure(expected_sig={})",
            expected_sig.repr(this.tcx()));
@@ -1373,7 +1374,7 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
     this: &AC,
     rscope: &RS,
     span: Span,
-    main_trait_refs: &[Rc<ty::TraitRef>],
+    main_trait_refs: &[Rc<ty::TraitRef<'tcx>>],
     ast_bounds: &[ast::TyParamBound])
     -> ty::ExistentialBounds
 {
@@ -1402,7 +1403,7 @@ fn conv_ty_poly_trait_ref<'tcx, AC, RS>(
     rscope: &RS,
     span: Span,
     ast_bounds: &[ast::TyParamBound])
-    -> Ty
+    -> Ty<'tcx>
     where AC: AstConv<'tcx>, RS:RegionScope
 {
     let ast_bounds: Vec<&ast::TyParamBound> = ast_bounds.iter().collect();
@@ -1436,7 +1437,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx, AC, RS>(
     this: &AC,
     rscope: &RS,
     span: Span,
-    main_trait_refs: &[Rc<ty::TraitRef>],
+    main_trait_refs: &[Rc<ty::TraitRef<'tcx>>],
     partitioned_bounds: PartitionedBounds)
     -> ty::ExistentialBounds
     where AC: AstConv<'tcx>, RS:RegionScope
@@ -1483,12 +1484,12 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx, AC, RS>(
     }
 }
 
-pub fn compute_opt_region_bound(tcx: &ty::ctxt,
-                                span: Span,
-                                builtin_bounds: ty::BuiltinBounds,
-                                region_bounds: &[&ast::Lifetime],
-                                trait_bounds: &[Rc<ty::TraitRef>])
-                                -> Option<ty::Region>
+pub fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                      span: Span,
+                                      builtin_bounds: ty::BuiltinBounds,
+                                      region_bounds: &[&ast::Lifetime],
+                                      trait_bounds: &[Rc<ty::TraitRef<'tcx>>])
+                                      -> Option<ty::Region>
 {
     /*!
      * Given the bounds on a type parameter / existential type,
@@ -1552,7 +1553,7 @@ fn compute_region_bound<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
     span: Span,
     builtin_bounds: ty::BuiltinBounds,
     region_bounds: &[&ast::Lifetime],
-    trait_bounds: &[Rc<ty::TraitRef>])
+    trait_bounds: &[Rc<ty::TraitRef<'tcx>>])
     -> ty::Region
 {
     /*!
index 17b2e51a42807b41a1ffadfa26b8c59359c98d4d..7b5a37148c033d80176394849a0bbd2a2c506411 100644 (file)
@@ -27,7 +27,8 @@
 use syntax::print::pprust;
 use syntax::ptr::P;
 
-pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: Ty) {
+pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
+                           pat: &ast::Pat, expected: Ty<'tcx>) {
     let fcx = pcx.fcx;
     let tcx = pcx.fcx.ccx.tcx;
 
@@ -207,8 +208,9 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: Ty) {
     }
 }
 
-pub fn check_dereferencable(pcx: &pat_ctxt, span: Span, expected: Ty,
-                            inner: &ast::Pat) -> bool {
+pub fn check_dereferencable<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
+                                      span: Span, expected: Ty<'tcx>,
+                                      inner: &ast::Pat) -> bool {
     let fcx = pcx.fcx;
     let tcx = pcx.fcx.ccx.tcx;
     match infer::resolve_type(
@@ -290,9 +292,9 @@ pub struct pat_ctxt<'a, 'tcx: 'a> {
     pub map: PatIdMap,
 }
 
-pub fn check_pat_struct(pcx: &pat_ctxt, pat: &ast::Pat,
-                        path: &ast::Path, fields: &[Spanned<ast::FieldPat>],
-                        etc: bool, expected: Ty) {
+pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
+                                  path: &ast::Path, fields: &[Spanned<ast::FieldPat>],
+                                  etc: bool, expected: Ty<'tcx>) {
     let fcx = pcx.fcx;
     let tcx = pcx.fcx.ccx.tcx;
 
@@ -349,9 +351,9 @@ pub fn check_pat_struct(pcx: &pat_ctxt, pat: &ast::Pat,
                             variant_def_id, etc);
 }
 
-pub fn check_pat_enum(pcx: &pat_ctxt, pat: &ast::Pat,
-                      path: &ast::Path, subpats: &Option<Vec<P<ast::Pat>>>,
-                      expected: Ty) {
+pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
+                                path: &ast::Path, subpats: &Option<Vec<P<ast::Pat>>>,
+                                expected: Ty<'tcx>) {
 
     // Typecheck the path.
     let fcx = pcx.fcx;
@@ -434,12 +436,12 @@ pub fn check_pat_enum(pcx: &pat_ctxt, pat: &ast::Pat,
 /// `struct_fields` describes the type of each field of the struct.
 /// `struct_id` is the ID of the struct.
 /// `etc` is true if the pattern said '...' and false otherwise.
-pub fn check_struct_pat_fields(pcx: &pat_ctxt,
-                               span: Span,
-                               fields: &[Spanned<ast::FieldPat>],
-                               struct_fields: &[ty::field],
-                               struct_id: ast::DefId,
-                               etc: bool) {
+pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
+                                         span: Span,
+                                         fields: &[Spanned<ast::FieldPat>],
+                                         struct_fields: &[ty::field<'tcx>],
+                                         struct_id: ast::DefId,
+                                         etc: bool) {
     let tcx = pcx.fcx.ccx.tcx;
 
     // Index the struct fields' types.
index 4d31275e45dbf385173702ad3f03077676fcf1b5..1e45d059b849ba018c79427659bae56d06639d0f 100644 (file)
 
 // Requires that the two types unify, and prints an error message if they
 // don't.
-pub fn suptype(fcx: &FnCtxt, sp: Span, expected: Ty, actual: Ty) {
+pub fn suptype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
+                         expected: Ty<'tcx>, actual: Ty<'tcx>) {
     suptype_with_fn(fcx, sp, false, expected, actual,
         |sp, e, a, s| { fcx.report_mismatched_types(sp, e, a, s) })
 }
 
-pub fn subtype(fcx: &FnCtxt, sp: Span, expected: Ty, actual: Ty) {
+pub fn subtype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
+                         expected: Ty<'tcx>, actual: Ty<'tcx>) {
     suptype_with_fn(fcx, sp, true, actual, expected,
         |sp, a, e, s| { fcx.report_mismatched_types(sp, e, a, s) })
 }
 
-pub fn suptype_with_fn(fcx: &FnCtxt,
-                       sp: Span,
-                       b_is_expected: bool,
-                       ty_a: Ty,
-                       ty_b: Ty,
-                       handle_err: |Span, Ty, Ty, &ty::type_err|) {
+pub fn suptype_with_fn<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                 sp: Span,
+                                 b_is_expected: bool,
+                                 ty_a: Ty<'tcx>,
+                                 ty_b: Ty<'tcx>,
+                                 handle_err: |Span, Ty<'tcx>, Ty<'tcx>, &ty::type_err<'tcx>|) {
     // n.b.: order of actual, expected is reversed
     match infer::mk_subty(fcx.infcx(), b_is_expected, infer::Misc(sp),
                           ty_b, ty_a) {
@@ -49,7 +51,8 @@ pub fn suptype_with_fn(fcx: &FnCtxt,
     }
 }
 
-pub fn eqtype(fcx: &FnCtxt, sp: Span, expected: Ty, actual: Ty) {
+pub fn eqtype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
+                        expected: Ty<'tcx>, actual: Ty<'tcx>) {
     match infer::mk_eqty(fcx.infcx(), false, infer::Misc(sp), actual, expected) {
         Ok(()) => { /* ok */ }
         Err(ref err) => {
@@ -59,7 +62,8 @@ pub fn eqtype(fcx: &FnCtxt, sp: Span, expected: Ty, actual: Ty) {
 }
 
 // Checks that the type `actual` can be coerced to `expected`.
-pub fn coerce(fcx: &FnCtxt, sp: Span, expected: Ty, expr: &ast::Expr) {
+pub fn coerce<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
+                        expected: Ty<'tcx>, expr: &ast::Expr) {
     let expr_ty = fcx.expr_ty(expr);
     debug!("demand::coerce(expected = {}, expr_ty = {})",
            expected.repr(fcx.ccx.tcx),
index 9c138499b424ae80e19e095652ef62a3fc0dfea1..8a337421b87e2c0feeda8a1b648602d4418351b8 100644 (file)
@@ -33,34 +33,33 @@ struct ConfirmContext<'a, 'tcx:'a> {
     self_expr: &'a ast::Expr,
 }
 
-struct InstantiatedMethodSig {
+struct InstantiatedMethodSig<'tcx> {
     /// Function signature of the method being invoked. The 0th
     /// argument is the receiver.
-    method_sig: ty::FnSig,
+    method_sig: ty::FnSig<'tcx>,
 
     /// Substitutions for all types/early-bound-regions declared on
     /// the method.
-    all_substs: subst::Substs,
+    all_substs: subst::Substs<'tcx>,
 
     /// Substitution to use when adding obligations from the method
     /// bounds. Normally equal to `all_substs` except for object
     /// receivers. See FIXME in instantiate_method_sig() for
     /// explanation.
-    method_bounds_substs: subst::Substs,
+    method_bounds_substs: subst::Substs<'tcx>,
 
     /// Generic bounds on the method's parameters which must be added
     /// as pending obligations.
-    method_bounds: ty::GenericBounds,
+    method_bounds: ty::GenericBounds<'tcx>,
 }
 
-
-pub fn confirm(fcx: &FnCtxt,
-               span: Span,
-               self_expr: &ast::Expr,
-               unadjusted_self_ty: Ty,
-               pick: probe::Pick,
-               supplied_method_types: Vec<Ty>)
-               -> MethodCallee
+pub fn confirm<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                         span: Span,
+                         self_expr: &ast::Expr,
+                         unadjusted_self_ty: Ty<'tcx>,
+                         pick: probe::Pick<'tcx>,
+                         supplied_method_types: Vec<Ty<'tcx>>)
+                         -> MethodCallee<'tcx>
 {
     debug!("confirm(unadjusted_self_ty={}, pick={}, supplied_method_types={})",
            unadjusted_self_ty.repr(fcx.tcx()),
@@ -81,10 +80,10 @@ fn new(fcx: &'a FnCtxt<'a, 'tcx>,
     }
 
     fn confirm(&mut self,
-               unadjusted_self_ty: Ty,
-               pick: probe::Pick,
-               supplied_method_types: Vec<Ty>)
-               -> MethodCallee
+               unadjusted_self_ty: Ty<'tcx>,
+               pick: probe::Pick<'tcx>,
+               supplied_method_types: Vec<Ty<'tcx>>)
+               -> MethodCallee<'tcx>
     {
         // Adjust the self expression the user provided and obtain the adjusted type.
         let self_ty = self.adjust_self_ty(unadjusted_self_ty, &pick.adjustment);
@@ -136,9 +135,9 @@ fn confirm(&mut self,
     // ADJUSTMENTS
 
     fn adjust_self_ty(&mut self,
-                      unadjusted_self_ty: Ty,
+                      unadjusted_self_ty: Ty<'tcx>,
                       adjustment: &probe::PickAdjustment)
-                      -> Ty
+                      -> Ty<'tcx>
     {
         // Construct the actual adjustment and write it into the table
         let auto_deref_ref = self.create_ty_adjustment(adjustment);
@@ -164,7 +163,7 @@ fn adjust_self_ty(&mut self,
 
     fn create_ty_adjustment(&mut self,
                             adjustment: &probe::PickAdjustment)
-                            -> ty::AutoDerefRef
+                            -> ty::AutoDerefRef<'tcx>
     {
         match *adjustment {
             probe::AutoDeref(num) => {
@@ -191,9 +190,9 @@ fn create_ty_adjustment(&mut self,
     //
 
     fn fresh_receiver_substs(&mut self,
-                             self_ty: Ty,
-                             pick: &probe::Pick)
-                             -> (subst::Substs, MethodOrigin)
+                             self_ty: Ty<'tcx>,
+                             pick: &probe::Pick<'tcx>)
+                             -> (subst::Substs<'tcx>, MethodOrigin<'tcx>)
     {
         /*!
          * Returns a set of substitutions for the method *receiver*
@@ -292,8 +291,9 @@ fn fresh_receiver_substs(&mut self,
     }
 
     fn extract_trait_ref<R>(&mut self,
-                            self_ty: Ty,
-                            closure: |&mut ConfirmContext<'a,'tcx>, Ty, &ty::TyTrait| -> R)
+                            self_ty: Ty<'tcx>,
+                            closure: |&mut ConfirmContext<'a,'tcx>,
+                                      Ty<'tcx>, &ty::TyTrait<'tcx>| -> R)
                             -> R
     {
         // If we specified that this is an object method, then the
@@ -323,9 +323,9 @@ fn extract_trait_ref<R>(&mut self,
     }
 
     fn instantiate_method_substs(&mut self,
-                                 pick: &probe::Pick,
-                                 supplied_method_types: Vec<Ty>)
-                                 -> (Vec<Ty>, Vec<ty::Region>)
+                                 pick: &probe::Pick<'tcx>,
+                                 supplied_method_types: Vec<Ty<'tcx>>)
+                                 -> (Vec<Ty<'tcx>>, Vec<ty::Region>)
     {
         // Determine the values for the generic parameters of the method.
         // If they were not explicitly supplied, just construct fresh
@@ -361,8 +361,8 @@ fn instantiate_method_substs(&mut self,
     }
 
     fn unify_receivers(&mut self,
-                       self_ty: Ty,
-                       method_self_ty: Ty)
+                       self_ty: Ty<'tcx>,
+                       method_self_ty: Ty<'tcx>)
     {
         match self.fcx.mk_subty(false, infer::Misc(self.span), self_ty, method_self_ty) {
             Ok(_) => {}
@@ -381,9 +381,9 @@ fn unify_receivers(&mut self,
     //
 
     fn instantiate_method_sig(&mut self,
-                              pick: &probe::Pick,
-                              all_substs: subst::Substs)
-                              -> InstantiatedMethodSig
+                              pick: &probe::Pick<'tcx>,
+                              all_substs: subst::Substs<'tcx>)
+                              -> InstantiatedMethodSig<'tcx>
     {
         // If this method comes from an impl (as opposed to a trait),
         // it may have late-bound regions from the impl that appear in
@@ -457,9 +457,9 @@ fn instantiate_method_sig(&mut self,
     }
 
     fn add_obligations(&mut self,
-                       pick: &probe::Pick,
-                       method_bounds_substs: &subst::Substs,
-                       method_bounds: &ty::GenericBounds) {
+                       pick: &probe::Pick<'tcx>,
+                       method_bounds_substs: &subst::Substs<'tcx>,
+                       method_bounds: &ty::GenericBounds<'tcx>) {
         debug!("add_obligations: pick={} method_bounds_substs={} method_bounds={}",
                pick.repr(self.tcx()),
                method_bounds_substs.repr(self.tcx()),
@@ -647,9 +647,9 @@ fn enforce_drop_trait_limitations(&self, pick: &probe::Pick) {
     }
 
     fn upcast(&mut self,
-              source_trait_ref: Rc<ty::TraitRef>,
+              source_trait_ref: Rc<ty::TraitRef<'tcx>>,
               target_trait_def_id: ast::DefId)
-              -> Rc<ty::TraitRef>
+              -> Rc<ty::TraitRef<'tcx>>
     {
         for super_trait_ref in traits::supertraits(self.tcx(), source_trait_ref.clone()) {
             if super_trait_ref.def_id == target_trait_def_id {
@@ -665,16 +665,16 @@ fn upcast(&mut self,
     }
 
     fn replace_late_bound_regions_with_fresh_var<T>(&self, value: &T) -> T
-        where T : HigherRankedFoldable
+        where T : HigherRankedFoldable<'tcx>
     {
         self.infcx().replace_late_bound_regions_with_fresh_var(
             self.span, infer::FnCall, value).0
     }
 }
 
-fn wrap_autoref(mut deref: ty::AutoDerefRef,
-                base_fn: |Option<Box<ty::AutoRef>>| -> ty::AutoRef)
-                -> ty::AutoDerefRef {
+fn wrap_autoref<'tcx>(mut deref: ty::AutoDerefRef<'tcx>,
+                      base_fn: |Option<Box<ty::AutoRef<'tcx>>>| -> ty::AutoRef<'tcx>)
+                      -> ty::AutoDerefRef<'tcx> {
     let autoref = mem::replace(&mut deref.autoref, None);
     let autoref = autoref.map(|r| box r);
     deref.autoref = Some(base_fn(autoref));
index f96384adc26720cd7a90f408509a4cb75c7794a0..69a55bf0906a5be671a0adc4ccf6f1f49506c517 100644 (file)
@@ -56,12 +56,12 @@ pub enum CandidateSource {
 
 type MethodIndex = uint; // just for doc purposes
 
-pub fn exists(fcx: &FnCtxt,
-              span: Span,
-              method_name: ast::Name,
-              self_ty: Ty,
-              call_expr_id: ast::NodeId)
-              -> bool
+pub fn exists<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                        span: Span,
+                        method_name: ast::Name,
+                        self_ty: Ty<'tcx>,
+                        call_expr_id: ast::NodeId)
+                        -> bool
 {
     /*!
      * Determines whether the type `self_ty` supports a method name `method_name` or not.
@@ -74,14 +74,14 @@ pub fn exists(fcx: &FnCtxt,
     }
 }
 
-pub fn lookup(fcx: &FnCtxt,
-              span: Span,
-              method_name: ast::Name,
-              self_ty: Ty,
-              supplied_method_types: Vec<Ty>,
-              call_expr_id: ast::NodeId,
-              self_expr: &ast::Expr)
-              -> Result<MethodCallee, MethodError>
+pub fn lookup<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                        span: Span,
+                        method_name: ast::Name,
+                        self_ty: Ty<'tcx>,
+                        supplied_method_types: Vec<Ty<'tcx>>,
+                        call_expr_id: ast::NodeId,
+                        self_expr: &ast::Expr)
+                        -> Result<MethodCallee<'tcx>, MethodError>
 {
     /*!
      * Performs method lookup. If lookup is successful, it will return the callee
@@ -115,9 +115,9 @@ pub fn lookup_in_trait<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
                                  self_expr: Option<&'a ast::Expr>,
                                  m_name: ast::Name,
                                  trait_def_id: DefId,
-                                 self_ty: Ty,
-                                 opt_input_types: Option<Vec<Ty>>)
-                                 -> Option<MethodCallee>
+                                 self_ty: Ty<'tcx>,
+                                 opt_input_types: Option<Vec<Ty<'tcx>>>)
+                                 -> Option<MethodCallee<'tcx>>
 {
     lookup_in_trait_adjusted(fcx, span, self_expr, m_name, trait_def_id,
                              ty::AutoDerefRef { autoderefs: 0, autoref: None },
@@ -129,10 +129,10 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
                                           self_expr: Option<&'a ast::Expr>,
                                           m_name: ast::Name,
                                           trait_def_id: DefId,
-                                          autoderefref: ty::AutoDerefRef,
-                                          self_ty: Ty,
-                                          opt_input_types: Option<Vec<Ty>>)
-                                          -> Option<MethodCallee>
+                                          autoderefref: ty::AutoDerefRef<'tcx>,
+                                          self_ty: Ty<'tcx>,
+                                          opt_input_types: Option<Vec<Ty<'tcx>>>)
+                                          -> Option<MethodCallee<'tcx>>
 {
     /*!
      * `lookup_in_trait_adjusted` is used for overloaded operators. It
@@ -308,11 +308,11 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
     Some(callee)
 }
 
-pub fn report_error(fcx: &FnCtxt,
-                    span: Span,
-                    rcvr_ty: Ty,
-                    method_name: ast::Name,
-                    error: MethodError)
+pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                              span: Span,
+                              rcvr_ty: Ty<'tcx>,
+                              method_name: ast::Name,
+                              error: MethodError)
 {
     match error {
         NoMatch(static_sources) => {
@@ -408,10 +408,10 @@ fn report_candidates(fcx: &FnCtxt,
     }
 }
 
-fn trait_method(tcx: &ty::ctxt,
-                trait_def_id: ast::DefId,
-                method_name: ast::Name)
-                -> Option<(uint, Rc<ty::Method>)>
+fn trait_method<'tcx>(tcx: &ty::ctxt<'tcx>,
+                      trait_def_id: ast::DefId,
+                      method_name: ast::Name)
+                      -> Option<(uint, Rc<ty::Method<'tcx>>)>
 {
     /*!
      * Find method with name `method_name` defined in `trait_def_id` and return it,
@@ -426,10 +426,10 @@ fn trait_method(tcx: &ty::ctxt,
         .and_then(|(idx, item)| item.as_opt_method().map(|m| (idx, m)))
 }
 
-fn impl_method(tcx: &ty::ctxt,
-               impl_def_id: ast::DefId,
-               method_name: ast::Name)
-               -> Option<Rc<ty::Method>>
+fn impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
+                     impl_def_id: ast::DefId,
+                     method_name: ast::Name)
+                     -> Option<Rc<ty::Method<'tcx>>>
 {
     let impl_items = tcx.impl_items.borrow();
     let impl_items = impl_items.get(&impl_def_id).unwrap();
index 1a1c19ddb1d9a70263673fc4d552af59b5f18074..921fd5bed8bd09e099c3c7a49dcebaaadf7950df 100644 (file)
@@ -37,49 +37,50 @@ struct ProbeContext<'a, 'tcx:'a> {
     fcx: &'a FnCtxt<'a, 'tcx>,
     span: Span,
     method_name: ast::Name,
-    steps: Rc<Vec<CandidateStep>>,
+    steps: Rc<Vec<CandidateStep<'tcx>>>,
     opt_simplified_steps: Option<Vec<fast_reject::SimplifiedType>>,
-    inherent_candidates: Vec<Candidate>,
-    extension_candidates: Vec<Candidate>,
+    inherent_candidates: Vec<Candidate<'tcx>>,
+    extension_candidates: Vec<Candidate<'tcx>>,
     impl_dups: HashSet<ast::DefId>,
     static_candidates: Vec<CandidateSource>,
 }
 
-struct CandidateStep {
-    self_ty: Ty,
+struct CandidateStep<'tcx> {
+    self_ty: Ty<'tcx>,
     adjustment: PickAdjustment,
 }
 
-struct Candidate {
-    xform_self_ty: Ty,
-    method_ty: Rc<ty::Method>,
-    kind: CandidateKind,
+struct Candidate<'tcx> {
+    xform_self_ty: Ty<'tcx>,
+    method_ty: Rc<ty::Method<'tcx>>,
+    kind: CandidateKind<'tcx>,
 }
 
-enum CandidateKind {
-    InherentImplCandidate(/* Impl */ ast::DefId, subst::Substs),
-    ObjectCandidate(MethodObject),
-    ExtensionImplCandidate(/* Impl */ ast::DefId, Rc<ty::TraitRef>, subst::Substs, MethodIndex),
+enum CandidateKind<'tcx> {
+    InherentImplCandidate(/* Impl */ ast::DefId, subst::Substs<'tcx>),
+    ObjectCandidate(MethodObject<'tcx>),
+    ExtensionImplCandidate(/* Impl */ ast::DefId, Rc<ty::TraitRef<'tcx>>,
+                           subst::Substs<'tcx>, MethodIndex),
     UnboxedClosureCandidate(/* Trait */ ast::DefId, MethodIndex),
-    WhereClauseCandidate(Rc<ty::TraitRef>, MethodIndex),
+    WhereClauseCandidate(Rc<ty::TraitRef<'tcx>>, MethodIndex),
 }
 
-pub struct Pick {
-    pub method_ty: Rc<ty::Method>,
+pub struct Pick<'tcx> {
+    pub method_ty: Rc<ty::Method<'tcx>>,
     pub adjustment: PickAdjustment,
-    pub kind: PickKind,
+    pub kind: PickKind<'tcx>,
 }
 
 #[deriving(Clone,Show)]
-pub enum PickKind {
+pub enum PickKind<'tcx> {
     InherentImplPick(/* Impl */ ast::DefId),
     ObjectPick(/* Trait */ ast::DefId, /* method_num */ uint, /* real_index */ uint),
     ExtensionImplPick(/* Impl */ ast::DefId, MethodIndex),
     TraitPick(/* Trait */ ast::DefId, MethodIndex),
-    WhereClausePick(/* Trait */ Rc<ty::TraitRef>, MethodIndex),
+    WhereClausePick(/* Trait */ Rc<ty::TraitRef<'tcx>>, MethodIndex),
 }
 
-pub type PickResult = Result<Pick, MethodError>;
+pub type PickResult<'tcx> = Result<Pick<'tcx>, MethodError>;
 
 // This is a kind of "abstracted" version of ty::AutoAdjustment.  The
 // difference is that it doesn't embed any regions or other
@@ -105,12 +106,12 @@ pub enum PickAdjustment {
     AutoRef(ast::Mutability, Box<PickAdjustment>),
 }
 
-pub fn probe(fcx: &FnCtxt,
-             span: Span,
-             method_name: ast::Name,
-             self_ty: Ty,
-             call_expr_id: ast::NodeId)
-             -> PickResult
+pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                       span: Span,
+                       method_name: ast::Name,
+                       self_ty: Ty<'tcx>,
+                       call_expr_id: ast::NodeId)
+                       -> PickResult<'tcx>
 {
     debug!("probe(self_ty={}, method_name={}, call_expr_id={})",
            self_ty.repr(fcx.tcx()),
@@ -157,7 +158,10 @@ pub fn probe(fcx: &FnCtxt,
     })
 }
 
-fn create_steps(fcx: &FnCtxt, span: Span, self_ty: Ty) -> Vec<CandidateStep> {
+fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                          span: Span,
+                          self_ty: Ty<'tcx>)
+                          -> Vec<CandidateStep<'tcx>> {
     let mut steps = Vec::new();
 
     let (fully_dereferenced_ty, dereferences, _) =
@@ -195,7 +199,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
     fn new(fcx: &'a FnCtxt<'a,'tcx>,
            span: Span,
            method_name: ast::Name,
-           steps: Vec<CandidateStep>,
+           steps: Vec<CandidateStep<'tcx>>,
            opt_simplified_steps: Option<Vec<fast_reject::SimplifiedType>>)
            -> ProbeContext<'a,'tcx>
     {
@@ -230,7 +234,7 @@ fn assemble_inherent_candidates(&mut self) {
         }
     }
 
-    fn assemble_probe(&mut self, self_ty: Ty) {
+    fn assemble_probe(&mut self, self_ty: Ty<'tcx>) {
         debug!("assemble_probe: self_ty={}",
                self_ty.repr(self.tcx()));
 
@@ -293,8 +297,8 @@ fn assemble_inherent_impl_probe(&mut self, impl_def_id: ast::DefId) {
     }
 
     fn assemble_inherent_candidates_from_object(&mut self,
-                                                self_ty: Ty,
-                                                principal: &ty::TraitRef,
+                                                self_ty: Ty<'tcx>,
+                                                principal: &ty::TraitRef<'tcx>,
                                                 _bounds: ty::ExistentialBounds) {
         debug!("assemble_inherent_candidates_from_object(self_ty={})",
                self_ty.repr(self.tcx()));
@@ -353,8 +357,8 @@ fn assemble_inherent_candidates_from_object(&mut self,
     }
 
     fn assemble_inherent_candidates_from_param(&mut self,
-                                           _rcvr_ty: Ty,
-                                           param_ty: ty::ParamTy) {
+                                               _rcvr_ty: Ty<'tcx>,
+                                               param_ty: ty::ParamTy) {
         // FIXME -- Do we want to commit to this behavior for param bounds?
 
         let ty::ParamTy { space, idx: index, .. } = param_ty;
@@ -397,11 +401,11 @@ fn assemble_inherent_candidates_from_param(&mut self,
     // create the candidates.
     fn elaborate_bounds(
         &mut self,
-        bounds: &[Rc<ty::TraitRef>],
-        mk_cand: |this: &mut ProbeContext,
-                  tr: Rc<ty::TraitRef>,
-                  m: Rc<ty::Method>,
-                  method_num: uint|)
+        bounds: &[Rc<ty::TraitRef<'tcx>>],
+        mk_cand: for<'a> |this: &mut ProbeContext<'a, 'tcx>,
+                          tr: Rc<ty::TraitRef<'tcx>>,
+                          m: Rc<ty::Method<'tcx>>,
+                          method_num: uint|)
     {
         let tcx = self.tcx();
         let mut cache = HashSet::new();
@@ -475,7 +479,7 @@ fn assemble_extension_candidates_for_trait(&mut self,
 
     fn assemble_extension_candidates_for_trait_impls(&mut self,
                                                      trait_def_id: ast::DefId,
-                                                     method: Rc<ty::Method>,
+                                                     method: Rc<ty::Method<'tcx>>,
                                                      method_index: uint)
     {
         ty::populate_implementations_for_trait_if_necessary(self.tcx(),
@@ -539,7 +543,7 @@ fn impl_can_possibly_match(&self, impl_def_id: ast::DefId) -> bool {
 
     fn assemble_unboxed_closure_candidates(&mut self,
                                            trait_def_id: ast::DefId,
-                                           method_ty: Rc<ty::Method>,
+                                           method_ty: Rc<ty::Method<'tcx>>,
                                            method_index: uint)
     {
         // Check if this is one of the Fn,FnMut,FnOnce traits.
@@ -600,7 +604,7 @@ fn assemble_unboxed_closure_candidates(&mut self,
     ///////////////////////////////////////////////////////////////////////////
     // THE ACTUAL SEARCH
 
-    fn pick(mut self) -> PickResult {
+    fn pick(mut self) -> PickResult<'tcx> {
         let steps = self.steps.clone();
 
         for step in steps.iter() {
@@ -615,7 +619,7 @@ fn pick(mut self) -> PickResult {
         Err(NoMatch(self.static_candidates))
     }
 
-    fn pick_step(&mut self, step: &CandidateStep) -> Option<PickResult> {
+    fn pick_step(&mut self, step: &CandidateStep<'tcx>) -> Option<PickResult<'tcx>> {
         debug!("pick_step: step={}", step.repr(self.tcx()));
 
         if ty::type_is_error(step.self_ty) {
@@ -641,15 +645,15 @@ fn pick_step(&mut self, step: &CandidateStep) -> Option<PickResult> {
     }
 
     fn pick_adjusted_method(&mut self,
-                            step: &CandidateStep)
-                            -> Option<PickResult>
+                            step: &CandidateStep<'tcx>)
+                            -> Option<PickResult<'tcx>>
     {
         self.pick_method(step.self_ty).map(|r| self.adjust(r, step.adjustment.clone()))
     }
 
     fn pick_autorefd_method(&mut self,
-                            step: &CandidateStep)
-                            -> Option<PickResult>
+                            step: &CandidateStep<'tcx>)
+                            -> Option<PickResult<'tcx>>
     {
         let tcx = self.tcx();
         self.search_mutabilities(
@@ -658,8 +662,8 @@ fn pick_autorefd_method(&mut self,
     }
 
     fn pick_autorefrefd_method(&mut self,
-                               step: &CandidateStep)
-                               -> Option<PickResult>
+                               step: &CandidateStep<'tcx>)
+                               -> Option<PickResult<'tcx>>
     {
         let tcx = self.tcx();
         self.search_mutabilities(
@@ -671,8 +675,8 @@ fn pick_autorefrefd_method(&mut self,
 
     fn search_mutabilities(&mut self,
                            mk_adjustment: |ast::Mutability| -> PickAdjustment,
-                           mk_autoref_ty: |ast::Mutability, ty::Region| -> Ty)
-                           -> Option<PickResult>
+                           mk_autoref_ty: |ast::Mutability, ty::Region| -> Ty<'tcx>)
+                           -> Option<PickResult<'tcx>>
     {
         // In general, during probing we erase regions. See
         // `impl_self_ty()` for an explanation.
@@ -690,7 +694,10 @@ fn search_mutabilities(&mut self,
             .nth(0)
     }
 
-    fn adjust(&mut self, result: PickResult, adjustment: PickAdjustment) -> PickResult {
+    fn adjust(&mut self,
+              result: PickResult<'tcx>,
+              adjustment: PickAdjustment)
+              -> PickResult<'tcx> {
         match result {
             Err(e) => Err(e),
             Ok(mut pick) => {
@@ -700,7 +707,7 @@ fn adjust(&mut self, result: PickResult, adjustment: PickAdjustment) -> PickResu
         }
     }
 
-    fn pick_method(&mut self, self_ty: Ty) -> Option<PickResult> {
+    fn pick_method(&mut self, self_ty: Ty<'tcx>) -> Option<PickResult<'tcx>> {
         debug!("pick_method(self_ty={})", self.infcx().ty_to_string(self_ty));
 
         debug!("searching inherent candidates");
@@ -715,7 +722,10 @@ fn pick_method(&mut self, self_ty: Ty) -> Option<PickResult> {
         self.consider_candidates(self_ty, self.extension_candidates[])
     }
 
-    fn consider_candidates(&self, self_ty: Ty, probes: &[Candidate]) -> Option<PickResult> {
+    fn consider_candidates(&self,
+                           self_ty: Ty<'tcx>,
+                           probes: &[Candidate<'tcx>])
+                           -> Option<PickResult<'tcx>> {
         let mut applicable_candidates: Vec<_> =
             probes.iter()
                   .filter(|&probe| self.consider_probe(self_ty, probe))
@@ -741,7 +751,7 @@ fn consider_candidates(&self, self_ty: Ty, probes: &[Candidate]) -> Option<PickR
         })
     }
 
-    fn consider_probe(&self, self_ty: Ty, probe: &Candidate) -> bool {
+    fn consider_probe(&self, self_ty: Ty<'tcx>, probe: &Candidate<'tcx>) -> bool {
         debug!("consider_probe: self_ty={} probe={}",
                self_ty.repr(self.tcx()),
                probe.repr(self.tcx()));
@@ -797,7 +807,9 @@ fn consider_probe(&self, self_ty: Ty, probe: &Candidate) -> bool {
         })
     }
 
-    fn collapse_candidates_to_trait_pick(&self, probes: &[&Candidate]) -> Option<Pick> {
+    fn collapse_candidates_to_trait_pick(&self,
+                                         probes: &[&Candidate<'tcx>])
+                                         -> Option<Pick<'tcx>> {
         /*!
          * Sometimes we get in a situation where we have multiple
          * probes that are all impls of the same trait, but we don't
@@ -844,7 +856,7 @@ fn collapse_candidates_to_trait_pick(&self, probes: &[&Candidate]) -> Option<Pic
     ///////////////////////////////////////////////////////////////////////////
     // MISCELLANY
 
-    fn make_sub_ty(&self, sub: Ty, sup: Ty) -> infer::ures {
+    fn make_sub_ty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>) -> infer::ures<'tcx> {
         self.infcx().sub_types(false, infer::Misc(DUMMY_SP), sub, sup)
     }
 
@@ -874,7 +886,10 @@ fn record_static_candidate(&mut self, source: CandidateSource) {
         self.static_candidates.push(source);
     }
 
-    fn xform_self_ty(&self, method: &Rc<ty::Method>, substs: &subst::Substs) -> Ty {
+    fn xform_self_ty(&self,
+                     method: &Rc<ty::Method<'tcx>>,
+                     substs: &subst::Substs<'tcx>)
+                     -> Ty<'tcx> {
         debug!("xform_self_ty(self_ty={}, substs={})",
                method.fty.sig.inputs[0].repr(self.tcx()),
                substs.repr(self.tcx()));
@@ -922,7 +937,7 @@ fn xform_self_ty(&self, method: &Rc<ty::Method>, substs: &subst::Substs) -> Ty {
 
     fn impl_substs(&self,
                    impl_def_id: ast::DefId)
-                   -> subst::Substs
+                   -> subst::Substs<'tcx>
     {
         let impl_pty = ty::lookup_item_type(self.tcx(), impl_def_id);
 
@@ -938,7 +953,7 @@ fn impl_substs(&self,
     }
 
     fn erase_late_bound_regions<T>(&self, value: &T) -> T
-        where T : HigherRankedFoldable
+        where T : HigherRankedFoldable<'tcx>
     {
         /*!
          * Replace late-bound-regions bound by `value` with `'static`
@@ -971,10 +986,10 @@ fn erase_late_bound_regions<T>(&self, value: &T) -> T
     }
 }
 
-fn impl_method(tcx: &ty::ctxt,
-               impl_def_id: ast::DefId,
-               method_name: ast::Name)
-               -> Option<Rc<ty::Method>>
+fn impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
+                     impl_def_id: ast::DefId,
+                     method_name: ast::Name)
+                     -> Option<Rc<ty::Method<'tcx>>>
 {
     let impl_items = tcx.impl_items.borrow();
     let impl_items = impl_items.get(&impl_def_id).unwrap();
@@ -985,10 +1000,10 @@ fn impl_method(tcx: &ty::ctxt,
         .and_then(|item| item.as_opt_method())
 }
 
-fn trait_method(tcx: &ty::ctxt,
-                trait_def_id: ast::DefId,
-                method_name: ast::Name)
-                -> Option<(uint, Rc<ty::Method>)>
+fn trait_method<'tcx>(tcx: &ty::ctxt<'tcx>,
+                      trait_def_id: ast::DefId,
+                      method_name: ast::Name)
+                      -> Option<(uint, Rc<ty::Method<'tcx>>)>
 {
     /*!
      * Find method with name `method_name` defined in `trait_def_id` and return it,
@@ -1005,10 +1020,10 @@ fn trait_method(tcx: &ty::ctxt,
 
 // Determine the index of a method in the list of all methods belonging
 // to a trait and its supertraits.
-fn get_method_index(tcx: &ty::ctxt,
-                    trait_ref: &ty::TraitRef,
-                    subtrait: Rc<ty::TraitRef>,
-                    n_method: uint) -> uint {
+fn get_method_index<'tcx>(tcx: &ty::ctxt<'tcx>,
+                          trait_ref: &ty::TraitRef<'tcx>,
+                          subtrait: Rc<ty::TraitRef<'tcx>>,
+                          n_method: uint) -> uint {
     // We need to figure the "real index" of the method in a
     // listing of all the methods of an object. We do this by
     // iterating down the supertraits of the object's trait until
@@ -1032,8 +1047,8 @@ fn get_method_index(tcx: &ty::ctxt,
     method_count + n_method
 }
 
-impl Candidate {
-    fn to_unadjusted_pick(&self) -> Pick {
+impl<'tcx> Candidate<'tcx> {
+    fn to_unadjusted_pick(&self) -> Pick<'tcx> {
         Pick {
             method_ty: self.method_ty.clone(),
             adjustment: AutoDeref(0),
@@ -1091,16 +1106,16 @@ fn to_trait_data(&self) -> Option<(ast::DefId,MethodIndex)> {
     }
 }
 
-impl Repr for Candidate {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for Candidate<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("Candidate(xform_self_ty={}, kind={})",
                 self.xform_self_ty.repr(tcx),
                 self.kind.repr(tcx))
     }
 }
 
-impl Repr for CandidateKind {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for CandidateKind<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             InherentImplCandidate(ref a, ref b) =>
                 format!("InherentImplCandidate({},{})", a.repr(tcx), b.repr(tcx)),
@@ -1117,28 +1132,28 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl Repr for CandidateStep {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for CandidateStep<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("CandidateStep({},{})",
                 self.self_ty.repr(tcx),
                 self.adjustment)
     }
 }
 
-impl Repr for PickAdjustment {
+impl<'tcx> Repr<'tcx> for PickAdjustment {
     fn repr(&self, _tcx: &ty::ctxt) -> String {
         format!("{}", self)
     }
 }
 
-impl Repr for PickKind {
+impl<'tcx> Repr<'tcx> for PickKind<'tcx> {
     fn repr(&self, _tcx: &ty::ctxt) -> String {
         format!("{}", self)
     }
 }
 
-impl Repr for Pick {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for Pick<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("Pick(method_ty={}, adjustment={}, kind={})",
                 self.method_ty.repr(tcx),
                 self.adjustment,
index 92518aada27daf12217b424fb75780190150bfc1..dcc5cfa760eaad971764f3ffe186e3a66a695680 100644 (file)
 /// share the inherited fields.
 pub struct Inherited<'a, 'tcx: 'a> {
     infcx: infer::InferCtxt<'a, 'tcx>,
-    locals: RefCell<NodeMap<Ty>>,
-    param_env: ty::ParameterEnvironment,
+    locals: RefCell<NodeMap<Ty<'tcx>>>,
+    param_env: ty::ParameterEnvironment<'tcx>,
 
     // Temporary tables:
-    node_types: RefCell<NodeMap<Ty>>,
-    item_substs: RefCell<NodeMap<ty::ItemSubsts>>,
-    adjustments: RefCell<NodeMap<ty::AutoAdjustment>>,
-    method_map: MethodMap,
+    node_types: RefCell<NodeMap<Ty<'tcx>>>,
+    item_substs: RefCell<NodeMap<ty::ItemSubsts<'tcx>>>,
+    adjustments: RefCell<NodeMap<ty::AutoAdjustment<'tcx>>>,
+    method_map: MethodMap<'tcx>,
     upvar_borrow_map: RefCell<ty::UpvarBorrowMap>,
-    unboxed_closures: RefCell<DefIdMap<ty::UnboxedClosure>>,
-    object_cast_map: ObjectCastMap,
+    unboxed_closures: RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>>,
+    object_cast_map: ObjectCastMap<'tcx>,
 
     // A mapping from each fn's id to its signature, with all bound
     // regions replaced with free ones. Unlike the other tables, this
     // one is never copied into the tcx: it is only used by regionck.
-    fn_sig_map: RefCell<NodeMap<Vec<Ty>>>,
+    fn_sig_map: RefCell<NodeMap<Vec<Ty<'tcx>>>>,
 
     // A set of constraints that regionck must validate. Each
     // constraint has the form `T:'a`, meaning "some type `T` must
@@ -201,29 +201,29 @@ pub struct Inherited<'a, 'tcx: 'a> {
     // regionck to be sure that it has found *all* the region
     // obligations (otherwise, it's easy to fail to walk to a
     // particular node-id).
-    region_obligations: RefCell<NodeMap<Vec<RegionObligation>>>,
+    region_obligations: RefCell<NodeMap<Vec<RegionObligation<'tcx>>>>,
 
     // Tracks trait obligations incurred during this function body.
-    fulfillment_cx: RefCell<traits::FulfillmentContext>,
+    fulfillment_cx: RefCell<traits::FulfillmentContext<'tcx>>,
 }
 
-struct RegionObligation {
+struct RegionObligation<'tcx> {
     sub_region: ty::Region,
-    sup_type: Ty,
-    origin: infer::SubregionOrigin,
+    sup_type: Ty<'tcx>,
+    origin: infer::SubregionOrigin<'tcx>,
 }
 
 /// When type-checking an expression, we propagate downward
 /// whatever type hint we are able in the form of an `Expectation`.
-enum Expectation {
+enum Expectation<'tcx> {
     /// We know nothing about what type this expression should have.
     NoExpectation,
 
     /// This expression should have the type given (or some subtype)
-    ExpectHasType(Ty),
+    ExpectHasType(Ty<'tcx>),
 
     /// This expression will be cast to the `Ty`
-    ExpectCastableToType(Ty),
+    ExpectCastableToType(Ty<'tcx>),
 }
 
 #[deriving(Clone)]
@@ -282,7 +282,7 @@ pub struct FnCtxt<'a, 'tcx: 'a> {
     // expects the types within the function to be consistent.
     err_count_on_creation: uint,
 
-    ret_ty: ty::FnOutput,
+    ret_ty: ty::FnOutput<'tcx>,
 
     ps: RefCell<FnStyleState>,
 
@@ -295,14 +295,14 @@ impl<'a, 'tcx> mem_categorization::Typer<'tcx> for FnCtxt<'a, 'tcx> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.ccx.tcx
     }
-    fn node_ty(&self, id: ast::NodeId) -> McResult<Ty> {
+    fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>> {
         Ok(self.node_ty(id))
     }
     fn node_method_ty(&self, method_call: typeck::MethodCall)
-                      -> Option<Ty> {
+                      -> Option<Ty<'tcx>> {
         self.inh.method_map.borrow().get(&method_call).map(|m| m.ty)
     }
-    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
+    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
         &self.inh.adjustments
     }
     fn is_method_call(&self, id: ast::NodeId) -> bool {
@@ -318,14 +318,15 @@ fn capture_mode(&self, closure_expr_id: ast::NodeId)
                     -> ast::CaptureClause {
         self.ccx.tcx.capture_mode(closure_expr_id)
     }
-    fn unboxed_closures<'a>(&'a self) -> &'a RefCell<DefIdMap<ty::UnboxedClosure>> {
+    fn unboxed_closures<'a>(&'a self)
+                        -> &'a RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>> {
         &self.inh.unboxed_closures
     }
 }
 
 impl<'a, 'tcx> Inherited<'a, 'tcx> {
     fn new(tcx: &'a ty::ctxt<'tcx>,
-           param_env: ty::ParameterEnvironment)
+           param_env: ty::ParameterEnvironment<'tcx>)
            -> Inherited<'a, 'tcx> {
         Inherited {
             infcx: infer::new_infer_ctxt(tcx),
@@ -348,7 +349,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
 // Used by check_const and check_enum_variants
 pub fn blank_fn_ctxt<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
                                inh: &'a Inherited<'a, 'tcx>,
-                               rty: ty::FnOutput,
+                               rty: ty::FnOutput<'tcx>,
                                body_id: ast::NodeId)
                                -> FnCtxt<'a, 'tcx> {
     FnCtxt {
@@ -394,12 +395,12 @@ pub fn check_item_types(ccx: &CrateCtxt) {
     ccx.tcx.sess.abort_if_errors();
 }
 
-fn check_bare_fn(ccx: &CrateCtxt,
-                 decl: &ast::FnDecl,
-                 body: &ast::Block,
-                 id: ast::NodeId,
-                 fty: Ty,
-                 param_env: ty::ParameterEnvironment) {
+fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                           decl: &ast::FnDecl,
+                           body: &ast::Block,
+                           id: ast::NodeId,
+                           fty: Ty<'tcx>,
+                           param_env: ty::ParameterEnvironment<'tcx>) {
     // Compute the fty from point of view of inside fn
     // (replace any type-scheme with a type)
     let fty = fty.subst(ccx.tcx, &param_env.free_substs);
@@ -425,7 +426,7 @@ struct GatherLocalsVisitor<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
-    fn assign(&mut self, _span: Span, nid: ast::NodeId, ty_opt: Option<Ty>) -> Ty {
+    fn assign(&mut self, _span: Span, nid: ast::NodeId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
         match ty_opt {
             None => {
                 // infer the variable's type
@@ -507,7 +508,7 @@ fn visit_item(&mut self, _: &ast::Item) { }
 fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
                       fn_style: ast::FnStyle,
                       fn_style_id: ast::NodeId,
-                      fn_sig: &ty::FnSig,
+                      fn_sig: &ty::FnSig<'tcx>,
                       decl: &ast::FnDecl,
                       fn_id: ast::NodeId,
                       body: &ast::Block,
@@ -719,9 +720,9 @@ pub fn check_item(ccx: &CrateCtxt, it: &ast::Item) {
     }
 }
 
-fn check_method_body(ccx: &CrateCtxt,
-                     item_generics: &ty::Generics,
-                     method: &ast::Method) {
+fn check_method_body<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                               item_generics: &ty::Generics<'tcx>,
+                               method: &ast::Method) {
     /*!
      * Type checks a method body.
      *
@@ -752,11 +753,11 @@ fn check_method_body(ccx: &CrateCtxt,
                   param_env);
 }
 
-fn check_impl_items_against_trait(ccx: &CrateCtxt,
-                                  impl_span: Span,
-                                  ast_trait_ref: &ast::TraitRef,
-                                  impl_trait_ref: &ty::TraitRef,
-                                  impl_items: &[ast::ImplItem]) {
+fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                            impl_span: Span,
+                                            ast_trait_ref: &ast::TraitRef,
+                                            impl_trait_ref: &ty::TraitRef<'tcx>,
+                                            impl_items: &[ast::ImplItem]) {
     // Locate trait methods
     let tcx = ccx.tcx;
     let trait_items = ty::trait_items(tcx, impl_trait_ref.def_id);
@@ -927,12 +928,12 @@ trait `{}`",
  * - trait_m: the method in the trait
  * - trait_to_impl_substs: the substitutions used on the type of the trait
  */
-fn compare_impl_method(tcx: &ty::ctxt,
-                       impl_m: &ty::Method,
-                       impl_m_span: Span,
-                       impl_m_body_id: ast::NodeId,
-                       trait_m: &ty::Method,
-                       impl_trait_ref: &ty::TraitRef) {
+fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
+                             impl_m: &ty::Method<'tcx>,
+                             impl_m_span: Span,
+                             impl_m_body_id: ast::NodeId,
+                             trait_m: &ty::Method<'tcx>,
+                             impl_trait_ref: &ty::TraitRef<'tcx>) {
     debug!("compare_impl_method(impl_trait_ref={})",
            impl_trait_ref.repr(tcx));
 
@@ -1236,15 +1237,15 @@ fn compare_impl_method(tcx: &ty::ctxt,
     // parameters.
     infcx.resolve_regions_and_report_errors();
 
-    fn check_region_bounds_on_impl_method(tcx: &ty::ctxt,
-                                          span: Span,
-                                          impl_m: &ty::Method,
-                                          impl_m_body_id: ast::NodeId,
-                                          trait_generics: &ty::Generics,
-                                          impl_generics: &ty::Generics,
-                                          trait_to_skol_substs: &Substs,
-                                          impl_to_skol_substs: &Substs)
-                                          -> bool
+    fn check_region_bounds_on_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                                span: Span,
+                                                impl_m: &ty::Method<'tcx>,
+                                                impl_m_body_id: ast::NodeId,
+                                                trait_generics: &ty::Generics<'tcx>,
+                                                impl_generics: &ty::Generics<'tcx>,
+                                                trait_to_skol_substs: &Substs<'tcx>,
+                                                impl_to_skol_substs: &Substs<'tcx>)
+                                                -> bool
     {
         /*!
 
@@ -1514,8 +1515,8 @@ fn check_cast(fcx: &FnCtxt,
         span_err!(fcx.tcx().sess, span, E0054,
             "cannot cast as `bool`, compare with zero instead");
     } else if ty::type_is_region_ptr(t_e) && ty::type_is_unsafe_ptr(t_1) {
-        fn types_compatible(fcx: &FnCtxt, sp: Span,
-                            t1: Ty, t2: Ty) -> bool {
+        fn types_compatible<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
+                                      t1: Ty<'tcx>, t2: Ty<'tcx>) -> bool {
             match ty::get(t1).sty {
                 ty::ty_vec(_, Some(_)) => {}
                 _ => return false
@@ -1580,15 +1581,15 @@ fn types_compatible(fcx: &FnCtxt, sp: Span,
 impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.ccx.tcx }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         ty::lookup_item_type(self.tcx(), id)
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         ty::lookup_trait_def(self.tcx(), id)
     }
 
-    fn ty_infer(&self, _span: Span) -> Ty {
+    fn ty_infer(&self, _span: Span) -> Ty<'tcx> {
         self.infcx().next_ty_var()
     }
 
@@ -1599,10 +1600,10 @@ fn associated_types_of_trait_are_valid(&self, _: Ty, _: ast::DefId)
 
     fn associated_type_binding(&self,
                                span: Span,
-                               _: Option<Ty>,
+                               _: Option<Ty<'tcx>>,
                                _: ast::DefId,
                                _: ast::DefId)
-                               -> Ty {
+                               -> Ty<'tcx> {
         self.tcx().sess.span_err(span, "unsupported associated type binding");
         ty::mk_err()
     }
@@ -1642,7 +1643,7 @@ pub fn tag(&self) -> String {
         format!("{}", self as *const FnCtxt)
     }
 
-    pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> Ty {
+    pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> Ty<'tcx> {
         match self.inh.locals.borrow().get(&nid) {
             Some(&t) => t,
             None => {
@@ -1663,7 +1664,7 @@ pub fn default_diverging_type_variables_to_nil(&self) {
     }
 
     #[inline]
-    pub fn write_ty(&self, node_id: ast::NodeId, ty: Ty) {
+    pub fn write_ty(&self, node_id: ast::NodeId, ty: Ty<'tcx>) {
         debug!("write_ty({}, {}) in fcx {}",
                node_id, ppaux::ty_to_string(self.tcx(), ty), self.tag());
         self.inh.node_types.borrow_mut().insert(node_id, ty);
@@ -1671,13 +1672,13 @@ pub fn write_ty(&self, node_id: ast::NodeId, ty: Ty) {
 
     pub fn write_object_cast(&self,
                              key: ast::NodeId,
-                             trait_ref: Rc<ty::TraitRef>) {
+                             trait_ref: Rc<ty::TraitRef<'tcx>>) {
         debug!("write_object_cast key={} trait_ref={}",
                key, trait_ref.repr(self.tcx()));
         self.inh.object_cast_map.borrow_mut().insert(key, trait_ref);
     }
 
-    pub fn write_substs(&self, node_id: ast::NodeId, substs: ty::ItemSubsts) {
+    pub fn write_substs(&self, node_id: ast::NodeId, substs: ty::ItemSubsts<'tcx>) {
         if !substs.substs.is_noop() {
             debug!("write_substs({}, {}) in fcx {}",
                    node_id,
@@ -1705,7 +1706,7 @@ pub fn write_autoderef_adjustment(&self,
     pub fn write_adjustment(&self,
                             node_id: ast::NodeId,
                             span: Span,
-                            adj: ty::AutoAdjustment) {
+                            adj: ty::AutoAdjustment<'tcx>) {
         debug!("write_adjustment(node_id={}, adj={})", node_id, adj);
 
         if adj.is_identity() {
@@ -1724,7 +1725,7 @@ pub fn write_adjustment(&self,
 
     fn register_adjustment_obligations(&self,
                                        span: Span,
-                                       adj: &ty::AutoAdjustment) {
+                                       adj: &ty::AutoAdjustment<'tcx>) {
         match *adj {
             ty::AdjustAddEnv(..) => { }
             ty::AdjustDerefRef(ref d_r) => {
@@ -1740,7 +1741,7 @@ fn register_adjustment_obligations(&self,
 
     fn register_autoref_obligations(&self,
                                     span: Span,
-                                    autoref: &ty::AutoRef) {
+                                    autoref: &ty::AutoRef<'tcx>) {
         match *autoref {
             ty::AutoUnsize(ref unsize) => {
                 self.register_unsize_obligations(span, unsize);
@@ -1760,7 +1761,7 @@ fn register_autoref_obligations(&self,
 
     fn register_unsize_obligations(&self,
                                    span: Span,
-                                   unsize: &ty::UnsizeKind) {
+                                   unsize: &ty::UnsizeKind<'tcx>) {
         debug!("register_unsize_obligations: unsize={}", unsize);
 
         match *unsize {
@@ -1788,7 +1789,7 @@ fn register_unsize_obligations(&self,
     pub fn instantiate_type(&self,
                             span: Span,
                             def_id: ast::DefId)
-                            -> TypeAndSubsts
+                            -> TypeAndSubsts<'tcx>
     {
         /*!
          * Returns the type of `def_id` with all generics replaced by
@@ -1833,9 +1834,9 @@ pub fn write_error(&self, node_id: ast::NodeId) {
     }
 
     pub fn require_type_meets(&self,
-                              ty: Ty,
+                              ty: Ty<'tcx>,
                               span: Span,
-                              code: traits::ObligationCauseCode,
+                              code: traits::ObligationCauseCode<'tcx>,
                               bound: ty::BuiltinBound)
     {
         let obligation = traits::obligation_for_builtin_bound(
@@ -1850,22 +1851,22 @@ pub fn require_type_meets(&self,
     }
 
     pub fn require_type_is_sized(&self,
-                                 ty: Ty,
+                                 ty: Ty<'tcx>,
                                  span: Span,
-                                 code: traits::ObligationCauseCode)
+                                 code: traits::ObligationCauseCode<'tcx>)
     {
         self.require_type_meets(ty, span, code, ty::BoundSized);
     }
 
     pub fn require_expr_have_sized_type(&self,
                                         expr: &ast::Expr,
-                                        code: traits::ObligationCauseCode)
+                                        code: traits::ObligationCauseCode<'tcx>)
     {
         self.require_type_is_sized(self.expr_ty(expr), expr.span, code);
     }
 
     pub fn register_obligation(&self,
-                               obligation: traits::Obligation)
+                               obligation: traits::Obligation<'tcx>)
     {
         debug!("register_obligation({})",
                obligation.repr(self.tcx()));
@@ -1875,7 +1876,7 @@ pub fn register_obligation(&self,
             .register_obligation(self.tcx(), obligation);
     }
 
-    pub fn to_ty(&self, ast_t: &ast::Ty) -> Ty {
+    pub fn to_ty(&self, ast_t: &ast::Ty) -> Ty<'tcx> {
         let t = ast_ty_to_ty(self, self.infcx(), ast_t);
 
         let mut bounds_checker = wf::BoundsChecker::new(self,
@@ -1891,7 +1892,7 @@ pub fn pat_to_string(&self, pat: &ast::Pat) -> String {
         pat.repr(self.tcx())
     }
 
-    pub fn expr_ty(&self, ex: &ast::Expr) -> Ty {
+    pub fn expr_ty(&self, ex: &ast::Expr) -> Ty<'tcx> {
         match self.inh.node_types.borrow().get(&ex.id) {
             Some(&t) => t,
             None => {
@@ -1901,7 +1902,7 @@ pub fn expr_ty(&self, ex: &ast::Expr) -> Ty {
         }
     }
 
-    pub fn expr_ty_adjusted(&self, expr: &ast::Expr) -> Ty {
+    pub fn expr_ty_adjusted(&self, expr: &ast::Expr) -> Ty<'tcx> {
         /*!
          * Fetch type of `expr` after applying adjustments that
          * have been recorded in the fcx.
@@ -1914,8 +1915,8 @@ pub fn expr_ty_adjusted(&self, expr: &ast::Expr) -> Ty {
 
     pub fn adjust_expr_ty(&self,
                           expr: &ast::Expr,
-                          adjustment: Option<&ty::AutoAdjustment>)
-                          -> Ty
+                          adjustment: Option<&ty::AutoAdjustment<'tcx>>)
+                          -> Ty<'tcx>
     {
         /*!
          * Apply `adjustment` to the type of `expr`
@@ -1933,7 +1934,7 @@ pub fn adjust_expr_ty(&self,
                                                        .map(|method| method.ty))
     }
 
-    pub fn node_ty(&self, id: ast::NodeId) -> Ty {
+    pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
         match self.inh.node_types.borrow().get(&id) {
             Some(&t) => t,
             None => {
@@ -1945,13 +1946,13 @@ pub fn node_ty(&self, id: ast::NodeId) -> Ty {
         }
     }
 
-    pub fn item_substs<'a>(&'a self) -> Ref<'a, NodeMap<ty::ItemSubsts>> {
+    pub fn item_substs<'a>(&'a self) -> Ref<'a, NodeMap<ty::ItemSubsts<'tcx>>> {
         self.inh.item_substs.borrow()
     }
 
     pub fn opt_node_ty_substs(&self,
                               id: ast::NodeId,
-                              f: |&ty::ItemSubsts|) {
+                              f: |&ty::ItemSubsts<'tcx>|) {
         match self.inh.item_substs.borrow().get(&id) {
             Some(s) => { f(s) }
             None => { }
@@ -1961,27 +1962,27 @@ pub fn opt_node_ty_substs(&self,
     pub fn mk_subty(&self,
                     a_is_expected: bool,
                     origin: infer::TypeOrigin,
-                    sub: Ty,
-                    sup: Ty)
-                    -> Result<(), ty::type_err> {
+                    sub: Ty<'tcx>,
+                    sup: Ty<'tcx>)
+                    -> Result<(), ty::type_err<'tcx>> {
         infer::mk_subty(self.infcx(), a_is_expected, origin, sub, sup)
     }
 
-    pub fn can_mk_subty(&self, sub: Ty, sup: Ty)
-                        -> Result<(), ty::type_err> {
+    pub fn can_mk_subty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>)
+                        -> Result<(), ty::type_err<'tcx>> {
         infer::can_mk_subty(self.infcx(), sub, sup)
     }
 
-    pub fn can_mk_eqty(&self, sub: Ty, sup: Ty)
-                       -> Result<(), ty::type_err> {
+    pub fn can_mk_eqty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>)
+                       -> Result<(), ty::type_err<'tcx>> {
         infer::can_mk_eqty(self.infcx(), sub, sup)
     }
 
     pub fn mk_assignty(&self,
                        expr: &ast::Expr,
-                       sub: Ty,
-                       sup: Ty)
-                       -> Result<(), ty::type_err> {
+                       sub: Ty<'tcx>,
+                       sup: Ty<'tcx>)
+                       -> Result<(), ty::type_err<'tcx>> {
         match infer::mk_coercety(self.infcx(),
                                  false,
                                  infer::ExprAssignable(expr.span),
@@ -1999,14 +2000,14 @@ pub fn mk_assignty(&self,
     pub fn mk_eqty(&self,
                    a_is_expected: bool,
                    origin: infer::TypeOrigin,
-                   sub: Ty,
-                   sup: Ty)
-                   -> Result<(), ty::type_err> {
+                   sub: Ty<'tcx>,
+                   sup: Ty<'tcx>)
+                   -> Result<(), ty::type_err<'tcx>> {
         infer::mk_eqty(self.infcx(), a_is_expected, origin, sub, sup)
     }
 
     pub fn mk_subr(&self,
-                   origin: infer::SubregionOrigin,
+                   origin: infer::SubregionOrigin<'tcx>,
                    sub: ty::Region,
                    sup: ty::Region) {
         infer::mk_subr(self.infcx(), origin, sub, sup)
@@ -2015,22 +2016,22 @@ pub fn mk_subr(&self,
     pub fn type_error_message(&self,
                               sp: Span,
                               mk_msg: |String| -> String,
-                              actual_ty: Ty,
-                              err: Option<&ty::type_err>) {
+                              actual_ty: Ty<'tcx>,
+                              err: Option<&ty::type_err<'tcx>>) {
         self.infcx().type_error_message(sp, mk_msg, actual_ty, err);
     }
 
     pub fn report_mismatched_types(&self,
                                    sp: Span,
-                                   e: Ty,
-                                   a: Ty,
-                                   err: &ty::type_err) {
+                                   e: Ty<'tcx>,
+                                   a: Ty<'tcx>,
+                                   err: &ty::type_err<'tcx>) {
         self.infcx().report_mismatched_types(sp, e, a, err)
     }
 
     pub fn register_region_obligation(&self,
-                                      origin: infer::SubregionOrigin,
-                                      ty: Ty,
+                                      origin: infer::SubregionOrigin<'tcx>,
+                                      ty: Ty<'tcx>,
                                       r: ty::Region)
     {
         /*!
@@ -2050,9 +2051,9 @@ pub fn register_region_obligation(&self,
     }
 
     pub fn add_obligations_for_parameters(&self,
-                                          cause: traits::ObligationCause,
-                                          substs: &Substs,
-                                          generic_bounds: &ty::GenericBounds)
+                                          cause: traits::ObligationCause<'tcx>,
+                                          substs: &Substs<'tcx>,
+                                          generic_bounds: &ty::GenericBounds<'tcx>)
     {
         /*!
          * Given a fully substituted set of bounds (`generic_bounds`),
@@ -2085,9 +2086,9 @@ pub fn add_obligations_for_parameters(&self,
     }
 
     fn add_trait_obligations_for_generics(&self,
-                                          cause: traits::ObligationCause,
-                                          substs: &Substs,
-                                          generic_bounds: &ty::GenericBounds) {
+                                          cause: traits::ObligationCause<'tcx>,
+                                          substs: &Substs<'tcx>,
+                                          generic_bounds: &ty::GenericBounds<'tcx>) {
         assert!(!generic_bounds.has_escaping_regions());
         assert!(!substs.has_regions_escaping_depth(0));
 
@@ -2100,9 +2101,9 @@ fn add_trait_obligations_for_generics(&self,
     }
 
     fn add_region_obligations_for_generics(&self,
-                                           cause: traits::ObligationCause,
-                                           substs: &Substs,
-                                           generic_bounds: &ty::GenericBounds)
+                                           cause: traits::ObligationCause<'tcx>,
+                                           substs: &Substs<'tcx>,
+                                           generic_bounds: &ty::GenericBounds<'tcx>)
     {
         assert!(!generic_bounds.has_escaping_regions());
         assert_eq!(generic_bounds.types.iter().len(), substs.types.iter().len());
@@ -2128,8 +2129,8 @@ fn add_region_obligations_for_generics(&self,
 
     fn add_region_obligations_for_type_parameter(&self,
                                                  span: Span,
-                                                 param_bound: &ty::ParamBounds,
-                                                 ty: Ty)
+                                                 param_bound: &ty::ParamBounds<'tcx>,
+                                                 ty: Ty<'tcx>)
     {
         // For each declared region bound `T:r`, `T` must outlive `r`.
         let region_bounds =
@@ -2164,11 +2165,12 @@ pub enum LvaluePreference {
     NoPreference
 }
 
-pub fn autoderef<T>(fcx: &FnCtxt, sp: Span, base_ty: Ty,
-                    expr_id: Option<ast::NodeId>,
-                    mut lvalue_pref: LvaluePreference,
-                    should_stop: |Ty, uint| -> Option<T>)
-                    -> (Ty, uint, Option<T>) {
+pub fn autoderef<'a, 'tcx, T>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
+                              base_ty: Ty<'tcx>,
+                              expr_id: Option<ast::NodeId>,
+                              mut lvalue_pref: LvaluePreference,
+                              should_stop: |Ty<'tcx>, uint| -> Option<T>)
+                              -> (Ty<'tcx>, uint, Option<T>) {
     /*!
      * Executes an autoderef loop for the type `t`. At each step, invokes
      * `should_stop` to decide whether to terminate the loop. Returns
@@ -2219,12 +2221,12 @@ pub fn autoderef<T>(fcx: &FnCtxt, sp: Span, base_ty: Ty,
 }
 
 /// Attempts to resolve a call expression as an overloaded call.
-fn try_overloaded_call(fcx: &FnCtxt,
-                       call_expression: &ast::Expr,
-                       callee: &ast::Expr,
-                       callee_type: Ty,
-                       args: &[&P<ast::Expr>])
-                       -> bool {
+fn try_overloaded_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                 call_expression: &ast::Expr,
+                                 callee: &ast::Expr,
+                                 callee_type: Ty<'tcx>,
+                                 args: &[&P<ast::Expr>])
+                                 -> bool {
     // Bail out if the callee is a bare function or a closure. We check those
     // manually.
     match *structure_of(fcx, callee.span, callee_type) {
@@ -2278,13 +2280,13 @@ fn try_overloaded_call(fcx: &FnCtxt,
     false
 }
 
-fn try_overloaded_deref(fcx: &FnCtxt,
-                        span: Span,
-                        method_call: Option<MethodCall>,
-                        base_expr: Option<&ast::Expr>,
-                        base_ty: Ty,
-                        lvalue_pref: LvaluePreference)
-                        -> Option<ty::mt>
+fn try_overloaded_deref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                  span: Span,
+                                  method_call: Option<MethodCall>,
+                                  base_expr: Option<&ast::Expr>,
+                                  base_ty: Ty<'tcx>,
+                                  lvalue_pref: LvaluePreference)
+                                  -> Option<ty::mt<'tcx>>
 {
     // Try DerefMut first, if preferred.
     let method = match (lvalue_pref, fcx.tcx().lang_items.deref_mut_trait()) {
@@ -2309,10 +2311,10 @@ fn try_overloaded_deref(fcx: &FnCtxt,
     make_overloaded_lvalue_return_type(fcx, method_call, method)
 }
 
-fn make_overloaded_lvalue_return_type(fcx: &FnCtxt,
-                                      method_call: Option<MethodCall>,
-                                      method: Option<MethodCallee>)
-                                      -> Option<ty::mt>
+fn make_overloaded_lvalue_return_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                                method_call: Option<MethodCall>,
+                                                method: Option<MethodCallee<'tcx>>)
+                                                -> Option<ty::mt<'tcx>>
 {
     /*!
      * For the overloaded lvalue expressions (`*x`, `x[3]`), the trait
@@ -2345,12 +2347,12 @@ fn make_overloaded_lvalue_return_type(fcx: &FnCtxt,
     }
 }
 
-fn autoderef_for_index<T>(fcx: &FnCtxt,
-                          base_expr: &ast::Expr,
-                          base_ty: Ty,
-                          lvalue_pref: LvaluePreference,
-                          step: |Ty, ty::AutoDerefRef| -> Option<T>)
-                          -> Option<T>
+fn autoderef_for_index<'a, 'tcx, T>(fcx: &FnCtxt<'a, 'tcx>,
+                                    base_expr: &ast::Expr,
+                                    base_ty: Ty<'tcx>,
+                                    lvalue_pref: LvaluePreference,
+                                    step: |Ty<'tcx>, ty::AutoDerefRef<'tcx>| -> Option<T>)
+                                    -> Option<T>
 {
     // FIXME(#18741) -- this is almost but not quite the same as the
     // autoderef that normal method probing does. They could likely be
@@ -2383,15 +2385,15 @@ fn autoderef_for_index<T>(fcx: &FnCtxt,
     }
 }
 
-fn try_overloaded_slice(fcx: &FnCtxt,
-                        method_call: MethodCall,
-                        expr: &ast::Expr,
-                        base_expr: &ast::Expr,
-                        base_ty: Ty,
-                        start_expr: &Option<P<ast::Expr>>,
-                        end_expr: &Option<P<ast::Expr>>,
-                        mutbl: ast::Mutability)
-                        -> Option<Ty> // return type is result of slice
+fn try_overloaded_slice<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                  method_call: MethodCall,
+                                  expr: &ast::Expr,
+                                  base_expr: &ast::Expr,
+                                  base_ty: Ty<'tcx>,
+                                  start_expr: &Option<P<ast::Expr>>,
+                                  end_expr: &Option<P<ast::Expr>>,
+                                  mutbl: ast::Mutability)
+                                  -> Option<Ty<'tcx>> // return type is result of slice
 {
     /*!
      * Autoderefs `base_expr`, looking for a `Slice` impl. If it
@@ -2439,16 +2441,17 @@ fn try_overloaded_slice(fcx: &FnCtxt,
     })
 }
 
-fn try_overloaded_slice_step(fcx: &FnCtxt,
-                             method_call: MethodCall,
-                             expr: &ast::Expr,
-                             base_expr: &ast::Expr,
-                             base_ty: Ty, // autoderef'd type
-                             autoderefref: ty::AutoDerefRef,
-                             mutbl: ast::Mutability,
-                             start_expr: &Option<P<ast::Expr>>,
-                             end_expr: &Option<P<ast::Expr>>)
-                             -> Option<Ty> // result type is type of method being called
+fn try_overloaded_slice_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                       method_call: MethodCall,
+                                       expr: &ast::Expr,
+                                       base_expr: &ast::Expr,
+                                       base_ty: Ty<'tcx>, // autoderef'd type
+                                       autoderefref: ty::AutoDerefRef<'tcx>,
+                                       mutbl: ast::Mutability,
+                                       start_expr: &Option<P<ast::Expr>>,
+                                       end_expr: &Option<P<ast::Expr>>)
+                                       // result type is type of method being called
+                                       -> Option<Ty<'tcx>>
 {
     /*!
      * Checks for a `Slice` (or `SliceMut`) impl at the relevant level
@@ -2512,14 +2515,14 @@ fn try_overloaded_slice_step(fcx: &FnCtxt,
     })
 }
 
-fn try_index_step(fcx: &FnCtxt,
-                  method_call: MethodCall,
-                  expr: &ast::Expr,
-                  base_expr: &ast::Expr,
-                  adjusted_ty: Ty,
-                  adjustment: ty::AutoDerefRef,
-                  lvalue_pref: LvaluePreference)
-                  -> Option<(/*index type*/ Ty, /*element type*/ Ty)>
+fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                            method_call: MethodCall,
+                            expr: &ast::Expr,
+                            base_expr: &ast::Expr,
+                            adjusted_ty: Ty<'tcx>,
+                            adjustment: ty::AutoDerefRef<'tcx>,
+                            lvalue_pref: LvaluePreference)
+                            -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)>
 {
     /*!
      * To type-check `base_expr[index_expr]`, we progressively autoderef (and otherwise adjust)
@@ -2591,10 +2594,10 @@ fn try_index_step(fcx: &FnCtxt,
 ///
 /// The return type of this function represents the concrete element type
 /// `A` in the type `Iterator<A>` that the method returns.
-fn lookup_method_for_for_loop(fcx: &FnCtxt,
-                              iterator_expr: &ast::Expr,
-                              loop_id: ast::NodeId)
-                              -> Ty {
+fn lookup_method_for_for_loop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                        iterator_expr: &ast::Expr,
+                                        loop_id: ast::NodeId)
+                                        -> Ty<'tcx> {
     let trait_did = match fcx.tcx().lang_items.require(IteratorItem) {
         Ok(trait_did) => trait_did,
         Err(ref err_string) => {
@@ -2672,14 +2675,14 @@ trait has an unexpected type `{}`",
     }
 }
 
-fn check_method_argument_types(fcx: &FnCtxt,
-                               sp: Span,
-                               method_fn_ty: Ty,
-                               callee_expr: &ast::Expr,
-                               args_no_rcvr: &[&P<ast::Expr>],
-                               deref_args: DerefArgs,
-                               tuple_arguments: TupleArgumentsFlag)
-                               -> ty::FnOutput {
+fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                         sp: Span,
+                                         method_fn_ty: Ty<'tcx>,
+                                         callee_expr: &ast::Expr,
+                                         args_no_rcvr: &[&P<ast::Expr>],
+                                         deref_args: DerefArgs,
+                                         tuple_arguments: TupleArgumentsFlag)
+                                         -> ty::FnOutput<'tcx> {
     if ty::type_is_error(method_fn_ty) {
        let err_inputs = err_args(args_no_rcvr.len());
         check_argument_types(fcx,
@@ -2713,14 +2716,14 @@ fn check_method_argument_types(fcx: &FnCtxt,
     }
 }
 
-fn check_argument_types(fcx: &FnCtxt,
-                        sp: Span,
-                        fn_inputs: &[Ty],
-                        _callee_expr: &ast::Expr,
-                        args: &[&P<ast::Expr>],
-                        deref_args: DerefArgs,
-                        variadic: bool,
-                        tuple_arguments: TupleArgumentsFlag) {
+fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                  sp: Span,
+                                  fn_inputs: &[Ty<'tcx>],
+                                  _callee_expr: &ast::Expr,
+                                  args: &[&P<ast::Expr>],
+                                  deref_args: DerefArgs,
+                                  variadic: bool,
+                                  tuple_arguments: TupleArgumentsFlag) {
     /*!
      *
      * Generic function that factors out common logic from
@@ -2891,11 +2894,14 @@ fn check_argument_types(fcx: &FnCtxt,
     }
 }
 
-fn err_args(len: uint) -> Vec<Ty> {
+// FIXME(#17596) Ty<'tcx> is incorrectly invariant w.r.t 'tcx.
+fn err_args<'tcx>(len: uint) -> Vec<Ty<'tcx>> {
     Vec::from_fn(len, |_| ty::mk_err())
 }
 
-fn write_call(fcx: &FnCtxt, call_expr: &ast::Expr, output: ty::FnOutput) {
+fn write_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                        call_expr: &ast::Expr,
+                        output: ty::FnOutput<'tcx>) {
     fcx.write_ty(call_expr.id, match output {
         ty::FnConverging(output_ty) => output_ty,
         ty::FnDiverging => fcx.infcx().next_diverging_ty_var()
@@ -2903,10 +2909,10 @@ fn write_call(fcx: &FnCtxt, call_expr: &ast::Expr, output: ty::FnOutput) {
 }
 
 // AST fragment checking
-fn check_lit(fcx: &FnCtxt,
-             lit: &ast::Lit,
-             expected: Expectation)
-             -> Ty
+fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                       lit: &ast::Lit,
+                       expected: Expectation<'tcx>)
+                       -> Ty<'tcx>
 {
     let tcx = fcx.ccx.tcx;
 
@@ -2958,40 +2964,41 @@ pub fn valid_range_bounds(ccx: &CrateCtxt,
     }
 }
 
-pub fn check_expr_has_type(fcx: &FnCtxt,
-                           expr: &ast::Expr,
-                           expected: Ty) {
+pub fn check_expr_has_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                     expr: &ast::Expr,
+                                     expected: Ty<'tcx>) {
     check_expr_with_unifier(
         fcx, expr, ExpectHasType(expected), NoPreference,
         || demand::suptype(fcx, expr.span, expected, fcx.expr_ty(expr)));
 }
 
-fn check_expr_coercable_to_type(fcx: &FnCtxt,
-                                expr: &ast::Expr,
-                                expected: Ty) {
+fn check_expr_coercable_to_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                          expr: &ast::Expr,
+                                          expected: Ty<'tcx>) {
     check_expr_with_unifier(
         fcx, expr, ExpectHasType(expected), NoPreference,
         || demand::coerce(fcx, expr.span, expected, expr));
 }
 
-fn check_expr_with_hint(fcx: &FnCtxt, expr: &ast::Expr, expected: Ty) {
+fn check_expr_with_hint<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, expr: &ast::Expr,
+                                  expected: Ty<'tcx>) {
     check_expr_with_unifier(
         fcx, expr, ExpectHasType(expected), NoPreference,
         || ())
 }
 
-fn check_expr_with_expectation(fcx: &FnCtxt,
-                               expr: &ast::Expr,
-                               expected: Expectation) {
+fn check_expr_with_expectation<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                         expr: &ast::Expr,
+                                         expected: Expectation<'tcx>) {
     check_expr_with_unifier(
         fcx, expr, expected, NoPreference,
         || ())
 }
 
-fn check_expr_with_expectation_and_lvalue_pref(fcx: &FnCtxt,
-                                            expr: &ast::Expr,
-                                            expected: Expectation,
-                                            lvalue_pref: LvaluePreference)
+fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                                         expr: &ast::Expr,
+                                                         expected: Expectation<'tcx>,
+                                                         lvalue_pref: LvaluePreference)
 {
     check_expr_with_unifier(fcx, expr, expected, lvalue_pref, || ())
 }
@@ -3009,10 +3016,10 @@ fn check_expr_with_lvalue_pref(fcx: &FnCtxt, expr: &ast::Expr,
 // declared on the impl declaration e.g., `impl<A,B> for ~[(A,B)]`
 // would return ($0, $1) where $0 and $1 are freshly instantiated type
 // variables.
-pub fn impl_self_ty(fcx: &FnCtxt,
-                    span: Span, // (potential) receiver for this impl
-                    did: ast::DefId)
-                    -> TypeAndSubsts {
+pub fn impl_self_ty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                              span: Span, // (potential) receiver for this impl
+                              did: ast::DefId)
+                              -> TypeAndSubsts<'tcx> {
     let tcx = fcx.tcx();
 
     let ity = ty::lookup_item_type(tcx, did);
@@ -3031,21 +3038,23 @@ pub fn impl_self_ty(fcx: &FnCtxt,
 
 // Only for fields! Returns <none> for methods>
 // Indifferent to privacy flags
-pub fn lookup_field_ty(tcx: &ty::ctxt,
-                       class_id: ast::DefId,
-                       items: &[ty::field_ty],
-                       fieldname: ast::Name,
-                       substs: &subst::Substs) -> Option<Ty> {
+pub fn lookup_field_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
+                             class_id: ast::DefId,
+                             items: &[ty::field_ty],
+                             fieldname: ast::Name,
+                             substs: &subst::Substs<'tcx>)
+                             -> Option<Ty<'tcx>> {
 
     let o_field = items.iter().find(|f| f.name == fieldname);
     o_field.map(|f| ty::lookup_field_type(tcx, class_id, f.id, substs))
 }
 
-pub fn lookup_tup_field_ty(tcx: &ty::ctxt,
-                           class_id: ast::DefId,
-                           items: &[ty::field_ty],
-                           idx: uint,
-                           substs: &subst::Substs) -> Option<Ty> {
+pub fn lookup_tup_field_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                 class_id: ast::DefId,
+                                 items: &[ty::field_ty],
+                                 idx: uint,
+                                 substs: &subst::Substs<'tcx>)
+                                 -> Option<Ty<'tcx>> {
 
     let o_field = if idx < items.len() { Some(&items[idx]) } else { None };
     o_field.map(|f| ty::lookup_field_type(tcx, class_id, f.id, substs))
@@ -3090,20 +3099,20 @@ enum TupleArgumentsFlag {
 /// Note that inspecting a type's structure *directly* may expose the fact
 /// that there are actually multiple representations for `ty_err`, so avoid
 /// that when err needs to be handled differently.
-fn check_expr_with_unifier(fcx: &FnCtxt,
-                           expr: &ast::Expr,
-                           expected: Expectation,
-                           lvalue_pref: LvaluePreference,
-                           unifier: ||)
+fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                     expr: &ast::Expr,
+                                     expected: Expectation<'tcx>,
+                                     lvalue_pref: LvaluePreference,
+                                     unifier: ||)
 {
     debug!(">> typechecking: expr={} expected={}",
            expr.repr(fcx.tcx()), expected.repr(fcx.tcx()));
 
     // A generic function for doing all of the checking for call expressions
-    fn check_call<'a>(fcx: &FnCtxt,
-                      call_expr: &ast::Expr,
-                      f: &ast::Expr,
-                      args: &[&'a P<ast::Expr>]) {
+    fn check_call(fcx: &FnCtxt,
+                  call_expr: &ast::Expr,
+                  f: &ast::Expr,
+                  args: &[&P<ast::Expr>]) {
         // Store the type of `f` as the type of the callee
         let fn_ty = fcx.expr_ty(f);
 
@@ -3201,13 +3210,13 @@ fn check_method_call(fcx: &FnCtxt,
 
     // A generic function for checking the then and else in an if
     // or if-check
-    fn check_then_else(fcx: &FnCtxt,
-                       cond_expr: &ast::Expr,
-                       then_blk: &ast::Block,
-                       opt_else_expr: Option<&ast::Expr>,
-                       id: ast::NodeId,
-                       sp: Span,
-                       expected: Expectation) {
+    fn check_then_else<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                 cond_expr: &ast::Expr,
+                                 then_blk: &ast::Block,
+                                 opt_else_expr: Option<&ast::Expr>,
+                                 id: ast::NodeId,
+                                 sp: Span,
+                                 expected: Expectation<'tcx>) {
         check_expr_has_type(fcx, cond_expr, ty::mk_bool());
 
         // Disregard "castable to" expectations because they
@@ -3271,12 +3280,12 @@ fn check_then_else(fcx: &FnCtxt,
 
     fn lookup_op_method<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
                                   op_ex: &ast::Expr,
-                                  lhs_ty: Ty,
+                                  lhs_ty: Ty<'tcx>,
                                   opname: ast::Name,
                                   trait_did: Option<ast::DefId>,
                                   lhs: &'a ast::Expr,
                                   rhs: Option<&P<ast::Expr>>,
-                                  unbound_method: ||) -> Ty {
+                                  unbound_method: ||) -> Ty<'tcx> {
         let method = match trait_did {
             Some(trait_did) => {
                 // We do eager coercions to make using operators
@@ -3454,12 +3463,12 @@ fn check_binop(fcx: &FnCtxt,
         }
     }
 
-    fn check_user_binop(fcx: &FnCtxt,
-                        ex: &ast::Expr,
-                        lhs_expr: &ast::Expr,
-                        lhs_resolved_t: Ty,
-                        op: ast::BinOp,
-                        rhs: &P<ast::Expr>) -> Ty {
+    fn check_user_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                  ex: &ast::Expr,
+                                  lhs_expr: &ast::Expr,
+                                  lhs_resolved_t: Ty<'tcx>,
+                                  op: ast::BinOp,
+                                  rhs: &P<ast::Expr>) -> Ty<'tcx> {
         let tcx = fcx.ccx.tcx;
         let lang = &tcx.lang_items;
         let (name, trait_did) = match op {
@@ -3494,13 +3503,13 @@ fn check_user_binop(fcx: &FnCtxt,
         })
     }
 
-    fn check_user_unop(fcx: &FnCtxt,
-                       op_str: &str,
-                       mname: &str,
-                       trait_did: Option<ast::DefId>,
-                       ex: &ast::Expr,
-                       rhs_expr: &ast::Expr,
-                       rhs_t: Ty) -> Ty {
+    fn check_user_unop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                 op_str: &str,
+                                 mname: &str,
+                                 trait_did: Option<ast::DefId>,
+                                 ex: &ast::Expr,
+                                 rhs_expr: &ast::Expr,
+                                 rhs_t: Ty<'tcx>) -> Ty<'tcx> {
        lookup_op_method(fcx, ex, rhs_t, token::intern(mname),
                         trait_did, rhs_expr, None, || {
             fcx.type_error_message(ex.span, |actual| {
@@ -3579,12 +3588,12 @@ fn check_unboxed_closure(fcx: &FnCtxt,
            .insert(local_def(expr.id), unboxed_closure);
     }
 
-    fn check_expr_fn(fcx: &FnCtxt,
-                     expr: &ast::Expr,
-                     store: ty::TraitStore,
-                     decl: &ast::FnDecl,
-                     body: &ast::Block,
-                     expected: Expectation) {
+    fn check_expr_fn<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                               expr: &ast::Expr,
+                               store: ty::TraitStore,
+                               decl: &ast::FnDecl,
+                               body: &ast::Block,
+                               expected: Expectation<'tcx>) {
         let tcx = fcx.ccx.tcx;
 
         debug!("check_expr_fn(expr={}, expected={})",
@@ -3799,15 +3808,15 @@ fn check_tup_field(fcx: &FnCtxt,
         fcx.write_error(expr.id);
     }
 
-    fn check_struct_or_variant_fields(fcx: &FnCtxt,
-                                      struct_ty: Ty,
-                                      span: Span,
-                                      class_id: ast::DefId,
-                                      node_id: ast::NodeId,
-                                      substitutions: subst::Substs,
-                                      field_types: &[ty::field_ty],
-                                      ast_fields: &[ast::Field],
-                                      check_completeness: bool)  {
+    fn check_struct_or_variant_fields<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                                struct_ty: Ty<'tcx>,
+                                                span: Span,
+                                                class_id: ast::DefId,
+                                                node_id: ast::NodeId,
+                                                substitutions: subst::Substs<'tcx>,
+                                                field_types: &[ty::field_ty],
+                                                ast_fields: &[ast::Field],
+                                                check_completeness: bool)  {
         let tcx = fcx.ccx.tcx;
 
         let mut class_field_map = FnvHashMap::new();
@@ -4692,8 +4701,8 @@ fn constrain_path_type_parameters(fcx: &FnCtxt,
     });
 }
 
-impl Expectation {
-    fn only_has_type(self) -> Expectation {
+impl<'tcx> Expectation<'tcx> {
+    fn only_has_type(self) -> Expectation<'tcx> {
         match self {
             NoExpectation | ExpectCastableToType(..) => NoExpectation,
             ExpectHasType(t) => ExpectHasType(t)
@@ -4703,7 +4712,7 @@ fn only_has_type(self) -> Expectation {
     // Resolves `expected` by a single level if it is a variable. If
     // there is no expected type or resolution is not possible (e.g.,
     // no constraints yet present), just returns `None`.
-    fn resolve(self, fcx: &FnCtxt) -> Expectation {
+    fn resolve<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Expectation<'tcx> {
         match self {
             NoExpectation => {
                 NoExpectation
@@ -4719,17 +4728,19 @@ fn resolve(self, fcx: &FnCtxt) -> Expectation {
         }
     }
 
-    fn map(self, fcx: &FnCtxt, unpack: |&ty::sty| -> Expectation) -> Expectation {
+    fn map<'a>(self, fcx: &FnCtxt<'a, 'tcx>,
+               unpack: |&ty::sty<'tcx>| -> Expectation<'tcx>)
+               -> Expectation<'tcx> {
         match self.resolve(fcx) {
             NoExpectation => NoExpectation,
             ExpectCastableToType(t) | ExpectHasType(t) => unpack(&ty::get(t).sty),
         }
     }
 
-    fn map_to_option<O>(self,
-                        fcx: &FnCtxt,
-                        unpack: |&ty::sty| -> Option<O>)
-                        -> Option<O>
+    fn map_to_option<'a, O>(self,
+                            fcx: &FnCtxt<'a, 'tcx>,
+                            unpack: |&ty::sty<'tcx>| -> Option<O>)
+                            -> Option<O>
     {
         match self.resolve(fcx) {
             NoExpectation => None,
@@ -4738,8 +4749,8 @@ fn map_to_option<O>(self,
     }
 }
 
-impl Repr for Expectation {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for Expectation<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             NoExpectation => format!("NoExpectation"),
             ExpectHasType(t) => format!("ExpectHasType({})",
@@ -4842,9 +4853,9 @@ pub fn check_block_no_value(fcx: &FnCtxt, blk: &ast::Block)  {
     }
 }
 
-fn check_block_with_expected(fcx: &FnCtxt,
-                             blk: &ast::Block,
-                             expected: Expectation) {
+fn check_block_with_expected<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                       blk: &ast::Block,
+                                       expected: Expectation<'tcx>) {
     let prev = {
         let mut fcx_ps = fcx.ps.borrow_mut();
         let fn_style_state = fcx_ps.recurse(blk);
@@ -4925,9 +4936,9 @@ fn check_block_with_expected(fcx: &FnCtxt,
 /// Checks a constant appearing in a type. At the moment this is just the
 /// length expression in a fixed-length vector, but someday it might be
 /// extended to type-level numeric literals.
-pub fn check_const_in_type(tcx: &ty::ctxt,
-                           expr: &ast::Expr,
-                           expected_type: Ty) {
+pub fn check_const_in_type<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                 expr: &ast::Expr,
+                                 expected_type: Ty<'tcx>) {
     // Synthesize a crate context. The trait map is not needed here (though I
     // imagine it will be if we have associated statics --pcwalton), so we
     // leave it blank.
@@ -4951,10 +4962,10 @@ pub fn check_const(ccx: &CrateCtxt,
     check_const_with_ty(&fcx, sp, e, declty);
 }
 
-pub fn check_const_with_ty(fcx: &FnCtxt,
-                           _: Span,
-                           e: &ast::Expr,
-                           declty: Ty) {
+pub fn check_const_with_ty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                     _: Span,
+                                     e: &ast::Expr,
+                                     declty: Ty<'tcx>) {
     // Gather locals in statics (because of block expressions).
     // This is technically unnecessary because locals in static items are forbidden,
     // but prevents type checking from blowing up before const checking can properly
@@ -5086,11 +5097,11 @@ fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
         }
     }
 
-    fn do_check(ccx: &CrateCtxt,
-                vs: &[P<ast::Variant>],
-                id: ast::NodeId,
-                hint: attr::ReprAttr)
-                -> Vec<Rc<ty::VariantInfo>> {
+    fn do_check<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                          vs: &[P<ast::Variant>],
+                          id: ast::NodeId,
+                          hint: attr::ReprAttr)
+                          -> Vec<Rc<ty::VariantInfo<'tcx>>> {
 
         let rty = ty::node_id_to_type(ccx.tcx, id);
         let mut variants: Vec<Rc<ty::VariantInfo>> = Vec::new();
@@ -5211,10 +5222,10 @@ pub fn lookup_def(fcx: &FnCtxt, sp: Span, id: ast::NodeId) -> def::Def {
 }
 
 // Returns the type parameter count and the type for the given definition.
-pub fn polytype_for_def(fcx: &FnCtxt,
-                        sp: Span,
-                        defn: def::Def)
-                        -> Polytype {
+pub fn polytype_for_def<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                  sp: Span,
+                                  defn: def::Def)
+                                  -> Polytype<'tcx> {
     match defn {
       def::DefLocal(nid) | def::DefUpvar(nid, _, _) => {
           let typ = fcx.local_ty(sp, nid);
@@ -5255,12 +5266,12 @@ pub fn polytype_for_def(fcx: &FnCtxt,
 
 // Instantiates the given path, which must refer to an item with the given
 // number of type parameters and type.
-pub fn instantiate_path(fcx: &FnCtxt,
-                        path: &ast::Path,
-                        polytype: Polytype,
-                        def: def::Def,
-                        span: Span,
-                        node_id: ast::NodeId) {
+pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                  path: &ast::Path,
+                                  polytype: Polytype<'tcx>,
+                                  def: def::Def,
+                                  span: Span,
+                                  node_id: ast::NodeId) {
     debug!("instantiate_path(path={}, def={}, node_id={}, polytype={})",
            path.repr(fcx.tcx()),
            def.repr(fcx.tcx()),
@@ -5472,14 +5483,14 @@ fn report_error_if_segment_contains_type_parameters(
         }
     }
 
-    fn push_explicit_parameters_from_segment_to_substs(
-        fcx: &FnCtxt,
+    fn push_explicit_parameters_from_segment_to_substs<'a, 'tcx>(
+        fcx: &FnCtxt<'a, 'tcx>,
         space: subst::ParamSpace,
         span: Span,
-        type_defs: &VecPerParamSpace<ty::TypeParameterDef>,
+        type_defs: &VecPerParamSpace<ty::TypeParameterDef<'tcx>>,
         region_defs: &VecPerParamSpace<ty::RegionParameterDef>,
         segment: &ast::PathSegment,
-        substs: &mut Substs)
+        substs: &mut Substs<'tcx>)
     {
         /*!
          * Finds the parameters that the user provided and adds them
@@ -5511,13 +5522,13 @@ fn push_explicit_parameters_from_segment_to_substs(
         }
     }
 
-    fn push_explicit_angle_bracketed_parameters_from_segment_to_substs(
-        fcx: &FnCtxt,
+    fn push_explicit_angle_bracketed_parameters_from_segment_to_substs<'a, 'tcx>(
+        fcx: &FnCtxt<'a, 'tcx>,
         space: subst::ParamSpace,
-        type_defs: &VecPerParamSpace<ty::TypeParameterDef>,
+        type_defs: &VecPerParamSpace<ty::TypeParameterDef<'tcx>>,
         region_defs: &VecPerParamSpace<ty::RegionParameterDef>,
         data: &ast::AngleBracketedParameterData,
-        substs: &mut Substs)
+        substs: &mut Substs<'tcx>)
     {
         {
             let type_count = type_defs.len(space);
@@ -5556,13 +5567,13 @@ fn push_explicit_angle_bracketed_parameters_from_segment_to_substs(
         }
     }
 
-    fn push_explicit_parenthesized_parameters_from_segment_to_substs(
-        fcx: &FnCtxt,
+    fn push_explicit_parenthesized_parameters_from_segment_to_substs<'a, 'tcx>(
+        fcx: &FnCtxt<'a, 'tcx>,
         space: subst::ParamSpace,
         span: Span,
-        type_defs: &VecPerParamSpace<ty::TypeParameterDef>,
+        type_defs: &VecPerParamSpace<ty::TypeParameterDef<'tcx>>,
         data: &ast::ParenthesizedParameterData,
-        substs: &mut Substs)
+        substs: &mut Substs<'tcx>)
     {
         /*!
          * As with
@@ -5602,12 +5613,12 @@ fn push_explicit_parenthesized_parameters_from_segment_to_substs(
         }
     }
 
-    fn adjust_type_parameters(
-        fcx: &FnCtxt,
+    fn adjust_type_parameters<'a, 'tcx>(
+        fcx: &FnCtxt<'a, 'tcx>,
         span: Span,
         space: ParamSpace,
-        defs: &VecPerParamSpace<ty::TypeParameterDef>,
-        substs: &mut Substs)
+        defs: &VecPerParamSpace<ty::TypeParameterDef<'tcx>>,
+        substs: &mut Substs<'tcx>)
     {
         let provided_len = substs.types.len(space);
         let desired = defs.get_slice(space);
@@ -5707,7 +5718,8 @@ fn adjust_region_parameters(
 
 // Resolves `typ` by a single level if `typ` is a type variable.  If no
 // resolution is possible, then an error is reported.
-pub fn structurally_resolved_type(fcx: &FnCtxt, sp: Span, mut ty: Ty) -> Ty {
+pub fn structurally_resolved_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
+                                            mut ty: Ty<'tcx>) -> Ty<'tcx> {
     // If `ty` is a type variable, see whether we already know what it is.
     ty = fcx.infcx().shallow_resolve(ty);
 
@@ -5736,8 +5748,8 @@ pub fn structurally_resolved_type(fcx: &FnCtxt, sp: Span, mut ty: Ty) -> Ty {
 }
 
 // Returns the one-level-deep structure of the given type.
-pub fn structure_of<'a>(fcx: &FnCtxt, sp: Span, typ: Ty)
-                        -> &'a ty::sty {
+pub fn structure_of<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span, typ: Ty<'tcx>)
+                        -> &'tcx ty::sty<'tcx> {
     &ty::get(structurally_resolved_type(fcx, sp, typ)).sty
 }
 
@@ -5765,10 +5777,10 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool {
         }}))
 }
 
-pub fn check_bounds_are_used(ccx: &CrateCtxt,
-                             span: Span,
-                             tps: &OwnedSlice<ast::TyParam>,
-                             ty: Ty) {
+pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                       span: Span,
+                                       tps: &OwnedSlice<ast::TyParam>,
+                                       ty: Ty<'tcx>) {
     debug!("check_bounds_are_used(n_tps={}, ty={})",
            tps.len(), ppaux::ty_to_string(ccx.tcx, ty));
 
@@ -5796,7 +5808,7 @@ pub fn check_bounds_are_used(ccx: &CrateCtxt,
 }
 
 pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
-    fn param(ccx: &CrateCtxt, n: uint) -> Ty {
+    fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: uint) -> Ty<'tcx> {
         ty::mk_param(ccx.tcx, subst::FnSpace, n, local_def(0))
     }
 
@@ -6077,8 +6089,8 @@ fn param(ccx: &CrateCtxt, n: uint) -> Ty {
     }
 }
 
-impl Repr for RegionObligation {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for RegionObligation<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("RegionObligation(sub_region={}, sup_type={}, origin={})",
                 self.sub_region.repr(tcx),
                 self.sup_type.repr(tcx),
index 2c71be2bbc6aa01b451d2b19f699f69ad3c0559f..ced8b4870874a09f7235dc168016251e94010182 100644 (file)
@@ -176,9 +176,9 @@ pub fn regionck_fn(fcx: &FnCtxt, id: ast::NodeId, blk: &ast::Block) {
     fcx.infcx().resolve_regions_and_report_errors();
 }
 
-pub fn regionck_ensure_component_tys_wf(fcx: &FnCtxt,
-                                        span: Span,
-                                        component_tys: &[Ty]) {
+pub fn regionck_ensure_component_tys_wf<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                                  span: Span,
+                                                  component_tys: &[Ty<'tcx>]) {
     /*!
      * Checks that the types in `component_tys` are well-formed.
      * This will add constraints into the region graph.
@@ -215,15 +215,15 @@ macro_rules! ignore_err(
 // Stores parameters for a potential call to link_region()
 // to perform if an upvar reference is marked unique/mutable after
 // it has already been processed before.
-struct MaybeLink {
+struct MaybeLink<'tcx> {
     span: Span,
     borrow_region: ty::Region,
     borrow_kind: ty::BorrowKind,
-    borrow_cmt: mc::cmt
+    borrow_cmt: mc::cmt<'tcx>
 }
 
 // A map associating an upvar ID to a vector of the above
-type MaybeLinkMap = RefCell<FnvHashMap<ty::UpvarId, Vec<MaybeLink>>>;
+type MaybeLinkMap<'tcx> = RefCell<FnvHashMap<ty::UpvarId, Vec<MaybeLink<'tcx>>>>;
 
 pub struct Rcx<'a, 'tcx: 'a> {
     fcx: &'a FnCtxt<'a, 'tcx>,
@@ -235,7 +235,7 @@ pub struct Rcx<'a, 'tcx: 'a> {
 
     // Possible region links we will establish if an upvar
     // turns out to be unique/mutable
-    maybe_links: MaybeLinkMap
+    maybe_links: MaybeLinkMap<'tcx>
 }
 
 fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region {
@@ -282,7 +282,7 @@ pub fn set_repeating_scope(&mut self, scope: ast::NodeId) -> ast::NodeId {
         old_scope
     }
 
-    pub fn resolve_type(&self, unresolved_ty: Ty) -> Ty {
+    pub fn resolve_type(&self, unresolved_ty: Ty<'tcx>) -> Ty<'tcx> {
         /*!
          * Try to resolve the type for the given node, returning
          * t_err if an error results.  Note that we never care
@@ -319,19 +319,19 @@ pub fn resolve_type(&self, unresolved_ty: Ty) -> Ty {
     }
 
     /// Try to resolve the type for the given node.
-    fn resolve_node_type(&self, id: ast::NodeId) -> Ty {
+    fn resolve_node_type(&self, id: ast::NodeId) -> Ty<'tcx> {
         let t = self.fcx.node_ty(id);
         self.resolve_type(t)
     }
 
-    fn resolve_method_type(&self, method_call: MethodCall) -> Option<Ty> {
+    fn resolve_method_type(&self, method_call: MethodCall) -> Option<Ty<'tcx>> {
         let method_ty = self.fcx.inh.method_map.borrow()
                             .get(&method_call).map(|method| method.ty);
         method_ty.map(|method_ty| self.resolve_type(method_ty))
     }
 
     /// Try to resolve the type for the given node.
-    pub fn resolve_expr_type_adjusted(&mut self, expr: &ast::Expr) -> Ty {
+    pub fn resolve_expr_type_adjusted(&mut self, expr: &ast::Expr) -> Ty<'tcx> {
         let ty_unadjusted = self.resolve_node_type(expr.id);
         if ty::type_is_error(ty_unadjusted) {
             ty_unadjusted
@@ -384,7 +384,7 @@ fn visit_region_obligations(&mut self, node_id: ast::NodeId)
     }
 
     fn relate_free_regions(&mut self,
-                           fn_sig_tys: &[Ty],
+                           fn_sig_tys: &[Ty<'tcx>],
                            body_id: ast::NodeId) {
         /*!
          * This method populates the region map's `free_region_map`.
@@ -457,16 +457,16 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.fcx.ccx.tcx
     }
 
-    fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty> {
+    fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
         let t = self.resolve_node_type(id);
         if ty::type_is_error(t) {Err(())} else {Ok(t)}
     }
 
-    fn node_method_ty(&self, method_call: MethodCall) -> Option<Ty> {
+    fn node_method_ty(&self, method_call: MethodCall) -> Option<Ty<'tcx>> {
         self.resolve_method_type(method_call)
     }
 
-    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
+    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
         &self.fcx.inh.adjustments
     }
 
@@ -488,7 +488,7 @@ fn capture_mode(&self, closure_expr_id: ast::NodeId)
     }
 
     fn unboxed_closures<'a>(&'a self)
-                        -> &'a RefCell<DefIdMap<ty::UnboxedClosure>> {
+                        -> &'a RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>> {
         &self.fcx.inh.unboxed_closures
     }
 }
@@ -807,10 +807,10 @@ fn constrain_cast(rcx: &mut Rcx,
 
     walk_cast(rcx, cast_expr, source_ty, target_ty);
 
-    fn walk_cast(rcx: &mut Rcx,
-                 cast_expr: &ast::Expr,
-                 from_ty: Ty,
-                 to_ty: Ty) {
+    fn walk_cast<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
+                           cast_expr: &ast::Expr,
+                           from_ty: Ty<'tcx>,
+                           to_ty: Ty<'tcx>) {
         debug!("walk_cast(from_ty={}, to_ty={})",
                from_ty.repr(rcx.tcx()),
                to_ty.repr(rcx.tcx()));
@@ -1182,10 +1182,10 @@ fn constrain_call<'a, I: Iterator<&'a ast::Expr>>(rcx: &mut Rcx,
     }
 }
 
-fn constrain_autoderefs(rcx: &mut Rcx,
-                        deref_expr: &ast::Expr,
-                        derefs: uint,
-                        mut derefd_ty: Ty) {
+fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
+                                  deref_expr: &ast::Expr,
+                                  derefs: uint,
+                                  mut derefd_ty: Ty<'tcx>) {
     /*!
      * Invoked on any auto-dereference that occurs.  Checks that if
      * this is a region pointer being dereferenced, the lifetime of
@@ -1258,9 +1258,9 @@ pub fn mk_subregion_due_to_dereference(rcx: &mut Rcx,
 }
 
 
-fn constrain_index(rcx: &mut Rcx,
-                   index_expr: &ast::Expr,
-                   indexed_ty: Ty)
+fn constrain_index<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
+                             index_expr: &ast::Expr,
+                             indexed_ty: Ty<'tcx>)
 {
     /*!
      * Invoked on any index expression that occurs.  Checks that if
@@ -1285,9 +1285,9 @@ fn constrain_index(rcx: &mut Rcx,
     }
 }
 
-fn type_of_node_must_outlive(
-    rcx: &mut Rcx,
-    origin: infer::SubregionOrigin,
+fn type_of_node_must_outlive<'a, 'tcx>(
+    rcx: &mut Rcx<'a, 'tcx>,
+    origin: infer::SubregionOrigin<'tcx>,
     id: ast::NodeId,
     minimum_lifetime: ty::Region)
 {
@@ -1365,10 +1365,10 @@ fn link_match(rcx: &Rcx, discr: &ast::Expr, arms: &[ast::Arm]) {
     }
 }
 
-fn link_pattern(rcx: &Rcx,
-                mc: mc::MemCategorizationContext<Rcx>,
-                discr_cmt: mc::cmt,
-                root_pat: &ast::Pat) {
+fn link_pattern<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
+                          mc: mc::MemCategorizationContext<Rcx<'a, 'tcx>>,
+                          discr_cmt: mc::cmt<'tcx>,
+                          root_pat: &ast::Pat) {
     /*!
      * Link lifetimes of any ref bindings in `root_pat` to
      * the pointers found in the discriminant, if needed.
@@ -1441,11 +1441,11 @@ fn link_by_ref(rcx: &Rcx,
     link_region(rcx, expr.span, borrow_region, ty::ImmBorrow, expr_cmt);
 }
 
-fn link_region_from_node_type(rcx: &Rcx,
-                              span: Span,
-                              id: ast::NodeId,
-                              mutbl: ast::Mutability,
-                              cmt_borrowed: mc::cmt) {
+fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
+                                        span: Span,
+                                        id: ast::NodeId,
+                                        mutbl: ast::Mutability,
+                                        cmt_borrowed: mc::cmt<'tcx>) {
     /*!
      * Like `link_region()`, except that the region is
      * extracted from the type of `id`, which must be some
@@ -1462,11 +1462,11 @@ fn link_region_from_node_type(rcx: &Rcx,
     }
 }
 
-fn link_region(rcx: &Rcx,
-               span: Span,
-               borrow_region: ty::Region,
-               borrow_kind: ty::BorrowKind,
-               borrow_cmt: mc::cmt) {
+fn link_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
+                         span: Span,
+                         borrow_region: ty::Region,
+                         borrow_kind: ty::BorrowKind,
+                         borrow_cmt: mc::cmt<'tcx>) {
     /*!
      * Informs the inference engine that `borrow_cmt` is being
      * borrowed with kind `borrow_kind` and lifetime `borrow_region`.
@@ -1524,15 +1524,15 @@ fn link_region(rcx: &Rcx,
     }
 }
 
-fn link_reborrowed_region(rcx: &Rcx,
-                          span: Span,
-                          borrow_region: ty::Region,
-                          borrow_kind: ty::BorrowKind,
-                          ref_cmt: mc::cmt,
-                          ref_region: ty::Region,
-                          mut ref_kind: ty::BorrowKind,
-                          note: mc::Note)
-                          -> Option<(mc::cmt, ty::BorrowKind)>
+fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
+                                    span: Span,
+                                    borrow_region: ty::Region,
+                                    borrow_kind: ty::BorrowKind,
+                                    ref_cmt: mc::cmt<'tcx>,
+                                    ref_region: ty::Region,
+                                    mut ref_kind: ty::BorrowKind,
+                                    note: mc::Note)
+                                    -> Option<(mc::cmt<'tcx>, ty::BorrowKind)>
 {
     /*!
      * This is the most complicated case: the path being borrowed is
@@ -1727,8 +1727,8 @@ fn adjust_borrow_kind_for_assignment_lhs(rcx: &Rcx,
     adjust_upvar_borrow_kind_for_mut(rcx, cmt);
 }
 
-fn adjust_upvar_borrow_kind_for_mut(rcx: &Rcx,
-                                    cmt: mc::cmt) {
+fn adjust_upvar_borrow_kind_for_mut<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
+                                              cmt: mc::cmt<'tcx>) {
     /*!
      * Indicates that `cmt` is being directly mutated (e.g., assigned
      * to).  If cmt contains any by-ref upvars, this implies that
@@ -1785,7 +1785,7 @@ fn adjust_upvar_borrow_kind_for_mut(rcx: &Rcx,
     }
 }
 
-fn adjust_upvar_borrow_kind_for_unique(rcx: &Rcx, cmt: mc::cmt) {
+fn adjust_upvar_borrow_kind_for_unique<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, cmt: mc::cmt<'tcx>) {
     let mut cmt = cmt;
     loop {
         debug!("adjust_upvar_borrow_kind_for_unique(cmt={})",
@@ -1910,10 +1910,10 @@ fn adjust_upvar_borrow_kind(rcx: &Rcx,
     }
 }
 
-fn type_must_outlive(rcx: &mut Rcx,
-                     origin: infer::SubregionOrigin,
-                     ty: Ty,
-                     region: ty::Region)
+fn type_must_outlive<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
+                               origin: infer::SubregionOrigin<'tcx>,
+                               ty: Ty<'tcx>,
+                               region: ty::Region)
 {
     /*!
      * Ensures that all borrowed data reachable via `ty` outlives `region`.
@@ -1949,10 +1949,10 @@ fn type_must_outlive(rcx: &mut Rcx,
     }
 }
 
-fn param_must_outlive(rcx: &Rcx,
-                      origin: infer::SubregionOrigin,
-                      region: ty::Region,
-                      param_ty: ty::ParamTy) {
+fn param_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
+                                origin: infer::SubregionOrigin<'tcx>,
+                                region: ty::Region,
+                                param_ty: ty::ParamTy) {
     let param_env = &rcx.fcx.inh.param_env;
 
     debug!("param_must_outlive(region={}, param_ty={})",
index af4917fb868b2508d454d31e3ccd41130453991d..d23131962873f6d2c38c1073e92446344c598f70 100644 (file)
 
 // Helper functions related to manipulating region types.
 
-pub enum WfConstraint {
-    RegionSubRegionConstraint(Option<Ty>, ty::Region, ty::Region),
-    RegionSubParamConstraint(Option<Ty>, ty::Region, ty::ParamTy),
+pub enum WfConstraint<'tcx> {
+    RegionSubRegionConstraint(Option<Ty<'tcx>>, ty::Region, ty::Region),
+    RegionSubParamConstraint(Option<Ty<'tcx>>, ty::Region, ty::ParamTy),
 }
 
 struct Wf<'a, 'tcx: 'a> {
     tcx: &'a ty::ctxt<'tcx>,
-    stack: Vec<(ty::Region, Option<Ty>)>,
-    out: Vec<WfConstraint>,
+    stack: Vec<(ty::Region, Option<Ty<'tcx>>)>,
+    out: Vec<WfConstraint<'tcx>>,
 }
 
-pub fn region_wf_constraints(
-    tcx: &ty::ctxt,
-    ty: Ty,
+pub fn region_wf_constraints<'tcx>(
+    tcx: &ty::ctxt<'tcx>,
+    ty: Ty<'tcx>,
     outer_region: ty::Region)
-    -> Vec<WfConstraint>
+    -> Vec<WfConstraint<'tcx>>
 {
     /*!
      * This routine computes the well-formedness constraints that must
@@ -55,7 +55,7 @@ pub fn region_wf_constraints(
 }
 
 impl<'a, 'tcx> Wf<'a, 'tcx> {
-    fn accumulate_from_ty(&mut self, ty: Ty) {
+    fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
         debug!("Wf::accumulate_from_ty(ty={})",
                ty.repr(self.tcx));
 
@@ -146,9 +146,9 @@ fn accumulate_from_ty(&mut self, ty: Ty) {
     }
 
     fn accumulate_from_rptr(&mut self,
-                            ty: Ty,
+                            ty: Ty<'tcx>,
                             r_b: ty::Region,
-                            ty_b: Ty) {
+                            ty_b: Ty<'tcx>) {
         // We are walking down a type like this, and current
         // position is indicated by caret:
         //
@@ -193,7 +193,7 @@ fn push_region_constraint_from_top(&mut self,
     }
 
     fn push_sub_region_constraint(&mut self,
-                                  opt_ty: Option<Ty>,
+                                  opt_ty: Option<Ty<'tcx>>,
                                   r_a: ty::Region,
                                   r_b: ty::Region) {
         /*! Pushes a constraint that `r_a <= r_b`, due to `opt_ty` */
@@ -213,16 +213,16 @@ fn push_param_constraint_from_top(&mut self,
 
     fn push_param_constraint(&mut self,
                              region: ty::Region,
-                             opt_ty: Option<Ty>,
+                             opt_ty: Option<Ty<'tcx>>,
                              param_ty: ty::ParamTy) {
         /*! Pushes a constraint that `region <= param_ty`, due to `opt_ty` */
         self.out.push(RegionSubParamConstraint(opt_ty, region, param_ty));
     }
 
     fn accumulate_from_adt(&mut self,
-                           ty: Ty,
+                           ty: Ty<'tcx>,
                            def_id: ast::DefId,
-                           substs: &Substs)
+                           substs: &Substs<'tcx>)
     {
         // The generic declarations from the type, appropriately
         // substituted for the actual substitutions.
@@ -322,8 +322,8 @@ fn accumulate_from_adt(&mut self,
     }
 
     fn accumulate_from_closure_ty(&mut self,
-                                  ty: Ty,
-                                  c: &ty::ClosureTy)
+                                  ty: Ty<'tcx>,
+                                  c: &ty::ClosureTy<'tcx>)
     {
         match c.store {
             ty::RegionTraitStore(r_b, _) => {
@@ -336,7 +336,7 @@ fn accumulate_from_closure_ty(&mut self,
     }
 
     fn accumulate_from_object_ty(&mut self,
-                                 ty: Ty,
+                                 ty: Ty<'tcx>,
                                  bounds: &ty::ExistentialBounds)
     {
         // Imagine a type like this:
index 3de059a408674c1614826b11ee3d266e27d0f0f5..5b5c6fe51e8c4fd76c5a2729cede6a2ade941894 100644 (file)
 use syntax::codemap::Span;
 use util::ppaux::{UserString, Repr, ty_to_string};
 
-pub fn check_object_cast(fcx: &FnCtxt,
-                         cast_expr: &ast::Expr,
-                         source_expr: &ast::Expr,
-                         target_object_ty: Ty)
+pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                   cast_expr: &ast::Expr,
+                                   source_expr: &ast::Expr,
+                                   target_object_ty: Ty<'tcx>)
 {
     debug!("check_object_cast(cast_expr={}, target_object_ty={})",
            cast_expr.repr(fcx.tcx()),
@@ -96,10 +96,7 @@ pub fn check_object_cast(fcx: &FnCtxt,
         }
     }
 
-    // Because we currently give unsound lifetimes to the "t_box", I
-    // could have written &'static ty::TyTrait here, but it seems
-    // gratuitously unsafe.
-    fn object_trait<'a>(t: &'a Ty) -> &'a ty::TyTrait {
+    fn object_trait<'a, 'tcx>(t: &'a Ty<'tcx>) -> &'a ty::TyTrait<'tcx> {
         match ty::get(*t).sty {
             ty::ty_trait(ref ty_trait) => &**ty_trait,
             _ => panic!("expected ty_trait")
@@ -113,10 +110,10 @@ fn mutability_allowed(a_mutbl: ast::Mutability,
             (a_mutbl == ast::MutMutable && b_mutbl == ast::MutImmutable)
     }
 
-    fn push_cast_obligation(fcx: &FnCtxt,
-                            cast_expr: &ast::Expr,
-                            object_trait: &ty::TyTrait,
-                            referent_ty: Ty) {
+    fn push_cast_obligation<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                      cast_expr: &ast::Expr,
+                                      object_trait: &ty::TyTrait<'tcx>,
+                                      referent_ty: Ty<'tcx>) {
         let object_trait_ref =
             register_object_cast_obligations(fcx,
                                              cast_expr.span,
@@ -135,7 +132,9 @@ fn push_cast_obligation(fcx: &FnCtxt,
 // methods are object-safe. A trait method is object-safe if it does not take
 // self by value, has no type parameters and does not use the `Self` type, except
 // in self position.
-pub fn check_object_safety(tcx: &ty::ctxt, object_trait: &ty::TyTrait, span: Span) {
+pub fn check_object_safety<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                 object_trait: &ty::TyTrait<'tcx>,
+                                 span: Span) {
     // Skip the fn_once lang item trait since only the compiler should call
     // `call_once` which is the method which takes self by value. What could go
     // wrong?
@@ -169,7 +168,9 @@ pub fn check_object_safety(tcx: &ty::ctxt, object_trait: &ty::TyTrait, span: Spa
     }
 
     // Returns a vec of error messages. If hte vec is empty - no errors!
-    fn check_object_safety_of_method(tcx: &ty::ctxt, method: &ty::Method) -> Vec<String> {
+    fn check_object_safety_of_method<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                           method: &ty::Method<'tcx>)
+                                           -> Vec<String> {
         /*!
          * There are some limitations to calling functions through an
          * object, because (a) the self type is not known
@@ -231,11 +232,11 @@ fn check_object_safety_of_method(tcx: &ty::ctxt, method: &ty::Method) -> Vec<Str
     }
 }
 
-pub fn register_object_cast_obligations(fcx: &FnCtxt,
-                                        span: Span,
-                                        object_trait: &ty::TyTrait,
-                                        referent_ty: Ty)
-                                        -> Rc<ty::TraitRef>
+pub fn register_object_cast_obligations<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                                  span: Span,
+                                                  object_trait: &ty::TyTrait<'tcx>,
+                                                  referent_ty: Ty<'tcx>)
+                                                  -> Rc<ty::TraitRef<'tcx>>
 {
     // This is just for better error reporting. Kinda goofy. The object type stuff
     // needs some refactoring so there is a more convenient type to pass around.
@@ -299,8 +300,8 @@ pub fn select_all_fcx_obligations_or_error(fcx: &FnCtxt) {
     }
 }
 
-fn resolve_trait_ref(fcx: &FnCtxt, obligation: &Obligation)
-                     -> (Rc<ty::TraitRef>, Ty)
+fn resolve_trait_ref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, obligation: &Obligation<'tcx>)
+                               -> (Rc<ty::TraitRef<'tcx>>, Ty<'tcx>)
 {
     let trait_ref =
         fcx.infcx().resolve_type_vars_in_trait_ref_if_possible(
@@ -310,15 +311,15 @@ fn resolve_trait_ref(fcx: &FnCtxt, obligation: &Obligation)
     (Rc::new(trait_ref), self_ty)
 }
 
-pub fn report_fulfillment_errors(fcx: &FnCtxt,
-                                 errors: &Vec<FulfillmentError>) {
+pub fn report_fulfillment_errors<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                           errors: &Vec<FulfillmentError<'tcx>>) {
     for error in errors.iter() {
         report_fulfillment_error(fcx, error);
     }
 }
 
-pub fn report_fulfillment_error(fcx: &FnCtxt,
-                                error: &FulfillmentError) {
+pub fn report_fulfillment_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                          error: &FulfillmentError<'tcx>) {
     match error.code {
         CodeSelectionError(ref e) => {
             report_selection_error(fcx, &error.obligation, e);
@@ -329,9 +330,9 @@ pub fn report_fulfillment_error(fcx: &FnCtxt,
     }
 }
 
-pub fn report_selection_error(fcx: &FnCtxt,
-                              obligation: &Obligation,
-                              error: &SelectionError)
+pub fn report_selection_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                        obligation: &Obligation<'tcx>,
+                                        error: &SelectionError<'tcx>)
 {
     match *error {
         Overflow => {
@@ -377,7 +378,8 @@ pub fn report_selection_error(fcx: &FnCtxt,
     }
 }
 
-pub fn maybe_report_ambiguity(fcx: &FnCtxt, obligation: &Obligation) {
+pub fn maybe_report_ambiguity<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                        obligation: &Obligation<'tcx>) {
     // Unable to successfully determine, probably means
     // insufficient type information, but could mean
     // ambiguous impls. The latter *ought* to be a
@@ -469,8 +471,8 @@ pub fn select_new_fcx_obligations(fcx: &FnCtxt) {
     }
 }
 
-fn note_obligation_cause(fcx: &FnCtxt,
-                         obligation: &Obligation) {
+fn note_obligation_cause<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                   obligation: &Obligation<'tcx>) {
     let tcx = fcx.tcx();
     let trait_name = ty::item_path_str(tcx, obligation.trait_ref.def_id);
     match obligation.cause.code {
index b07b7526fe4a1f54558f9c815fba2114fb9fcdd9..3557059951500d8cc9f467dda46b370892e9a912 100644 (file)
@@ -29,7 +29,7 @@
 
 pub struct CheckTypeWellFormedVisitor<'ccx, 'tcx:'ccx> {
     ccx: &'ccx CrateCtxt<'ccx, 'tcx>,
-    cache: HashSet<Ty>
+    cache: HashSet<Ty<'tcx>>
 }
 
 impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
@@ -37,7 +37,7 @@ pub fn new(ccx: &'ccx CrateCtxt<'ccx, 'tcx>) -> CheckTypeWellFormedVisitor<'ccx,
         CheckTypeWellFormedVisitor { ccx: ccx, cache: HashSet::new() }
     }
 
-    fn check_item_well_formed(&mut self, ccx: &CrateCtxt, item: &ast::Item) {
+    fn check_item_well_formed(&mut self, item: &ast::Item) {
         /*!
          * Checks that the field types (in a struct def'n) or
          * argument types (in an enum def'n) are well-formed,
@@ -55,6 +55,7 @@ fn check_item_well_formed(&mut self, ccx: &CrateCtxt, item: &ast::Item) {
          * the types first.
          */
 
+        let ccx = self.ccx;
         debug!("check_item_well_formed(it.id={}, it.ident={})",
                item.id,
                ty::item_path_str(ccx.tcx, local_def(item.id)));
@@ -87,9 +88,10 @@ fn check_item_well_formed(&mut self, ccx: &CrateCtxt, item: &ast::Item) {
     }
 
     fn with_fcx(&mut self,
-                ccx: &CrateCtxt,
                 item: &ast::Item,
-                f: |&mut CheckTypeWellFormedVisitor, &FnCtxt|) {
+                f: for<'fcx> |&mut CheckTypeWellFormedVisitor<'ccx, 'tcx>,
+                              &FnCtxt<'fcx, 'tcx>|) {
+        let ccx = self.ccx;
         let item_def_id = local_def(item.id);
         let polytype = ty::lookup_item_type(ccx.tcx, item_def_id);
         let param_env =
@@ -106,14 +108,15 @@ fn with_fcx(&mut self,
 
     fn check_type_defn(&mut self,
                        item: &ast::Item,
-                       lookup_fields: |&FnCtxt| -> Vec<AdtVariant>)
+                       lookup_fields: for<'fcx> |&FnCtxt<'fcx, 'tcx>|
+                                                 -> Vec<AdtVariant<'tcx>>)
     {
         /*!
          * In a type definition, we check that to ensure that the types of the fields are
          * well-formed.
          */
 
-        self.with_fcx(self.ccx, item, |this, fcx| {
+        self.with_fcx(item, |this, fcx| {
             let variants = lookup_fields(fcx);
             let mut bounds_checker = BoundsChecker::new(fcx, item.span,
                                                         item.id, Some(&mut this.cache));
@@ -150,7 +153,7 @@ fn check_type_defn(&mut self,
     fn check_item_type(&mut self,
                        item: &ast::Item)
     {
-        self.with_fcx(self.ccx, item, |this, fcx| {
+        self.with_fcx(item, |this, fcx| {
             let mut bounds_checker = BoundsChecker::new(fcx, item.span,
                                                         item.id, Some(&mut this.cache));
             let polytype = ty::lookup_item_type(fcx.tcx(), local_def(item.id));
@@ -162,7 +165,7 @@ fn check_item_type(&mut self,
     fn check_impl(&mut self,
                   item: &ast::Item)
     {
-        self.with_fcx(self.ccx, item, |this, fcx| {
+        self.with_fcx(item, |this, fcx| {
             let mut bounds_checker = BoundsChecker::new(fcx, item.span,
                                                         item.id, Some(&mut this.cache));
 
@@ -245,8 +248,8 @@ fn check_impl(&mut self,
 }
 
 impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
-    fn visit_item(&mut self, i: &'v ast::Item) {
-        self.check_item_well_formed(self.ccx, i);
+    fn visit_item(&mut self, i: &ast::Item) {
+        self.check_item_well_formed(i);
         visit::walk_item(self, i);
     }
 }
@@ -256,20 +259,20 @@ pub struct BoundsChecker<'cx,'tcx:'cx> {
     span: Span,
     scope_id: ast::NodeId,
     binding_count: uint,
-    cache: Option<&'cx mut HashSet<Ty>>,
+    cache: Option<&'cx mut HashSet<Ty<'tcx>>>,
 }
 
 impl<'cx,'tcx> BoundsChecker<'cx,'tcx> {
     pub fn new(fcx: &'cx FnCtxt<'cx,'tcx>,
                span: Span,
                scope_id: ast::NodeId,
-               cache: Option<&'cx mut HashSet<Ty>>)
+               cache: Option<&'cx mut HashSet<Ty<'tcx>>>)
                -> BoundsChecker<'cx,'tcx> {
         BoundsChecker { fcx: fcx, span: span, scope_id: scope_id,
                         cache: cache, binding_count: 0 }
     }
 
-    pub fn check_trait_ref(&mut self, trait_ref: &ty::TraitRef) {
+    pub fn check_trait_ref(&mut self, trait_ref: &ty::TraitRef<'tcx>) {
         /*!
          * Given a trait ref like `A : Trait<B>`, where `Trait` is
          * defined as (say):
@@ -300,11 +303,11 @@ pub fn check_trait_ref(&mut self, trait_ref: &ty::TraitRef) {
         }
     }
 
-    pub fn check_ty(&mut self, ty: Ty) {
+    pub fn check_ty(&mut self, ty: Ty<'tcx>) {
         ty.fold_with(self);
     }
 
-    fn check_traits_in_ty(&mut self, ty: Ty) {
+    fn check_traits_in_ty(&mut self, ty: Ty<'tcx>) {
         // When checking types outside of a type def'n, we ignore
         // region obligations. See discussion below in fold_ty().
         self.binding_count += 1;
@@ -318,7 +321,7 @@ fn tcx(&self) -> &ty::ctxt<'tcx> {
         self.fcx.tcx()
     }
 
-    fn fold_ty(&mut self, t: Ty) -> Ty {
+    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
         debug!("BoundsChecker t={}",
                t.repr(self.tcx()));
 
@@ -401,16 +404,18 @@ fn fold_ty(&mut self, t: Ty) -> Ty {
 ///////////////////////////////////////////////////////////////////////////
 // ADT
 
-struct AdtVariant {
-    fields: Vec<AdtField>,
+struct AdtVariant<'tcx> {
+    fields: Vec<AdtField<'tcx>>,
 }
 
-struct AdtField {
-    ty: Ty,
+struct AdtField<'tcx> {
+    ty: Ty<'tcx>,
     span: Span,
 }
 
-fn struct_variant(fcx: &FnCtxt, struct_def: &ast::StructDef) -> AdtVariant {
+fn struct_variant<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                            struct_def: &ast::StructDef)
+                            -> AdtVariant<'tcx> {
     let fields =
         struct_def.fields
         .iter()
@@ -423,7 +428,9 @@ fn struct_variant(fcx: &FnCtxt, struct_def: &ast::StructDef) -> AdtVariant {
     AdtVariant { fields: fields }
 }
 
-fn enum_variants(fcx: &FnCtxt, enum_def: &ast::EnumDef) -> Vec<AdtVariant> {
+fn enum_variants<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                           enum_def: &ast::EnumDef)
+                           -> Vec<AdtVariant<'tcx>> {
     enum_def.variants.iter()
         .map(|variant| {
             match variant.node.kind {
@@ -457,10 +464,10 @@ fn enum_variants(fcx: &FnCtxt, enum_def: &ast::EnumDef) -> Vec<AdtVariant> {
 ///////////////////////////////////////////////////////////////////////////
 // Special drop trait checking
 
-fn check_struct_safe_for_destructor(fcx: &FnCtxt,
-                                    span: Span,
-                                    self_ty: Ty,
-                                    struct_did: ast::DefId) {
+fn check_struct_safe_for_destructor<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
+                                              span: Span,
+                                              self_ty: Ty<'tcx>,
+                                              struct_did: ast::DefId) {
     let struct_tpt = ty::lookup_item_type(fcx.tcx(), struct_did);
     if !struct_tpt.generics.has_type_params(subst::TypeSpace)
         && !struct_tpt.generics.has_region_params(subst::TypeSpace)
index 4f3fd4fae98b91ca1a16b6bdc7146d4221453afd..76d9ed15e518018f08c0c5a239e1fb0bf7fa57b3 100644 (file)
@@ -340,7 +340,7 @@ fn visit_method_map_entry(&self,
         }
     }
 
-    fn resolve<T:ResolveIn>(&self, t: &T, reason: ResolveReason) -> T {
+    fn resolve<T:ResolveIn<'tcx>>(&self, t: &T, reason: ResolveReason) -> T {
         t.resolve_in(&mut Resolver::new(self.fcx, reason))
     }
 }
@@ -379,12 +379,12 @@ fn span(&self, tcx: &ty::ctxt) -> Span {
 ///////////////////////////////////////////////////////////////////////////
 // Convenience methods for resolving different kinds of things.
 
-trait ResolveIn {
-    fn resolve_in(&self, resolver: &mut Resolver) -> Self;
+trait ResolveIn<'tcx> {
+    fn resolve_in<'a>(&self, resolver: &mut Resolver<'a, 'tcx>) -> Self;
 }
 
-impl<T:TypeFoldable> ResolveIn for T {
-    fn resolve_in(&self, resolver: &mut Resolver) -> T {
+impl<'tcx, T: TypeFoldable<'tcx>> ResolveIn<'tcx> for T {
+    fn resolve_in<'a>(&self, resolver: &mut Resolver<'a, 'tcx>) -> T {
         self.fold_with(resolver)
     }
 }
@@ -465,7 +465,7 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.tcx
     }
 
-    fn fold_ty(&mut self, t: Ty) -> Ty {
+    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
         if !ty::type_needs_infer(t) {
             return t;
         }
index 12a0e0d01f05975370f5dd2f29949a7a65e07dd7..c12aed77342746411f5a6650609fb317af7ca358 100644 (file)
 mod orphan;
 mod overlap;
 
-fn get_base_type(inference_context: &InferCtxt,
-                 span: Span,
-                 original_type: Ty)
-                 -> Option<Ty> {
+fn get_base_type<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
+                           span: Span,
+                           original_type: Ty<'tcx>)
+                           -> Option<Ty<'tcx>> {
     let resolved_type = match resolve_type(inference_context,
                                            Some(span),
                                            original_type,
@@ -95,10 +95,10 @@ fn get_base_type(inference_context: &InferCtxt,
 }
 
 // Returns the def ID of the base type, if there is one.
-fn get_base_type_def_id(inference_context: &InferCtxt,
-                        span: Span,
-                        original_type: Ty)
-                        -> Option<DefId> {
+fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
+                                  span: Span,
+                                  original_type: Ty<'tcx>)
+                                  -> Option<DefId> {
     match get_base_type(inference_context, span, original_type) {
         None => None,
         Some(base_type) => {
@@ -242,7 +242,7 @@ fn check_implementation(&self,
     fn instantiate_default_methods(
             &self,
             impl_id: DefId,
-            trait_ref: &ty::TraitRef,
+            trait_ref: &ty::TraitRef<'tcx>,
             all_impl_items: &mut Vec<ImplOrTraitItemId>) {
         let tcx = self.crate_context.tcx;
         debug!("instantiate_default_methods(impl_id={}, trait_ref={})",
@@ -316,7 +316,7 @@ fn add_trait_impl(&self, base_def_id: DefId, impl_def_id: DefId) {
     }
 
     fn get_self_type_for_implementation(&self, impl_did: DefId)
-                                        -> Polytype {
+                                        -> Polytype<'tcx> {
         self.crate_context.tcx.tcache.borrow()[impl_did].clone()
     }
 
@@ -478,10 +478,10 @@ fn populate_destructor_table(&self) {
     }
 }
 
-pub fn make_substs_for_receiver_types(tcx: &ty::ctxt,
-                                      trait_ref: &ty::TraitRef,
-                                      method: &ty::Method)
-                                      -> subst::Substs
+pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                            trait_ref: &ty::TraitRef<'tcx>,
+                                            method: &ty::Method<'tcx>)
+                                            -> subst::Substs<'tcx>
 {
     /*!
      * Substitutes the values for the receiver's type parameters
@@ -503,14 +503,14 @@ pub fn make_substs_for_receiver_types(tcx: &ty::ctxt,
     trait_ref.substs.clone().with_method(meth_tps, meth_regions)
 }
 
-fn subst_receiver_types_in_method_ty(tcx: &ty::ctxt,
-                                     impl_id: ast::DefId,
-                                     impl_poly_type: &ty::Polytype,
-                                     trait_ref: &ty::TraitRef,
-                                     new_def_id: ast::DefId,
-                                     method: &ty::Method,
-                                     provided_source: Option<ast::DefId>)
-                                     -> ty::Method
+fn subst_receiver_types_in_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                           impl_id: ast::DefId,
+                                           impl_poly_type: &ty::Polytype<'tcx>,
+                                           trait_ref: &ty::TraitRef<'tcx>,
+                                           new_def_id: ast::DefId,
+                                           method: &ty::Method<'tcx>,
+                                           provided_source: Option<ast::DefId>)
+                                           -> ty::Method<'tcx>
 {
     let combined_substs = make_substs_for_receiver_types(tcx, trait_ref, method);
 
index f011c36f782d394f872a9d1e95f8cfe2938b9873..8ed630e88618954cba5eabe3a3cfb8e6a15e732e 100644 (file)
@@ -136,18 +136,18 @@ fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
 ///////////////////////////////////////////////////////////////////////////
 // Utility types and common code for the above passes.
 
-pub trait ToTy {
-    fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> Ty;
+pub trait ToTy<'tcx> {
+    fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> Ty<'tcx>;
 }
 
-impl<'a,'tcx> ToTy for ImplCtxt<'a,'tcx> {
-    fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> Ty {
+impl<'a,'tcx> ToTy<'tcx> for ImplCtxt<'a,'tcx> {
+    fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> Ty<'tcx> {
         ast_ty_to_ty(self, rs, ast_ty)
     }
 }
 
-impl<'a,'tcx> ToTy for CrateCtxt<'a,'tcx> {
-    fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> Ty {
+impl<'a,'tcx> ToTy<'tcx> for CrateCtxt<'a,'tcx> {
+    fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> Ty<'tcx> {
         ast_ty_to_ty(self, rs, ast_ty)
     }
 }
@@ -155,7 +155,7 @@ fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> Ty {
 impl<'a, 'tcx> AstConv<'tcx> for CrateCtxt<'a, 'tcx> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         if id.krate != ast::LOCAL_CRATE {
             return csearch::get_type(self.tcx, id)
         }
@@ -177,37 +177,37 @@ fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
         }
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         get_trait_def(self, id)
     }
 
-    fn ty_infer(&self, span: Span) -> Ty {
+    fn ty_infer(&self, span: Span) -> Ty<'tcx> {
         span_err!(self.tcx.sess, span, E0121,
                   "the type placeholder `_` is not allowed within types on item signatures.");
         ty::mk_err()
     }
 
-    fn associated_types_of_trait_are_valid(&self, _: Ty, _: ast::DefId)
+    fn associated_types_of_trait_are_valid(&self, _: Ty<'tcx>, _: ast::DefId)
                                            -> bool {
         false
     }
 
     fn associated_type_binding(&self,
                                span: Span,
-                               _: Option<Ty>,
+                               _: Option<Ty<'tcx>>,
                                _: ast::DefId,
                                _: ast::DefId)
-                               -> Ty {
+                               -> Ty<'tcx> {
         self.tcx().sess.span_err(span, "associated types may not be \
                                         referenced here");
         ty::mk_err()
     }
 }
 
-pub fn get_enum_variant_types(ccx: &CrateCtxt,
-                              enum_ty: Ty,
-                              variants: &[P<ast::Variant>],
-                              generics: &ast::Generics) {
+pub fn get_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                        enum_ty: Ty<'tcx>,
+                                        variants: &[P<ast::Variant>],
+                                        generics: &ast::Generics) {
     let tcx = ccx.tcx;
 
     // Create a set of parameter types shared among all the variants.
@@ -253,9 +253,9 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt,
     }
 }
 
-fn collect_trait_methods(ccx: &CrateCtxt,
-                         trait_id: ast::NodeId,
-                         trait_def: &ty::TraitDef) {
+fn collect_trait_methods<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                   trait_id: ast::NodeId,
+                                   trait_def: &ty::TraitDef<'tcx>) {
     let tcx = ccx.tcx;
     match tcx.map.get(trait_id) {
         ast_map::NodeItem(item) => {
@@ -365,7 +365,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
         _ => { /* Ignore things that aren't traits */ }
     }
 
-    fn make_method_ty(ccx: &CrateCtxt, m: &ty::Method) {
+    fn make_method_ty<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, m: &ty::Method<'tcx>) {
         ccx.tcx.tcache.borrow_mut().insert(
             m.def_id,
             Polytype {
@@ -373,18 +373,18 @@ fn make_method_ty(ccx: &CrateCtxt, m: &ty::Method) {
                 ty: ty::mk_bare_fn(ccx.tcx, m.fty.clone()) });
     }
 
-    fn ty_method_of_trait_method(ccx: &CrateCtxt,
-                                 trait_id: ast::NodeId,
-                                 trait_generics: &ty::Generics,
-                                 trait_items: &[ast::TraitItem],
-                                 m_id: &ast::NodeId,
-                                 m_name: &ast::Name,
-                                 m_explicit_self: &ast::ExplicitSelf,
-                                 m_abi: abi::Abi,
-                                 m_generics: &ast::Generics,
-                                 m_fn_style: &ast::FnStyle,
-                                 m_decl: &ast::FnDecl)
-                                 -> ty::Method {
+    fn ty_method_of_trait_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                           trait_id: ast::NodeId,
+                                           trait_generics: &ty::Generics<'tcx>,
+                                           trait_items: &[ast::TraitItem],
+                                           m_id: &ast::NodeId,
+                                           m_name: &ast::Name,
+                                           m_explicit_self: &ast::ExplicitSelf,
+                                           m_abi: abi::Abi,
+                                           m_generics: &ast::Generics,
+                                           m_fn_style: &ast::FnStyle,
+                                           m_decl: &ast::FnDecl)
+                                           -> ty::Method<'tcx> {
         let ty_generics =
             ty_generics_for_fn_or_method(
                 ccx,
@@ -423,10 +423,10 @@ fn ty_method_of_trait_method(ccx: &CrateCtxt,
     }
 }
 
-pub fn convert_field(ccx: &CrateCtxt,
-                     struct_generics: &ty::Generics,
-                     v: &ast::StructField,
-                     origin: ast::DefId) -> ty::field_ty {
+pub fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                struct_generics: &ty::Generics<'tcx>,
+                                v: &ast::StructField,
+                                origin: ast::DefId) -> ty::field_ty {
     let tt = ccx.to_ty(&ExplicitRscope, &*v.node.ty);
     write_ty_to_tcx(ccx.tcx, v.node.id, tt);
     /* add the field to the tcache */
@@ -456,10 +456,10 @@ pub fn convert_field(ccx: &CrateCtxt,
     }
 }
 
-fn convert_associated_type(ccx: &CrateCtxt,
-                           trait_def: &ty::TraitDef,
-                           associated_type: &ast::AssociatedType)
-                           -> ty::Polytype {
+fn convert_associated_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                     trait_def: &ty::TraitDef<'tcx>,
+                                     associated_type: &ast::AssociatedType)
+                                     -> ty::Polytype<'tcx> {
     // Find the type parameter ID corresponding to this
     // associated type.
     let type_parameter_def = trait_def.generics
@@ -515,14 +515,14 @@ enum ConvertMethodContext<'a> {
     TraitConvertMethodContext(ast::DefId, &'a [ast::TraitItem]),
 }
 
-fn convert_methods<'a,I>(ccx: &CrateCtxt,
-                         convert_method_context: ConvertMethodContext,
-                         container: ImplOrTraitItemContainer,
-                         mut ms: I,
-                         untransformed_rcvr_ty: Ty,
-                         rcvr_ty_generics: &ty::Generics,
-                         rcvr_visibility: ast::Visibility)
-                         where I: Iterator<&'a ast::Method> {
+fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
+                                 convert_method_context: ConvertMethodContext,
+                                 container: ImplOrTraitItemContainer,
+                                 mut ms: I,
+                                 untransformed_rcvr_ty: Ty<'tcx>,
+                                 rcvr_ty_generics: &ty::Generics<'tcx>,
+                                 rcvr_visibility: ast::Visibility)
+                                 where I: Iterator<&'i ast::Method> {
     debug!("convert_methods(untransformed_rcvr_ty={}, \
             rcvr_ty_generics={})",
            untransformed_rcvr_ty.repr(ccx.tcx),
@@ -564,14 +564,14 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
            .insert(mty.def_id, ty::MethodTraitItem(mty));
     }
 
-    fn ty_of_method(ccx: &CrateCtxt,
+    fn ty_of_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                     convert_method_context: ConvertMethodContext,
-                    container: ImplOrTraitItemContainer,
-                    m: &ast::Method,
-                    untransformed_rcvr_ty: Ty,
-                    rcvr_ty_generics: &ty::Generics,
-                    rcvr_visibility: ast::Visibility)
-                    -> ty::Method {
+                              container: ImplOrTraitItemContainer,
+                              m: &ast::Method,
+                              untransformed_rcvr_ty: Ty<'tcx>,
+                              rcvr_ty_generics: &ty::Generics<'tcx>,
+                              rcvr_visibility: ast::Visibility)
+                              -> ty::Method<'tcx> {
         let m_ty_generics =
             ty_generics_for_fn_or_method(
                 ccx,
@@ -679,12 +679,12 @@ fn is_associated_type_valid_for_param(ty: Ty,
     false
 }
 
-fn find_associated_type_in_generics(tcx: &ty::ctxt,
-                                    span: Span,
-                                    ty: Option<Ty>,
-                                    associated_type_id: ast::DefId,
-                                    generics: &ty::Generics)
-                                    -> Ty {
+fn find_associated_type_in_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                          span: Span,
+                                          ty: Option<Ty<'tcx>>,
+                                          associated_type_id: ast::DefId,
+                                          generics: &ty::Generics<'tcx>)
+                                          -> Ty<'tcx> {
     let ty = match ty {
         None => {
             tcx.sess.span_bug(span,
@@ -732,7 +732,7 @@ struct ImplCtxt<'a,'tcx:'a> {
     ccx: &'a CrateCtxt<'a,'tcx>,
     opt_trait_ref_id: Option<ast::DefId>,
     impl_items: &'a [ast::ImplItem],
-    impl_generics: &'a ty::Generics,
+    impl_generics: &'a ty::Generics<'tcx>,
 }
 
 impl<'a,'tcx> AstConv<'tcx> for ImplCtxt<'a,'tcx> {
@@ -740,20 +740,20 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.ccx.tcx
     }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         self.ccx.get_item_ty(id)
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         self.ccx.get_trait_def(id)
     }
 
-    fn ty_infer(&self, span: Span) -> Ty {
+    fn ty_infer(&self, span: Span) -> Ty<'tcx> {
         self.ccx.ty_infer(span)
     }
 
     fn associated_types_of_trait_are_valid(&self,
-                                           ty: Ty,
+                                           ty: Ty<'tcx>,
                                            trait_id: ast::DefId)
                                            -> bool {
         // OK if the trait with the associated type is the trait we're
@@ -774,10 +774,10 @@ fn associated_types_of_trait_are_valid(&self,
 
     fn associated_type_binding(&self,
                                span: Span,
-                               ty: Option<Ty>,
+                               ty: Option<Ty<'tcx>>,
                                trait_id: ast::DefId,
                                associated_type_id: ast::DefId)
-                               -> Ty
+                               -> Ty<'tcx>
     {
         let trait_def = ty::lookup_trait_def(self.tcx(), trait_id);
         match self.opt_trait_ref_id {
@@ -821,7 +821,7 @@ fn associated_type_binding(&self,
 
 struct FnCtxt<'a,'tcx:'a> {
     ccx: &'a CrateCtxt<'a,'tcx>,
-    generics: &'a ty::Generics,
+    generics: &'a ty::Generics<'tcx>,
 }
 
 impl<'a,'tcx> AstConv<'tcx> for FnCtxt<'a,'tcx> {
@@ -829,20 +829,20 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.ccx.tcx
     }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         self.ccx.get_item_ty(id)
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         self.ccx.get_trait_def(id)
     }
 
-    fn ty_infer(&self, span: Span) -> Ty {
+    fn ty_infer(&self, span: Span) -> Ty<'tcx> {
         self.ccx.ty_infer(span)
     }
 
     fn associated_types_of_trait_are_valid(&self,
-                                           ty: Ty,
+                                           ty: Ty<'tcx>,
                                            trait_id: ast::DefId)
                                            -> bool {
         // OK if the trait with the associated type is one of the traits in
@@ -852,10 +852,10 @@ fn associated_types_of_trait_are_valid(&self,
 
     fn associated_type_binding(&self,
                                span: Span,
-                               ty: Option<Ty>,
+                               ty: Option<Ty<'tcx>>,
                                _: ast::DefId,
                                associated_type_id: ast::DefId)
-                               -> Ty {
+                               -> Ty<'tcx> {
         debug!("collect::FnCtxt::associated_type_binding()");
 
         // The ID should map to an associated type on one of the traits in
@@ -870,7 +870,7 @@ fn associated_type_binding(&self,
 
 struct ImplMethodCtxt<'a,'tcx:'a> {
     ccx: &'a CrateCtxt<'a,'tcx>,
-    method_generics: &'a ty::Generics,
+    method_generics: &'a ty::Generics<'tcx>,
 }
 
 impl<'a,'tcx> AstConv<'tcx> for ImplMethodCtxt<'a,'tcx> {
@@ -878,20 +878,20 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.ccx.tcx
     }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         self.ccx.get_item_ty(id)
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         self.ccx.get_trait_def(id)
     }
 
-    fn ty_infer(&self, span: Span) -> Ty {
+    fn ty_infer(&self, span: Span) -> Ty<'tcx> {
         self.ccx.ty_infer(span)
     }
 
     fn associated_types_of_trait_are_valid(&self,
-                                           ty: Ty,
+                                           ty: Ty<'tcx>,
                                            trait_id: ast::DefId)
                                            -> bool {
         is_associated_type_valid_for_param(ty, trait_id, self.method_generics)
@@ -899,10 +899,10 @@ fn associated_types_of_trait_are_valid(&self,
 
     fn associated_type_binding(&self,
                                span: Span,
-                               ty: Option<Ty>,
+                               ty: Option<Ty<'tcx>>,
                                _: ast::DefId,
                                associated_type_id: ast::DefId)
-                               -> Ty {
+                               -> Ty<'tcx> {
         debug!("collect::ImplMethodCtxt::associated_type_binding()");
 
         // The ID should map to an associated type on one of the traits in
@@ -919,7 +919,7 @@ struct TraitMethodCtxt<'a,'tcx:'a> {
     ccx: &'a CrateCtxt<'a,'tcx>,
     trait_id: ast::DefId,
     trait_items: &'a [ast::TraitItem],
-    method_generics: &'a ty::Generics,
+    method_generics: &'a ty::Generics<'tcx>,
 }
 
 impl<'a,'tcx> AstConv<'tcx> for TraitMethodCtxt<'a,'tcx> {
@@ -927,20 +927,20 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.ccx.tcx
     }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         self.ccx.get_item_ty(id)
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         self.ccx.get_trait_def(id)
     }
 
-    fn ty_infer(&self, span: Span) -> Ty {
+    fn ty_infer(&self, span: Span) -> Ty<'tcx> {
         self.ccx.ty_infer(span)
     }
 
     fn associated_types_of_trait_are_valid(&self,
-                                           ty: Ty,
+                                           ty: Ty<'tcx>,
                                            trait_id: ast::DefId)
                                            -> bool {
         // OK if the trait with the associated type is this trait.
@@ -955,10 +955,10 @@ fn associated_types_of_trait_are_valid(&self,
 
     fn associated_type_binding(&self,
                                span: Span,
-                               ty: Option<Ty>,
+                               ty: Option<Ty<'tcx>>,
                                trait_id: ast::DefId,
                                associated_type_id: ast::DefId)
-                               -> Ty {
+                               -> Ty<'tcx> {
         debug!("collect::TraitMethodCtxt::associated_type_binding()");
 
         // If this is one of our own associated types, return it.
@@ -997,30 +997,30 @@ fn associated_type_binding(&self,
     }
 }
 
-struct GenericsCtxt<'a,AC:'a> {
+struct GenericsCtxt<'a,'tcx:'a,AC:'a> {
     chain: &'a AC,
-    associated_types_generics: &'a ty::Generics,
+    associated_types_generics: &'a ty::Generics<'tcx>,
 }
 
-impl<'a,'tcx,AC:AstConv<'tcx>> AstConv<'tcx> for GenericsCtxt<'a,AC> {
+impl<'a,'tcx,AC:AstConv<'tcx>> AstConv<'tcx> for GenericsCtxt<'a,'tcx,AC> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.chain.tcx()
     }
 
-    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
+    fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
         self.chain.get_item_ty(id)
     }
 
-    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
+    fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
         self.chain.get_trait_def(id)
     }
 
-    fn ty_infer(&self, span: Span) -> Ty {
+    fn ty_infer(&self, span: Span) -> Ty<'tcx> {
         self.chain.ty_infer(span)
     }
 
     fn associated_types_of_trait_are_valid(&self,
-                                           ty: Ty,
+                                           ty: Ty<'tcx>,
                                            trait_id: ast::DefId)
                                            -> bool {
         // OK if the trait with the associated type is one of the traits in
@@ -1032,10 +1032,10 @@ fn associated_types_of_trait_are_valid(&self,
 
     fn associated_type_binding(&self,
                                span: Span,
-                               ty: Option<Ty>,
+                               ty: Option<Ty<'tcx>>,
                                _: ast::DefId,
                                associated_type_id: ast::DefId)
-                               -> Ty {
+                               -> Ty<'tcx> {
         debug!("collect::GenericsCtxt::associated_type_binding()");
 
         // The ID should map to an associated type on one of the traits in
@@ -1241,10 +1241,10 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
     }
 }
 
-pub fn convert_struct(ccx: &CrateCtxt,
-                      struct_def: &ast::StructDef,
-                      pty: ty::Polytype,
-                      id: ast::NodeId) {
+pub fn convert_struct<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                struct_def: &ast::StructDef,
+                                pty: ty::Polytype<'tcx>,
+                                id: ast::NodeId) {
     let tcx = ccx.tcx;
 
     // Write the type of each of the members and check for duplicate fields.
@@ -1324,7 +1324,9 @@ pub fn convert_foreign(ccx: &CrateCtxt, i: &ast::ForeignItem) {
     ccx.tcx.tcache.borrow_mut().insert(local_def(i.id), pty);
 }
 
-fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> Rc<ty::TraitDef> {
+fn get_trait_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                           trait_id: ast::DefId)
+                           -> Rc<ty::TraitDef<'tcx>> {
     if trait_id.krate != ast::LOCAL_CRATE {
         return ty::lookup_trait_def(ccx.tcx, trait_id)
     }
@@ -1338,7 +1340,9 @@ fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> Rc<ty::TraitDef> {
     }
 }
 
-pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
+pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                   it: &ast::Item)
+                                   -> Rc<ty::TraitDef<'tcx>> {
     let def_id = local_def(it.id);
     let tcx = ccx.tcx;
     match tcx.trait_defs.borrow().get(&def_id) {
@@ -1387,11 +1391,11 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
 
     return trait_def;
 
-    fn mk_trait_substs(ccx: &CrateCtxt,
-                       trait_id: ast::NodeId,
-                       generics: &ast::Generics,
-                       items: &[ast::TraitItem])
-                        -> subst::Substs
+    fn mk_trait_substs<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                 trait_id: ast::NodeId,
+                                 generics: &ast::Generics,
+                                 items: &[ast::TraitItem])
+                                 -> subst::Substs<'tcx>
     {
         // Creates a no-op substitution for the trait's type parameters.
         let regions =
@@ -1437,8 +1441,8 @@ fn mk_trait_substs(ccx: &CrateCtxt,
     }
 }
 
-pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item)
-                  -> ty::Polytype {
+pub fn ty_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
+                            -> ty::Polytype<'tcx> {
     let def_id = local_def(it.id);
     let tcx = ccx.tcx;
     match tcx.tcache.borrow().get(&def_id) {
@@ -1537,9 +1541,9 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item)
     }
 }
 
-pub fn ty_of_foreign_item(ccx: &CrateCtxt,
-                          it: &ast::ForeignItem,
-                          abi: abi::Abi) -> ty::Polytype
+pub fn ty_of_foreign_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                    it: &ast::ForeignItem,
+                                    abi: abi::Abi) -> ty::Polytype<'tcx>
 {
     match it.node {
         ast::ForeignItemFn(ref fn_decl, ref generics) => {
@@ -1558,8 +1562,9 @@ pub fn ty_of_foreign_item(ccx: &CrateCtxt,
     }
 }
 
-fn ty_of_trait_item(ccx: &CrateCtxt, trait_item: &ast::TraitItem)
-                    -> ty::Polytype {
+fn ty_of_trait_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                              trait_item: &ast::TraitItem)
+                              -> ty::Polytype<'tcx> {
     match *trait_item {
         ast::RequiredMethod(ref m) => {
             ccx.tcx.sess.span_bug(m.span,
@@ -1584,11 +1589,11 @@ fn ty_of_trait_item(ccx: &CrateCtxt, trait_item: &ast::TraitItem)
     }
 }
 
-fn ty_generics_for_type(ccx: &CrateCtxt,
-                        generics: &ast::Generics,
-                        create_type_parameters_for_associated_types:
-                            CreateTypeParametersForAssociatedTypesFlag)
-                        -> ty::Generics {
+fn ty_generics_for_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                  generics: &ast::Generics,
+                                  create_type_parameters_for_associated_types:
+                                      CreateTypeParametersForAssociatedTypesFlag)
+                                  -> ty::Generics<'tcx> {
     ty_generics(ccx,
                 subst::TypeSpace,
                 generics.lifetimes.as_slice(),
@@ -1598,12 +1603,12 @@ fn ty_generics_for_type(ccx: &CrateCtxt,
                 create_type_parameters_for_associated_types)
 }
 
-fn ty_generics_for_trait(ccx: &CrateCtxt,
-                         trait_id: ast::NodeId,
-                         substs: &subst::Substs,
-                         ast_generics: &ast::Generics,
-                         items: &[ast::TraitItem])
-                         -> ty::Generics {
+fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                   trait_id: ast::NodeId,
+                                   substs: &subst::Substs<'tcx>,
+                                   ast_generics: &ast::Generics,
+                                   items: &[ast::TraitItem])
+                                   -> ty::Generics<'tcx> {
     let mut generics =
         ty_generics(ccx,
                     subst::TypeSpace,
@@ -1667,10 +1672,10 @@ fn ty_generics_for_trait(ccx: &CrateCtxt,
 fn ty_generics_for_fn_or_method<'tcx,AC>(
         this: &AC,
         generics: &ast::Generics,
-        base_generics: ty::Generics,
+        base_generics: ty::Generics<'tcx>,
         create_type_parameters_for_associated_types:
         CreateTypeParametersForAssociatedTypesFlag)
-        -> ty::Generics
+        -> ty::Generics<'tcx>
         where AC: AstConv<'tcx> {
     let early_lifetimes = resolve_lifetime::early_bound_lifetimes(generics);
     ty_generics(this,
@@ -1730,11 +1735,11 @@ fn ty_generics<'tcx,AC>(this: &AC,
                         space: subst::ParamSpace,
                         lifetime_defs: &[ast::LifetimeDef],
                         types: &[ast::TyParam],
-                        base_generics: ty::Generics,
+                        base_generics: ty::Generics<'tcx>,
                         where_clause: &ast::WhereClause,
                         create_type_parameters_for_associated_types_flag:
                         CreateTypeParametersForAssociatedTypesFlag)
-                        -> ty::Generics
+                        -> ty::Generics<'tcx>
                         where AC: AstConv<'tcx>
 {
     let mut result = base_generics;
@@ -1801,7 +1806,7 @@ fn create_type_parameters_for_associated_types<'tcx,AC>(
         this: &AC,
         space: subst::ParamSpace,
         types: &[ast::TyParam],
-        associated_types_generics: &mut ty::Generics)
+        associated_types_generics: &mut ty::Generics<'tcx>)
         where AC: AstConv<'tcx>
     {
         // The idea here is roughly as follows. We start with
@@ -1880,7 +1885,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
                                              index: uint,
                                              where_clause: &ast::WhereClause,
                                              associated_with: Option<ast::DefId>)
-                                             -> ty::TypeParameterDef
+                                             -> ty::TypeParameterDef<'tcx>
     where AC: AstConv<'tcx>
 {
     match this.tcx().ty_param_defs.borrow().get(&param.id) {
@@ -1939,7 +1944,7 @@ fn compute_bounds<'tcx,AC>(this: &AC,
                            unbound: &Option<ast::TraitRef>,
                            span: Span,
                            where_clause: &ast::WhereClause)
-                           -> ty::ParamBounds
+                           -> ty::ParamBounds<'tcx>
                            where AC: AstConv<'tcx> {
     /*!
      * Translate the AST's notion of ty param bounds (which are an
@@ -1971,10 +1976,10 @@ fn compute_bounds<'tcx,AC>(this: &AC,
     param_bounds
 }
 
-fn check_bounds_compatible(tcx: &ty::ctxt,
-                           name_of_bounded_thing: ast::Name,
-                           param_bounds: &ty::ParamBounds,
-                           span: Span) {
+fn check_bounds_compatible<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                 name_of_bounded_thing: ast::Name,
+                                 param_bounds: &ty::ParamBounds<'tcx>,
+                                 span: Span) {
     // Currently the only bound which is incompatible with other bounds is
     // Sized/Unsized.
     if !param_bounds.builtin_bounds.contains(&ty::BoundSized) {
@@ -2000,7 +2005,7 @@ fn conv_param_bounds<'tcx,AC>(this: &AC,
                               param_ty: ty::ParamTy,
                               ast_bounds: &[ast::TyParamBound],
                               where_clause: &ast::WhereClause)
-                              -> ty::ParamBounds
+                              -> ty::ParamBounds<'tcx>
                               where AC: AstConv<'tcx> {
     let all_bounds =
         merge_param_bounds(this.tcx(), param_ty, ast_bounds, where_clause);
@@ -2064,12 +2069,12 @@ fn merge_param_bounds<'a>(tcx: &ty::ctxt,
     result
 }
 
-pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
-                             decl: &ast::FnDecl,
-                             def_id: ast::DefId,
-                             ast_generics: &ast::Generics,
-                             abi: abi::Abi)
-                             -> ty::Polytype {
+pub fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                       decl: &ast::FnDecl,
+                                       def_id: ast::DefId,
+                                       ast_generics: &ast::Generics,
+                                       abi: abi::Abi)
+                                       -> ty::Polytype<'tcx> {
     for i in decl.inputs.iter() {
         match (*i).pat.node {
             ast::PatIdent(_, _, _) => (),
@@ -2117,9 +2122,9 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
     return pty;
 }
 
-pub fn mk_item_substs(ccx: &CrateCtxt,
-                      ty_generics: &ty::Generics)
-                      -> subst::Substs
+pub fn mk_item_substs<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
+                                ty_generics: &ty::Generics<'tcx>)
+                                -> subst::Substs<'tcx>
 {
     let types =
         ty_generics.types.map(
@@ -2135,10 +2140,10 @@ pub fn mk_item_substs(ccx: &CrateCtxt,
 
 /// Verifies that the explicit self type of a method matches the impl or
 /// trait.
-fn check_method_self_type<RS:RegionScope>(
-    crate_context: &CrateCtxt,
+fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
+    crate_context: &CrateCtxt<'a, 'tcx>,
     rs: &RS,
-    required_type: Ty,
+    required_type: Ty<'tcx>,
     explicit_self: &ast::ExplicitSelf,
     body_id: ast::NodeId)
 {
index bc520e264d1374e502999ae639074b0d9344dbaa..c2e9a5d513325a73cbadc8047f044b4efca9ad54 100644 (file)
@@ -88,7 +88,7 @@ pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f, 'tcx> {
         let Coerce(ref v) = *self; v
     }
 
-    pub fn tys(&self, a: Ty, b: Ty) -> CoerceResult {
+    pub fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CoerceResult<'tcx> {
         debug!("Coerce.tys({} => {})",
                a.repr(self.get_ref().infcx.tcx),
                b.repr(self.get_ref().infcx.tcx));
@@ -190,14 +190,14 @@ pub fn tys(&self, a: Ty, b: Ty) -> CoerceResult {
         })
     }
 
-    pub fn subtype(&self, a: Ty, b: Ty) -> CoerceResult {
+    pub fn subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CoerceResult<'tcx> {
         match Sub(self.get_ref().clone()).tys(a, b) {
             Ok(_) => Ok(None),         // No coercion required.
             Err(ref e) => Err(*e)
         }
     }
 
-    pub fn unpack_actual_value<T>(&self, a: Ty, f: |&ty::sty| -> T)
+    pub fn unpack_actual_value<T>(&self, a: Ty<'tcx>, f: |&ty::sty<'tcx>| -> T)
                                   -> T {
         match resolve_type(self.get_ref().infcx, None,
                            a, try_resolve_tvar_shallow) {
@@ -215,11 +215,11 @@ pub fn unpack_actual_value<T>(&self, a: Ty, f: |&ty::sty| -> T)
 
     // ~T -> &T or &mut T -> &T (including where T = [U] or str)
     pub fn coerce_borrowed_pointer(&self,
-                                   a: Ty,
-                                   sty_a: &ty::sty,
-                                   b: Ty,
+                                   a: Ty<'tcx>,
+                                   sty_a: &ty::sty<'tcx>,
+                                   b: Ty<'tcx>,
                                    mutbl_b: ast::Mutability)
-                                   -> CoerceResult {
+                                   -> CoerceResult<'tcx> {
         debug!("coerce_borrowed_pointer(a={}, sty_a={}, b={})",
                a.repr(self.get_ref().infcx.tcx), sty_a,
                b.repr(self.get_ref().infcx.tcx));
@@ -258,10 +258,10 @@ pub fn coerce_borrowed_pointer(&self,
     // or &mut [T, ..n] -> &mut [T]
     // or &Concrete -> &Trait, etc.
     fn coerce_unsized(&self,
-                      a: Ty,
-                      sty_a: &ty::sty,
-                      b: Ty)
-                      -> CoerceResult {
+                      a: Ty<'tcx>,
+                      sty_a: &ty::sty<'tcx>,
+                      b: Ty<'tcx>)
+                      -> CoerceResult<'tcx> {
         debug!("coerce_unsized(a={}, sty_a={}, b={})",
                a.repr(self.get_ref().infcx.tcx), sty_a,
                b.repr(self.get_ref().infcx.tcx));
@@ -349,10 +349,10 @@ fn coerce_unsized(&self,
     // performed to unsize it.
     // E.g., `[T, ..n]` -> `([T], UnsizeLength(n))`
     fn unsize_ty(&self,
-                 ty_a: Ty,
-                 sty_a: &ty::sty,
-                 ty_b: Ty)
-                 -> Option<(Ty, ty::UnsizeKind)> {
+                 ty_a: Ty<'tcx>,
+                 sty_a: &ty::sty<'tcx>,
+                 ty_b: Ty<'tcx>)
+                 -> Option<(Ty<'tcx>, ty::UnsizeKind<'tcx>)> {
         debug!("unsize_ty(sty_a={}, ty_b={})", sty_a, ty_b.repr(self.get_ref().infcx.tcx));
 
         let tcx = self.get_ref().infcx.tcx;
@@ -425,10 +425,10 @@ fn unsize_ty(&self,
     }
 
     fn coerce_borrowed_object(&self,
-                              a: Ty,
-                              sty_a: &ty::sty,
-                              b: Ty,
-                              b_mutbl: ast::Mutability) -> CoerceResult
+                              a: Ty<'tcx>,
+                              sty_a: &ty::sty<'tcx>,
+                              b: Ty<'tcx>,
+                              b_mutbl: ast::Mutability) -> CoerceResult<'tcx>
     {
         let tcx = self.get_ref().infcx.tcx;
 
@@ -445,10 +445,10 @@ fn coerce_borrowed_object(&self,
     }
 
     fn coerce_unsafe_object(&self,
-                            a: Ty,
-                            sty_a: &ty::sty,
-                            b: Ty,
-                            b_mutbl: ast::Mutability) -> CoerceResult
+                            a: Ty<'tcx>,
+                            sty_a: &ty::sty<'tcx>,
+                            b: Ty<'tcx>,
+                            b_mutbl: ast::Mutability) -> CoerceResult<'tcx>
     {
         let tcx = self.get_ref().infcx.tcx;
 
@@ -462,12 +462,12 @@ fn coerce_unsafe_object(&self,
     }
 
     fn coerce_object(&self,
-                     a: Ty,
-                     sty_a: &ty::sty,
-                     b: Ty,
+                     a: Ty<'tcx>,
+                     sty_a: &ty::sty<'tcx>,
+                     b: Ty<'tcx>,
                      b_mutbl: ast::Mutability,
-                     mk_ty: |Ty| -> Ty,
-                     mk_adjust: || -> ty::AutoRef) -> CoerceResult
+                     mk_ty: |Ty<'tcx>| -> Ty<'tcx>,
+                     mk_adjust: || -> ty::AutoRef<'tcx>) -> CoerceResult<'tcx>
     {
         let tcx = self.get_ref().infcx.tcx;
 
@@ -494,10 +494,10 @@ fn coerce_object(&self,
     }
 
     pub fn coerce_borrowed_fn(&self,
-                              a: Ty,
-                              sty_a: &ty::sty,
-                              b: Ty)
-                              -> CoerceResult {
+                              a: Ty<'tcx>,
+                              sty_a: &ty::sty<'tcx>,
+                              b: Ty<'tcx>)
+                              -> CoerceResult<'tcx> {
         debug!("coerce_borrowed_fn(a={}, sty_a={}, b={})",
                a.repr(self.get_ref().infcx.tcx), sty_a,
                b.repr(self.get_ref().infcx.tcx));
@@ -512,8 +512,8 @@ pub fn coerce_borrowed_fn(&self,
         }
     }
 
-    fn coerce_from_bare_fn(&self, a: Ty, fn_ty_a: &ty::BareFnTy, b: Ty)
-                           -> CoerceResult {
+    fn coerce_from_bare_fn(&self, a: Ty<'tcx>, fn_ty_a: &ty::BareFnTy<'tcx>, b: Ty<'tcx>)
+                           -> CoerceResult<'tcx> {
         /*!
          *
          * Attempts to coerce from a bare Rust function (`extern
@@ -546,11 +546,11 @@ fn coerce_from_bare_fn(&self, a: Ty, fn_ty_a: &ty::BareFnTy, b: Ty)
     }
 
     pub fn coerce_unsafe_ptr(&self,
-                             a: Ty,
-                             sty_a: &ty::sty,
-                             b: Ty,
+                             a: Ty<'tcx>,
+                             sty_a: &ty::sty<'tcx>,
+                             b: Ty<'tcx>,
                              mutbl_b: ast::Mutability)
-                             -> CoerceResult {
+                             -> CoerceResult<'tcx> {
         debug!("coerce_unsafe_ptr(a={}, sty_a={}, b={})",
                a.repr(self.get_ref().infcx.tcx), sty_a,
                b.repr(self.get_ref().infcx.tcx));
index c0258c0c651a3a9aa70168eab234cf0cc50af482..811284cdd727892c558bbe38a422fd79f06f7bc5 100644 (file)
@@ -62,22 +62,22 @@ pub trait Combine<'tcx> {
     fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.infcx().tcx }
     fn tag(&self) -> String;
     fn a_is_expected(&self) -> bool;
-    fn trace(&self) -> TypeTrace;
+    fn trace(&self) -> TypeTrace<'tcx>;
 
     fn equate<'a>(&'a self) -> Equate<'a, 'tcx>;
     fn sub<'a>(&'a self) -> Sub<'a, 'tcx>;
     fn lub<'a>(&'a self) -> Lub<'a, 'tcx>;
     fn glb<'a>(&'a self) -> Glb<'a, 'tcx>;
 
-    fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt>;
-    fn contratys(&self, a: Ty, b: Ty) -> cres<Ty>;
-    fn tys(&self, a: Ty, b: Ty) -> cres<Ty>;
+    fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>>;
+    fn contratys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>>;
+    fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>>;
 
     fn tps(&self,
            _: subst::ParamSpace,
-           as_: &[Ty],
-           bs: &[Ty])
-           -> cres<Vec<Ty>> {
+           as_: &[Ty<'tcx>],
+           bs: &[Ty<'tcx>])
+           -> cres<'tcx, Vec<Ty<'tcx>>> {
         // FIXME -- In general, we treat variance a bit wrong
         // here. For historical reasons, we treat tps and Self
         // as invariant. This is overly conservative.
@@ -96,9 +96,9 @@ fn tps(&self,
 
     fn substs(&self,
               item_def_id: ast::DefId,
-              a_subst: &subst::Substs,
-              b_subst: &subst::Substs)
-              -> cres<subst::Substs>
+              a_subst: &subst::Substs<'tcx>,
+              b_subst: &subst::Substs<'tcx>)
+              -> cres<'tcx, subst::Substs<'tcx>>
     {
         let variances = if self.infcx().tcx.variance_computed.get() {
             Some(ty::item_variances(self.infcx().tcx, item_def_id))
@@ -110,9 +110,9 @@ fn substs(&self,
 
     fn substs_variances(&self,
                         variances: Option<&ty::ItemVariances>,
-                        a_subst: &subst::Substs,
-                        b_subst: &subst::Substs)
-                        -> cres<subst::Substs>
+                        a_subst: &subst::Substs<'tcx>,
+                        b_subst: &subst::Substs<'tcx>)
+                        -> cres<'tcx, subst::Substs<'tcx>>
     {
         let mut substs = subst::Substs::empty();
 
@@ -161,7 +161,7 @@ fn relate_region_params<'tcx, C: Combine<'tcx>>(this: &C,
                                                         variances: &[ty::Variance],
                                                         a_rs: &[ty::Region],
                                                         b_rs: &[ty::Region])
-                                                        -> cres<Vec<ty::Region>> {
+                                                        -> cres<'tcx, Vec<ty::Region>> {
             let tcx = this.infcx().tcx;
             let num_region_params = variances.len();
 
@@ -192,8 +192,8 @@ fn relate_region_params<'tcx, C: Combine<'tcx>>(this: &C,
         }
     }
 
-    fn bare_fn_tys(&self, a: &ty::BareFnTy,
-                   b: &ty::BareFnTy) -> cres<ty::BareFnTy> {
+    fn bare_fn_tys(&self, a: &ty::BareFnTy<'tcx>,
+                   b: &ty::BareFnTy<'tcx>) -> cres<'tcx, ty::BareFnTy<'tcx>> {
         let fn_style = try!(self.fn_styles(a.fn_style, b.fn_style));
         let abi = try!(self.abi(a.abi, b.abi));
         let sig = try!(self.fn_sigs(&a.sig, &b.sig));
@@ -202,8 +202,8 @@ fn bare_fn_tys(&self, a: &ty::BareFnTy,
                 sig: sig})
     }
 
-    fn closure_tys(&self, a: &ty::ClosureTy,
-                   b: &ty::ClosureTy) -> cres<ty::ClosureTy> {
+    fn closure_tys(&self, a: &ty::ClosureTy<'tcx>,
+                   b: &ty::ClosureTy<'tcx>) -> cres<'tcx, ty::ClosureTy<'tcx>> {
 
         let store = match (a.store, b.store) {
             (ty::RegionTraitStore(a_r, a_m),
@@ -235,15 +235,15 @@ fn closure_tys(&self, a: &ty::ClosureTy,
         })
     }
 
-    fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig>;
+    fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> cres<'tcx, ty::FnSig<'tcx>>;
 
-    fn args(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn args(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         self.contratys(a, b).and_then(|t| Ok(t))
     }
 
-    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle>;
+    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<'tcx, FnStyle>;
 
-    fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<abi::Abi> {
+    fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<'tcx, abi::Abi> {
         if a == b {
             Ok(a)
         } else {
@@ -251,12 +251,12 @@ fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<abi::Abi> {
         }
     }
 
-    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness>;
+    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<'tcx, Onceness>;
 
     fn existential_bounds(&self,
                           a: ty::ExistentialBounds,
                           b: ty::ExistentialBounds)
-                          -> cres<ty::ExistentialBounds>
+                          -> cres<'tcx, ty::ExistentialBounds>
     {
         let r = try!(self.contraregions(a.region_bound, b.region_bound));
         let nb = try!(self.builtin_bounds(a.builtin_bounds, b.builtin_bounds));
@@ -267,18 +267,18 @@ fn existential_bounds(&self,
     fn builtin_bounds(&self,
                       a: ty::BuiltinBounds,
                       b: ty::BuiltinBounds)
-                      -> cres<ty::BuiltinBounds>;
+                      -> cres<'tcx, ty::BuiltinBounds>;
 
     fn contraregions(&self, a: ty::Region, b: ty::Region)
-                  -> cres<ty::Region>;
+                  -> cres<'tcx, ty::Region>;
 
-    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region>;
+    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region>;
 
     fn trait_stores(&self,
                     vk: ty::terr_vstore_kind,
                     a: ty::TraitStore,
                     b: ty::TraitStore)
-                    -> cres<ty::TraitStore> {
+                    -> cres<'tcx, ty::TraitStore> {
         debug!("{}.trait_stores(a={}, b={})", self.tag(), a, b);
 
         match (a, b) {
@@ -300,9 +300,9 @@ fn trait_stores(&self,
     }
 
     fn trait_refs(&self,
-                  a: &ty::TraitRef,
-                  b: &ty::TraitRef)
-                  -> cres<ty::TraitRef>;
+                  a: &ty::TraitRef<'tcx>,
+                  b: &ty::TraitRef<'tcx>)
+                  -> cres<'tcx, ty::TraitRef<'tcx>>;
     // this must be overridden to do correctly, so as to account for higher-ranked
     // behavior
 }
@@ -311,7 +311,7 @@ fn trait_refs(&self,
 pub struct CombineFields<'a, 'tcx: 'a> {
     pub infcx: &'a InferCtxt<'a, 'tcx>,
     pub a_is_expected: bool,
-    pub trace: TypeTrace,
+    pub trace: TypeTrace<'tcx>,
 }
 
 pub fn expected_found<'tcx, C: Combine<'tcx>, T>(
@@ -323,7 +323,10 @@ pub fn expected_found<'tcx, C: Combine<'tcx>, T>(
     }
 }
 
-pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: Ty, b: Ty) -> cres<Ty> {
+pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
+                                         a: Ty<'tcx>,
+                                         b: Ty<'tcx>)
+                                         -> cres<'tcx, Ty<'tcx>> {
 
     let tcx = this.infcx().tcx;
     let a_sty = &ty::get(a).sty;
@@ -513,7 +516,7 @@ fn unify_integral_variable<'tcx, C: Combine<'tcx>>(
         this: &C,
         vid_is_expected: bool,
         vid: ty::IntVid,
-        val: ty::IntVarValue) -> cres<Ty>
+        val: ty::IntVarValue) -> cres<'tcx, Ty<'tcx>>
     {
         try!(this.infcx().simple_var_t(vid_is_expected, vid, val));
         match val {
@@ -526,7 +529,7 @@ fn unify_float_variable<'tcx, C: Combine<'tcx>>(
         this: &C,
         vid_is_expected: bool,
         vid: ty::FloatVid,
-        val: ast::FloatTy) -> cres<Ty>
+        val: ast::FloatTy) -> cres<'tcx, Ty<'tcx>>
     {
         try!(this.infcx().simple_var_t(vid_is_expected, vid, val));
         Ok(ty::mk_mach_float(val))
@@ -550,10 +553,10 @@ fn sub(&self) -> Sub<'f, 'tcx> {
     }
 
     pub fn instantiate(&self,
-                       a_ty: Ty,
+                       a_ty: Ty<'tcx>,
                        dir: RelationDir,
                        b_vid: ty::TyVid)
-                       -> cres<()>
+                       -> cres<'tcx, ()>
     {
         let tcx = self.infcx.tcx;
         let mut stack = Vec::new();
@@ -640,10 +643,10 @@ pub fn instantiate(&self,
     }
 
     fn generalize(&self,
-                  ty: Ty,
+                  ty: Ty<'tcx>,
                   for_vid: ty::TyVid,
                   make_region_vars: bool)
-                  -> cres<Ty>
+                  -> cres<'tcx, Ty<'tcx>>
     {
         /*!
          * Attempts to generalize `ty` for the type variable
@@ -681,7 +684,7 @@ fn tcx(&self) -> &ty::ctxt<'tcx> {
         self.infcx.tcx
     }
 
-    fn fold_ty(&mut self, t: Ty) -> Ty {
+    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
         // Check to see whether the type we are genealizing references
         // `vid`. At the same time, also update any type variables to
         // the values that they are bound to. This is needed to truly
index 88afbf0307ca6c4af777e0ffd4325c38dfb57984..86c51fff640e79aab0e834816df67802caf2c3bf 100644 (file)
@@ -36,22 +36,22 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
     fn infcx<'a>(&'a self) -> &'a InferCtxt<'a, 'tcx> { self.fields.infcx }
     fn tag(&self) -> String { "eq".to_string() }
     fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
-    fn trace(&self) -> TypeTrace { self.fields.trace.clone() }
+    fn trace(&self) -> TypeTrace<'tcx> { self.fields.trace.clone() }
 
     fn equate<'a>(&'a self) -> Equate<'a, 'tcx> { Equate(self.fields.clone()) }
     fn sub<'a>(&'a self) -> Sub<'a, 'tcx> { Sub(self.fields.clone()) }
     fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields.clone()) }
     fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields.clone()) }
 
-    fn contratys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn contratys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         self.tys(a, b)
     }
 
-    fn contraregions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
+    fn contraregions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
         self.regions(a, b)
     }
 
-    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
+    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
         debug!("{}.regions({}, {})",
                self.tag(),
                a.repr(self.fields.infcx.tcx),
@@ -60,7 +60,7 @@ fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
         Ok(a)
     }
 
-    fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
+    fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
         debug!("mts({} <: {})",
                a.repr(self.fields.infcx.tcx),
                b.repr(self.fields.infcx.tcx));
@@ -70,7 +70,7 @@ fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
         Ok(ty::mt { mutbl: a.mutbl, ty: t })
     }
 
-    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
+    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<'tcx, FnStyle> {
         if a != b {
             Err(ty::terr_fn_style_mismatch(expected_found(self, a, b)))
         } else {
@@ -78,7 +78,7 @@ fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
         }
     }
 
-    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
+    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<'tcx, Onceness> {
         if a != b {
             Err(ty::terr_onceness_mismatch(expected_found(self, a, b)))
         } else {
@@ -89,7 +89,7 @@ fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
     fn builtin_bounds(&self,
                       a: BuiltinBounds,
                       b: BuiltinBounds)
-                      -> cres<BuiltinBounds>
+                      -> cres<'tcx, BuiltinBounds>
     {
         // More bounds is a subtype of fewer bounds.
         //
@@ -103,7 +103,7 @@ fn builtin_bounds(&self,
         }
     }
 
-    fn tys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         debug!("{}.tys({}, {})", self.tag(),
                a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));
         if a == b { return Ok(a); }
@@ -133,12 +133,14 @@ fn tys(&self, a: Ty, b: Ty) -> cres<Ty> {
         }
     }
 
-    fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
+    fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>)
+               -> cres<'tcx, ty::FnSig<'tcx>> {
         try!(self.sub().fn_sigs(a, b));
         self.sub().fn_sigs(b, a)
     }
 
-    fn trait_refs(&self, a: &ty::TraitRef, b: &ty::TraitRef) -> cres<ty::TraitRef> {
+    fn trait_refs(&self, a: &ty::TraitRef<'tcx>, b: &ty::TraitRef<'tcx>)
+                  -> cres<'tcx, ty::TraitRef<'tcx>> {
         try!(self.sub().trait_refs(a, b));
         self.sub().trait_refs(b, a)
     }
index 2274a7fecac1aedbbf2499a5c20f62bc31ac1861..7a7a7c796740aa646feab24154e764124edb56e3 100644 (file)
 // messages shouldn't include debug serializations.
 use util::ppaux::UserString;
 
-pub trait ErrorReporting {
+pub trait ErrorReporting<'tcx> {
     fn report_region_errors(&self,
-                            errors: &Vec<RegionResolutionError>);
+                            errors: &Vec<RegionResolutionError<'tcx>>);
 
-    fn process_errors(&self, errors: &Vec<RegionResolutionError>)
-                      -> Vec<RegionResolutionError>;
+    fn process_errors(&self, errors: &Vec<RegionResolutionError<'tcx>>)
+                      -> Vec<RegionResolutionError<'tcx>>;
 
-    fn report_type_error(&self, trace: TypeTrace, terr: &ty::type_err);
+    fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::type_err<'tcx>);
 
     fn report_and_explain_type_error(&self,
-                                     trace: TypeTrace,
-                                     terr: &ty::type_err);
+                                     trace: TypeTrace<'tcx>,
+                                     terr: &ty::type_err<'tcx>);
 
-    fn values_str(&self, values: &ValuePairs) -> Option<String>;
+    fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String>;
 
-    fn expected_found_str<T: UserString + Resolvable>(
+    fn expected_found_str<T: UserString<'tcx> + Resolvable<'tcx>>(
         &self,
         exp_found: &ty::expected_found<T>)
         -> Option<String>;
 
     fn report_concrete_failure(&self,
-                               origin: SubregionOrigin,
+                               origin: SubregionOrigin<'tcx>,
                                sub: Region,
                                sup: Region);
 
     fn report_param_bound_failure(&self,
-                                  origin: SubregionOrigin,
+                                  origin: SubregionOrigin<'tcx>,
                                   param_ty: ty::ParamTy,
                                   sub: Region,
                                   sups: Vec<Region>);
 
     fn report_sub_sup_conflict(&self,
                                var_origin: RegionVariableOrigin,
-                               sub_origin: SubregionOrigin,
+                               sub_origin: SubregionOrigin<'tcx>,
                                sub_region: Region,
-                               sup_origin: SubregionOrigin,
+                               sup_origin: SubregionOrigin<'tcx>,
                                sup_region: Region);
 
     fn report_sup_sup_conflict(&self,
                                var_origin: RegionVariableOrigin,
-                               origin1: SubregionOrigin,
+                               origin1: SubregionOrigin<'tcx>,
                                region1: Region,
-                               origin2: SubregionOrigin,
+                               origin2: SubregionOrigin<'tcx>,
                                region2: Region);
 
     fn report_processed_errors(&self,
                                var_origin: &[RegionVariableOrigin],
-                               trace_origin: &[(TypeTrace, ty::type_err)],
+                               trace_origin: &[(TypeTrace<'tcx>, ty::type_err<'tcx>)],
                                same_regions: &[SameRegions]);
 
     fn give_suggestion(&self, same_regions: &[SameRegions]);
 }
 
-trait ErrorReportingHelpers {
+trait ErrorReportingHelpers<'tcx> {
     fn report_inference_failure(&self,
                                 var_origin: RegionVariableOrigin);
 
     fn note_region_origin(&self,
-                          origin: &SubregionOrigin);
+                          origin: &SubregionOrigin<'tcx>);
 
     fn give_expl_lifetime_param(&self,
                                 decl: &ast::FnDecl,
@@ -166,9 +166,9 @@ fn give_expl_lifetime_param(&self,
                                 span: codemap::Span);
 }
 
-impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> {
+impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
     fn report_region_errors(&self,
-                            errors: &Vec<RegionResolutionError>) {
+                            errors: &Vec<RegionResolutionError<'tcx>>) {
         let p_errors = self.process_errors(errors);
         let errors = if p_errors.is_empty() { errors } else { &p_errors };
         for error in errors.iter() {
@@ -216,8 +216,8 @@ fn report_region_errors(&self,
     // complete view of what lifetimes should be the same.
     // If the return value is an empty vector, it means that processing
     // failed (so the return value of this method should not be used)
-    fn process_errors(&self, errors: &Vec<RegionResolutionError>)
-                      -> Vec<RegionResolutionError> {
+    fn process_errors(&self, errors: &Vec<RegionResolutionError<'tcx>>)
+                      -> Vec<RegionResolutionError<'tcx>> {
         debug!("process_errors()");
         let mut var_origins = Vec::new();
         let mut trace_origins = Vec::new();
@@ -350,7 +350,7 @@ fn append_to_same_regions(same_regions: &mut Vec<SameRegions>,
         }
     }
 
-    fn report_type_error(&self, trace: TypeTrace, terr: &ty::type_err) {
+    fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::type_err<'tcx>) {
         let expected_found_str = match self.values_str(&trace.values) {
             Some(v) => v,
             None => {
@@ -385,13 +385,13 @@ fn report_type_error(&self, trace: TypeTrace, terr: &ty::type_err) {
     }
 
     fn report_and_explain_type_error(&self,
-                                     trace: TypeTrace,
-                                     terr: &ty::type_err) {
+                                     trace: TypeTrace<'tcx>,
+                                     terr: &ty::type_err<'tcx>) {
         self.report_type_error(trace, terr);
         ty::note_and_explain_type_err(self.tcx, terr);
     }
 
-    fn values_str(&self, values: &ValuePairs) -> Option<String> {
+    fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String> {
         /*!
          * Returns a string of the form "expected `{}`, found `{}`",
          * or None if this is a derived error.
@@ -402,7 +402,7 @@ fn values_str(&self, values: &ValuePairs) -> Option<String> {
         }
     }
 
-    fn expected_found_str<T: UserString + Resolvable>(
+    fn expected_found_str<T: UserString<'tcx> + Resolvable<'tcx>>(
         &self,
         exp_found: &ty::expected_found<T>)
         -> Option<String>
@@ -423,7 +423,7 @@ fn expected_found_str<T: UserString + Resolvable>(
     }
 
     fn report_param_bound_failure(&self,
-                                  origin: SubregionOrigin,
+                                  origin: SubregionOrigin<'tcx>,
                                   param_ty: ty::ParamTy,
                                   sub: Region,
                                   _sups: Vec<Region>) {
@@ -488,7 +488,7 @@ fn report_param_bound_failure(&self,
     }
 
     fn report_concrete_failure(&self,
-                               origin: SubregionOrigin,
+                               origin: SubregionOrigin<'tcx>,
                                sub: Region,
                                sup: Region) {
         match origin {
@@ -786,9 +786,9 @@ fn report_concrete_failure(&self,
 
     fn report_sub_sup_conflict(&self,
                                var_origin: RegionVariableOrigin,
-                               sub_origin: SubregionOrigin,
+                               sub_origin: SubregionOrigin<'tcx>,
                                sub_region: Region,
-                               sup_origin: SubregionOrigin,
+                               sup_origin: SubregionOrigin<'tcx>,
                                sup_region: Region) {
         self.report_inference_failure(var_origin);
 
@@ -811,9 +811,9 @@ fn report_sub_sup_conflict(&self,
 
     fn report_sup_sup_conflict(&self,
                                var_origin: RegionVariableOrigin,
-                               origin1: SubregionOrigin,
+                               origin1: SubregionOrigin<'tcx>,
                                region1: Region,
-                               origin2: SubregionOrigin,
+                               origin2: SubregionOrigin<'tcx>,
                                region2: Region) {
         self.report_inference_failure(var_origin);
 
@@ -836,7 +836,7 @@ fn report_sup_sup_conflict(&self,
 
     fn report_processed_errors(&self,
                                var_origins: &[RegionVariableOrigin],
-                               trace_origins: &[(TypeTrace, ty::type_err)],
+                               trace_origins: &[(TypeTrace<'tcx>, ty::type_err<'tcx>)],
                                same_regions: &[SameRegions]) {
         for vo in var_origins.iter() {
             self.report_inference_failure(vo.clone());
@@ -1430,7 +1430,7 @@ fn rebuild_path(&self,
     }
 }
 
-impl<'a, 'tcx> ErrorReportingHelpers for InferCtxt<'a, 'tcx> {
+impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
     fn give_expl_lifetime_param(&self,
                                 decl: &ast::FnDecl,
                                 fn_style: ast::FnStyle,
@@ -1483,7 +1483,7 @@ fn report_inference_failure(&self,
                     var_description).as_slice());
     }
 
-    fn note_region_origin(&self, origin: &SubregionOrigin) {
+    fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
         match *origin {
             infer::Subtype(ref trace) => {
                 let desc = match trace.origin {
@@ -1674,13 +1674,13 @@ fn note_region_origin(&self, origin: &SubregionOrigin) {
     }
 }
 
-pub trait Resolvable {
-    fn resolve(&self, infcx: &InferCtxt) -> Self;
+pub trait Resolvable<'tcx> {
+    fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>) -> Self;
     fn contains_error(&self) -> bool;
 }
 
-impl Resolvable for Ty {
-    fn resolve(&self, infcx: &InferCtxt) -> Ty {
+impl<'tcx> Resolvable<'tcx> for Ty<'tcx> {
+    fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>) -> Ty<'tcx> {
         infcx.resolve_type_vars_if_possible(*self)
     }
     fn contains_error(&self) -> bool {
@@ -1688,8 +1688,9 @@ fn contains_error(&self) -> bool {
     }
 }
 
-impl Resolvable for Rc<ty::TraitRef> {
-    fn resolve(&self, infcx: &InferCtxt) -> Rc<ty::TraitRef> {
+impl<'tcx> Resolvable<'tcx> for Rc<ty::TraitRef<'tcx>> {
+    fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>)
+                   -> Rc<ty::TraitRef<'tcx>> {
         Rc::new(infcx.resolve_type_vars_in_trait_ref_if_possible(&**self))
     }
     fn contains_error(&self) -> bool {
index 940bcf22df506f93e40aaedb30492c12907a1040..671d2e3837c798d8bad9bc820be0e4c4edd602d8 100644 (file)
@@ -39,14 +39,14 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
     fn infcx<'a>(&'a self) -> &'a InferCtxt<'a, 'tcx> { self.fields.infcx }
     fn tag(&self) -> String { "glb".to_string() }
     fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
-    fn trace(&self) -> TypeTrace { self.fields.trace.clone() }
+    fn trace(&self) -> TypeTrace<'tcx> { self.fields.trace.clone() }
 
     fn equate<'a>(&'a self) -> Equate<'a, 'tcx> { Equate(self.fields.clone()) }
     fn sub<'a>(&'a self) -> Sub<'a, 'tcx> { Sub(self.fields.clone()) }
     fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields.clone()) }
     fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields.clone()) }
 
-    fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
+    fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
         let tcx = self.fields.infcx.tcx;
 
         debug!("{}.mts({}, {})",
@@ -77,18 +77,18 @@ fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
         }
     }
 
-    fn contratys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn contratys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         self.lub().tys(a, b)
     }
 
-    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
+    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<'tcx, FnStyle> {
         match (a, b) {
           (NormalFn, _) | (_, NormalFn) => Ok(NormalFn),
           (UnsafeFn, UnsafeFn) => Ok(UnsafeFn)
         }
     }
 
-    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
+    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<'tcx, Onceness> {
         match (a, b) {
             (Many, _) | (_, Many) => Ok(Many),
             (Once, Once) => Ok(Once)
@@ -98,13 +98,13 @@ fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
     fn builtin_bounds(&self,
                       a: ty::BuiltinBounds,
                       b: ty::BuiltinBounds)
-                      -> cres<ty::BuiltinBounds> {
+                      -> cres<'tcx, ty::BuiltinBounds> {
         // More bounds is a subtype of fewer bounds, so
         // the GLB (mutual subtype) is the union.
         Ok(a.union(b))
     }
 
-    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
+    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
         debug!("{}.regions({}, {})",
                self.tag(),
                a.repr(self.fields.infcx.tcx),
@@ -114,19 +114,21 @@ fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
     }
 
     fn contraregions(&self, a: ty::Region, b: ty::Region)
-                    -> cres<ty::Region> {
+                    -> cres<'tcx, ty::Region> {
         self.lub().regions(a, b)
     }
 
-    fn tys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         super_lattice_tys(self, a, b)
     }
 
-    fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
+    fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>)
+               -> cres<'tcx, ty::FnSig<'tcx>> {
         self.higher_ranked_glb(a, b)
     }
 
-    fn trait_refs(&self, a: &ty::TraitRef, b: &ty::TraitRef) -> cres<ty::TraitRef> {
+    fn trait_refs(&self, a: &ty::TraitRef<'tcx>, b: &ty::TraitRef<'tcx>)
+                  -> cres<'tcx, ty::TraitRef<'tcx>> {
         self.higher_ranked_glb(a, b)
     }
 }
index abe82eb1d9a913be8a84c24e27722475126955da..812aa5c55572814c22e4df034da1b32fbc31d5b9 100644 (file)
 use util::nodemap::FnvHashMap;
 use util::ppaux::{bound_region_to_string, Repr};
 
-pub trait HigherRankedCombineable : HigherRankedFoldable + TypeFoldable + Repr {
-    fn super_combine<'tcx,C:Combine<'tcx>>(combiner: &C, a: &Self, b: &Self) -> cres<Self>;
+pub trait HigherRankedCombineable<'tcx>: HigherRankedFoldable<'tcx> +
+                                         TypeFoldable<'tcx> + Repr<'tcx> {
+    fn super_combine<C:Combine<'tcx>>(combiner: &C, a: &Self, b: &Self) -> cres<'tcx, Self>;
 }
 
-pub trait HigherRankedRelations {
-    fn higher_ranked_sub<T>(&self, a: &T, b: &T) -> cres<T>
-        where T : HigherRankedCombineable;
+pub trait HigherRankedRelations<'tcx> {
+    fn higher_ranked_sub<T>(&self, a: &T, b: &T) -> cres<'tcx, T>
+        where T : HigherRankedCombineable<'tcx>;
 
-    fn higher_ranked_lub<T>(&self, a: &T, b: &T) -> cres<T>
-        where T : HigherRankedCombineable;
+    fn higher_ranked_lub<T>(&self, a: &T, b: &T) -> cres<'tcx, T>
+        where T : HigherRankedCombineable<'tcx>;
 
-    fn higher_ranked_glb<T>(&self, a: &T, b: &T) -> cres<T>
-        where T : HigherRankedCombineable;
+    fn higher_ranked_glb<T>(&self, a: &T, b: &T) -> cres<'tcx, T>
+        where T : HigherRankedCombineable<'tcx>;
 }
 
-impl<'tcx,C> HigherRankedRelations for C
+impl<'tcx,C> HigherRankedRelations<'tcx> for C
     where C : Combine<'tcx>
 {
-    fn higher_ranked_sub<T>(&self, a: &T, b: &T) -> cres<T>
-        where T : HigherRankedCombineable
+    fn higher_ranked_sub<T>(&self, a: &T, b: &T) -> cres<'tcx, T>
+        where T : HigherRankedCombineable<'tcx>
     {
         debug!("higher_ranked_sub(a={}, b={})",
                a.repr(self.tcx()), b.repr(self.tcx()));
@@ -121,8 +122,8 @@ fn higher_ranked_sub<T>(&self, a: &T, b: &T) -> cres<T>
         return Ok(result);
     }
 
-    fn higher_ranked_lub<T>(&self, a: &T, b: &T) -> cres<T>
-        where T : HigherRankedCombineable
+    fn higher_ranked_lub<T>(&self, a: &T, b: &T) -> cres<'tcx, T>
+        where T : HigherRankedCombineable<'tcx>
     {
         // Make a mark so we can examine "all bindings that were
         // created as part of this type comparison".
@@ -209,8 +210,8 @@ fn generalize_region(infcx: &InferCtxt,
         }
     }
 
-    fn higher_ranked_glb<T>(&self, a: &T, b: &T) -> cres<T>
-        where T : HigherRankedCombineable
+    fn higher_ranked_glb<T>(&self, a: &T, b: &T) -> cres<'tcx, T>
+        where T : HigherRankedCombineable<'tcx>
     {
         debug!("{}.higher_ranked_glb({}, {})",
                self.tag(), a.repr(self.tcx()), b.repr(self.tcx()));
@@ -345,9 +346,9 @@ fn fresh_bound_variable(infcx: &InferCtxt, debruijn: ty::DebruijnIndex) -> ty::R
     }
 }
 
-impl HigherRankedCombineable for ty::FnSig {
-    fn super_combine<'tcx,C:Combine<'tcx>>(combiner: &C, a: &ty::FnSig, b: &ty::FnSig)
-                                           -> cres<ty::FnSig>
+impl<'tcx> HigherRankedCombineable<'tcx> for ty::FnSig<'tcx> {
+    fn super_combine<C:Combine<'tcx>>(combiner: &C, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>)
+                                      -> cres<'tcx, ty::FnSig<'tcx>>
     {
         if a.variadic != b.variadic {
             return Err(ty::terr_variadic_mismatch(
@@ -374,9 +375,9 @@ fn super_combine<'tcx,C:Combine<'tcx>>(combiner: &C, a: &ty::FnSig, b: &ty::FnSi
 
 
         fn argvecs<'tcx, C: Combine<'tcx>>(combiner: &C,
-                                           a_args: &[Ty],
-                                           b_args: &[Ty])
-                                           -> cres<Vec<Ty>>
+                                           a_args: &[Ty<'tcx>],
+                                           b_args: &[Ty<'tcx>])
+                                           -> cres<'tcx, Vec<Ty<'tcx>>>
         {
             if a_args.len() == b_args.len() {
                 a_args.iter().zip(b_args.iter())
@@ -388,9 +389,11 @@ fn argvecs<'tcx, C: Combine<'tcx>>(combiner: &C,
     }
 }
 
-impl HigherRankedCombineable for ty::TraitRef {
-    fn super_combine<'tcx,C:Combine<'tcx>>(combiner: &C, a: &ty::TraitRef, b: &ty::TraitRef)
-                                           -> cres<ty::TraitRef>
+impl<'tcx> HigherRankedCombineable<'tcx> for ty::TraitRef<'tcx> {
+    fn super_combine<C:Combine<'tcx>>(combiner: &C,
+                                      a: &ty::TraitRef<'tcx>,
+                                      b: &ty::TraitRef<'tcx>)
+                                      -> cres<'tcx, ty::TraitRef<'tcx>>
     {
         // Different traits cannot be related
         if a.def_id != b.def_id {
@@ -424,10 +427,11 @@ fn is_var_in_set(new_vars: &[ty::RegionVid], r: ty::Region) -> bool {
     }
 }
 
-fn fold_regions_in<T:HigherRankedFoldable>(tcx: &ty::ctxt,
-                                           value: &T,
-                                           fldr: |ty::Region, ty::DebruijnIndex| -> ty::Region)
-                                           -> T
+fn fold_regions_in<'tcx, T>(tcx: &ty::ctxt<'tcx>,
+                            value: &T,
+                            fldr: |ty::Region, ty::DebruijnIndex| -> ty::Region)
+                            -> T
+    where T: HigherRankedFoldable<'tcx>
 {
     value.fold_contents(&mut ty_fold::RegionFolder::new(tcx, |region, current_depth| {
         // we should only be encountering "escaping" late-bound regions here,
index 2df42002fa70940f2d3ab25c1ab2116b5357c7f6..4767aa258ba9c7c8fe21ba8a05cd69a2eeb4c525 100644 (file)
 use middle::typeck::infer::lub::Lub;
 use util::ppaux::Repr;
 
-pub trait LatticeDir {
+pub trait LatticeDir<'tcx> {
     // Relates the type `v` to `a` and `b` such that `v` represents
     // the LUB/GLB of `a` and `b` as appropriate.
-    fn relate_bound<'a>(&'a self, v: Ty, a: Ty, b: Ty) -> cres<()>;
+    fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, ()>;
 }
 
-impl<'a, 'tcx> LatticeDir for Lub<'a, 'tcx> {
-    fn relate_bound<'a>(&'a self, v: Ty, a: Ty, b: Ty) -> cres<()> {
+impl<'a, 'tcx> LatticeDir<'tcx> for Lub<'a, 'tcx> {
+    fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, ()> {
         let sub = self.sub();
         try!(sub.tys(a, v));
         try!(sub.tys(b, v));
@@ -54,8 +54,8 @@ fn relate_bound<'a>(&'a self, v: Ty, a: Ty, b: Ty) -> cres<()> {
     }
 }
 
-impl<'a, 'tcx> LatticeDir for Glb<'a, 'tcx> {
-    fn relate_bound<'a>(&'a self, v: Ty, a: Ty, b: Ty) -> cres<()> {
+impl<'a, 'tcx> LatticeDir<'tcx> for Glb<'a, 'tcx> {
+    fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, ()> {
         let sub = self.sub();
         try!(sub.tys(v, a));
         try!(sub.tys(v, b));
@@ -63,10 +63,10 @@ fn relate_bound<'a>(&'a self, v: Ty, a: Ty, b: Ty) -> cres<()> {
     }
 }
 
-pub fn super_lattice_tys<'tcx, L:LatticeDir+Combine<'tcx>>(this: &L,
-                                                           a: Ty,
-                                                           b: Ty)
-                                                           -> cres<Ty>
+pub fn super_lattice_tys<'tcx, L:LatticeDir<'tcx>+Combine<'tcx>>(this: &L,
+                                                                 a: Ty<'tcx>,
+                                                                 b: Ty<'tcx>)
+                                                                 -> cres<'tcx, Ty<'tcx>>
 {
     debug!("{}.lattice_tys({}, {})",
            this.tag(),
index 2ed8b9c73807f68d96a31157cf4f28dd28e702fd..e7bd1f3716c12e3ddef4bef12f63be027fbc8399 100644 (file)
@@ -39,14 +39,14 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> {
     fn infcx<'a>(&'a self) -> &'a InferCtxt<'a, 'tcx> { self.fields.infcx }
     fn tag(&self) -> String { "lub".to_string() }
     fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
-    fn trace(&self) -> TypeTrace { self.fields.trace.clone() }
+    fn trace(&self) -> TypeTrace<'tcx> { self.fields.trace.clone() }
 
     fn equate<'a>(&'a self) -> Equate<'a, 'tcx> { Equate(self.fields.clone()) }
     fn sub<'a>(&'a self) -> Sub<'a, 'tcx> { Sub(self.fields.clone()) }
     fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields.clone()) }
     fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields.clone()) }
 
-    fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
+    fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
         let tcx = self.tcx();
 
         debug!("{}.mts({}, {})",
@@ -72,18 +72,18 @@ fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
         }
     }
 
-    fn contratys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn contratys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         self.glb().tys(a, b)
     }
 
-    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
+    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<'tcx, FnStyle> {
         match (a, b) {
           (UnsafeFn, _) | (_, UnsafeFn) => Ok(UnsafeFn),
           (NormalFn, NormalFn) => Ok(NormalFn),
         }
     }
 
-    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
+    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<'tcx, Onceness> {
         match (a, b) {
             (Once, _) | (_, Once) => Ok(Once),
             (Many, Many) => Ok(Many)
@@ -93,18 +93,18 @@ fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
     fn builtin_bounds(&self,
                       a: ty::BuiltinBounds,
                       b: ty::BuiltinBounds)
-                      -> cres<ty::BuiltinBounds> {
+                      -> cres<'tcx, ty::BuiltinBounds> {
         // More bounds is a subtype of fewer bounds, so
         // the LUB (mutual supertype) is the intersection.
         Ok(a.intersection(b))
     }
 
     fn contraregions(&self, a: ty::Region, b: ty::Region)
-                    -> cres<ty::Region> {
+                    -> cres<'tcx, ty::Region> {
         self.glb().regions(a, b)
     }
 
-    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
+    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
         debug!("{}.regions({}, {})",
                self.tag(),
                a.repr(self.tcx()),
@@ -113,15 +113,17 @@ fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
         Ok(self.infcx().region_vars.lub_regions(Subtype(self.trace()), a, b))
     }
 
-    fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
+    fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>)
+               -> cres<'tcx, ty::FnSig<'tcx>> {
         self.higher_ranked_lub(a, b)
     }
 
-    fn tys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         super_lattice_tys(self, a, b)
     }
 
-    fn trait_refs(&self, a: &ty::TraitRef, b: &ty::TraitRef) -> cres<ty::TraitRef> {
+    fn trait_refs(&self, a: &ty::TraitRef<'tcx>, b: &ty::TraitRef<'tcx>)
+                  -> cres<'tcx, ty::TraitRef<'tcx>> {
         self.higher_ranked_lub(a, b)
     }
 }
index 539b220a0227c94e5a700b4fae8ba4b684a228ae..729fbd6b337b5e5e23bda561c052b80f2a9f42a3 100644 (file)
 
 pub type Bound<T> = Option<T>;
 
-pub type cres<T> = Result<T,ty::type_err>; // "combine result"
-pub type ures = cres<()>; // "unify result"
+pub type cres<'tcx, T> = Result<T,ty::type_err<'tcx>>; // "combine result"
+pub type ures<'tcx> = cres<'tcx, ()>; // "unify result"
 pub type fres<T> = Result<T, fixup_err>; // "fixup result"
-pub type CoerceResult = cres<Option<ty::AutoAdjustment>>;
+pub type CoerceResult<'tcx> = cres<'tcx, Option<ty::AutoAdjustment<'tcx>>>;
 
 pub struct InferCtxt<'a, 'tcx: 'a> {
     pub tcx: &'a ty::ctxt<'tcx>,
@@ -83,7 +83,7 @@ pub struct InferCtxt<'a, 'tcx: 'a> {
     // We instantiate UnificationTable with bounds<Ty> because the
     // types that might instantiate a general type variable have an
     // order, represented by its upper and lower bounds.
-    type_variables: RefCell<type_variable::TypeVariableTable>,
+    type_variables: RefCell<type_variable::TypeVariableTable<'tcx>>,
 
     // Map from integral variable to the kind of integer it represents
     int_unification_table:
@@ -134,9 +134,9 @@ pub enum TypeOrigin {
 
 /// See `error_reporting.rs` for more details
 #[deriving(Clone, Show)]
-pub enum ValuePairs {
-    Types(ty::expected_found<Ty>),
-    TraitRefs(ty::expected_found<Rc<ty::TraitRef>>),
+pub enum ValuePairs<'tcx> {
+    Types(ty::expected_found<Ty<'tcx>>),
+    TraitRefs(ty::expected_found<Rc<ty::TraitRef<'tcx>>>),
 }
 
 /// The trace designates the path through inference that we took to
@@ -144,18 +144,18 @@ pub enum ValuePairs {
 ///
 /// See `error_reporting.rs` for more details.
 #[deriving(Clone, Show)]
-pub struct TypeTrace {
+pub struct TypeTrace<'tcx> {
     origin: TypeOrigin,
-    values: ValuePairs,
+    values: ValuePairs<'tcx>,
 }
 
 /// The origin of a `r1 <= r2` constraint.
 ///
 /// See `error_reporting.rs` for more details
 #[deriving(Clone, Show)]
-pub enum SubregionOrigin {
+pub enum SubregionOrigin<'tcx> {
     // Arose from a subtyping relation
-    Subtype(TypeTrace),
+    Subtype(TypeTrace<'tcx>),
 
     // Stack-allocated closures cannot outlive innermost loop
     // or function so as to ensure we only require finite stack
@@ -182,11 +182,11 @@ pub enum SubregionOrigin {
 
     // When closing over a variable in a closure/proc, ensure that the
     // type of the variable outlives the lifetime bound.
-    RelateProcBound(Span, ast::NodeId, Ty),
+    RelateProcBound(Span, ast::NodeId, Ty<'tcx>),
 
     // Some type parameter was instantiated with the given type,
     // and that type must outlive some region.
-    RelateParamBound(Span, Ty),
+    RelateParamBound(Span, Ty<'tcx>),
 
     // The given region parameter was instantiated with a region
     // that must outlive some other region.
@@ -194,7 +194,7 @@ pub enum SubregionOrigin {
 
     // A bound placed on type parameters that states that must outlive
     // the moment of their instantiation.
-    RelateDefaultParamBound(Span, Ty),
+    RelateDefaultParamBound(Span, Ty<'tcx>),
 
     // Creating a pointer `b` to contents of another reference
     Reborrow(Span),
@@ -203,10 +203,10 @@ pub enum SubregionOrigin {
     ReborrowUpvar(Span, ty::UpvarId),
 
     // (&'a &'b T) where a >= b
-    ReferenceOutlivesReferent(Ty, Span),
+    ReferenceOutlivesReferent(Ty<'tcx>, Span),
 
     // The type T of an expression E must outlive the lifetime for E.
-    ExprTypeIsNotInScope(Ty, Span),
+    ExprTypeIsNotInScope(Ty<'tcx>, Span),
 
     // A `ref b` whose region does not enclose the decl site
     BindingTypeIsNotValidAtDecl(Span),
@@ -241,7 +241,7 @@ pub enum LateBoundRegionConversionTime {
 ///
 /// See `error_reporting.rs` for more details
 #[deriving(Clone, Show)]
-pub enum RegionVariableOrigin {
+pub enum RegionVariableOrigin<'tcx> {
     // Region variables created for ill-categorized reasons,
     // mostly indicates places in need of refactoring
     MiscVariable(Span),
@@ -259,7 +259,7 @@ pub enum RegionVariableOrigin {
     Autoref(Span),
 
     // Regions created as part of an automatic coercion
-    Coercion(TypeTrace),
+    Coercion(TypeTrace<'tcx>),
 
     // Region variables created as the values for early-bound regions
     EarlyBoundRegion(Span, ast::Name),
@@ -305,12 +305,12 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>)
     }
 }
 
-pub fn common_supertype(cx: &InferCtxt,
-                        origin: TypeOrigin,
-                        a_is_expected: bool,
-                        a: Ty,
-                        b: Ty)
-                        -> Ty
+pub fn common_supertype<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                                  origin: TypeOrigin,
+                                  a_is_expected: bool,
+                                  a: Ty<'tcx>,
+                                  b: Ty<'tcx>)
+                                  -> Ty<'tcx>
 {
     /*!
      * Computes the least upper-bound of `a` and `b`. If this is
@@ -336,12 +336,12 @@ pub fn common_supertype(cx: &InferCtxt,
     }
 }
 
-pub fn mk_subty(cx: &InferCtxt,
-                a_is_expected: bool,
-                origin: TypeOrigin,
-                a: Ty,
-                b: Ty)
-                -> ures
+pub fn mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                          a_is_expected: bool,
+                          origin: TypeOrigin,
+                          a: Ty<'tcx>,
+                          b: Ty<'tcx>)
+                          -> ures<'tcx>
 {
     debug!("mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
     cx.commit_if_ok(|| {
@@ -349,7 +349,10 @@ pub fn mk_subty(cx: &InferCtxt,
     })
 }
 
-pub fn can_mk_subty(cx: &InferCtxt, a: Ty, b: Ty) -> ures {
+pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                              a: Ty<'tcx>,
+                              b: Ty<'tcx>)
+                              -> ures<'tcx> {
     debug!("can_mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
     cx.probe(|| {
         let trace = TypeTrace {
@@ -360,7 +363,9 @@ pub fn can_mk_subty(cx: &InferCtxt, a: Ty, b: Ty) -> ures {
     })
 }
 
-pub fn can_mk_eqty(cx: &InferCtxt, a: Ty, b: Ty) -> ures {
+pub fn can_mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                             a: Ty<'tcx>, b: Ty<'tcx>)
+                             -> ures<'tcx> {
     debug!("can_mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
     cx.probe(|| {
         let trace = TypeTrace {
@@ -371,21 +376,21 @@ pub fn can_mk_eqty(cx: &InferCtxt, a: Ty, b: Ty) -> ures {
     }).to_ures()
 }
 
-pub fn mk_subr(cx: &InferCtxt,
-               origin: SubregionOrigin,
-               a: ty::Region,
-               b: ty::Region) {
+pub fn mk_subr<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                         origin: SubregionOrigin<'tcx>,
+                         a: ty::Region,
+                         b: ty::Region) {
     debug!("mk_subr({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
     let snapshot = cx.region_vars.start_snapshot();
     cx.region_vars.make_subregion(origin, a, b);
     cx.region_vars.commit(snapshot);
 }
 
-pub fn verify_param_bound(cx: &InferCtxt,
-                          origin: SubregionOrigin,
-                          param_ty: ty::ParamTy,
-                          a: ty::Region,
-                          bs: Vec<ty::Region>) {
+pub fn verify_param_bound<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                                    origin: SubregionOrigin<'tcx>,
+                                    param_ty: ty::ParamTy,
+                                    a: ty::Region,
+                                    bs: Vec<ty::Region>) {
     debug!("verify_param_bound({}, {} <: {})",
            param_ty.repr(cx.tcx),
            a.repr(cx.tcx),
@@ -394,24 +399,24 @@ pub fn verify_param_bound(cx: &InferCtxt,
     cx.region_vars.verify_param_bound(origin, param_ty, a, bs);
 }
 
-pub fn mk_eqty(cx: &InferCtxt,
-               a_is_expected: bool,
-               origin: TypeOrigin,
-               a: Ty,
-               b: Ty)
-            -> ures
+pub fn mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                         a_is_expected: bool,
+                         origin: TypeOrigin,
+                         a: Ty<'tcx>,
+                         b: Ty<'tcx>)
+                         -> ures<'tcx>
 {
     debug!("mk_eqty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
     cx.commit_if_ok(
         || cx.eq_types(a_is_expected, origin, a, b))
 }
 
-pub fn mk_sub_trait_refs(cx: &InferCtxt,
-                         a_is_expected: bool,
-                         origin: TypeOrigin,
-                         a: Rc<ty::TraitRef>,
-                         b: Rc<ty::TraitRef>)
-                         -> ures
+pub fn mk_sub_trait_refs<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                                   a_is_expected: bool,
+                                   origin: TypeOrigin,
+                                   a: Rc<ty::TraitRef<'tcx>>,
+                                   b: Rc<ty::TraitRef<'tcx>>)
+                                   -> ures<'tcx>
 {
     debug!("mk_sub_trait_refs({} <: {})",
            a.repr(cx.tcx), b.repr(cx.tcx));
@@ -431,12 +436,12 @@ fn expected_found<T>(a_is_expected: bool,
     }
 }
 
-pub fn mk_coercety(cx: &InferCtxt,
-                   a_is_expected: bool,
-                   origin: TypeOrigin,
-                   a: Ty,
-                   b: Ty)
-                -> CoerceResult {
+pub fn mk_coercety<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                             a_is_expected: bool,
+                             origin: TypeOrigin,
+                             a: Ty<'tcx>,
+                             b: Ty<'tcx>)
+                             -> CoerceResult<'tcx> {
     debug!("mk_coercety({} -> {})", a.repr(cx.tcx), b.repr(cx.tcx));
     indent(|| {
         cx.commit_if_ok(|| {
@@ -450,11 +455,11 @@ pub fn mk_coercety(cx: &InferCtxt,
 }
 
 // See comment on the type `resolve_state` below
-pub fn resolve_type(cx: &InferCtxt,
-                    span: Option<Span>,
-                    a: Ty,
-                    modes: uint)
-                    -> fres<Ty> {
+pub fn resolve_type<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
+                              span: Option<Span>,
+                              a: Ty<'tcx>,
+                              modes: uint)
+                              -> fres<Ty<'tcx>> {
     let mut resolver = resolver(cx, modes, span);
     cx.commit_unconditionally(|| resolver.resolve_type_chk(a))
 }
@@ -465,24 +470,24 @@ pub fn resolve_region(cx: &InferCtxt, r: ty::Region, modes: uint)
     resolver.resolve_region_chk(r)
 }
 
-trait then {
-    fn then<T:Clone>(&self, f: || -> Result<T,ty::type_err>)
-        -> Result<T,ty::type_err>;
+trait then<'tcx> {
+    fn then<T:Clone>(&self, f: || -> Result<T,ty::type_err<'tcx>>)
+        -> Result<T,ty::type_err<'tcx>>;
 }
 
-impl then for ures {
-    fn then<T:Clone>(&self, f: || -> Result<T,ty::type_err>)
-        -> Result<T,ty::type_err> {
+impl<'tcx> then<'tcx> for ures<'tcx> {
+    fn then<T:Clone>(&self, f: || -> Result<T,ty::type_err<'tcx>>)
+        -> Result<T,ty::type_err<'tcx>> {
         self.and_then(|_i| f())
     }
 }
 
-trait ToUres {
-    fn to_ures(&self) -> ures;
+trait ToUres<'tcx> {
+    fn to_ures(&self) -> ures<'tcx>;
 }
 
-impl<T> ToUres for cres<T> {
-    fn to_ures(&self) -> ures {
+impl<'tcx, T> ToUres<'tcx> for cres<'tcx, T> {
+    fn to_ures(&self) -> ures<'tcx> {
         match *self {
           Ok(ref _v) => Ok(()),
           Err(ref e) => Err((*e))
@@ -490,12 +495,12 @@ fn to_ures(&self) -> ures {
     }
 }
 
-trait CresCompare<T> {
-    fn compare(&self, t: T, f: || -> ty::type_err) -> cres<T>;
+trait CresCompare<'tcx, T> {
+    fn compare(&self, t: T, f: || -> ty::type_err<'tcx>) -> cres<'tcx, T>;
 }
 
-impl<T:Clone + PartialEq> CresCompare<T> for cres<T> {
-    fn compare(&self, t: T, f: || -> ty::type_err) -> cres<T> {
+impl<'tcx, T:Clone + PartialEq> CresCompare<'tcx, T> for cres<'tcx, T> {
+    fn compare(&self, t: T, f: || -> ty::type_err<'tcx>) -> cres<'tcx, T> {
         (*self).clone().and_then(|s| {
             if s == t {
                 (*self).clone()
@@ -506,7 +511,7 @@ fn compare(&self, t: T, f: || -> ty::type_err) -> cres<T> {
     }
 }
 
-pub fn uok() -> ures {
+pub fn uok<'tcx>() -> ures<'tcx> {
     Ok(())
 }
 
@@ -518,7 +523,7 @@ pub struct CombinedSnapshot {
 }
 
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
-    pub fn skolemize<T:TypeFoldable>(&self, t: T) -> T {
+    pub fn skolemize<T:TypeFoldable<'tcx>>(&self, t: T) -> T {
         t.fold_with(&mut self.skolemizer())
     }
 
@@ -533,22 +538,25 @@ pub fn skolemizer<'a>(&'a self) -> TypeSkolemizer<'a, 'tcx> {
         skolemize::TypeSkolemizer::new(self)
     }
 
-    pub fn combine_fields<'a>(&'a self, a_is_expected: bool, trace: TypeTrace)
+    pub fn combine_fields<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>)
                               -> CombineFields<'a, 'tcx> {
         CombineFields {infcx: self,
                        a_is_expected: a_is_expected,
                        trace: trace}
     }
 
-    pub fn equate<'a>(&'a self, a_is_expected: bool, trace: TypeTrace) -> Equate<'a, 'tcx> {
+    pub fn equate<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>)
+                      -> Equate<'a, 'tcx> {
         Equate(self.combine_fields(a_is_expected, trace))
     }
 
-    pub fn sub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace) -> Sub<'a, 'tcx> {
+    pub fn sub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>)
+                   -> Sub<'a, 'tcx> {
         Sub(self.combine_fields(a_is_expected, trace))
     }
 
-    pub fn lub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace) -> Lub<'a, 'tcx> {
+    pub fn lub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>)
+                   -> Lub<'a, 'tcx> {
         Lub(self.combine_fields(a_is_expected, trace))
     }
 
@@ -651,9 +659,9 @@ pub fn add_given(&self,
     pub fn sub_types(&self,
                      a_is_expected: bool,
                      origin: TypeOrigin,
-                     a: Ty,
-                     b: Ty)
-                     -> ures
+                     a: Ty<'tcx>,
+                     b: Ty<'tcx>)
+                     -> ures<'tcx>
     {
         debug!("sub_types({} <: {})", a.repr(self.tcx), b.repr(self.tcx));
         self.commit_if_ok(|| {
@@ -668,9 +676,9 @@ pub fn sub_types(&self,
     pub fn eq_types(&self,
                     a_is_expected: bool,
                     origin: TypeOrigin,
-                    a: Ty,
-                    b: Ty)
-                    -> ures
+                    a: Ty<'tcx>,
+                    b: Ty<'tcx>)
+                    -> ures<'tcx>
     {
         self.commit_if_ok(|| {
             let trace = TypeTrace {
@@ -684,9 +692,9 @@ pub fn eq_types(&self,
     pub fn sub_trait_refs(&self,
                           a_is_expected: bool,
                           origin: TypeOrigin,
-                          a: Rc<ty::TraitRef>,
-                          b: Rc<ty::TraitRef>)
-                          -> ures
+                          a: Rc<ty::TraitRef<'tcx>>,
+                          b: Rc<ty::TraitRef<'tcx>>)
+                          -> ures<'tcx>
     {
         debug!("sub_trait_refs({} <: {})",
                a.repr(self.tcx),
@@ -709,15 +717,15 @@ pub fn next_ty_var_id(&self, diverging: bool) -> TyVid {
             .new_var(diverging)
     }
 
-    pub fn next_ty_var(&self) -> Ty {
+    pub fn next_ty_var(&self) -> Ty<'tcx> {
         ty::mk_var(self.tcx, self.next_ty_var_id(false))
     }
 
-    pub fn next_diverging_ty_var(&self) -> Ty {
+    pub fn next_diverging_ty_var(&self) -> Ty<'tcx> {
         ty::mk_var(self.tcx, self.next_ty_var_id(true))
     }
 
-    pub fn next_ty_vars(&self, n: uint) -> Vec<Ty> {
+    pub fn next_ty_vars(&self, n: uint) -> Vec<Ty<'tcx>> {
         Vec::from_fn(n, |_i| self.next_ty_var())
     }
 
@@ -733,7 +741,7 @@ pub fn next_float_var_id(&self) -> FloatVid {
             .new_key(None)
     }
 
-    pub fn next_region_var(&self, origin: RegionVariableOrigin) -> ty::Region {
+    pub fn next_region_var(&self, origin: RegionVariableOrigin<'tcx>) -> ty::Region {
         ty::ReInfer(ty::ReVar(self.region_vars.new_region_var(origin)))
     }
 
@@ -748,8 +756,8 @@ pub fn region_vars_for_defs(&self,
 
     pub fn fresh_substs_for_generics(&self,
                                      span: Span,
-                                     generics: &ty::Generics)
-                                     -> subst::Substs
+                                     generics: &ty::Generics<'tcx>)
+                                     -> subst::Substs<'tcx>
     {
         /*!
          * Given a set of generics defined on a type or impl, returns
@@ -768,9 +776,9 @@ pub fn fresh_substs_for_generics(&self,
 
     pub fn fresh_substs_for_trait(&self,
                                   span: Span,
-                                  generics: &ty::Generics,
-                                  self_ty: Ty)
-                                  -> subst::Substs
+                                  generics: &ty::Generics<'tcx>,
+                                  self_ty: Ty<'tcx>)
+                                  -> subst::Substs<'tcx>
     {
         /*!
          * Given a set of generics defined on a trait, returns a
@@ -805,22 +813,22 @@ pub fn resolve_regions_and_report_errors(&self) {
         self.report_region_errors(&errors); // see error_reporting.rs
     }
 
-    pub fn ty_to_string(&self, t: Ty) -> String {
+    pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
         ty_to_string(self.tcx,
                      self.resolve_type_vars_if_possible(t))
     }
 
-    pub fn tys_to_string(&self, ts: &[Ty]) -> String {
+    pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String {
         let tstrs: Vec<String> = ts.iter().map(|t| self.ty_to_string(*t)).collect();
         format!("({})", tstrs.connect(", "))
     }
 
-    pub fn trait_ref_to_string(&self, t: &Rc<ty::TraitRef>) -> String {
+    pub fn trait_ref_to_string(&self, t: &Rc<ty::TraitRef<'tcx>>) -> String {
         let t = self.resolve_type_vars_in_trait_ref_if_possible(&**t);
         trait_ref_to_string(self.tcx, &t)
     }
 
-    pub fn contains_unbound_type_variables(&self, typ: Ty) -> Ty {
+    pub fn contains_unbound_type_variables(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
         match resolve_type(self,
                            None,
                            typ, resolve_nested_tvar | resolve_ivar) {
@@ -829,7 +837,7 @@ pub fn contains_unbound_type_variables(&self, typ: Ty) -> Ty {
         }
     }
 
-    pub fn shallow_resolve(&self, typ: Ty) -> Ty {
+    pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
         match ty::get(typ).sty {
             ty::ty_infer(ty::TyVar(v)) => {
                 self.type_variables.borrow()
@@ -853,7 +861,7 @@ pub fn shallow_resolve(&self, typ: Ty) -> Ty {
         }
     }
 
-    pub fn resolve_type_vars_if_possible(&self, typ: Ty) -> Ty {
+    pub fn resolve_type_vars_if_possible(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
         match resolve_type(self,
                            None,
                            typ, resolve_nested_tvar | resolve_ivar) {
@@ -863,8 +871,8 @@ pub fn resolve_type_vars_if_possible(&self, typ: Ty) -> Ty {
     }
 
     pub fn resolve_type_vars_in_trait_ref_if_possible(&self,
-                                                      trait_ref: &ty::TraitRef)
-                                                      -> ty::TraitRef {
+                                                      trait_ref: &ty::TraitRef<'tcx>)
+                                                      -> ty::TraitRef<'tcx> {
         // make up a dummy type just to reuse/abuse the resolve machinery
         let dummy0 = ty::mk_trait(self.tcx,
                                   (*trait_ref).clone(),
@@ -899,7 +907,7 @@ pub fn type_error_message_str(&self,
                                   sp: Span,
                                   mk_msg: |Option<String>, String| -> String,
                                   actual_ty: String,
-                                  err: Option<&ty::type_err>) {
+                                  err: Option<&ty::type_err<'tcx>>) {
         self.type_error_message_str_with_expected(sp, mk_msg, None, actual_ty, err)
     }
 
@@ -908,9 +916,9 @@ pub fn type_error_message_str_with_expected(&self,
                                                 mk_msg: |Option<String>,
                                                          String|
                                                          -> String,
-                                                expected_ty: Option<Ty>,
+                                                expected_ty: Option<Ty<'tcx>>,
                                                 actual_ty: String,
-                                                err: Option<&ty::type_err>) {
+                                                err: Option<&ty::type_err<'tcx>>) {
         debug!("hi! expected_ty = {}, actual_ty = {}", expected_ty, actual_ty);
 
         let resolved_expected = expected_ty.map(|e_ty| {
@@ -938,8 +946,8 @@ pub fn type_error_message_str_with_expected(&self,
     pub fn type_error_message(&self,
                               sp: Span,
                               mk_msg: |String| -> String,
-                              actual_ty: Ty,
-                              err: Option<&ty::type_err>) {
+                              actual_ty: Ty<'tcx>,
+                              err: Option<&ty::type_err<'tcx>>) {
         let actual_ty = self.resolve_type_vars_if_possible(actual_ty);
 
         // Don't report an error if actual type is ty_err.
@@ -952,9 +960,9 @@ pub fn type_error_message(&self,
 
     pub fn report_mismatched_types(&self,
                                    span: Span,
-                                   expected: Ty,
-                                   actual: Ty,
-                                   err: &ty::type_err) {
+                                   expected: Ty<'tcx>,
+                                   actual: Ty<'tcx>,
+                                   err: &ty::type_err<'tcx>) {
         let trace = TypeTrace {
             origin: Misc(span),
             values: Types(ty::expected_found {
@@ -971,7 +979,7 @@ pub fn replace_late_bound_regions_with_fresh_var<T>(
         lbrct: LateBoundRegionConversionTime,
         value: &T)
         -> (T, FnvHashMap<ty::BoundRegion,ty::Region>)
-        where T : HigherRankedFoldable
+        where T : HigherRankedFoldable<'tcx>
     {
         ty::replace_late_bound_regions(
             self.tcx,
@@ -980,12 +988,12 @@ pub fn replace_late_bound_regions_with_fresh_var<T>(
     }
 }
 
-impl TypeTrace {
+impl<'tcx> TypeTrace<'tcx> {
     pub fn span(&self) -> Span {
         self.origin.span()
     }
 
-    pub fn dummy() -> TypeTrace {
+    pub fn dummy() -> TypeTrace<'tcx> {
         TypeTrace {
             origin: Misc(codemap::DUMMY_SP),
             values: Types(ty::expected_found {
@@ -996,7 +1004,7 @@ pub fn dummy() -> TypeTrace {
     }
 }
 
-impl Repr for TypeTrace {
+impl<'tcx> Repr<'tcx> for TypeTrace<'tcx> {
     fn repr(&self, tcx: &ty::ctxt) -> String {
         format!("TypeTrace({})", self.origin.repr(tcx))
     }
@@ -1018,7 +1026,7 @@ pub fn span(&self) -> Span {
     }
 }
 
-impl Repr for TypeOrigin {
+impl<'tcx> Repr<'tcx> for TypeOrigin {
     fn repr(&self, tcx: &ty::ctxt) -> String {
         match *self {
             MethodCompatCheck(a) => {
@@ -1050,7 +1058,7 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl SubregionOrigin {
+impl<'tcx> SubregionOrigin<'tcx> {
     pub fn span(&self) -> Span {
         match *self {
             Subtype(ref a) => a.span(),
@@ -1079,8 +1087,8 @@ pub fn span(&self) -> Span {
     }
 }
 
-impl Repr for SubregionOrigin {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for SubregionOrigin<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             Subtype(ref a) => {
                 format!("Subtype({})", a.repr(tcx))
@@ -1150,7 +1158,7 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl RegionVariableOrigin {
+impl<'tcx> RegionVariableOrigin<'tcx> {
     pub fn span(&self) -> Span {
         match *self {
             MiscVariable(a) => a,
@@ -1167,8 +1175,8 @@ pub fn span(&self) -> Span {
     }
 }
 
-impl Repr for RegionVariableOrigin {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for RegionVariableOrigin<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             MiscVariable(a) => {
                 format!("MiscVariable({})", a.repr(tcx))
index 54fb7872f3b03ccab1be84f4c66904c71dbf8d62..5452a99127fc47f643af5fca363e28d3daf00a14 100644 (file)
@@ -52,17 +52,17 @@ pub enum Constraint {
 
 // Something we have to verify after region inference is done, but
 // which does not directly influence the inference process
-pub enum Verify {
+pub enum Verify<'tcx> {
     // VerifyRegSubReg(a, b): Verify that `a <= b`. Neither `a` nor
     // `b` are inference variables.
-    VerifyRegSubReg(SubregionOrigin, Region, Region),
+    VerifyRegSubReg(SubregionOrigin<'tcx>, Region, Region),
 
     // VerifyParamBound(T, _, R, RS): The parameter type `T` must
     // outlive the region `R`. `T` is known to outlive `RS`. Therefore
     // verify that `R <= RS[i]` for some `i`. Inference variables may
     // be involved (but this verification step doesn't influence
     // inference).
-    VerifyParamBound(ty::ParamTy, SubregionOrigin, Region, Vec<Region>),
+    VerifyParamBound(ty::ParamTy, SubregionOrigin<'tcx>, Region, Vec<Region>),
 }
 
 #[deriving(PartialEq, Eq, Hash)]
@@ -89,43 +89,43 @@ pub enum CombineMapType {
 }
 
 #[deriving(Clone, Show)]
-pub enum RegionResolutionError {
+pub enum RegionResolutionError<'tcx> {
     /// `ConcreteFailure(o, a, b)`:
     ///
     /// `o` requires that `a <= b`, but this does not hold
-    ConcreteFailure(SubregionOrigin, Region, Region),
+    ConcreteFailure(SubregionOrigin<'tcx>, Region, Region),
 
     /// `ParamBoundFailure(p, s, a, bs)
     ///
     /// The parameter type `p` must be known to outlive the lifetime
     /// `a`, but it is only known to outlive `bs` (and none of the
     /// regions in `bs` outlive `a`).
-    ParamBoundFailure(SubregionOrigin, ty::ParamTy, Region, Vec<Region>),
+    ParamBoundFailure(SubregionOrigin<'tcx>, ty::ParamTy, Region, Vec<Region>),
 
     /// `SubSupConflict(v, sub_origin, sub_r, sup_origin, sup_r)`:
     ///
     /// Could not infer a value for `v` because `sub_r <= v` (due to
     /// `sub_origin`) but `v <= sup_r` (due to `sup_origin`) and
     /// `sub_r <= sup_r` does not hold.
-    SubSupConflict(RegionVariableOrigin,
-                   SubregionOrigin, Region,
-                   SubregionOrigin, Region),
+    SubSupConflict(RegionVariableOrigin<'tcx>,
+                   SubregionOrigin<'tcx>, Region,
+                   SubregionOrigin<'tcx>, Region),
 
     /// `SupSupConflict(v, origin1, r1, origin2, r2)`:
     ///
     /// Could not infer a value for `v` because `v <= r1` (due to
     /// `origin1`) and `v <= r2` (due to `origin2`) and
     /// `r1` and `r2` have no intersection.
-    SupSupConflict(RegionVariableOrigin,
-                   SubregionOrigin, Region,
-                   SubregionOrigin, Region),
+    SupSupConflict(RegionVariableOrigin<'tcx>,
+                   SubregionOrigin<'tcx>, Region,
+                   SubregionOrigin<'tcx>, Region),
 
     /// For subsets of `ConcreteFailure` and `SubSupConflict`, we can derive
     /// more specific errors message by suggesting to the user where they
     /// should put a lifetime. In those cases we process and put those errors
     /// into `ProcessedErrors` before we do any reporting.
-    ProcessedErrors(Vec<RegionVariableOrigin>,
-                    Vec<(TypeTrace, ty::type_err)>,
+    ProcessedErrors(Vec<RegionVariableOrigin<'tcx>>,
+                    Vec<(TypeTrace<'tcx>, ty::type_err<'tcx>)>,
                     Vec<SameRegions>),
 }
 
@@ -160,19 +160,19 @@ pub fn push(&mut self, other: BoundRegion) {
 
 pub struct RegionVarBindings<'a, 'tcx: 'a> {
     tcx: &'a ty::ctxt<'tcx>,
-    var_origins: RefCell<Vec<RegionVariableOrigin>>,
+    var_origins: RefCell<Vec<RegionVariableOrigin<'tcx>>>,
 
     // Constraints of the form `A <= B` introduced by the region
     // checker.  Here at least one of `A` and `B` must be a region
     // variable.
-    constraints: RefCell<FnvHashMap<Constraint, SubregionOrigin>>,
+    constraints: RefCell<FnvHashMap<Constraint, SubregionOrigin<'tcx>>>,
 
     // A "verify" is something that we need to verify after inference is
     // done, but which does not directly affect inference in any way.
     //
     // An example is a `A <= B` where neither `A` nor `B` are
     // inference variables.
-    verifys: RefCell<Vec<Verify>>,
+    verifys: RefCell<Vec<Verify<'tcx>>>,
 
     // A "given" is a relationship that is known to hold. In particular,
     // we often know from closure fn signatures that a particular free
@@ -314,7 +314,7 @@ pub fn num_vars(&self) -> uint {
         self.var_origins.borrow().len()
     }
 
-    pub fn new_region_var(&self, origin: RegionVariableOrigin) -> RegionVid {
+    pub fn new_region_var(&self, origin: RegionVariableOrigin<'tcx>) -> RegionVid {
         let id = self.num_vars();
         self.var_origins.borrow_mut().push(origin.clone());
         let vid = RegionVid { index: id };
@@ -367,7 +367,7 @@ fn values_are_none(&self) -> bool {
 
     fn add_constraint(&self,
                       constraint: Constraint,
-                      origin: SubregionOrigin) {
+                      origin: SubregionOrigin<'tcx>) {
         // cannot add constraints once regions are resolved
         assert!(self.values_are_none());
 
@@ -382,7 +382,7 @@ fn add_constraint(&self,
     }
 
     fn add_verify(&self,
-                  verify: Verify) {
+                  verify: Verify<'tcx>) {
         // cannot add verifys once regions are resolved
         assert!(self.values_are_none());
 
@@ -414,7 +414,7 @@ pub fn add_given(&self,
     }
 
     pub fn make_eqregion(&self,
-                         origin: SubregionOrigin,
+                         origin: SubregionOrigin<'tcx>,
                          sub: Region,
                          sup: Region) {
         if sub != sup {
@@ -426,7 +426,7 @@ pub fn make_eqregion(&self,
     }
 
     pub fn make_subregion(&self,
-                          origin: SubregionOrigin,
+                          origin: SubregionOrigin<'tcx>,
                           sub: Region,
                           sup: Region) {
         // cannot add constraints once regions are resolved
@@ -474,7 +474,7 @@ pub fn make_subregion(&self,
     }
 
     pub fn verify_param_bound(&self,
-                              origin: SubregionOrigin,
+                              origin: SubregionOrigin<'tcx>,
                               param_ty: ty::ParamTy,
                               sub: Region,
                               sups: Vec<Region>) {
@@ -482,7 +482,7 @@ pub fn verify_param_bound(&self,
     }
 
     pub fn lub_regions(&self,
-                       origin: SubregionOrigin,
+                       origin: SubregionOrigin<'tcx>,
                        a: Region,
                        b: Region)
                        -> Region {
@@ -507,7 +507,7 @@ pub fn lub_regions(&self,
     }
 
     pub fn glb_regions(&self,
-                       origin: SubregionOrigin,
+                       origin: SubregionOrigin<'tcx>,
                        a: Region,
                        b: Region)
                        -> Region {
@@ -560,8 +560,8 @@ pub fn combine_vars(&self,
                         t: CombineMapType,
                         a: Region,
                         b: Region,
-                        origin: SubregionOrigin,
-                        relate: |this: &RegionVarBindings,
+                        origin: SubregionOrigin<'tcx>,
+                        relate: |this: &RegionVarBindings<'a, 'tcx>,
                                  old_r: Region,
                                  new_r: Region|)
                         -> Region {
@@ -700,7 +700,7 @@ fn consider_adding_directed_edge(result_set: &mut Vec<Region>,
     constraints, assuming such values can be found; if they cannot,
     errors are reported.
     */
-    pub fn resolve_regions(&self) -> Vec<RegionResolutionError> {
+    pub fn resolve_regions(&self) -> Vec<RegionResolutionError<'tcx>> {
         debug!("RegionVarBindings: resolve_regions()");
         let mut errors = vec!();
         let v = self.infer_variable_values(&mut errors);
@@ -815,7 +815,7 @@ fn helper(this: &RegionVarBindings,
     fn glb_concrete_regions(&self,
                             a: Region,
                             b: Region)
-                         -> cres<Region> {
+                         -> cres<'tcx, Region> {
         debug!("glb_concrete_regions({}, {})", a, b);
         match (a, b) {
             (ReLateBound(..), _) |
@@ -885,7 +885,7 @@ fn glb_concrete_regions(&self,
 
     fn glb_free_regions(&self,
                         a: &FreeRegion,
-                        b: &FreeRegion) -> cres<ty::Region>
+                        b: &FreeRegion) -> cres<'tcx, ty::Region>
     {
         /*!
          * Computes a region that is enclosed by both free region arguments,
@@ -899,9 +899,9 @@ fn glb_free_regions(&self,
             Equal => Ok(ty::ReFree(*a))
         };
 
-        fn helper(this: &RegionVarBindings,
-                  a: &FreeRegion,
-                  b: &FreeRegion) -> cres<ty::Region>
+        fn helper<'a, 'tcx>(this: &RegionVarBindings<'a, 'tcx>,
+                            a: &FreeRegion,
+                            b: &FreeRegion) -> cres<'tcx, ty::Region>
         {
             if this.tcx.region_maps.sub_free_region(*a, *b) {
                 Ok(ty::ReFree(*a))
@@ -918,7 +918,7 @@ fn intersect_scopes(&self,
                         region_a: ty::Region,
                         region_b: ty::Region,
                         scope_a: ast::NodeId,
-                        scope_b: ast::NodeId) -> cres<Region>
+                        scope_b: ast::NodeId) -> cres<'tcx, Region>
     {
         // We want to generate the intersection of two
         // scopes or two free regions.  So, if one of
@@ -946,16 +946,16 @@ struct VarData {
     value: VarValue,
 }
 
-struct RegionAndOrigin {
+struct RegionAndOrigin<'tcx> {
     region: Region,
-    origin: SubregionOrigin,
+    origin: SubregionOrigin<'tcx>,
 }
 
 type RegionGraph = graph::Graph<(), Constraint>;
 
 impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
     fn infer_variable_values(&self,
-                             errors: &mut Vec<RegionResolutionError>)
+                             errors: &mut Vec<RegionResolutionError<'tcx>>)
                              -> Vec<VarValue>
     {
         let mut var_data = self.construct_var_data();
@@ -1188,7 +1188,7 @@ fn adjust_node(this: &RegionVarBindings,
 
     fn collect_concrete_region_errors(&self,
                                       values: &Vec<VarValue>,
-                                      errors: &mut Vec<RegionResolutionError>)
+                                      errors: &mut Vec<RegionResolutionError<'tcx>>)
     {
         let mut reg_reg_dups = FnvHashSet::new();
         for verify in self.verifys.borrow().iter() {
@@ -1230,7 +1230,7 @@ fn collect_concrete_region_errors(&self,
     fn extract_values_and_collect_conflicts(
         &self,
         var_data: &[VarData],
-        errors: &mut Vec<RegionResolutionError>)
+        errors: &mut Vec<RegionResolutionError<'tcx>>)
         -> Vec<VarValue>
     {
         debug!("extract_values_and_collect_conflicts()");
@@ -1353,7 +1353,7 @@ fn collect_error_for_expanding_node(
         var_data: &[VarData],
         dup_vec: &mut [uint],
         node_idx: RegionVid,
-        errors: &mut Vec<RegionResolutionError>)
+        errors: &mut Vec<RegionResolutionError<'tcx>>)
     {
         // Errors in expanding nodes result from a lower-bound that is
         // not contained by an upper-bound.
@@ -1414,7 +1414,7 @@ fn collect_error_for_contracting_node(
         var_data: &[VarData],
         dup_vec: &mut [uint],
         node_idx: RegionVid,
-        errors: &mut Vec<RegionResolutionError>)
+        errors: &mut Vec<RegionResolutionError<'tcx>>)
     {
         // Errors in contracting nodes result from two upper-bounds
         // that have no intersection.
@@ -1458,11 +1458,11 @@ fn collect_concrete_regions(&self,
                                 orig_node_idx: RegionVid,
                                 dir: Direction,
                                 dup_vec: &mut [uint])
-                                -> (Vec<RegionAndOrigin, bool) {
-        struct WalkState {
+                                -> (Vec<RegionAndOrigin<'tcx>>, bool) {
+        struct WalkState<'tcx> {
             set: FnvHashSet<RegionVid>,
-            stack: Vec<RegionVid> ,
-            result: Vec<RegionAndOrigin,
+            stack: Vec<RegionVid>,
+            result: Vec<RegionAndOrigin<'tcx>>,
             dup_found: bool
         }
         let mut state = WalkState {
@@ -1505,8 +1505,8 @@ struct WalkState {
         let WalkState {result, dup_found, ..} = state;
         return (result, dup_found);
 
-        fn process_edges(this: &RegionVarBindings,
-                         state: &mut WalkState,
+        fn process_edges<'a, 'tcx>(this: &RegionVarBindings<'a, 'tcx>,
+                         state: &mut WalkState<'tcx>,
                          graph: &RegionGraph,
                          source_vid: RegionVid,
                          dir: Direction) {
@@ -1559,7 +1559,7 @@ fn iterate_until_fixed_point(&self,
 
 }
 
-impl Repr for Constraint {
+impl<'tcx> Repr<'tcx> for Constraint {
     fn repr(&self, tcx: &ty::ctxt) -> String {
         match *self {
             ConstrainVarSubVar(a, b) => {
@@ -1575,8 +1575,8 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl Repr for Verify {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for Verify<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             VerifyRegSubReg(_, ref a, ref b) => {
                 format!("VerifyRegSubReg({}, {})", a.repr(tcx), b.repr(tcx))
@@ -1604,7 +1604,7 @@ fn lookup(values: &Vec<VarValue>, rid: ty::RegionVid) -> ty::Region {
     }
 }
 
-impl Repr for VarValue {
+impl<'tcx> Repr<'tcx> for VarValue {
     fn repr(&self, tcx: &ty::ctxt) -> String {
         match *self {
             NoValue => format!("NoValue"),
@@ -1614,8 +1614,8 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
     }
 }
 
-impl Repr for RegionAndOrigin {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for RegionAndOrigin<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         format!("RegionAndOrigin({},{})",
                 self.region.repr(tcx),
                 self.origin.repr(tcx))
index 94b8485834fe9607db4dd6fc89090702db8c5517..f4bff7eeb7bdb0f32e0c8039ec5f4d702ad29ae1 100644 (file)
@@ -98,7 +98,7 @@ fn tcx(&self) -> &ty::ctxt<'tcx> {
         self.infcx.tcx
     }
 
-    fn fold_ty(&mut self, t: Ty) -> Ty {
+    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
         self.resolve_type(t)
     }
 
@@ -112,7 +112,7 @@ pub fn should(&mut self, mode: uint) -> bool {
         (self.modes & mode) == mode
     }
 
-    pub fn resolve_type_chk(&mut self, typ: Ty) -> fres<Ty> {
+    pub fn resolve_type_chk(&mut self, typ: Ty<'tcx>) -> fres<Ty<'tcx>> {
         self.err = None;
 
         debug!("Resolving {} (modes={:x})",
@@ -148,7 +148,7 @@ pub fn resolve_region_chk(&mut self,
         }
     }
 
-    pub fn resolve_type(&mut self, typ: Ty) -> Ty {
+    pub fn resolve_type(&mut self, typ: Ty<'tcx>) -> Ty<'tcx> {
         debug!("resolve_type({})", typ.repr(self.infcx.tcx));
 
         if !ty::type_needs_infer(typ) {
@@ -200,7 +200,7 @@ pub fn resolve_region_var(&mut self, rid: RegionVid) -> ty::Region {
         self.infcx.region_vars.resolve_var(rid)
     }
 
-    pub fn resolve_ty_var(&mut self, vid: TyVid) -> Ty {
+    pub fn resolve_ty_var(&mut self, vid: TyVid) -> Ty<'tcx> {
         let tcx = self.infcx.tcx;
         let tv = self.infcx.type_variables.borrow();
         match tv.probe(vid) {
@@ -216,7 +216,7 @@ pub fn resolve_ty_var(&mut self, vid: TyVid) -> Ty {
         }
     }
 
-    pub fn resolve_int_var(&mut self, vid: IntVid) -> Ty {
+    pub fn resolve_int_var(&mut self, vid: IntVid) -> Ty<'tcx> {
         if !self.should(resolve_ivar) {
             return ty::mk_int_var(self.infcx.tcx, vid);
         }
@@ -237,7 +237,7 @@ pub fn resolve_int_var(&mut self, vid: IntVid) -> Ty {
         }
     }
 
-    pub fn resolve_float_var(&mut self, vid: FloatVid) -> Ty {
+    pub fn resolve_float_var(&mut self, vid: FloatVid) -> Ty<'tcx> {
         if !self.should(resolve_fvar) {
             return ty::mk_float_var(self.infcx.tcx, vid);
         }
index e8630b8ae82b74e7c884a69681caeab1e0f7c0b6..3c9a1345c47bf17e9c93ef4e7a514830a9cc5752 100644 (file)
@@ -52,7 +52,7 @@
 pub struct TypeSkolemizer<'a, 'tcx:'a> {
     infcx: &'a InferCtxt<'a, 'tcx>,
     skolemization_count: uint,
-    skolemization_map: hash_map::HashMap<ty::InferTy, Ty>,
+    skolemization_map: hash_map::HashMap<ty::InferTy, Ty<'tcx>>,
 }
 
 impl<'a, 'tcx> TypeSkolemizer<'a, 'tcx> {
@@ -65,10 +65,10 @@ pub fn new<'tcx>(infcx: &'a InferCtxt<'a, 'tcx>) -> TypeSkolemizer<'a, 'tcx> {
     }
 
     fn skolemize(&mut self,
-                 opt_ty: Option<Ty>,
+                 opt_ty: Option<Ty<'tcx>>,
                  key: ty::InferTy,
                  skolemizer: |uint| -> ty::InferTy)
-                 -> Ty
+                 -> Ty<'tcx>
     {
         match opt_ty {
             Some(ty) => { return ty.fold_with(self); }
@@ -112,7 +112,7 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
         }
     }
 
-    fn fold_ty(&mut self, t: Ty) -> Ty {
+    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
         match ty::get(t).sty {
             ty::ty_infer(ty::TyVar(v)) => {
                 self.skolemize(self.infcx.type_variables.borrow().probe(v),
index 1a3b626e1f5edf6767b6957901bf77ce3ef9722b..ec260c6c363040e82ccd0169b2d09dc7975111c1 100644 (file)
@@ -40,19 +40,19 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
     fn infcx<'a>(&'a self) -> &'a InferCtxt<'a, 'tcx> { self.fields.infcx }
     fn tag(&self) -> String { "sub".to_string() }
     fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
-    fn trace(&self) -> TypeTrace { self.fields.trace.clone() }
+    fn trace(&self) -> TypeTrace<'tcx> { self.fields.trace.clone() }
 
     fn equate<'a>(&'a self) -> Equate<'a, 'tcx> { Equate(self.fields.clone()) }
     fn sub<'a>(&'a self) -> Sub<'a, 'tcx> { Sub(self.fields.clone()) }
     fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields.clone()) }
     fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields.clone()) }
 
-    fn contratys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn contratys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         Sub(self.fields.switch_expected()).tys(b, a)
     }
 
     fn contraregions(&self, a: ty::Region, b: ty::Region)
-                     -> cres<ty::Region> {
+                     -> cres<'tcx, ty::Region> {
                          let opp = CombineFields {
                              a_is_expected: !self.fields.a_is_expected,
                              ..self.fields.clone()
@@ -60,7 +60,7 @@ fn contraregions(&self, a: ty::Region, b: ty::Region)
                          Sub(opp).regions(b, a)
                      }
 
-    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
+    fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
         debug!("{}.regions({}, {})",
                self.tag(),
                a.repr(self.tcx()),
@@ -69,7 +69,7 @@ fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> {
         Ok(a)
     }
 
-    fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
+    fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
         debug!("mts({} <: {})",
                a.repr(self.tcx()),
                b.repr(self.tcx()));
@@ -93,20 +93,20 @@ fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
         Ok(*a) // return is meaningless in sub, just return *a
     }
 
-    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
+    fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<'tcx, FnStyle> {
         self.lub().fn_styles(a, b).compare(b, || {
             ty::terr_fn_style_mismatch(expected_found(self, a, b))
         })
     }
 
-    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<Onceness> {
+    fn oncenesses(&self, a: Onceness, b: Onceness) -> cres<'tcx, Onceness> {
         self.lub().oncenesses(a, b).compare(b, || {
             ty::terr_onceness_mismatch(expected_found(self, a, b))
         })
     }
 
     fn builtin_bounds(&self, a: BuiltinBounds, b: BuiltinBounds)
-                      -> cres<BuiltinBounds> {
+                      -> cres<'tcx, BuiltinBounds> {
         // More bounds is a subtype of fewer bounds.
         //
         // e.g., fn:Copy() <: fn(), because the former is a function
@@ -119,7 +119,7 @@ fn builtin_bounds(&self, a: BuiltinBounds, b: BuiltinBounds)
         }
     }
 
-    fn tys(&self, a: Ty, b: Ty) -> cres<Ty> {
+    fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
         debug!("{}.tys({}, {})", self.tag(),
                a.repr(self.tcx()), b.repr(self.tcx()));
         if a == b { return Ok(a); }
@@ -155,11 +155,13 @@ fn tys(&self, a: Ty, b: Ty) -> cres<Ty> {
         }
     }
 
-    fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
+    fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>)
+               -> cres<'tcx, ty::FnSig<'tcx>> {
         self.higher_ranked_sub(a, b)
     }
 
-    fn trait_refs(&self, a: &ty::TraitRef, b: &ty::TraitRef) -> cres<ty::TraitRef> {
+    fn trait_refs(&self, a: &ty::TraitRef<'tcx>, b: &ty::TraitRef<'tcx>)
+                  -> cres<'tcx, ty::TraitRef<'tcx>> {
         self.higher_ranked_sub(a, b)
     }
 }
index 1bda448990e30c6f343d202f6ffb327335f653f9..aaa77d251933ffa72d23755510adbc1fe71fce9e 100644 (file)
 use std::mem;
 use util::snapshot_vec as sv;
 
-pub struct TypeVariableTable {
-    values: sv::SnapshotVec<TypeVariableData,UndoEntry,Delegate>,
+pub struct TypeVariableTable<'tcx> {
+    values: sv::SnapshotVec<TypeVariableData<'tcx>,UndoEntry,Delegate>,
 }
 
-struct TypeVariableData {
-    value: TypeVariableValue,
+struct TypeVariableData<'tcx> {
+    value: TypeVariableValue<'tcx>,
     diverging: bool
 }
 
-enum TypeVariableValue {
-    Known(Ty),
+enum TypeVariableValue<'tcx> {
+    Known(Ty<'tcx>),
     Bounded(Vec<Relation>),
 }
 
@@ -59,8 +59,8 @@ fn opposite(self) -> RelationDir {
     }
 }
 
-impl TypeVariableTable {
-    pub fn new() -> TypeVariableTable {
+impl<'tcx> TypeVariableTable<'tcx> {
+    pub fn new() -> TypeVariableTable<'tcx> {
         TypeVariableTable { values: sv::SnapshotVec::new(Delegate) }
     }
 
@@ -89,8 +89,8 @@ pub fn relate_vars(&mut self, a: ty::TyVid, dir: RelationDir, b: ty::TyVid) {
     pub fn instantiate_and_push(
         &mut self,
         vid: ty::TyVid,
-        ty: Ty,
-        stack: &mut Vec<(Ty, RelationDir, ty::TyVid)>)
+        ty: Ty<'tcx>,
+        stack: &mut Vec<(Ty<'tcx>, RelationDir, ty::TyVid)>)
     {
         /*!
          * Instantiates `vid` with the type `ty` and then pushes an
@@ -125,14 +125,14 @@ pub fn new_var(&mut self, diverging: bool) -> ty::TyVid {
         ty::TyVid { index: index }
     }
 
-    pub fn probe(&self, vid: ty::TyVid) -> Option<Ty> {
+    pub fn probe(&self, vid: ty::TyVid) -> Option<Ty<'tcx>> {
         match self.values.get(vid.index).value {
             Bounded(..) => None,
             Known(t) => Some(t)
         }
     }
 
-    pub fn replace_if_possible(&self, t: Ty) -> Ty {
+    pub fn replace_if_possible(&self, t: Ty<'tcx>) -> Ty<'tcx> {
         match ty::get(t).sty {
             ty::ty_infer(ty::TyVar(v)) => {
                 match self.probe(v) {
@@ -157,7 +157,7 @@ pub fn commit(&mut self, s: Snapshot) {
     }
 }
 
-impl sv::SnapshotVecDelegate<TypeVariableData,UndoEntry> for Delegate {
+impl<'tcx> sv::SnapshotVecDelegate<TypeVariableData<'tcx>,UndoEntry> for Delegate {
     fn reverse(&mut self,
                values: &mut Vec<TypeVariableData>,
                action: UndoEntry) {
index 8596be7f536faafd2a4f1dc7c160649bf0ea1164..fcf042b3f8b80e4cb56f1e565c809bbd7304b5a8 100644 (file)
@@ -34,7 +34,7 @@
  *
  * Implementations of this trait are at the end of this file.
  */
-pub trait UnifyKey<V> : Clone + Show + PartialEq + Repr {
+pub trait UnifyKey<'tcx, V> : Clone + Show + PartialEq + Repr<'tcx> {
     fn index(&self) -> uint;
 
     fn from_index(u: uint) -> Self;
@@ -57,7 +57,7 @@ fn unification_table<'v>(infcx: &'v InferCtxt)
  *
  * Implementations of this trait are at the end of this file.
  */
-pub trait UnifyValue : Clone + Repr + PartialEq {
+pub trait UnifyValue<'tcx> : Clone + Repr<'tcx> + PartialEq {
 }
 
 /**
@@ -114,7 +114,7 @@ pub struct Node<K,V> {
 // other type parameter U, and we have no way to say
 // Option<U>:LatticeValue.
 
-impl<V:PartialEq+Clone+Repr,K:UnifyKey<V>> UnificationTable<K,V> {
+impl<'tcx, V:PartialEq+Clone+Repr<'tcx>, K:UnifyKey<'tcx, V>> UnificationTable<K,V> {
     pub fn new() -> UnificationTable<K,V> {
         UnificationTable {
             values: sv::SnapshotVec::new(Delegate),
@@ -189,7 +189,7 @@ fn is_root(&self, key: &K) -> bool {
     }
 
     pub fn set(&mut self,
-               tcx: &ty::ctxt,
+               tcx: &ty::ctxt<'tcx>,
                key: K,
                new_value: VarValue<K,V>)
     {
@@ -208,7 +208,7 @@ pub fn set(&mut self,
     }
 
     pub fn unify(&mut self,
-                 tcx: &ty::ctxt,
+                 tcx: &ty::ctxt<'tcx>,
                  node_a: &Node<K,V>,
                  node_b: &Node<K,V>)
                  -> (K, uint)
@@ -259,15 +259,15 @@ fn reverse(&mut self, _: &mut Vec<VarValue<K,V>>, _: ()) {
  * Indicates a type that does not have any kind of subtyping
  * relationship.
  */
-pub trait SimplyUnifiable : Clone + PartialEq + Repr {
-    fn to_type(&self) -> Ty;
-    fn to_type_err(expected_found<Self>) -> ty::type_err;
+pub trait SimplyUnifiable<'tcx> : Clone + PartialEq + Repr<'tcx> {
+    fn to_type(&self) -> Ty<'tcx>;
+    fn to_type_err(expected_found<Self>) -> ty::type_err<'tcx>;
 }
 
-pub fn err<V:SimplyUnifiable>(a_is_expected: bool,
-                              a_t: V,
-                              b_t: V)
-                              -> ures {
+pub fn err<'tcx, V:SimplyUnifiable<'tcx>>(a_is_expected: bool,
+                                          a_t: V,
+                                          b_t: V)
+                                          -> ures<'tcx> {
     if a_is_expected {
         Err(SimplyUnifiable::to_type_err(
             ty::expected_found {expected: a_t, found: b_t}))
@@ -277,29 +277,29 @@ pub fn err<V:SimplyUnifiable>(a_is_expected: bool,
     }
 }
 
-pub trait InferCtxtMethodsForSimplyUnifiableTypes<V:SimplyUnifiable,
-                                                  K:UnifyKey<Option<V>>> {
+pub trait InferCtxtMethodsForSimplyUnifiableTypes<'tcx, V:SimplyUnifiable<'tcx>,
+                                                  K:UnifyKey<'tcx, Option<V>>> {
     fn simple_vars(&self,
                    a_is_expected: bool,
                    a_id: K,
                    b_id: K)
-                   -> ures;
+                   -> ures<'tcx>;
     fn simple_var_t(&self,
                     a_is_expected: bool,
                     a_id: K,
                     b: V)
-                    -> ures;
-    fn probe_var(&self, a_id: K) -> Option<Ty>;
+                    -> ures<'tcx>;
+    fn probe_var(&self, a_id: K) -> Option<Ty<'tcx>>;
 }
 
-impl<'a,'tcx,V:SimplyUnifiable,K:UnifyKey<Option<V>>>
-    InferCtxtMethodsForSimplyUnifiableTypes<V,K> for InferCtxt<'a, 'tcx>
+impl<'a,'tcx,V:SimplyUnifiable<'tcx>,K:UnifyKey<'tcx, Option<V>>>
+    InferCtxtMethodsForSimplyUnifiableTypes<'tcx, V, K> for InferCtxt<'a, 'tcx>
 {
     fn simple_vars(&self,
                    a_is_expected: bool,
                    a_id: K,
                    b_id: K)
-                   -> ures
+                   -> ures<'tcx>
     {
         /*!
          * Unifies two simple keys.  Because simple keys do
@@ -345,7 +345,7 @@ fn simple_var_t(&self,
                     a_is_expected: bool,
                     a_id: K,
                     b: V)
-                    -> ures
+                    -> ures<'tcx>
     {
         /*!
          * Sets the value of the key `a_id` to `b`.  Because
@@ -375,7 +375,7 @@ fn simple_var_t(&self,
         }
     }
 
-    fn probe_var(&self, a_id: K) -> Option<Ty> {
+    fn probe_var(&self, a_id: K) -> Option<Ty<'tcx>> {
         let tcx = self.tcx;
         let table = UnifyKey::unification_table(self);
         let node_a = table.borrow_mut().get(tcx, a_id);
@@ -390,7 +390,7 @@ fn probe_var(&self, a_id: K) -> Option<Ty> {
 
 // Integral type keys
 
-impl UnifyKey<Option<IntVarValue>> for ty::IntVid {
+impl<'tcx> UnifyKey<'tcx, Option<IntVarValue>> for ty::IntVid {
     fn index(&self) -> uint { self.index }
 
     fn from_index(i: uint) -> ty::IntVid { ty::IntVid { index: i } }
@@ -406,24 +406,24 @@ fn tag(_: Option<ty::IntVid>) -> &'static str {
     }
 }
 
-impl SimplyUnifiable for IntVarValue {
-    fn to_type(&self) -> Ty {
+impl<'tcx> SimplyUnifiable<'tcx> for IntVarValue {
+    fn to_type(&self) -> Ty<'tcx> {
         match *self {
             ty::IntType(i) => ty::mk_mach_int(i),
             ty::UintType(i) => ty::mk_mach_uint(i),
         }
     }
 
-    fn to_type_err(err: expected_found<IntVarValue>) -> ty::type_err {
+    fn to_type_err(err: expected_found<IntVarValue>) -> ty::type_err<'tcx> {
         return ty::terr_int_mismatch(err);
     }
 }
 
-impl UnifyValue for Option<IntVarValue> { }
+impl<'tcx> UnifyValue<'tcx> for Option<IntVarValue> { }
 
 // Floating point type keys
 
-impl UnifyKey<Option<ast::FloatTy>> for ty::FloatVid {
+impl<'tcx> UnifyKey<'tcx, Option<ast::FloatTy>> for ty::FloatVid {
     fn index(&self) -> uint { self.index }
 
     fn from_index(i: uint) -> ty::FloatVid { ty::FloatVid { index: i } }
@@ -439,21 +439,21 @@ fn tag(_: Option<ty::FloatVid>) -> &'static str {
     }
 }
 
-impl UnifyValue for Option<ast::FloatTy> {
+impl<'tcx> UnifyValue<'tcx> for Option<ast::FloatTy> {
 }
 
-impl SimplyUnifiable for ast::FloatTy {
-    fn to_type(&self) -> Ty {
+impl<'tcx> SimplyUnifiable<'tcx> for ast::FloatTy {
+    fn to_type(&self) -> Ty<'tcx> {
         ty::mk_mach_float(*self)
     }
 
-    fn to_type_err(err: expected_found<ast::FloatTy>) -> ty::type_err {
-        return ty::terr_float_mismatch(err);
+    fn to_type_err(err: expected_found<ast::FloatTy>) -> ty::type_err<'tcx> {
+        ty::terr_float_mismatch(err)
     }
 }
 
-impl<K:Repr,V:Repr> Repr for VarValue<K,V> {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx, K:Repr<'tcx>, V:Repr<'tcx>> Repr<'tcx> for VarValue<K,V> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             Redirect(ref k) => format!("Redirect({})", k.repr(tcx)),
             Root(ref v, r) => format!("Root({}, {})", v.repr(tcx), r)
index da1ff84f718c2fed2834c4cd5cd352d1ae0c8f93..b322dacfb1a846ce78554180bd9f55c5e5d694ef 100644 (file)
@@ -97,7 +97,7 @@ pub struct param_index {
 }
 
 #[deriving(Clone, Show)]
-pub enum MethodOrigin {
+pub enum MethodOrigin<'tcx> {
     // fully statically resolved method
     MethodStatic(ast::DefId),
 
@@ -105,20 +105,20 @@ pub enum MethodOrigin {
     MethodStaticUnboxedClosure(ast::DefId),
 
     // method invoked on a type parameter with a bounded trait
-    MethodTypeParam(MethodParam),
+    MethodTypeParam(MethodParam<'tcx>),
 
     // method invoked on a trait instance
-    MethodTraitObject(MethodObject),
+    MethodTraitObject(MethodObject<'tcx>),
 
 }
 
 // details for a method invoked with a receiver whose type is a type parameter
 // with a bounded trait.
 #[deriving(Clone, Show)]
-pub struct MethodParam {
+pub struct MethodParam<'tcx> {
     // the precise trait reference that occurs as a bound -- this may
     // be a supertrait of what the user actually typed.
-    pub trait_ref: Rc<ty::TraitRef>,
+    pub trait_ref: Rc<ty::TraitRef<'tcx>>,
 
     // index of uint in the list of methods for the trait
     pub method_num: uint,
@@ -126,9 +126,9 @@ pub struct MethodParam {
 
 // details for a method invoked with a receiver whose type is an object
 #[deriving(Clone, Show)]
-pub struct MethodObject {
+pub struct MethodObject<'tcx> {
     // the (super)trait containing the method to be invoked
-    pub trait_ref: Rc<ty::TraitRef>,
+    pub trait_ref: Rc<ty::TraitRef<'tcx>>,
 
     // the actual base trait id of the object
     pub object_trait_id: ast::DefId,
@@ -144,10 +144,10 @@ pub struct MethodObject {
 }
 
 #[deriving(Clone)]
-pub struct MethodCallee {
-    pub origin: MethodOrigin,
-    pub ty: Ty,
-    pub substs: subst::Substs
+pub struct MethodCallee<'tcx> {
+    pub origin: MethodOrigin<'tcx>,
+    pub ty: Ty<'tcx>,
+    pub substs: subst::Substs<'tcx>
 }
 
 /**
@@ -177,9 +177,9 @@ pub enum ExprAdjustment {
     AutoObject
 }
 
-pub struct TypeAndSubsts {
-    pub substs: subst::Substs,
-    pub ty: Ty,
+pub struct TypeAndSubsts<'tcx> {
+    pub substs: subst::Substs<'tcx>,
+    pub ty: Ty<'tcx>,
 }
 
 impl MethodCall {
@@ -207,21 +207,21 @@ pub fn autoderef(expr_id: ast::NodeId, autoderef: uint) -> MethodCall {
 
 // maps from an expression id that corresponds to a method call to the details
 // of the method to be invoked
-pub type MethodMap = RefCell<FnvHashMap<MethodCall, MethodCallee>>;
+pub type MethodMap<'tcx> = RefCell<FnvHashMap<MethodCall, MethodCallee<'tcx>>>;
 
-pub type vtable_param_res = Vec<vtable_origin>;
+pub type vtable_param_res<'tcx> = Vec<vtable_origin<'tcx>>;
 
 // Resolutions for bounds of all parameters, left to right, for a given path.
-pub type vtable_res = VecPerParamSpace<vtable_param_res>;
+pub type vtable_res<'tcx> = VecPerParamSpace<vtable_param_res<'tcx>>;
 
 #[deriving(Clone)]
-pub enum vtable_origin {
+pub enum vtable_origin<'tcx> {
     /*
       Statically known vtable. def_id gives the impl item
       from whence comes the vtable, and tys are the type substs.
       vtable_res is the vtable itself.
      */
-    vtable_static(ast::DefId, subst::Substs, vtable_res),
+    vtable_static(ast::DefId, subst::Substs<'tcx>, vtable_res<'tcx>),
 
     /*
       Dynamic vtable, comes from a parameter that has a bound on it:
@@ -248,8 +248,8 @@ fn foo<T:quux,baz,bar>(a: T) -- a's vtable would have a
     vtable_error,
 }
 
-impl Repr for vtable_origin {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for vtable_origin<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             vtable_static(def_id, ref tys, ref vtable_res) => {
                 format!("vtable_static({}:{}, {}, {})",
@@ -276,7 +276,7 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
 
 // For every explicit cast into an object type, maps from the cast
 // expr to the associated trait ref.
-pub type ObjectCastMap = RefCell<NodeMap<Rc<ty::TraitRef>>>;
+pub type ObjectCastMap<'tcx> = RefCell<NodeMap<Rc<ty::TraitRef<'tcx>>>>;
 
 pub struct CrateCtxt<'a, 'tcx: 'a> {
     // A mapping from method call sites to traits that have that method.
@@ -285,15 +285,15 @@ pub struct CrateCtxt<'a, 'tcx: 'a> {
 }
 
 // Functions that write types into the node type table
-pub fn write_ty_to_tcx(tcx: &ty::ctxt, node_id: ast::NodeId, ty: Ty) {
+pub fn write_ty_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, node_id: ast::NodeId, ty: Ty<'tcx>) {
     debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_string(tcx, ty));
     assert!(!ty::type_needs_infer(ty));
     tcx.node_types.borrow_mut().insert(node_id, ty);
 }
 
-pub fn write_substs_to_tcx(tcx: &ty::ctxt,
-                           node_id: ast::NodeId,
-                           item_substs: ty::ItemSubsts) {
+pub fn write_substs_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                 node_id: ast::NodeId,
+                                 item_substs: ty::ItemSubsts<'tcx>) {
     if !item_substs.is_noop() {
         debug!("write_substs_to_tcx({}, {})",
                node_id,
@@ -318,7 +318,7 @@ pub fn lookup_def_ccx(ccx: &CrateCtxt, sp: Span, id: ast::NodeId)
     lookup_def_tcx(ccx.tcx, sp, id)
 }
 
-pub fn no_params(t: Ty) -> ty::Polytype {
+pub fn no_params<'tcx>(t: Ty<'tcx>) -> ty::Polytype<'tcx> {
     ty::Polytype {
         generics: ty::Generics {types: VecPerParamSpace::empty(),
                                 regions: VecPerParamSpace::empty()},
@@ -326,14 +326,14 @@ pub fn no_params(t: Ty) -> ty::Polytype {
     }
 }
 
-pub fn require_same_types(tcx: &ty::ctxt,
-                          maybe_infcx: Option<&infer::InferCtxt>,
-                          t1_is_expected: bool,
-                          span: Span,
-                          t1: Ty,
-                          t2: Ty,
-                          msg: || -> String)
-                          -> bool {
+pub fn require_same_types<'a, 'tcx>(tcx: &ty::ctxt<'tcx>,
+                                    maybe_infcx: Option<&infer::InferCtxt<'a, 'tcx>>,
+                                    t1_is_expected: bool,
+                                    span: Span,
+                                    t1: Ty<'tcx>,
+                                    t2: Ty<'tcx>,
+                                    msg: || -> String)
+                                    -> bool {
     let result = match maybe_infcx {
         None => {
             let infcx = infer::new_infer_ctxt(tcx);
index e3df42c2adad3b6b976a0b480d897401b7307705..27b9d9d19da3cc74aa4af1b3e653b3971c4dbaf7 100644 (file)
@@ -725,7 +725,7 @@ fn xform(&mut self,
     /// Adds constraints appropriate for an instance of `ty` appearing
     /// in a context with ambient variance `variance`
     fn add_constraints_from_ty(&mut self,
-                               ty: Ty,
+                               ty: Ty<'tcx>,
                                variance: VarianceTermPtr<'a>) {
         debug!("add_constraints_from_ty(ty={})", ty.repr(self.tcx()));
 
@@ -854,9 +854,9 @@ fn add_constraints_from_ty(&mut self,
     /// object, etc) appearing in a context with ambient variance `variance`
     fn add_constraints_from_substs(&mut self,
                                    def_id: ast::DefId,
-                                   type_param_defs: &[ty::TypeParameterDef],
+                                   type_param_defs: &[ty::TypeParameterDef<'tcx>],
                                    region_param_defs: &[ty::RegionParameterDef],
-                                   substs: &subst::Substs,
+                                   substs: &subst::Substs<'tcx>,
                                    variance: VarianceTermPtr<'a>) {
         debug!("add_constraints_from_substs(def_id={})", def_id);
 
@@ -882,7 +882,7 @@ fn add_constraints_from_substs(&mut self,
     /// Adds constraints appropriate for a function with signature
     /// `sig` appearing in a context with ambient variance `variance`
     fn add_constraints_from_sig(&mut self,
-                                sig: &ty::FnSig,
+                                sig: &ty::FnSig<'tcx>,
                                 variance: VarianceTermPtr<'a>) {
         let contra = self.contravariant(variance);
         for &input in sig.inputs.iter() {
@@ -929,7 +929,7 @@ fn add_constraints_from_region(&mut self,
     /// Adds constraints appropriate for a mutability-type pair
     /// appearing in a context with ambient variance `variance`
     fn add_constraints_from_mt(&mut self,
-                               mt: &ty::mt,
+                               mt: &ty::mt<'tcx>,
                                variance: VarianceTermPtr<'a>) {
         match mt.mutbl {
             ast::MutMutable => {
index 28ddec69781a26ef6bcb7df2c9be6c34bc4c0164..76055372a61491ca7dbe612008bbabaf24fe5f1e 100644 (file)
 use syntax::owned_slice::OwnedSlice;
 
 /// Produces a string suitable for debugging output.
-pub trait Repr for Sized? {
-    fn repr(&self, tcx: &ctxt) -> String;
+pub trait Repr<'tcx> for Sized? {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String;
 }
 
 /// Produces a string suitable for showing to the user.
-pub trait UserString {
-    fn user_string(&self, tcx: &ctxt) -> String;
+pub trait UserString<'tcx> {
+    fn user_string(&self, tcx: &ctxt<'tcx>) -> String;
 }
 
 pub fn note_and_explain_region(cx: &ctxt,
@@ -231,7 +231,7 @@ pub fn mutability_to_string(m: ast::Mutability) -> String {
     }
 }
 
-pub fn mt_to_string(cx: &ctxt, m: &mt) -> String {
+pub fn mt_to_string<'tcx>(cx: &ctxt<'tcx>, m: &mt<'tcx>) -> String {
     format!("{}{}",
         mutability_to_string(m.mutbl),
         ty_to_string(cx, m.ty))
@@ -251,21 +251,22 @@ pub fn vec_map_to_string<T>(ts: &[T], f: |t: &T| -> String) -> String {
     format!("[{}]", tstrs.connect(", "))
 }
 
-pub fn fn_sig_to_string(cx: &ctxt, typ: &ty::FnSig) -> String {
+pub fn fn_sig_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::FnSig<'tcx>) -> String {
     format!("fn{} -> {}", typ.inputs.repr(cx), typ.output.repr(cx))
 }
 
-pub fn trait_ref_to_string(cx: &ctxt, trait_ref: &ty::TraitRef) -> String {
+pub fn trait_ref_to_string<'tcx>(cx: &ctxt<'tcx>,
+                                 trait_ref: &ty::TraitRef<'tcx>) -> String {
     trait_ref.user_string(cx).to_string()
 }
 
-pub fn ty_to_string(cx: &ctxt, typ: Ty) -> String {
-    fn bare_fn_to_string(cx: &ctxt,
-                         fn_style: ast::FnStyle,
-                         abi: abi::Abi,
-                         ident: Option<ast::Ident>,
-                         sig: &ty::FnSig)
-                         -> String {
+pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
+    fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>,
+                               fn_style: ast::FnStyle,
+                               abi: abi::Abi,
+                               ident: Option<ast::Ident>,
+                               sig: &ty::FnSig<'tcx>)
+                               -> String {
         let mut s = String::new();
         match fn_style {
             ast::NormalFn => {}
@@ -294,7 +295,7 @@ fn bare_fn_to_string(cx: &ctxt,
         s
     }
 
-    fn closure_to_string(cx: &ctxt, cty: &ty::ClosureTy) -> String {
+    fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, cty: &ty::ClosureTy<'tcx>) -> String {
         let mut s = String::new();
 
         match cty.store {
@@ -334,12 +335,12 @@ fn closure_to_string(cx: &ctxt, cty: &ty::ClosureTy) -> String {
         s
     }
 
-    fn push_sig_to_string(cx: &ctxt,
-                       s: &mut String,
-                       bra: char,
-                       ket: char,
-                       sig: &ty::FnSig,
-                       bounds: &str) {
+    fn push_sig_to_string<'tcx>(cx: &ctxt<'tcx>,
+                                s: &mut String,
+                                bra: char,
+                                ket: char,
+                                sig: &ty::FnSig<'tcx>,
+                                bounds: &str) {
         s.push(bra);
         let strs = sig.inputs
             .iter()
@@ -382,7 +383,7 @@ fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
     }
 
     // pretty print the structural type representation:
-    match ty::get(typ).sty {
+    match typ.sty {
         ty_bool => "bool".to_string(),
         ty_char => "char".to_string(),
         ty_int(t) => ast_util::int_ty_to_string(t, None).to_string(),
@@ -476,11 +477,11 @@ pub fn explicit_self_category_to_str(category: &ty::ExplicitSelfCategory)
     }
 }
 
-pub fn parameterized(cx: &ctxt,
-                     base: &str,
-                     substs: &subst::Substs,
-                     generics: &ty::Generics)
-                     -> String
+pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
+                           base: &str,
+                           substs: &subst::Substs<'tcx>,
+                           generics: &ty::Generics<'tcx>)
+                           -> String
 {
     if cx.sess.verbose() {
         if substs.is_noop() {
@@ -539,7 +540,7 @@ pub fn parameterized(cx: &ctxt,
     }
 }
 
-pub fn ty_to_short_str(cx: &ctxt, typ: Ty) -> String {
+pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String {
     let mut s = typ.repr(cx).to_string();
     if s.len() >= 32u {
         s = s.as_slice().slice(0u, 32u).to_string();
@@ -547,8 +548,8 @@ pub fn ty_to_short_str(cx: &ctxt, typ: Ty) -> String {
     return s;
 }
 
-impl<T:Repr> Repr for Option<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Option<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         match self {
             &None => "None".to_string(),
             &Some(ref t) => t.repr(tcx),
@@ -556,14 +557,14 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl<T:Repr> Repr for P<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for P<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         (*self).repr(tcx)
     }
 }
 
-impl<T:Repr,U:Repr> Repr for Result<T,U> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx,T:Repr<'tcx>,U:Repr<'tcx>> Repr<'tcx> for Result<T,U> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         match self {
             &Ok(ref t) => t.repr(tcx),
             &Err(ref u) => format!("Err({})", u.repr(tcx))
@@ -571,70 +572,70 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for () {
+impl<'tcx> Repr<'tcx> for () {
     fn repr(&self, _tcx: &ctxt) -> String {
         "()".to_string()
     }
 }
 
-impl<'a, Sized? T:Repr> Repr for &'a T {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'a, 'tcx, Sized? T:Repr<'tcx>> Repr<'tcx> for &'a T {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         Repr::repr(*self, tcx)
     }
 }
 
-impl<T:Repr> Repr for Rc<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Rc<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         (&**self).repr(tcx)
     }
 }
 
-impl<T:Repr> Repr for Box<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Box<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         (&**self).repr(tcx)
     }
 }
 
-fn repr_vec<T:Repr>(tcx: &ctxt, v: &[T]) -> String {
+fn repr_vec<'tcx, T:Repr<'tcx>>(tcx: &ctxt<'tcx>, v: &[T]) -> String {
     vec_map_to_string(v, |t| t.repr(tcx))
 }
 
-impl<T:Repr> Repr for [T] {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for [T] {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         repr_vec(tcx, self)
     }
 }
 
-impl<T:Repr> Repr for OwnedSlice<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         repr_vec(tcx, self.as_slice())
     }
 }
 
 // This is necessary to handle types like Option<~[T]>, for which
 // autoderef cannot convert the &[T] handler
-impl<T:Repr> Repr for Vec<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         repr_vec(tcx, self.as_slice())
     }
 }
 
-impl<T:UserString> UserString for Vec<T> {
-    fn user_string(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:UserString<'tcx>> UserString<'tcx> for Vec<T> {
+    fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
         let strs: Vec<String> =
             self.iter().map(|t| t.user_string(tcx)).collect();
         strs.connect(", ")
     }
 }
 
-impl Repr for def::Def {
+impl<'tcx> Repr<'tcx> for def::Def {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ty::TypeParameterDef {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::TypeParameterDef<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("TypeParameterDef({}, {}, {}/{})",
                 self.def_id,
                 self.bounds.repr(tcx),
@@ -643,7 +644,7 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::RegionParameterDef {
+impl<'tcx> Repr<'tcx> for ty::RegionParameterDef {
     fn repr(&self, tcx: &ctxt) -> String {
         format!("RegionParameterDef(name={}, def_id={}, bounds={})",
                 token::get_name(self.name),
@@ -652,28 +653,28 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for Ty {
-    fn repr(&self, tcx: &ctxt) -> String {
-        ty_to_string(tcx, *self)
+impl<'tcx> Repr<'tcx> for ty::TyS<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
+        ty_to_string(tcx, self)
     }
 }
 
-impl Repr for ty::mt {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::mt<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         mt_to_string(tcx, self)
     }
 }
 
-impl Repr for subst::Substs {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for subst::Substs<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("Substs[types={}, regions={}]",
                        self.types.repr(tcx),
                        self.regions.repr(tcx))
     }
 }
 
-impl<T:Repr> Repr for subst::VecPerParamSpace<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for subst::VecPerParamSpace<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("[{};{};{};{}]",
                 self.get_slice(subst::TypeSpace).repr(tcx),
                 self.get_slice(subst::SelfSpace).repr(tcx),
@@ -682,13 +683,13 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::ItemSubsts {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::ItemSubsts<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("ItemSubsts({})", self.substs.repr(tcx))
     }
 }
 
-impl Repr for subst::RegionSubsts {
+impl<'tcx> Repr<'tcx> for subst::RegionSubsts {
     fn repr(&self, tcx: &ctxt) -> String {
         match *self {
             subst::ErasedRegions => "erased".to_string(),
@@ -697,7 +698,7 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::BuiltinBounds {
+impl<'tcx> Repr<'tcx> for ty::BuiltinBounds {
     fn repr(&self, _tcx: &ctxt) -> String {
         let mut res = Vec::new();
         for b in self.iter() {
@@ -712,14 +713,14 @@ fn repr(&self, _tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::ExistentialBounds {
+impl<'tcx> Repr<'tcx> for ty::ExistentialBounds {
     fn repr(&self, tcx: &ctxt) -> String {
         self.user_string(tcx)
     }
 }
 
-impl Repr for ty::ParamBounds {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::ParamBounds<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         let mut res = Vec::new();
         res.push(self.builtin_bounds.repr(tcx));
         for t in self.trait_bounds.iter() {
@@ -729,8 +730,8 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::TraitRef {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         // when printing out the debug representation, we don't need
         // to enumerate the `for<...>` etc because the debruijn index
         // tells you everything you need to know.
@@ -742,8 +743,8 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::TraitDef {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::TraitDef<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("TraitDef(generics={}, bounds={}, trait_ref={})",
                 self.generics.repr(tcx),
                 self.bounds.repr(tcx),
@@ -751,7 +752,7 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ast::TraitItem {
+impl<'tcx> Repr<'tcx> for ast::TraitItem {
     fn repr(&self, _tcx: &ctxt) -> String {
         match *self {
             ast::RequiredMethod(ref data) => format!("RequiredMethod({}, id={})",
@@ -764,43 +765,43 @@ fn repr(&self, _tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ast::Expr {
+impl<'tcx> Repr<'tcx> for ast::Expr {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("expr({}: {})", self.id, pprust::expr_to_string(self))
     }
 }
 
-impl Repr for ast::Path {
+impl<'tcx> Repr<'tcx> for ast::Path {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("path({})", pprust::path_to_string(self))
     }
 }
 
-impl UserString for ast::Path {
+impl<'tcx> UserString<'tcx> for ast::Path {
     fn user_string(&self, _tcx: &ctxt) -> String {
         pprust::path_to_string(self)
     }
 }
 
-impl Repr for ast::Ty {
+impl<'tcx> Repr<'tcx> for ast::Ty {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("type({})", pprust::ty_to_string(self))
     }
 }
 
-impl Repr for ast::Item {
+impl<'tcx> Repr<'tcx> for ast::Item {
     fn repr(&self, tcx: &ctxt) -> String {
         format!("item({})", tcx.map.node_to_string(self.id))
     }
 }
 
-impl Repr for ast::Lifetime {
+impl<'tcx> Repr<'tcx> for ast::Lifetime {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("lifetime({}: {})", self.id, pprust::lifetime_to_string(self))
     }
 }
 
-impl Repr for ast::Stmt {
+impl<'tcx> Repr<'tcx> for ast::Stmt {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("stmt({}: {})",
                 ast_util::stmt_id(self),
@@ -808,13 +809,13 @@ fn repr(&self, _tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ast::Pat {
+impl<'tcx> Repr<'tcx> for ast::Pat {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("pat({}: {})", self.id, pprust::pat_to_string(self))
     }
 }
 
-impl Repr for ty::BoundRegion {
+impl<'tcx> Repr<'tcx> for ty::BoundRegion {
     fn repr(&self, tcx: &ctxt) -> String {
         match *self {
             ty::BrAnon(id) => format!("BrAnon({})", id),
@@ -827,7 +828,7 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::Region {
+impl<'tcx> Repr<'tcx> for ty::Region {
     fn repr(&self, tcx: &ctxt) -> String {
         match *self {
             ty::ReEarlyBound(id, space, index, name) => {
@@ -869,13 +870,13 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl UserString for ty::Region {
+impl<'tcx> UserString<'tcx> for ty::Region {
     fn user_string(&self, tcx: &ctxt) -> String {
         region_to_string(tcx, "", false, *self)
     }
 }
 
-impl Repr for ty::FreeRegion {
+impl<'tcx> Repr<'tcx> for ty::FreeRegion {
     fn repr(&self, tcx: &ctxt) -> String {
         format!("ReFree({}, {})",
                 self.scope_id,
@@ -883,7 +884,7 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ast::DefId {
+impl<'tcx> Repr<'tcx> for ast::DefId {
     fn repr(&self, tcx: &ctxt) -> String {
         // Unfortunately, there seems to be no way to attempt to print
         // a path for a def-id, so I'll just make a best effort for now
@@ -908,31 +909,31 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::Polytype {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::Polytype<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("Polytype {{generics: {}, ty: {}}}",
                 self.generics.repr(tcx),
                 self.ty.repr(tcx))
     }
 }
 
-impl Repr for ty::Generics {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::Generics<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("Generics(types: {}, regions: {})",
                 self.types.repr(tcx),
                 self.regions.repr(tcx))
     }
 }
 
-impl Repr for ty::GenericBounds {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::GenericBounds<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("GenericBounds(types: {}, regions: {})",
                 self.types.repr(tcx),
                 self.regions.repr(tcx))
     }
 }
 
-impl Repr for ty::ItemVariances {
+impl<'tcx> Repr<'tcx> for ty::ItemVariances {
     fn repr(&self, tcx: &ctxt) -> String {
         format!("ItemVariances(types={}, \
                 regions={})",
@@ -941,7 +942,7 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::Variance {
+impl<'tcx> Repr<'tcx> for ty::Variance {
     fn repr(&self, _: &ctxt) -> String {
         // The first `.to_string()` returns a &'static str (it is not an implementation
         // of the ToString trait). Because of that, we need to call `.to_string()` again
@@ -951,8 +952,8 @@ fn repr(&self, _: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::Method {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::Method<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("method(name: {}, generics: {}, fty: {}, \
                  explicit_self: {}, vis: {}, def_id: {})",
                 self.name.repr(tcx),
@@ -964,38 +965,38 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ast::Name {
+impl<'tcx> Repr<'tcx> for ast::Name {
     fn repr(&self, _tcx: &ctxt) -> String {
         token::get_name(*self).get().to_string()
     }
 }
 
-impl UserString for ast::Name {
+impl<'tcx> UserString<'tcx> for ast::Name {
     fn user_string(&self, _tcx: &ctxt) -> String {
         token::get_name(*self).get().to_string()
     }
 }
 
-impl Repr for ast::Ident {
+impl<'tcx> Repr<'tcx> for ast::Ident {
     fn repr(&self, _tcx: &ctxt) -> String {
         token::get_ident(*self).get().to_string()
     }
 }
 
-impl Repr for ast::ExplicitSelf_ {
+impl<'tcx> Repr<'tcx> for ast::ExplicitSelf_ {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ast::Visibility {
+impl<'tcx> Repr<'tcx> for ast::Visibility {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ty::BareFnTy {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::BareFnTy<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("BareFnTy {{fn_style: {}, abi: {}, sig: {}}}",
                 self.fn_style,
                 self.abi.to_string(),
@@ -1003,14 +1004,14 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::FnSig {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::FnSig<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         fn_sig_to_string(tcx, self)
     }
 }
 
-impl Repr for ty::FnOutput {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for ty::FnOutput<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         match *self {
             ty::FnConverging(ty) =>
                 format!("FnConverging({0})", ty.repr(tcx)),
@@ -1020,8 +1021,8 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for typeck::MethodCallee {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for typeck::MethodCallee<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("MethodCallee {{origin: {}, ty: {}, {}}}",
                 self.origin.repr(tcx),
                 self.ty.repr(tcx),
@@ -1029,8 +1030,8 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for typeck::MethodOrigin {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for typeck::MethodOrigin<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         match self {
             &typeck::MethodStatic(def_id) => {
                 format!("MethodStatic({})", def_id.repr(tcx))
@@ -1048,16 +1049,16 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for typeck::MethodParam {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for typeck::MethodParam<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("MethodParam({},{})",
                 self.trait_ref.repr(tcx),
                 self.method_num)
     }
 }
 
-impl Repr for typeck::MethodObject {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx> Repr<'tcx> for typeck::MethodObject<'tcx> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("MethodObject({},{},{})",
                 self.trait_ref.repr(tcx),
                 self.method_num,
@@ -1065,19 +1066,19 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::TraitStore {
+impl<'tcx> Repr<'tcx> for ty::TraitStore {
     fn repr(&self, tcx: &ctxt) -> String {
         trait_store_to_string(tcx, *self)
     }
 }
 
-impl Repr for ty::BuiltinBound {
+impl<'tcx> Repr<'tcx> for ty::BuiltinBound {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl UserString for ty::BuiltinBound {
+impl<'tcx> UserString<'tcx> for ty::BuiltinBound {
     fn user_string(&self, _tcx: &ctxt) -> String {
         match *self {
             ty::BoundSend => "Send".to_string(),
@@ -1088,21 +1089,21 @@ fn user_string(&self, _tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for Span {
+impl<'tcx> Repr<'tcx> for Span {
     fn repr(&self, tcx: &ctxt) -> String {
         tcx.sess.codemap().span_to_string(*self).to_string()
     }
 }
 
-impl<A:UserString> UserString for Rc<A> {
-    fn user_string(&self, tcx: &ctxt) -> String {
+impl<'tcx, A:UserString<'tcx>> UserString<'tcx> for Rc<A> {
+    fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
         let this: &A = &**self;
         this.user_string(tcx)
     }
 }
 
-impl UserString for ty::ParamBounds {
-    fn user_string(&self, tcx: &ctxt) -> String {
+impl<'tcx> UserString<'tcx> for ty::ParamBounds<'tcx> {
+    fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
         let mut result = Vec::new();
         let s = self.builtin_bounds.user_string(tcx);
         if !s.is_empty() {
@@ -1115,7 +1116,7 @@ fn user_string(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl UserString for ty::ExistentialBounds {
+impl<'tcx> UserString<'tcx> for ty::ExistentialBounds {
     fn user_string(&self, tcx: &ctxt) -> String {
         if self.builtin_bounds.contains(&ty::BoundSend) &&
             self.region_bound == ty::ReStatic
@@ -1138,7 +1139,7 @@ fn user_string(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl UserString for ty::BuiltinBounds {
+impl<'tcx> UserString<'tcx> for ty::BuiltinBounds {
     fn user_string(&self, tcx: &ctxt) -> String {
         self.iter()
             .map(|bb| bb.user_string(tcx))
@@ -1148,8 +1149,8 @@ fn user_string(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl UserString for ty::TraitRef {
-    fn user_string(&self, tcx: &ctxt) -> String {
+impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> {
+    fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
         // Replace any anonymous late-bound regions with named
         // variants, using gensym'd identifiers, so that we can
         // clearly differentiate between named and unnamed regions in
@@ -1188,31 +1189,31 @@ fn user_string(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl UserString for Ty {
-    fn user_string(&self, tcx: &ctxt) -> String {
+impl<'tcx> UserString<'tcx> for Ty<'tcx> {
+    fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
         ty_to_string(tcx, *self)
     }
 }
 
-impl UserString for ast::Ident {
+impl<'tcx> UserString<'tcx> for ast::Ident {
     fn user_string(&self, _tcx: &ctxt) -> String {
         token::get_name(self.name).get().to_string()
     }
 }
 
-impl Repr for abi::Abi {
+impl<'tcx> Repr<'tcx> for abi::Abi {
     fn repr(&self, _tcx: &ctxt) -> String {
         self.to_string()
     }
 }
 
-impl UserString for abi::Abi {
+impl<'tcx> UserString<'tcx> for abi::Abi {
     fn user_string(&self, _tcx: &ctxt) -> String {
         self.to_string()
     }
 }
 
-impl Repr for ty::UpvarId {
+impl<'tcx> Repr<'tcx> for ty::UpvarId {
     fn repr(&self, tcx: &ctxt) -> String {
         format!("UpvarId({};`{}`;{})",
                 self.var_id,
@@ -1221,19 +1222,19 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ast::Mutability {
+impl<'tcx> Repr<'tcx> for ast::Mutability {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ty::BorrowKind {
+impl<'tcx> Repr<'tcx> for ty::BorrowKind {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ty::UpvarBorrow {
+impl<'tcx> Repr<'tcx> for ty::UpvarBorrow {
     fn repr(&self, tcx: &ctxt) -> String {
         format!("UpvarBorrow({}, {})",
                 self.kind.repr(tcx),
@@ -1241,62 +1242,62 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ty::IntVid {
+impl<'tcx> Repr<'tcx> for ty::IntVid {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", self)
     }
 }
 
-impl Repr for ty::FloatVid {
+impl<'tcx> Repr<'tcx> for ty::FloatVid {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", self)
     }
 }
 
-impl Repr for ty::RegionVid {
+impl<'tcx> Repr<'tcx> for ty::RegionVid {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", self)
     }
 }
 
-impl Repr for ty::TyVid {
+impl<'tcx> Repr<'tcx> for ty::TyVid {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", self)
     }
 }
 
-impl Repr for ty::IntVarValue {
+impl<'tcx> Repr<'tcx> for ty::IntVarValue {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ast::IntTy {
+impl<'tcx> Repr<'tcx> for ast::IntTy {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ast::UintTy {
+impl<'tcx> Repr<'tcx> for ast::UintTy {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ast::FloatTy {
+impl<'tcx> Repr<'tcx> for ast::FloatTy {
     fn repr(&self, _tcx: &ctxt) -> String {
         format!("{}", *self)
     }
 }
 
-impl Repr for ty::ExplicitSelfCategory {
+impl<'tcx> Repr<'tcx> for ty::ExplicitSelfCategory {
     fn repr(&self, _: &ctxt) -> String {
         explicit_self_category_to_str(self).to_string()
     }
 }
 
 
-impl Repr for regionmanip::WfConstraint {
+impl<'tcx> Repr<'tcx> for regionmanip::WfConstraint<'tcx> {
     fn repr(&self, tcx: &ctxt) -> String {
         match *self {
             regionmanip::RegionSubRegionConstraint(_, r_a, r_b) => {
@@ -1314,7 +1315,7 @@ fn repr(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl UserString for ParamTy {
+impl<'tcx> UserString<'tcx> for ParamTy {
     fn user_string(&self, tcx: &ctxt) -> String {
         let id = self.idx;
         let did = self.def_id;
@@ -1329,22 +1330,22 @@ fn user_string(&self, tcx: &ctxt) -> String {
     }
 }
 
-impl Repr for ParamTy {
+impl<'tcx> Repr<'tcx> for ParamTy {
     fn repr(&self, tcx: &ctxt) -> String {
         let ident = self.user_string(tcx);
         format!("{}/{}.{}", ident, self.space, self.idx)
     }
 }
 
-impl<A:Repr,B:Repr> Repr for (A,B) {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, A:Repr<'tcx>, B:Repr<'tcx>> Repr<'tcx> for (A,B) {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         let &(ref a, ref b) = self;
         format!("({},{})", a.repr(tcx), b.repr(tcx))
     }
 }
 
-impl<T:Repr> Repr for ty::Binder<T> {
-    fn repr(&self, tcx: &ctxt) -> String {
+impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for ty::Binder<T> {
+    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("Binder({})", self.value.repr(tcx))
     }
 }
index 264756ccf1ee9a0ae2f4608f12aa52114e970409..d27a338b308c70babc25b0ea2ee238b073eed771 100644 (file)
@@ -196,11 +196,11 @@ fn truncated_hash_result(symbol_hasher: &mut Sha256) -> String {
 
 
 // This calculates STH for a symbol, as defined above
-fn symbol_hash(tcx: &ty::ctxt,
-               symbol_hasher: &mut Sha256,
-               t: Ty,
-               link_meta: &LinkMeta)
-               -> String {
+fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
+                     symbol_hasher: &mut Sha256,
+                     t: Ty<'tcx>,
+                     link_meta: &LinkMeta)
+                     -> String {
     // NB: do *not* use abbrevs here as we want the symbol names
     // to be independent of one another in the crate.
 
@@ -219,7 +219,7 @@ fn symbol_hash(tcx: &ty::ctxt,
     hash
 }
 
-fn get_symbol_hash(ccx: &CrateContext, t: Ty) -> String {
+fn get_symbol_hash<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> String {
     match ccx.type_hashcodes().borrow().get(&t) {
         Some(h) => return h.to_string(),
         None => {}
@@ -320,8 +320,8 @@ pub fn exported_name(path: PathElems, hash: &str) -> String {
     mangle(path, Some(hash))
 }
 
-pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems,
-                            t: Ty, id: ast::NodeId) -> String {
+pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathElems,
+                                      t: Ty<'tcx>, id: ast::NodeId) -> String {
     let mut hash = get_symbol_hash(ccx, t);
 
     // Paths can be completely identical for different nodes,
@@ -345,9 +345,9 @@ pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems,
     exported_name(path, hash.as_slice())
 }
 
-pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext,
-                                            t: Ty,
-                                            name: &str) -> String {
+pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                                      t: Ty<'tcx>,
+                                                      name: &str) -> String {
     let s = ppaux::ty_to_string(ccx.tcx(), t);
     let path = [PathName(token::intern(s.as_slice())),
                 gensym_name(name)];
index a0e2bf07b830f94dc505173126b74530ac4959e5..98cf779fcd2a28fc8dfa35b4bce70fc6f62f2d7d 100644 (file)
@@ -358,7 +358,7 @@ pub struct CrateAnalysis<'tcx> {
 /// structures carrying the results of the analysis.
 pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
                                          ast_map: ast_map::Map<'tcx>,
-                                         type_arena: &'tcx TypedArena<ty::t_box_>,
+                                         type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
                                          name: String) -> CrateAnalysis<'tcx> {
     let time_passes = sess.time_passes();
     let krate = ast_map.krate();
index c20f2e097f31f3050eb5d37f462eafac3d08bdf9..aa6ac6564e205a4613a4e0a0f1cb44d8334160d4 100644 (file)
@@ -98,7 +98,7 @@ impl PpSourceMode {
     fn call_with_pp_support<'tcx, A, B>(&self,
                                         sess: Session,
                                         ast_map: Option<ast_map::Map<'tcx>>,
-                                        type_arena: &'tcx TypedArena<ty::t_box_>,
+                                        type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
                                         id: String,
                                         payload: B,
                                         f: |&PrinterSupport, B| -> A) -> A {
index 897cd3cc542245fc5e15654d611e08d4f4ef8173..984c1f99720eae65a5d82ab36d3f9b45544a75c9 100644 (file)
@@ -215,7 +215,7 @@ fn search(this: &Env,
         }
     }
 
-    pub fn make_subtype(&self, a: Ty, b: Ty) -> bool {
+    pub fn make_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
         match infer::mk_subty(self.infcx, true, infer::Misc(DUMMY_SP), a, b) {
             Ok(_) => true,
             Err(ref e) => panic!("Encountered error: {}",
@@ -223,14 +223,14 @@ pub fn make_subtype(&self, a: Ty, b: Ty) -> bool {
         }
     }
 
-    pub fn is_subtype(&self, a: Ty, b: Ty) -> bool {
+    pub fn is_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
         match infer::can_mk_subty(self.infcx, a, b) {
             Ok(_) => true,
             Err(_) => false
         }
     }
 
-    pub fn assert_subtype(&self, a: Ty, b: Ty) {
+    pub fn assert_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) {
         if !self.is_subtype(a, b) {
             panic!("{} is not a subtype of {}, but it should be",
                   self.ty_to_string(a),
@@ -238,36 +238,36 @@ pub fn assert_subtype(&self, a: Ty, b: Ty) {
         }
     }
 
-    pub fn assert_eq(&self, a: Ty, b: Ty) {
+    pub fn assert_eq(&self, a: Ty<'tcx>, b: Ty<'tcx>) {
         self.assert_subtype(a, b);
         self.assert_subtype(b, a);
     }
 
-    pub fn ty_to_string(&self, a: Ty) -> String {
+    pub fn ty_to_string(&self, a: Ty<'tcx>) -> String {
         ty_to_string(self.infcx.tcx, a)
     }
 
     pub fn t_fn(&self,
-                input_tys: &[Ty],
-                output_ty: Ty)
-                -> Ty
+                input_tys: &[Ty<'tcx>],
+                output_ty: Ty<'tcx>)
+                -> Ty<'tcx>
     {
         ty::mk_ctor_fn(self.infcx.tcx, input_tys, output_ty)
     }
 
-    pub fn t_nil(&self) -> Ty {
+    pub fn t_nil(&self) -> Ty<'tcx> {
         ty::mk_nil(self.infcx.tcx)
     }
 
-    pub fn t_pair(&self, ty1: Ty, ty2: Ty) -> Ty {
+    pub fn t_pair(&self, ty1: Ty<'tcx>, ty2: Ty<'tcx>) -> Ty<'tcx> {
         ty::mk_tup(self.infcx.tcx, vec![ty1, ty2])
     }
 
     pub fn t_closure(&self,
-                     input_tys: &[Ty],
-                     output_ty: Ty,
+                     input_tys: &[Ty<'tcx>],
+                     output_ty: Ty<'tcx>,
                      region_bound: ty::Region)
-                     -> Ty
+                     -> Ty<'tcx>
     {
         ty::mk_closure(self.infcx.tcx, ty::ClosureTy {
             fn_style: ast::NormalFn,
@@ -283,7 +283,7 @@ pub fn t_closure(&self,
         })
     }
 
-    pub fn t_param(&self, space: subst::ParamSpace, index: uint) -> Ty {
+    pub fn t_param(&self, space: subst::ParamSpace, index: uint) -> Ty<'tcx> {
         ty::mk_param(self.infcx.tcx, space, index, ast_util::local_def(ast::DUMMY_NODE_ID))
     }
 
@@ -301,23 +301,26 @@ pub fn re_late_bound_with_debruijn(&self, id: uint, debruijn: ty::DebruijnIndex)
         ty::ReLateBound(debruijn, ty::BrAnon(id))
     }
 
-    pub fn t_rptr(&self, r: ty::Region) -> Ty {
+    pub fn t_rptr(&self, r: ty::Region) -> Ty<'tcx> {
         ty::mk_imm_rptr(self.infcx.tcx, r, ty::mk_int())
     }
 
-    pub fn t_rptr_late_bound(&self, id: uint) -> Ty {
+    pub fn t_rptr_late_bound(&self, id: uint) -> Ty<'tcx> {
         ty::mk_imm_rptr(self.infcx.tcx,
                         self.re_late_bound_with_debruijn(id, ty::DebruijnIndex::new(1)),
                         ty::mk_int())
     }
 
-    pub fn t_rptr_late_bound_with_debruijn(&self, id: uint, debruijn: ty::DebruijnIndex) -> Ty {
+    pub fn t_rptr_late_bound_with_debruijn(&self,
+                                           id: uint,
+                                           debruijn: ty::DebruijnIndex)
+                                           -> Ty<'tcx> {
         ty::mk_imm_rptr(self.infcx.tcx,
                         self.re_late_bound_with_debruijn(id, debruijn),
                         ty::mk_int())
     }
 
-    pub fn t_rptr_scope(&self, id: ast::NodeId) -> Ty {
+    pub fn t_rptr_scope(&self, id: ast::NodeId) -> Ty<'tcx> {
         ty::mk_imm_rptr(self.infcx.tcx, ty::ReScope(id), ty::mk_int())
     }
 
@@ -326,15 +329,15 @@ pub fn re_free(&self, nid: ast::NodeId, id: uint) -> ty::Region {
                                    bound_region: ty::BrAnon(id)})
     }
 
-    pub fn t_rptr_free(&self, nid: ast::NodeId, id: uint) -> Ty {
+    pub fn t_rptr_free(&self, nid: ast::NodeId, id: uint) -> Ty<'tcx> {
         ty::mk_imm_rptr(self.infcx.tcx, self.re_free(nid, id), ty::mk_int())
     }
 
-    pub fn t_rptr_static(&self) -> Ty {
+    pub fn t_rptr_static(&self) -> Ty<'tcx> {
         ty::mk_imm_rptr(self.infcx.tcx, ty::ReStatic, ty::mk_int())
     }
 
-    pub fn dummy_type_trace(&self) -> infer::TypeTrace {
+    pub fn dummy_type_trace(&self) -> infer::TypeTrace<'tcx> {
         infer::TypeTrace::dummy()
     }
 
@@ -348,7 +351,7 @@ pub fn glb(&self) -> Glb<'a, 'tcx> {
         Glb(self.infcx.combine_fields(true, trace))
     }
 
-    pub fn make_lub_ty(&self, t1: Ty, t2: Ty) -> Ty {
+    pub fn make_lub_ty(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> Ty<'tcx> {
         match self.lub().tys(t1, t2) {
             Ok(t) => t,
             Err(ref e) => panic!("unexpected error computing LUB: {}",
@@ -357,7 +360,7 @@ pub fn make_lub_ty(&self, t1: Ty, t2: Ty) -> Ty {
     }
 
     /// Checks that `LUB(t1,t2) == t_lub`
-    pub fn check_lub(&self, t1: Ty, t2: Ty, t_lub: Ty) {
+    pub fn check_lub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_lub: Ty<'tcx>) {
         match self.lub().tys(t1, t2) {
             Ok(t) => {
                 self.assert_eq(t, t_lub);
@@ -370,7 +373,7 @@ pub fn check_lub(&self, t1: Ty, t2: Ty, t_lub: Ty) {
     }
 
     /// Checks that `GLB(t1,t2) == t_glb`
-    pub fn check_glb(&self, t1: Ty, t2: Ty, t_glb: Ty) {
+    pub fn check_glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_glb: Ty<'tcx>) {
         debug!("check_glb(t1={}, t2={}, t_glb={})",
                self.ty_to_string(t1),
                self.ty_to_string(t2),
index 5c90f64f298d7089897be446ebd6d67adf8e8259..8d16e56d435aa221969b2aeb7835b0e30c620579 100644 (file)
@@ -248,16 +248,16 @@ fn eq(self, other: ConstantExpr<'a>, tcx: &ty::ctxt) -> bool {
 
 // An option identifying a branch (either a literal, an enum variant or a range)
 #[deriving(Show)]
-enum Opt<'a> {
+enum Opt<'a, 'tcx> {
     ConstantValue(ConstantExpr<'a>),
     ConstantRange(ConstantExpr<'a>, ConstantExpr<'a>),
-    Variant(ty::Disr, Rc<adt::Repr>, ast::DefId),
+    Variant(ty::Disr, Rc<adt::Repr<'tcx>>, ast::DefId),
     SliceLengthEqual(uint),
     SliceLengthGreaterOrEqual(/* prefix length */ uint, /* suffix length */ uint),
 }
 
-impl<'a> Opt<'a> {
-    fn eq(&self, other: &Opt<'a>, tcx: &ty::ctxt) -> bool {
+impl<'a, 'tcx> Opt<'a, 'tcx> {
+    fn eq(&self, other: &Opt<'a, 'tcx>, tcx: &ty::ctxt<'tcx>) -> bool {
         match (self, other) {
             (&ConstantValue(a), &ConstantValue(b)) => a.eq(b, tcx),
             (&ConstantRange(a1, a2), &ConstantRange(b1, b2)) => {
@@ -274,7 +274,7 @@ fn eq(&self, other: &Opt<'a>, tcx: &ty::ctxt) -> bool {
         }
     }
 
-    fn trans<'blk, 'tcx>(&self, mut bcx: Block<'blk, 'tcx>) -> OptResult<'blk, 'tcx> {
+    fn trans<'blk>(&self, mut bcx: Block<'blk, 'tcx>) -> OptResult<'blk, 'tcx> {
         let _icx = push_ctxt("match::trans_opt");
         let ccx = bcx.ccx();
         match *self {
@@ -334,20 +334,20 @@ pub enum TransBindingMode {
  * - `id` is the node id of the binding
  * - `ty` is the Rust type of the binding */
  #[deriving(Clone)]
-pub struct BindingInfo {
+pub struct BindingInfo<'tcx> {
     pub llmatch: ValueRef,
     pub trmode: TransBindingMode,
     pub id: ast::NodeId,
     pub span: Span,
-    pub ty: Ty,
+    pub ty: Ty<'tcx>,
 }
 
-type BindingsMap = FnvHashMap<Ident, BindingInfo>;
+type BindingsMap<'tcx> = FnvHashMap<Ident, BindingInfo<'tcx>>;
 
 struct ArmData<'p, 'blk, 'tcx: 'blk> {
     bodycx: Block<'blk, 'tcx>,
     arm: &'p ast::Arm,
-    bindings_map: BindingsMap
+    bindings_map: BindingsMap<'tcx>
 }
 
 /**
@@ -362,7 +362,7 @@ struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
     bound_ptrs: Vec<(Ident, ValueRef)>,
 }
 
-impl<'a, 'p, 'blk, 'tcx> Repr for Match<'a, 'p, 'blk, 'tcx> {
+impl<'a, 'p, 'blk, 'tcx> Repr<'tcx> for Match<'a, 'p, 'blk, 'tcx> {
     fn repr(&self, tcx: &ty::ctxt) -> String {
         if tcx.sess.verbose() {
             // for many programs, this just take too long to serialize
@@ -564,7 +564,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
 // on a set of enum variants or a literal.
 fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                     m: &[Match<'a, 'p, 'blk, 'tcx>], col: uint)
-                                    -> Vec<Opt<'p>> {
+                                    -> Vec<Opt<'p, 'tcx>> {
     let tcx = bcx.tcx();
 
     let mut found: Vec<Opt> = vec![];
@@ -608,7 +608,7 @@ struct ExtractedBlock<'blk, 'tcx: 'blk> {
 }
 
 fn extract_variant_args<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                    repr: &adt::Repr,
+                                    repr: &adt::Repr<'tcx>,
                                     disr_val: ty::Disr,
                                     val: ValueRef)
                                     -> ExtractedBlock<'blk, 'tcx> {
@@ -620,7 +620,7 @@ fn extract_variant_args<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     ExtractedBlock { vals: args, bcx: bcx }
 }
 
-fn match_datum(val: ValueRef, left_ty: Ty) -> Datum<Lvalue> {
+fn match_datum<'tcx>(val: ValueRef, left_ty: Ty<'tcx>) -> Datum<'tcx, Lvalue> {
     /*!
      * Helper for converting from the ValueRef that we pass around in
      * the match code, which is always an lvalue, into a Datum. Eventually
@@ -790,12 +790,12 @@ fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> uint {
 fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                               lhs: ValueRef,
                               rhs: ValueRef,
-                              rhs_t: Ty)
+                              rhs_t: Ty<'tcx>)
                               -> Result<'blk, 'tcx> {
     fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                                lhs: ValueRef,
                                rhs: ValueRef,
-                               rhs_t: Ty)
+                               rhs_t: Ty<'tcx>)
                                -> Result<'blk, 'tcx> {
         let did = langcall(cx,
                            None,
@@ -832,7 +832,7 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
 }
 
 fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
-                               bindings_map: &BindingsMap,
+                               bindings_map: &BindingsMap<'tcx>,
                                cs: Option<cleanup::ScopeId>)
                                -> Block<'blk, 'tcx> {
     /*!
@@ -889,7 +889,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 
 fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                      guard_expr: &ast::Expr,
-                                     data: &ArmData,
+                                     data: &ArmData<'p, 'blk, 'tcx>,
                                      m: &[Match<'a, 'p, 'blk, 'tcx>],
                                      vals: &[ValueRef],
                                      chk: &FailureHandler,
@@ -1272,7 +1272,7 @@ struct ReassignmentChecker {
     reassigned: bool
 }
 
-impl euv::Delegate for ReassignmentChecker {
+impl<'tcx> euv::Delegate<'tcx> for ReassignmentChecker {
     fn consume(&mut self, _: ast::NodeId, _: Span, _: mc::cmt, _: euv::ConsumeMode) {}
     fn consume_pat(&mut self, _: &ast::Pat, _: mc::cmt, _: euv::ConsumeMode) {}
     fn borrow(&mut self, _: ast::NodeId, _: Span, _: mc::cmt, _: ty::Region,
@@ -1288,8 +1288,9 @@ fn mutate(&mut self, _: ast::NodeId, _: Span, cmt: mc::cmt, _: euv::MutateMode)
     }
 }
 
-fn create_bindings_map(bcx: Block, pat: &ast::Pat,
-                      discr: &ast::Expr, body: &ast::Expr) -> BindingsMap {
+fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
+                                   discr: &ast::Expr, body: &ast::Expr)
+                                   -> BindingsMap<'tcx> {
     // Create the bindings map, which is a mapping from each binding name
     // to an alloca() that will be the value for that local variable.
     // Note that we use the names because each binding will have many ids
@@ -1482,7 +1483,7 @@ fn create_dummy_locals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 
 pub fn store_arg<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                              pat: &ast::Pat,
-                             arg: Datum<Rvalue>,
+                             arg: Datum<'tcx, Rvalue>,
                              arg_scope: cleanup::ScopeId)
                              -> Block<'blk, 'tcx> {
     /*!
@@ -1560,7 +1561,7 @@ fn mk_binding_alloca<'blk, 'tcx, A>(bcx: Block<'blk, 'tcx>,
                                     ident: &ast::Ident,
                                     cleanup_scope: cleanup::ScopeId,
                                     arg: A,
-                                    populate: |A, Block<'blk, 'tcx>, ValueRef, Ty|
+                                    populate: |A, Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|
                                               -> Block<'blk, 'tcx>)
                                     -> Block<'blk, 'tcx> {
     let var_ty = node_id_type(bcx, p_id);
index 195808f2419cbc7c34c8a85ed855573ee22a87a4..eaf3f904107b2c561ccfa0b055abd7824fd4df3c 100644 (file)
@@ -76,7 +76,7 @@
 
 /// Representations.
 #[deriving(Eq, PartialEq, Show)]
-pub enum Repr {
+pub enum Repr<'tcx> {
     /// C-like enums; basically an int.
     CEnum(IntType, Disr, Disr), // discriminant range (signedness based on the IntType)
     /**
@@ -86,7 +86,7 @@ pub enum Repr {
      * avoid running the destructor too many times; this is included
      * in the `Struct` if present.
      */
-    Univariant(Struct, bool),
+    Univariant(Struct<'tcx>, bool),
     /**
      * General-case enums: for each case there is a struct, and they
      * all start with a field for the discriminant.
@@ -95,7 +95,7 @@ pub enum Repr {
      * avoid running the destructor too many times; the last argument
      * indicates whether such a flag is present.
      */
-    General(IntType, Vec<Struct>, bool),
+    General(IntType, Vec<Struct<'tcx>>, bool),
     /**
      * Two cases distinguished by a nullable pointer: the case with discriminant
      * `nndiscr` must have single field which is known to be nonnull due to its type.
@@ -105,8 +105,8 @@ pub enum Repr {
      */
     RawNullablePointer {
         nndiscr: Disr,
-        nnty: Ty,
-        nullfields: Vec<Ty>
+        nnty: Ty<'tcx>,
+        nullfields: Vec<Ty<'tcx>>
     },
     /**
      * Two cases distinguished by a nullable pointer: the case with discriminant
@@ -120,23 +120,23 @@ pub enum Repr {
      * identity function.
      */
     StructWrappedNullablePointer {
-        nonnull: Struct,
+        nonnull: Struct<'tcx>,
         nndiscr: Disr,
         ptrfield: PointerField,
-        nullfields: Vec<Ty>,
+        nullfields: Vec<Ty<'tcx>>,
     }
 }
 
 /// For structs, and struct-like parts of anything fancier.
 #[deriving(Eq, PartialEq, Show)]
-pub struct Struct {
+pub struct Struct<'tcx> {
     // If the struct is DST, then the size and alignment do not take into
     // account the unsized fields of the struct.
     pub size: u64,
     pub align: u32,
     pub sized: bool,
     pub packed: bool,
-    pub fields: Vec<Ty>
+    pub fields: Vec<Ty<'tcx>>
 }
 
 /**
@@ -144,12 +144,14 @@ pub struct Struct {
  * these, for places in trans where the `Ty` isn't directly
  * available.
  */
-pub fn represent_node(bcx: Block, node: ast::NodeId) -> Rc<Repr> {
+pub fn represent_node<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                  node: ast::NodeId) -> Rc<Repr<'tcx>> {
     represent_type(bcx.ccx(), node_id_type(bcx, node))
 }
 
 /// Decides how to represent a given type.
-pub fn represent_type(cx: &CrateContext, t: Ty) -> Rc<Repr> {
+pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                t: Ty<'tcx>) -> Rc<Repr<'tcx>> {
     debug!("Representing: {}", ty_to_string(cx.tcx(), t));
     match cx.adt_reprs().borrow().get(&t) {
         Some(repr) => return repr.clone(),
@@ -162,10 +164,11 @@ pub fn represent_type(cx: &CrateContext, t: Ty) -> Rc<Repr> {
     repr
 }
 
-fn represent_type_uncached(cx: &CrateContext, t: Ty) -> Repr {
+fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                     t: Ty<'tcx>) -> Repr<'tcx> {
     match ty::get(t).sty {
         ty::ty_tup(ref elems) => {
-            return Univariant(mk_struct(cx, elems.as_slice(), false, t), false)
+            Univariant(mk_struct(cx, elems.as_slice(), false, t), false)
         }
         ty::ty_struct(def_id, ref substs) => {
             let fields = ty::lookup_struct_fields(cx.tcx(), def_id);
@@ -176,13 +179,12 @@ fn represent_type_uncached(cx: &CrateContext, t: Ty) -> Repr {
             let dtor = ty::ty_dtor(cx.tcx(), def_id).has_drop_flag();
             if dtor { ftys.push(ty::mk_bool()); }
 
-            return Univariant(mk_struct(cx, ftys.as_slice(), packed, t), dtor)
+            Univariant(mk_struct(cx, ftys.as_slice(), packed, t), dtor)
         }
         ty::ty_unboxed_closure(def_id, _, ref substs) => {
             let upvars = ty::unboxed_closure_upvars(cx.tcx(), def_id, substs);
             let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>();
-            return Univariant(mk_struct(cx, upvar_types.as_slice(), false, t),
-                              false)
+            Univariant(mk_struct(cx, upvar_types.as_slice(), false, t), false)
         }
         ty::ty_enum(def_id, ref substs) => {
             let cases = get_cases(cx.tcx(), def_id, substs);
@@ -285,9 +287,9 @@ fn represent_type_uncached(cx: &CrateContext, t: Ty) -> Repr {
 }
 
 // this should probably all be in ty
-struct Case {
+struct Case<'tcx> {
     discr: Disr,
-    tys: Vec<Ty>
+    tys: Vec<Ty<'tcx>>
 }
 
 
@@ -297,12 +299,12 @@ pub enum PointerField {
     FatPointer(uint)
 }
 
-impl Case {
-    fn is_zerolen(&self, cx: &CrateContext, scapegoat: Ty) -> bool {
+impl<'tcx> Case<'tcx> {
+    fn is_zerolen<'a>(&self, cx: &CrateContext<'a, 'tcx>, scapegoat: Ty<'tcx>) -> bool {
         mk_struct(cx, self.tys.as_slice(), false, scapegoat).size == 0
     }
 
-    fn find_ptr(&self, cx: &CrateContext) -> Option<PointerField> {
+    fn find_ptr<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> Option<PointerField> {
         for (i, &ty) in self.tys.iter().enumerate() {
             match ty::get(ty).sty {
                 // &T/&mut T/Box<T> could either be a thin or fat pointer depending on T
@@ -336,7 +338,10 @@ fn find_ptr(&self, cx: &CrateContext) -> Option<PointerField> {
     }
 }
 
-fn get_cases(tcx: &ty::ctxt, def_id: ast::DefId, substs: &subst::Substs) -> Vec<Case> {
+fn get_cases<'tcx>(tcx: &ty::ctxt<'tcx>,
+                   def_id: ast::DefId,
+                   substs: &subst::Substs<'tcx>)
+                   -> Vec<Case<'tcx>> {
     ty::enum_variants(tcx, def_id).iter().map(|vi| {
         let arg_tys = vi.args.iter().map(|&raw_ty| {
             raw_ty.subst(tcx, substs)
@@ -345,7 +350,10 @@ fn get_cases(tcx: &ty::ctxt, def_id: ast::DefId, substs: &subst::Substs) -> Vec<
     }).collect()
 }
 
-fn mk_struct(cx: &CrateContext, tys: &[Ty], packed: bool, scapegoat: Ty) -> Struct {
+fn mk_struct<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                       tys: &[Ty<'tcx>], packed: bool,
+                       scapegoat: Ty<'tcx>)
+                       -> Struct<'tcx> {
     let sized = tys.iter().all(|&ty| ty::type_is_sized(cx.tcx(), ty));
     let lltys : Vec<Type> = if sized {
         tys.iter()
@@ -375,7 +383,9 @@ struct IntBounds {
     uhi: u64
 }
 
-fn mk_cenum(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> Repr {
+fn mk_cenum<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                      hint: Hint, bounds: &IntBounds)
+                      -> Repr<'tcx> {
     let it = range_to_inttype(cx, hint, bounds);
     match it {
         attr::SignedInt(_) => CEnum(it, bounds.slo as Disr, bounds.shi as Disr),
@@ -450,7 +460,8 @@ fn bounds_usable(cx: &CrateContext, ity: IntType, bounds: &IntBounds) -> bool {
     }
 }
 
-pub fn ty_of_inttype(ity: IntType) -> Ty {
+// FIXME(#17596) Ty<'tcx> is incorrectly invariant w.r.t 'tcx.
+pub fn ty_of_inttype<'tcx>(ity: IntType) -> Ty<'tcx> {
     match ity {
         attr::SignedInt(t) => ty::mk_mach_int(t),
         attr::UnsignedInt(t) => ty::mk_mach_uint(t)
@@ -458,10 +469,10 @@ pub fn ty_of_inttype(ity: IntType) -> Ty {
 }
 
 // LLVM doesn't like types that don't fit in the address space
-fn ensure_struct_fits_in_address_space(ccx: &CrateContext,
-                                       fields: &[Type],
-                                       packed: bool,
-                                       scapegoat: Ty) {
+fn ensure_struct_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                                 fields: &[Type],
+                                                 packed: bool,
+                                                 scapegoat: Ty<'tcx>) {
     let mut offset = 0;
     for &llty in fields.iter() {
         // Invariant: offset < ccx.max_obj_size() <= 1<<61
@@ -486,10 +497,10 @@ fn union_size_and_align(sts: &[Struct]) -> (machine::llsize, machine::llalign) {
     (size, most_aligned.align)
 }
 
-fn ensure_enum_fits_in_address_space(ccx: &CrateContext,
-                                     discr: IntType,
-                                     fields: &[Struct],
-                                     scapegoat: Ty) {
+fn ensure_enum_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                               discr: IntType,
+                                               fields: &[Struct],
+                                               scapegoat: Ty<'tcx>) {
     let discr_size = machine::llsize_of_alloc(ccx, ll_inttype(ccx, discr));
     let (field_size, field_align) = union_size_and_align(fields);
 
@@ -513,19 +524,22 @@ fn ensure_enum_fits_in_address_space(ccx: &CrateContext,
  * and fill in the actual contents in a second pass to prevent
  * unbounded recursion; see also the comments in `trans::type_of`.
  */
-pub fn type_of(cx: &CrateContext, r: &Repr) -> Type {
+pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>) -> Type {
     generic_type_of(cx, r, None, false, false)
 }
 // Pass dst=true if the type you are passing is a DST. Yes, we could figure
 // this out, but if you call this on an unsized type without realising it, you
 // are going to get the wrong type (it will not include the unsized parts of it).
-pub fn sizing_type_of(cx: &CrateContext, r: &Repr, dst: bool) -> Type {
+pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                r: &Repr<'tcx>, dst: bool) -> Type {
     generic_type_of(cx, r, None, true, dst)
 }
-pub fn incomplete_type_of(cx: &CrateContext, r: &Repr, name: &str) -> Type {
+pub fn incomplete_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                    r: &Repr<'tcx>, name: &str) -> Type {
     generic_type_of(cx, r, Some(name), false, false)
 }
-pub fn finish_type_of(cx: &CrateContext, r: &Repr, llty: &mut Type) {
+pub fn finish_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                r: &Repr<'tcx>, llty: &mut Type) {
     match *r {
         CEnum(..) | General(..) | RawNullablePointer { .. } => { }
         Univariant(ref st, _) | StructWrappedNullablePointer { nonnull: ref st, .. } =>
@@ -534,11 +548,11 @@ pub fn finish_type_of(cx: &CrateContext, r: &Repr, llty: &mut Type) {
     }
 }
 
-fn generic_type_of(cx: &CrateContext,
-                   r: &Repr,
-                   name: Option<&str>,
-                   sizing: bool,
-                   dst: bool) -> Type {
+fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                             r: &Repr<'tcx>,
+                             name: Option<&str>,
+                             sizing: bool,
+                             dst: bool) -> Type {
     match *r {
         CEnum(ity, _, _) => ll_inttype(cx, ity),
         RawNullablePointer { nnty, .. } => type_of::sizing_type_of(cx, nnty),
@@ -596,7 +610,8 @@ fn generic_type_of(cx: &CrateContext,
     }
 }
 
-fn struct_llfields(cx: &CrateContext, st: &Struct, sizing: bool, dst: bool) -> Vec<Type> {
+fn struct_llfields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, st: &Struct<'tcx>,
+                             sizing: bool, dst: bool) -> Vec<Type> {
     if sizing {
         st.fields.iter().filter(|&ty| !dst || ty::type_is_sized(cx.tcx(), *ty))
             .map(|&ty| type_of::sizing_type_of(cx, ty)).collect()
@@ -611,8 +626,9 @@ fn struct_llfields(cx: &CrateContext, st: &Struct, sizing: bool, dst: bool) -> V
  *
  * This should ideally be less tightly tied to `_match`.
  */
-pub fn trans_switch(bcx: Block, r: &Repr, scrutinee: ValueRef)
-    -> (_match::BranchKind, Option<ValueRef>) {
+pub fn trans_switch<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                r: &Repr<'tcx>, scrutinee: ValueRef)
+                                -> (_match::BranchKind, Option<ValueRef>) {
     match *r {
         CEnum(..) | General(..) |
         RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
@@ -627,7 +643,8 @@ pub fn trans_switch(bcx: Block, r: &Repr, scrutinee: ValueRef)
 
 
 /// Obtain the actual discriminant of a value.
-pub fn trans_get_discr(bcx: Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>)
+pub fn trans_get_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
+                                   scrutinee: ValueRef, cast_to: Option<Type>)
     -> ValueRef {
     let signed;
     let val;
@@ -728,7 +745,8 @@ pub fn trans_case<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr, discr: Disr)
  * Set the discriminant for a new value of the given case of the given
  * representation.
  */
-pub fn trans_set_discr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr) {
+pub fn trans_set_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
+                                   val: ValueRef, discr: Disr) {
     match *r {
         CEnum(ity, min, max) => {
             assert_discr_in_range(ity, min, max, discr);
@@ -806,8 +824,8 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint {
 }
 
 /// Access a field, at a point when the value's case is known.
-pub fn trans_field_ptr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr,
-                       ix: uint) -> ValueRef {
+pub fn trans_field_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
+                                   val: ValueRef, discr: Disr, ix: uint) -> ValueRef {
     // Note: if this ever needs to generate conditionals (e.g., if we
     // decide to do some kind of cdr-coding-like non-unique repr
     // someday), it will need to return a possibly-new bcx as well.
@@ -845,8 +863,8 @@ pub fn trans_field_ptr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr,
     }
 }
 
-pub fn struct_field_ptr(bcx: Block, st: &Struct, val: ValueRef,
-                        ix: uint, needs_cast: bool) -> ValueRef {
+pub fn struct_field_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, st: &Struct<'tcx>, val: ValueRef,
+                                    ix: uint, needs_cast: bool) -> ValueRef {
     let val = if needs_cast {
         let ccx = bcx.ccx();
         let fields = st.fields.iter().map(|&ty| type_of::type_of(ccx, ty)).collect::<Vec<_>>();
@@ -860,8 +878,8 @@ pub fn struct_field_ptr(bcx: Block, st: &Struct, val: ValueRef,
 }
 
 pub fn fold_variants<'blk, 'tcx>(
-        bcx: Block<'blk, 'tcx>, r: &Repr, value: ValueRef,
-        f: |Block<'blk, 'tcx>, &Struct, ValueRef| -> Block<'blk, 'tcx>)
+        bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>, value: ValueRef,
+        f: |Block<'blk, 'tcx>, &Struct<'tcx>, ValueRef| -> Block<'blk, 'tcx>)
         -> Block<'blk, 'tcx> {
     let fcx = bcx.fcx;
     match *r {
@@ -900,7 +918,7 @@ pub fn fold_variants<'blk, 'tcx>(
 }
 
 /// Access the struct drop flag, if present.
-pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr, val: ValueRef)
+pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>, val: ValueRef)
                                        -> datum::DatumBlock<'blk, 'tcx, datum::Expr> {
     let ptr_ty = ty::mk_imm_ptr(bcx.tcx(), ty::mk_bool());
     match *r {
@@ -949,8 +967,8 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr, val
  * this could be changed in the future to avoid allocating unnecessary
  * space after values of shorter-than-maximum cases.
  */
-pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr,
-                   vals: &[ValueRef]) -> ValueRef {
+pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr: Disr,
+                             vals: &[ValueRef]) -> ValueRef {
     match *r {
         CEnum(ity, min, max) => {
             assert_eq!(vals.len(), 0);
@@ -1004,7 +1022,8 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr,
 /**
  * Compute struct field offsets relative to struct begin.
  */
-fn compute_struct_field_offsets(ccx: &CrateContext, st: &Struct) -> Vec<u64> {
+fn compute_struct_field_offsets<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                          st: &Struct<'tcx>) -> Vec<u64> {
     let mut offsets = vec!();
 
     let mut offset = 0;
@@ -1031,8 +1050,9 @@ fn compute_struct_field_offsets(ccx: &CrateContext, st: &Struct) -> Vec<u64> {
  * a two-element struct will locate it at offset 4, and accesses to it
  * will read the wrong memory.
  */
-fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef])
-    -> Vec<ValueRef> {
+fn build_const_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                st: &Struct<'tcx>, vals: &[ValueRef])
+                                -> Vec<ValueRef> {
     assert_eq!(vals.len(), st.fields.len());
 
     let target_offsets = compute_struct_field_offsets(ccx, st);
index fdb19605b76296cd39a59e98726cc69840c3c25d..979082737c531d8ad94647c2a21dd7237ec3e435 100644 (file)
@@ -25,7 +25,6 @@
 
 #![allow(non_camel_case_types)]
 
-pub use self::IsUnboxedClosureFlag::*;
 pub use self::ValueOrigin::*;
 pub use self::scalar_type::*;
 
@@ -49,8 +48,9 @@
 use trans::build::*;
 use trans::builder::{Builder, noname};
 use trans::callee;
-use trans::cleanup::{CleanupMethods, ScopeId};
+use trans::cleanup::CleanupMethods;
 use trans::cleanup;
+use trans::closure;
 use trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral};
 use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef};
 use trans::common::{CrateContext, ExternMap, FunctionContext};
@@ -224,7 +224,8 @@ pub fn get_extern_fn(ccx: &CrateContext,
     f
 }
 
-fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: Ty, name: &str, did: ast::DefId) -> ValueRef {
+fn get_extern_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<'tcx>,
+                                name: &str, did: ast::DefId) -> ValueRef {
     match ccx.externs().borrow().get(name) {
         Some(n) => return *n,
         None => ()
@@ -240,10 +241,10 @@ fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: Ty, name: &str, did: ast::DefId
     f
 }
 
-pub fn self_type_for_unboxed_closure(ccx: &CrateContext,
+pub fn self_type_for_unboxed_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                      closure_id: ast::DefId,
-                                     fn_ty: Ty)
-                                     -> Ty {
+                                     fn_ty: Ty<'tcx>)
+                                     -> Ty<'tcx> {
     let unboxed_closures = ccx.tcx().unboxed_closures.borrow();
     let unboxed_closure = &(*unboxed_closures)[closure_id];
     match unboxed_closure.kind {
@@ -263,7 +264,8 @@ pub fn kind_for_unboxed_closure(ccx: &CrateContext, closure_id: ast::DefId)
     (*unboxed_closures)[closure_id].kind
 }
 
-pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: Ty, name: &str) -> ValueRef {
+pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                              fn_ty: Ty<'tcx>, name: &str) -> ValueRef {
     let (inputs, output, abi, env) = match ty::get(fn_ty).sty {
         ty::ty_bare_fn(ref f) => {
             (f.sig.inputs.clone(), f.sig.output, f.abi, None)
@@ -297,14 +299,15 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: Ty, name: &str) -> ValueRef {
     llfn
 }
 
-pub fn decl_internal_rust_fn(ccx: &CrateContext, fn_ty: Ty, name: &str) -> ValueRef {
+pub fn decl_internal_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                       fn_ty: Ty<'tcx>, name: &str) -> ValueRef {
     let llfn = decl_rust_fn(ccx, fn_ty, name);
     llvm::SetLinkage(llfn, llvm::InternalLinkage);
     llfn
 }
 
-pub fn get_extern_const(ccx: &CrateContext, did: ast::DefId,
-                        t: Ty) -> ValueRef {
+pub fn get_extern_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, did: ast::DefId,
+                                  t: Ty<'tcx>) -> ValueRef {
     let name = csearch::get_symbol(&ccx.sess().cstore, did);
     let ty = type_of(ccx, t);
     match ccx.externs().borrow_mut().get(&name) {
@@ -335,7 +338,8 @@ pub fn get_extern_const(ccx: &CrateContext, did: ast::DefId,
 // Returns a pointer to the body for the box. The box may be an opaque
 // box. The result will be casted to the type of body_t, if it is statically
 // known.
-pub fn at_box_body(bcx: Block, body_t: Ty, boxptr: ValueRef) -> ValueRef {
+pub fn at_box_body<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                               body_t: Ty<'tcx>, boxptr: ValueRef) -> ValueRef {
     let _icx = push_ctxt("at_box_body");
     let ccx = bcx.ccx();
     let ty = Type::at_box(ccx, type_of(ccx, body_t));
@@ -343,7 +347,8 @@ pub fn at_box_body(bcx: Block, body_t: Ty, boxptr: ValueRef) -> ValueRef {
     GEPi(bcx, boxptr, &[0u, abi::box_field_body])
 }
 
-fn require_alloc_fn(bcx: Block, info_ty: Ty, it: LangItem) -> ast::DefId {
+fn require_alloc_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                info_ty: Ty<'tcx>, it: LangItem) -> ast::DefId {
     match bcx.tcx().lang_items.require(it) {
         Ok(id) => id,
         Err(s) => {
@@ -359,7 +364,7 @@ fn require_alloc_fn(bcx: Block, info_ty: Ty, it: LangItem) -> ast::DefId {
 
 pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                   llty_ptr: Type,
-                                  info_ty: Ty,
+                                  info_ty: Ty<'tcx>,
                                   size: ValueRef,
                                   align: ValueRef)
                                   -> Result<'blk, 'tcx> {
@@ -374,7 +379,8 @@ pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     Result::new(r.bcx, PointerCast(r.bcx, r.val, llty_ptr))
 }
 
-pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty) -> Result<'blk, 'tcx> {
+pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>)
+                                       -> Result<'blk, 'tcx> {
     let _icx = push_ctxt("malloc_raw_dyn_proc");
     let ccx = bcx.ccx();
 
@@ -399,7 +405,8 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty) -> Result<
 
 // Type descriptor and type glue stuff
 
-pub fn get_tydesc(ccx: &CrateContext, t: Ty) -> Rc<tydesc_info> {
+pub fn get_tydesc<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                            t: Ty<'tcx>) -> Rc<tydesc_info<'tcx>> {
     match ccx.tydescs().borrow().get(&t) {
         Some(inf) => return inf.clone(),
         _ => { }
@@ -494,12 +501,12 @@ pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: String) {
 }
 
 
-pub fn get_res_dtor(ccx: &CrateContext,
-                    did: ast::DefId,
-                    t: Ty,
-                    parent_id: ast::DefId,
-                    substs: &subst::Substs)
-                 -> ValueRef {
+pub fn get_res_dtor<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                              did: ast::DefId,
+                              t: Ty<'tcx>,
+                              parent_id: ast::DefId,
+                              substs: &subst::Substs<'tcx>)
+                              -> ValueRef {
     let _icx = push_ctxt("trans_res_dtor");
     let did = inline::maybe_instantiate_inline(ccx, did);
 
@@ -549,7 +556,7 @@ pub enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, }
 pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                                         lhs: ValueRef,
                                         rhs: ValueRef,
-                                        t: Ty,
+                                        t: Ty<'tcx>,
                                         op: ast::BinOp)
                                         -> Result<'blk, 'tcx> {
     let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
@@ -627,11 +634,11 @@ fn die(cx: Block) -> ! {
     }
 }
 
-pub fn compare_simd_types(
-                    cx: Block,
+pub fn compare_simd_types<'blk, 'tcx>(
+                    cx: Block<'blk, 'tcx>,
                     lhs: ValueRef,
                     rhs: ValueRef,
-                    t: Ty,
+                    t: Ty<'tcx>,
                     size: uint,
                     op: ast::BinOp)
                     -> ValueRef {
@@ -666,21 +673,21 @@ pub fn compare_simd_types(
 }
 
 pub type val_and_ty_fn<'a, 'blk, 'tcx> =
-    |Block<'blk, 'tcx>, ValueRef, Ty|: 'a -> Block<'blk, 'tcx>;
+    |Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|: 'a -> Block<'blk, 'tcx>;
 
 // Iterates through the elements of a structural type.
 pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                                           av: ValueRef,
-                                          t: Ty,
+                                          t: Ty<'tcx>,
                                           f: val_and_ty_fn<'a, 'blk, 'tcx>)
                                           -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("iter_structural_ty");
 
     fn iter_variant<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
-                                    repr: &adt::Repr,
+                                    repr: &adt::Repr<'tcx>,
                                     av: ValueRef,
-                                    variant: &ty::VariantInfo,
-                                    substs: &subst::Substs,
+                                    variant: &ty::VariantInfo<'tcx>,
+                                    substs: &subst::Substs<'tcx>,
                                     f: val_and_ty_fn<'a, 'blk, 'tcx>)
                                     -> Block<'blk, 'tcx> {
         let _icx = push_ctxt("iter_variant");
@@ -855,7 +862,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
                                 divrem: ast::BinOp,
                                 lhs: ValueRef,
                                 rhs: ValueRef,
-                                rhs_t: Ty)
+                                rhs_t: Ty<'tcx>)
                                 -> Block<'blk, 'tcx> {
     let (zero_text, overflow_text) = if divrem == ast::BiDiv {
         ("attempted to divide by zero",
@@ -922,7 +929,8 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
     }
 }
 
-pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: Ty) -> ValueRef {
+pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                     did: ast::DefId, t: Ty<'tcx>) -> ValueRef {
     let name = csearch::get_symbol(&ccx.sess().cstore, did);
     match ty::get(t).sty {
         ty::ty_bare_fn(ref fn_ty) => {
@@ -951,7 +959,7 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: Ty) -> ValueR
 pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                           llfn: ValueRef,
                           llargs: Vec<ValueRef> ,
-                          fn_ty: Ty,
+                          fn_ty: Ty<'tcx>,
                           call_info: Option<NodeInfo>,
                           // FIXME(15064) is_lang_item is a horrible hack, please remove it
                           // at the soonest opportunity.
@@ -1028,13 +1036,15 @@ pub fn need_invoke(bcx: Block) -> bool {
     bcx.fcx.needs_invoke()
 }
 
-pub fn load_if_immediate(cx: Block, v: ValueRef, t: Ty) -> ValueRef {
+pub fn load_if_immediate<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
+                                     v: ValueRef, t: Ty<'tcx>) -> ValueRef {
     let _icx = push_ctxt("load_if_immediate");
     if type_is_immediate(cx.ccx(), t) { return load_ty(cx, v, t); }
     return v;
 }
 
-pub fn load_ty(cx: Block, ptr: ValueRef, t: Ty) -> ValueRef {
+pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
+                           ptr: ValueRef, t: Ty<'tcx>) -> ValueRef {
     /*!
      * Helper for loading values from memory. Does the necessary conversion if
      * the in-memory type differs from the type used for SSA values. Also
@@ -1148,7 +1158,9 @@ pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, a
     Call(cx, memcpy, &[dst_ptr, src_ptr, size, align, volatile], None);
 }
 
-pub fn memcpy_ty(bcx: Block, dst: ValueRef, src: ValueRef, t: Ty) {
+pub fn memcpy_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                             dst: ValueRef, src: ValueRef,
+                             t: Ty<'tcx>) {
     let _icx = push_ctxt("memcpy_ty");
     let ccx = bcx.ccx();
     if ty::type_is_structural(t) {
@@ -1161,7 +1173,7 @@ pub fn memcpy_ty(bcx: Block, dst: ValueRef, src: ValueRef, t: Ty) {
     }
 }
 
-pub fn zero_mem(cx: Block, llptr: ValueRef, t: Ty) {
+pub fn zero_mem<'blk, 'tcx>(cx: Block<'blk, 'tcx>, llptr: ValueRef, t: Ty<'tcx>) {
     if cx.unreachable.get() { return; }
     let _icx = push_ctxt("zero_mem");
     let bcx = cx;
@@ -1173,7 +1185,7 @@ pub fn zero_mem(cx: Block, llptr: ValueRef, t: Ty) {
 // allocation for large data structures, and the generated code will be
 // awful. (A telltale sign of this is large quantities of
 // `mov [byte ptr foo],0` in the generated code.)
-fn memzero(b: &Builder, llptr: ValueRef, ty: Ty) {
+fn memzero<'a, 'tcx>(b: &Builder<'a, 'tcx>, llptr: ValueRef, ty: Ty<'tcx>) {
     let _icx = push_ctxt("memzero");
     let ccx = b.ccx;
 
@@ -1194,7 +1206,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: Ty) {
     b.call(llintrinsicfn, &[llptr, llzeroval, size, align, volatile], None);
 }
 
-pub fn alloc_ty(bcx: Block, t: Ty, name: &str) -> ValueRef {
+pub fn alloc_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, name: &str) -> ValueRef {
     let _icx = push_ctxt("alloc_ty");
     let ccx = bcx.ccx();
     let ty = type_of::type_of(ccx, t);
@@ -1220,7 +1232,8 @@ pub fn alloca_no_lifetime(cx: Block, ty: Type, name: &str) -> ValueRef {
     Alloca(cx, ty, name)
 }
 
-pub fn alloca_zeroed(cx: Block, ty: Ty, name: &str) -> ValueRef {
+pub fn alloca_zeroed<'blk, 'tcx>(cx: Block<'blk, 'tcx>, ty: Ty<'tcx>,
+                                 name: &str) -> ValueRef {
     let llty = type_of::type_of(cx.ccx(), ty);
     if cx.unreachable.get() {
         unsafe {
@@ -1248,7 +1261,8 @@ pub fn arrayalloca(cx: Block, ty: Type, v: ValueRef) -> ValueRef {
 }
 
 // Creates the alloca slot which holds the pointer to the slot for the final return value
-pub fn make_return_slot_pointer(fcx: &FunctionContext, output_type: Ty) -> ValueRef {
+pub fn make_return_slot_pointer<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
+                                          output_type: Ty<'tcx>) -> ValueRef {
     let lloutputtype = type_of::type_of(fcx.ccx, output_type);
 
     // We create an alloca to hold a pointer of type `output_type`
@@ -1407,8 +1421,8 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
                              llfndecl: ValueRef,
                              id: ast::NodeId,
                              has_env: bool,
-                             output_type: ty::FnOutput,
-                             param_substs: &'a param_substs,
+                             output_type: ty::FnOutput<'tcx>,
+                             param_substs: &'a param_substs<'tcx>,
                              sp: Option<Span>,
                              block_arena: &'a TypedArena<common::BlockS<'a, 'tcx>>)
                              -> FunctionContext<'a, 'tcx> {
@@ -1463,7 +1477,8 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
 /// and allocating space for the return pointer.
 pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
                                skip_retptr: bool,
-                               output: ty::FnOutput) -> Block<'a, 'tcx> {
+                               output: ty::FnOutput<'tcx>)
+                               -> Block<'a, 'tcx> {
     let entry_bcx = fcx.new_temp_block("entry-block");
 
     // Use a dummy instruction as the insertion point for all allocas.
@@ -1499,7 +1514,8 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
 //  - new_fn_ctxt
 //  - trans_args
 
-pub fn arg_kind(cx: &FunctionContext, t: Ty) -> datum::Rvalue {
+pub fn arg_kind<'a, 'tcx>(cx: &FunctionContext<'a, 'tcx>, t: Ty<'tcx>)
+                          -> datum::Rvalue {
     use trans::datum::{ByRef, ByValue};
 
     datum::Rvalue {
@@ -1508,15 +1524,15 @@ pub fn arg_kind(cx: &FunctionContext, t: Ty) -> datum::Rvalue {
 }
 
 // work around bizarre resolve errors
-pub type RvalueDatum = datum::Datum<datum::Rvalue>;
-pub type LvalueDatum = datum::Datum<datum::Lvalue>;
+pub type RvalueDatum<'tcx> = datum::Datum<'tcx, datum::Rvalue>;
+pub type LvalueDatum<'tcx> = datum::Datum<'tcx, datum::Lvalue>;
 
 // create_datums_for_fn_args: creates rvalue datums for each of the
 // incoming function arguments. These will later be stored into
 // appropriate lvalue datums.
-pub fn create_datums_for_fn_args(fcx: &FunctionContext,
-                                 arg_tys: &[Ty])
-                                 -> Vec<RvalueDatum> {
+pub fn create_datums_for_fn_args<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
+                                           arg_tys: &[Ty<'tcx>])
+                                           -> Vec<RvalueDatum<'tcx>> {
     let _icx = push_ctxt("create_datums_for_fn_args");
 
     // Return an array wrapping the ValueRefs that we get from `get_param` for
@@ -1532,11 +1548,11 @@ pub fn create_datums_for_fn_args(fcx: &FunctionContext,
 /// datums.
 ///
 /// FIXME(pcwalton): Reduce the amount of code bloat this is responsible for.
-fn create_datums_for_fn_args_under_call_abi(
-        mut bcx: Block,
+fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>(
+        mut bcx: Block<'blk, 'tcx>,
         arg_scope: cleanup::CustomScopeIndex,
-        arg_tys: &[Ty])
-        -> Vec<RvalueDatum> {
+        arg_tys: &[Ty<'tcx>])
+        -> Vec<RvalueDatum<'tcx>> {
     let mut result = Vec::new();
     for (i, &arg_ty) in arg_tys.iter().enumerate() {
         if i < arg_tys.len() - 1 {
@@ -1597,7 +1613,7 @@ fn copy_args_to_allocas<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
                                     arg_scope: cleanup::CustomScopeIndex,
                                     bcx: Block<'blk, 'tcx>,
                                     args: &[ast::Arg],
-                                    arg_datums: Vec<RvalueDatum)
+                                    arg_datums: Vec<RvalueDatum<'tcx>>)
                                     -> Block<'blk, 'tcx> {
     debug!("copy_args_to_allocas");
 
@@ -1629,8 +1645,8 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
                                         mut bcx: Block<'blk, 'tcx>,
                                         arg_scope: cleanup::CustomScopeIndex,
                                         args: &[ast::Arg],
-                                        arg_datums: Vec<RvalueDatum>,
-                                        monomorphized_arg_types: &[Ty])
+                                        arg_datums: Vec<RvalueDatum<'tcx>>,
+                                        monomorphized_arg_types: &[Ty<'tcx>])
                                         -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("copy_unboxed_closure_args_to_allocas");
     let arg_scope_id = cleanup::CustomScope(arg_scope);
@@ -1681,7 +1697,7 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
 // and builds the return block.
 pub fn finish_fn<'blk, 'tcx>(fcx: &'blk FunctionContext<'blk, 'tcx>,
                              last_bcx: Block<'blk, 'tcx>,
-                             retty: ty::FnOutput) {
+                             retty: ty::FnOutput<'tcx>) {
     let _icx = push_ctxt("finish_fn");
 
     let ret_cx = match fcx.llreturn.get() {
@@ -1704,7 +1720,9 @@ pub fn finish_fn<'blk, 'tcx>(fcx: &'blk FunctionContext<'blk, 'tcx>,
 }
 
 // Builds the return block for a function.
-pub fn build_return_block(fcx: &FunctionContext, ret_cx: Block, retty: ty::FnOutput) {
+pub fn build_return_block<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
+                                      ret_cx: Block<'blk, 'tcx>,
+                                      retty: ty::FnOutput<'tcx>) {
     if fcx.llretslotptr.get().is_none() ||
        (!fcx.needs_ret_allocas && fcx.caller_expects_out_pointer) {
         return RetVoid(ret_cx);
@@ -1763,28 +1781,19 @@ pub fn build_return_block(fcx: &FunctionContext, ret_cx: Block, retty: ty::FnOut
     }
 }
 
-#[deriving(Clone, Eq, PartialEq)]
-pub enum IsUnboxedClosureFlag {
-    NotUnboxedClosure,
-    IsUnboxedClosure,
-}
-
 // trans_closure: Builds an LLVM function out of a source function.
 // If the function closes over its environment a closure will be
 // returned.
-pub fn trans_closure(ccx: &CrateContext,
-                     decl: &ast::FnDecl,
-                     body: &ast::Block,
-                     llfndecl: ValueRef,
-                     param_substs: &param_substs,
-                     fn_ast_id: ast::NodeId,
-                     _attributes: &[ast::Attribute],
-                     output_type: ty::FnOutput,
-                     abi: Abi,
-                     has_env: bool,
-                     is_unboxed_closure: IsUnboxedClosureFlag,
-                     maybe_load_env: for<'blk, 'tcx> |Block<'blk, 'tcx>, ScopeId|
-                                                     -> Block<'blk, 'tcx>) {
+pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                   decl: &ast::FnDecl,
+                                   body: &ast::Block,
+                                   llfndecl: ValueRef,
+                                   param_substs: &param_substs<'tcx>,
+                                   fn_ast_id: ast::NodeId,
+                                   _attributes: &[ast::Attribute],
+                                   output_type: ty::FnOutput<'tcx>,
+                                   abi: Abi,
+                                   closure_env: closure::ClosureEnv<'b, 'tcx>) {
     ccx.stats().n_closures.set(ccx.stats().n_closures.get() + 1);
 
     let _icx = push_ctxt("trans_closure");
@@ -1797,7 +1806,7 @@ pub fn trans_closure(ccx: &CrateContext,
     let fcx = new_fn_ctxt(ccx,
                           llfndecl,
                           fn_ast_id,
-                          has_env,
+                          closure_env.kind != closure::NotClosure,
                           output_type,
                           param_substs,
                           Some(body.span),
@@ -1816,11 +1825,15 @@ pub fn trans_closure(ccx: &CrateContext,
         decl.inputs.iter()
                    .map(|arg| node_id_type(bcx, arg.id))
                    .collect::<Vec<_>>();
-    let monomorphized_arg_types = match is_unboxed_closure {
-        NotUnboxedClosure => monomorphized_arg_types,
+    let monomorphized_arg_types = match closure_env.kind {
+        closure::NotClosure | closure::BoxedClosure(..) => {
+            monomorphized_arg_types
+        }
 
         // Tuple up closure argument types for the "rust-call" ABI.
-        IsUnboxedClosure => vec![ty::mk_tup(ccx.tcx(), monomorphized_arg_types)]
+        closure::UnboxedClosure(..) => {
+            vec![ty::mk_tup(ccx.tcx(), monomorphized_arg_types)]
+        }
     };
     for monomorphized_arg_type in monomorphized_arg_types.iter() {
         debug!("trans_closure: monomorphized_arg_type: {}",
@@ -1839,15 +1852,15 @@ pub fn trans_closure(ccx: &CrateContext,
             monomorphized_arg_types.as_slice())
     };
 
-    bcx = match is_unboxed_closure {
-        NotUnboxedClosure => {
+    bcx = match closure_env.kind {
+        closure::NotClosure | closure::BoxedClosure(..) => {
             copy_args_to_allocas(&fcx,
                                  arg_scope,
                                  bcx,
                                  decl.inputs.as_slice(),
                                  arg_datums)
         }
-        IsUnboxedClosure => {
+        closure::UnboxedClosure(..) => {
             copy_unboxed_closure_args_to_allocas(
                 bcx,
                 arg_scope,
@@ -1857,7 +1870,7 @@ pub fn trans_closure(ccx: &CrateContext,
         }
     };
 
-    bcx = maybe_load_env(bcx, cleanup::CustomScope(arg_scope));
+    bcx = closure_env.load(bcx, cleanup::CustomScope(arg_scope));
 
     // Up until here, IR instructions for this function have explicitly not been annotated with
     // source code location, so we don't step into call setup code. From here on, source location
@@ -1912,13 +1925,13 @@ pub fn trans_closure(ccx: &CrateContext,
 
 // trans_fn: creates an LLVM function corresponding to a source language
 // function.
-pub fn trans_fn(ccx: &CrateContext,
-                decl: &ast::FnDecl,
-                body: &ast::Block,
-                llfndecl: ValueRef,
-                param_substs: &param_substs,
-                id: ast::NodeId,
-                attrs: &[ast::Attribute]) {
+pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                          decl: &ast::FnDecl,
+                          body: &ast::Block,
+                          llfndecl: ValueRef,
+                          param_substs: &param_substs<'tcx>,
+                          id: ast::NodeId,
+                          attrs: &[ast::Attribute]) {
     let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string());
     debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
     let _icx = push_ctxt("trans_fn");
@@ -1934,18 +1947,16 @@ pub fn trans_fn(ccx: &CrateContext,
                   attrs,
                   output_type,
                   abi,
-                  false,
-                  NotUnboxedClosure,
-                  |bcx, _| bcx);
-}
-
-pub fn trans_enum_variant(ccx: &CrateContext,
-                          _enum_id: ast::NodeId,
-                          variant: &ast::Variant,
-                          _args: &[ast::VariantArg],
-                          disr: ty::Disr,
-                          param_substs: &param_substs,
-                          llfndecl: ValueRef) {
+                  closure::ClosureEnv::new(&[], closure::NotClosure));
+}
+
+pub fn trans_enum_variant<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                    _enum_id: ast::NodeId,
+                                    variant: &ast::Variant,
+                                    _args: &[ast::VariantArg],
+                                    disr: ty::Disr,
+                                    param_substs: &param_substs<'tcx>,
+                                    llfndecl: ValueRef) {
     let _icx = push_ctxt("trans_enum_variant");
 
     trans_enum_variant_or_tuple_like_struct(
@@ -1957,7 +1968,7 @@ pub fn trans_enum_variant(ccx: &CrateContext,
 }
 
 pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
-                                                 ctor_ty: Ty,
+                                                 ctor_ty: Ty<'tcx>,
                                                  disr: ty::Disr,
                                                  args: callee::CallArgs,
                                                  dest: expr::Dest,
@@ -2016,11 +2027,11 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
     Result::new(bcx, llresult)
 }
 
-pub fn trans_tuple_struct(ccx: &CrateContext,
-                          _fields: &[ast::StructField],
-                          ctor_id: ast::NodeId,
-                          param_substs: &param_substs,
-                          llfndecl: ValueRef) {
+pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                    _fields: &[ast::StructField],
+                                    ctor_id: ast::NodeId,
+                                    param_substs: &param_substs<'tcx>,
+                                    llfndecl: ValueRef) {
     let _icx = push_ctxt("trans_tuple_struct");
 
     trans_enum_variant_or_tuple_like_struct(
@@ -2031,11 +2042,11 @@ pub fn trans_tuple_struct(ccx: &CrateContext,
         llfndecl);
 }
 
-fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
-                                           ctor_id: ast::NodeId,
-                                           disr: ty::Disr,
-                                           param_substs: &param_substs,
-                                           llfndecl: ValueRef) {
+fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                                     ctor_id: ast::NodeId,
+                                                     disr: ty::Disr,
+                                                     param_substs: &param_substs<'tcx>,
+                                                     llfndecl: ValueRef) {
     let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
     let ctor_ty = ctor_ty.substp(ccx.tcx(), param_substs);
 
@@ -2370,12 +2381,12 @@ fn finish_register_fn(ccx: &CrateContext, sp: Span, sym: String, node_id: ast::N
     }
 }
 
-fn register_fn(ccx: &CrateContext,
-               sp: Span,
-               sym: String,
-               node_id: ast::NodeId,
-               node_type: Ty)
-               -> ValueRef {
+fn register_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                         sp: Span,
+                         sym: String,
+                         node_id: ast::NodeId,
+                         node_type: Ty<'tcx>)
+                         -> ValueRef {
     match ty::get(node_type).sty {
         ty::ty_bare_fn(ref f) => {
             assert!(f.abi == Rust || f.abi == RustCall);
@@ -2388,8 +2399,8 @@ fn register_fn(ccx: &CrateContext,
     llfn
 }
 
-pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: Ty)
-                              -> llvm::AttrBuilder {
+pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<'tcx>)
+                                        -> llvm::AttrBuilder {
     use middle::ty::{BrAnon, ReLateBound};
 
     let (fn_sig, abi, has_env) = match ty::get(fn_ty).sty {
@@ -2664,8 +2675,8 @@ fn create_entry_fn(ccx: &CrateContext,
     }
 }
 
-fn exported_name(ccx: &CrateContext, id: ast::NodeId,
-                 ty: Ty, attrs: &[ast::Attribute]) -> String {
+fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, id: ast::NodeId,
+                           ty: Ty<'tcx>, attrs: &[ast::Attribute]) -> String {
     match ccx.external_srcs().borrow().get(&id) {
         Some(&did) => {
             let sym = csearch::get_symbol(&ccx.sess().cstore, did);
index 574ead622c3b1f980284ff2b69f5ec366326ad9c..f35671f81a4d91153451bdb133fb2fb251d3354e 100644 (file)
@@ -66,26 +66,26 @@ pub struct MethodData {
     pub llself: ValueRef,
 }
 
-pub enum CalleeData {
-    Closure(Datum<Lvalue>),
+pub enum CalleeData<'tcx> {
+    Closure(Datum<'tcx, Lvalue>),
 
     // Constructor for enum variant/tuple-like-struct
     // i.e. Some, Ok
-    NamedTupleConstructor(subst::Substs, ty::Disr),
+    NamedTupleConstructor(subst::Substs<'tcx>, ty::Disr),
 
     // Represents a (possibly monomorphized) top-level fn item or method
     // item. Note that this is just the fn-ptr and is not a Rust closure
     // value (which is a pair).
     Fn(/* llfn */ ValueRef),
 
-    Intrinsic(ast::NodeId, subst::Substs),
+    Intrinsic(ast::NodeId, subst::Substs<'tcx>),
 
     TraitItem(MethodData)
 }
 
 pub struct Callee<'blk, 'tcx: 'blk> {
     pub bcx: Block<'blk, 'tcx>,
-    pub data: CalleeData,
+    pub data: CalleeData<'tcx>,
 }
 
 fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
@@ -240,7 +240,7 @@ pub fn trans_fn_ref(bcx: Block, def_id: ast::DefId, node: ExprOrMethodCall) -> V
 fn trans_fn_ref_with_substs_to_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                                   def_id: ast::DefId,
                                                   ref_id: ast::NodeId,
-                                                  substs: subst::Substs)
+                                                  substs: subst::Substs<'tcx>)
                                                   -> Callee<'blk, 'tcx> {
     Callee {
         bcx: bcx,
@@ -253,12 +253,12 @@ fn trans_fn_ref_with_substs_to_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
 /// Translates the adapter that deconstructs a `Box<Trait>` object into
 /// `Trait` so that a by-value self method can be called.
-pub fn trans_unboxing_shim(bcx: Block,
-                           llshimmedfn: ValueRef,
-                           fty: &ty::BareFnTy,
-                           method_id: ast::DefId,
-                           substs: &subst::Substs)
-                           -> ValueRef {
+pub fn trans_unboxing_shim<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                       llshimmedfn: ValueRef,
+                                       fty: &ty::BareFnTy<'tcx>,
+                                       method_id: ast::DefId,
+                                       substs: &subst::Substs<'tcx>)
+                                       -> ValueRef {
     let _icx = push_ctxt("trans_unboxing_shim");
     let ccx = bcx.ccx();
     let tcx = bcx.tcx();
@@ -399,11 +399,11 @@ pub fn trans_unboxing_shim(bcx: Block,
     llfn
 }
 
-pub fn trans_fn_ref_with_substs(
-    bcx: Block,                  //
+pub fn trans_fn_ref_with_substs<'blk, 'tcx>(
+    bcx: Block<'blk, 'tcx>,      //
     def_id: ast::DefId,          // def id of fn
     node: ExprOrMethodCall,      // node id of use of fn; may be zero if N/A
-    substs: subst::Substs)       // vtables for the call
+    substs: subst::Substs<'tcx>) // vtables for the call
     -> ValueRef
 {
     /*!
@@ -610,12 +610,12 @@ pub fn trans_fn_ref_with_substs(
 // ______________________________________________________________________
 // Translating calls
 
-pub fn trans_call<'blk, 'tcx>(in_cx: Block<'blk, 'tcx>,
-                              call_ex: &ast::Expr,
-                              f: &ast::Expr,
-                              args: CallArgs,
-                              dest: expr::Dest)
-                              -> Block<'blk, 'tcx> {
+pub fn trans_call<'a, 'blk, 'tcx>(in_cx: Block<'blk, 'tcx>,
+                                  call_ex: &ast::Expr,
+                                  f: &ast::Expr,
+                                  args: CallArgs<'a, 'tcx>,
+                                  dest: expr::Dest)
+                                  -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("trans_call");
     trans_call_inner(in_cx,
                      Some(common::expr_info(call_ex)),
@@ -625,12 +625,12 @@ pub fn trans_call<'blk, 'tcx>(in_cx: Block<'blk, 'tcx>,
                      Some(dest)).bcx
 }
 
-pub fn trans_method_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                     call_ex: &ast::Expr,
-                                     rcvr: &ast::Expr,
-                                     args: CallArgs,
-                                     dest: expr::Dest)
-                                     -> Block<'blk, 'tcx> {
+pub fn trans_method_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                         call_ex: &ast::Expr,
+                                         rcvr: &ast::Expr,
+                                         args: CallArgs<'a, 'tcx>,
+                                         dest: expr::Dest)
+                                         -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("trans_method_call");
     debug!("trans_method_call(call_ex={})", call_ex.repr(bcx.tcx()));
     let method_call = MethodCall::expr(call_ex.id);
@@ -669,15 +669,15 @@ pub fn trans_lang_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                              dest)
 }
 
-pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                    call_info: Option<NodeInfo>,
-                                    callee_ty: Ty,
-                                    get_callee: |bcx: Block<'blk, 'tcx>,
-                                                arg_cleanup_scope: cleanup::ScopeId|
-                                                -> Callee<'blk, 'tcx>,
-                                    args: CallArgs,
-                                    dest: Option<expr::Dest>)
-                                    -> Result<'blk, 'tcx> {
+pub fn trans_call_inner<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                        call_info: Option<NodeInfo>,
+                                        callee_ty: Ty<'tcx>,
+                                        get_callee: |bcx: Block<'blk, 'tcx>,
+                                                     arg_cleanup_scope: cleanup::ScopeId|
+                                                     -> Callee<'blk, 'tcx>,
+                                        args: CallArgs<'a, 'tcx>,
+                                        dest: Option<expr::Dest>)
+                                        -> Result<'blk, 'tcx> {
     /*!
      * This behemoth of a function translates function calls.
      * Unfortunately, in order to generate more efficient LLVM
@@ -890,7 +890,7 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     Result::new(bcx, llresult)
 }
 
-pub enum CallArgs<'a> {
+pub enum CallArgs<'a, 'tcx> {
     // Supply value of arguments as a list of expressions that must be
     // translated. This is used in the common case of `foo(bar, qux)`.
     ArgExprs(&'a [P<ast::Expr>]),
@@ -903,7 +903,7 @@ pub enum CallArgs<'a> {
     // For overloaded operators: `(lhs, Vec(rhs, rhs_id))`. `lhs`
     // is the left-hand-side and `rhs/rhs_id` is the datum/expr-id of
     // the right-hand-side arguments (if any).
-    ArgOverloadedOp(Datum<Expr>, Vec<(Datum<Expr>, ast::NodeId)>),
+    ArgOverloadedOp(Datum<'tcx, Expr>, Vec<(Datum<'tcx, Expr>, ast::NodeId)>),
 
     // Supply value of arguments as a list of expressions that must be
     // translated, for overloaded call operators.
@@ -913,7 +913,7 @@ pub enum CallArgs<'a> {
 fn trans_args_under_call_abi<'blk, 'tcx>(
                              mut bcx: Block<'blk, 'tcx>,
                              arg_exprs: &[P<ast::Expr>],
-                             fn_ty: Ty,
+                             fn_ty: Ty<'tcx>,
                              llargs: &mut Vec<ValueRef>,
                              arg_cleanup_scope: cleanup::ScopeId,
                              ignore_self: bool)
@@ -973,7 +973,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
 fn trans_overloaded_call_args<'blk, 'tcx>(
                               mut bcx: Block<'blk, 'tcx>,
                               arg_exprs: Vec<&ast::Expr>,
-                              fn_ty: Ty,
+                              fn_ty: Ty<'tcx>,
                               llargs: &mut Vec<ValueRef>,
                               arg_cleanup_scope: cleanup::ScopeId,
                               ignore_self: bool)
@@ -1016,14 +1016,14 @@ fn trans_overloaded_call_args<'blk, 'tcx>(
     bcx
 }
 
-pub fn trans_args<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
-                              args: CallArgs,
-                              fn_ty: Ty,
-                              llargs: &mut Vec<ValueRef> ,
-                              arg_cleanup_scope: cleanup::ScopeId,
-                              ignore_self: bool,
-                              abi: synabi::Abi)
-                              -> Block<'blk, 'tcx> {
+pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
+                                  args: CallArgs<'a, 'tcx>,
+                                  fn_ty: Ty<'tcx>,
+                                  llargs: &mut Vec<ValueRef>,
+                                  arg_cleanup_scope: cleanup::ScopeId,
+                                  ignore_self: bool,
+                                  abi: synabi::Abi)
+                                  -> Block<'blk, 'tcx> {
     debug!("trans_args(abi={})", abi);
 
     let _icx = push_ctxt("trans_args");
@@ -1108,8 +1108,8 @@ pub enum AutorefArg {
 }
 
 pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                   formal_arg_ty: Ty,
-                                   arg_datum: Datum<Expr>,
+                                   formal_arg_ty: Ty<'tcx>,
+                                   arg_datum: Datum<'tcx, Expr>,
                                    arg_cleanup_scope: cleanup::ScopeId,
                                    autoref_arg: AutorefArg)
                                    -> Result<'blk, 'tcx> {
index 94b32c9b3af849c341ea5d5548ff86876b8ec8be..0a26922e1846836b2d002032386f75506d8941e4 100644 (file)
@@ -41,7 +41,7 @@ pub struct CleanupScope<'blk, 'tcx: 'blk> {
     kind: CleanupScopeKind<'blk, 'tcx>,
 
     // Cleanups to run upon scope exit.
-    cleanups: Vec<CleanupObj>,
+    cleanups: Vec<CleanupObj<'tcx>>,
 
     // The debug location any drop calls generated for this scope will be
     // associated with.
@@ -94,17 +94,17 @@ pub struct CachedEarlyExit {
     cleanup_block: BasicBlockRef,
 }
 
-pub trait Cleanup {
+pub trait Cleanup<'tcx> {
     fn must_unwind(&self) -> bool;
     fn clean_on_unwind(&self) -> bool;
     fn is_lifetime_end(&self) -> bool;
-    fn trans<'blk, 'tcx>(&self,
-                         bcx: Block<'blk, 'tcx>,
-                         debug_loc: Option<NodeInfo>)
-                      -> Block<'blk, 'tcx>;
+    fn trans<'blk>(&self,
+                   bcx: Block<'blk, 'tcx>,
+                   debug_loc: Option<NodeInfo>)
+                   -> Block<'blk, 'tcx>;
 }
 
-pub type CleanupObj = Box<Cleanup+'static>;
+pub type CleanupObj<'tcx> = Box<Cleanup<'tcx>+'tcx>;
 
 #[deriving(Show)]
 pub enum ScopeId {
@@ -307,7 +307,7 @@ fn schedule_lifetime_end(&self,
     fn schedule_drop_mem(&self,
                          cleanup_scope: ScopeId,
                          val: ValueRef,
-                         ty: Ty) {
+                         ty: Ty<'tcx>) {
         /*!
          * Schedules a (deep) drop of `val`, which is a pointer to an
          * instance of `ty`
@@ -333,7 +333,7 @@ fn schedule_drop_mem(&self,
     fn schedule_drop_and_zero_mem(&self,
                                   cleanup_scope: ScopeId,
                                   val: ValueRef,
-                                  ty: Ty) {
+                                  ty: Ty<'tcx>) {
         /*!
          * Schedules a (deep) drop and zero-ing of `val`, which is a pointer
          * to an instance of `ty`
@@ -360,7 +360,7 @@ fn schedule_drop_and_zero_mem(&self,
     fn schedule_drop_immediate(&self,
                                cleanup_scope: ScopeId,
                                val: ValueRef,
-                               ty: Ty) {
+                               ty: Ty<'tcx>) {
         /*!
          * Schedules a (deep) drop of `val`, which is an instance of `ty`
          */
@@ -386,7 +386,7 @@ fn schedule_free_value(&self,
                            cleanup_scope: ScopeId,
                            val: ValueRef,
                            heap: Heap,
-                           content_ty: Ty) {
+                           content_ty: Ty<'tcx>) {
         /*!
          * Schedules a call to `free(val)`. Note that this is a shallow
          * operation.
@@ -425,7 +425,7 @@ fn schedule_free_slice(&self,
 
     fn schedule_clean(&self,
                       cleanup_scope: ScopeId,
-                      cleanup: CleanupObj) {
+                      cleanup: CleanupObj<'tcx>) {
         match cleanup_scope {
             AstScope(id) => self.schedule_clean_in_ast_scope(id, cleanup),
             CustomScope(id) => self.schedule_clean_in_custom_scope(id, cleanup),
@@ -434,7 +434,7 @@ fn schedule_clean(&self,
 
     fn schedule_clean_in_ast_scope(&self,
                                    cleanup_scope: ast::NodeId,
-                                   cleanup: CleanupObj) {
+                                   cleanup: CleanupObj<'tcx>) {
         /*!
          * Schedules a cleanup to occur upon exit from `cleanup_scope`.
          * If `cleanup_scope` is not provided, then the cleanup is scheduled
@@ -462,7 +462,7 @@ fn schedule_clean_in_ast_scope(&self,
 
     fn schedule_clean_in_custom_scope(&self,
                                       custom_scope: CustomScopeIndex,
-                                      cleanup: CleanupObj) {
+                                      cleanup: CleanupObj<'tcx>) {
         /*!
          * Schedules a cleanup to occur in the top-most scope,
          * which must be a temporary scope.
@@ -559,7 +559,7 @@ fn is_valid_custom_scope(&self, custom_scope: CustomScopeIndex) -> bool {
 
     fn trans_scope_cleanups(&self, // cannot borrow self, will recurse
                             bcx: Block<'blk, 'tcx>,
-                            scope: &CleanupScope) -> Block<'blk, 'tcx> {
+                            scope: &CleanupScope<'blk, 'tcx>) -> Block<'blk, 'tcx> {
         /*! Generates the cleanups for `scope` into `bcx` */
 
         let mut bcx = bcx;
@@ -955,15 +955,15 @@ fn is_unwind(&self) -> bool {
 ///////////////////////////////////////////////////////////////////////////
 // Cleanup types
 
-pub struct DropValue {
+pub struct DropValue<'tcx> {
     is_immediate: bool,
     must_unwind: bool,
     val: ValueRef,
-    ty: Ty,
+    ty: Ty<'tcx>,
     zero: bool
 }
 
-impl Cleanup for DropValue {
+impl<'tcx> Cleanup<'tcx> for DropValue<'tcx> {
     fn must_unwind(&self) -> bool {
         self.must_unwind
     }
@@ -976,10 +976,10 @@ fn is_lifetime_end(&self) -> bool {
         false
     }
 
-    fn trans<'blk, 'tcx>(&self,
-                         bcx: Block<'blk, 'tcx>,
-                         debug_loc: Option<NodeInfo>)
-                         -> Block<'blk, 'tcx> {
+    fn trans<'blk>(&self,
+                   bcx: Block<'blk, 'tcx>,
+                   debug_loc: Option<NodeInfo>)
+                   -> Block<'blk, 'tcx> {
         let bcx = if self.is_immediate {
             glue::drop_ty_immediate(bcx, self.val, self.ty, debug_loc)
         } else {
@@ -997,13 +997,13 @@ pub enum Heap {
     HeapExchange
 }
 
-pub struct FreeValue {
+pub struct FreeValue<'tcx> {
     ptr: ValueRef,
     heap: Heap,
-    content_ty: Ty
+    content_ty: Ty<'tcx>
 }
 
-impl Cleanup for FreeValue {
+impl<'tcx> Cleanup<'tcx> for FreeValue<'tcx> {
     fn must_unwind(&self) -> bool {
         true
     }
@@ -1016,10 +1016,10 @@ fn is_lifetime_end(&self) -> bool {
         false
     }
 
-    fn trans<'blk, 'tcx>(&self,
-                         bcx: Block<'blk, 'tcx>,
-                         debug_loc: Option<NodeInfo>)
-                      -> Block<'blk, 'tcx> {
+    fn trans<'blk>(&self,
+                   bcx: Block<'blk, 'tcx>,
+                   debug_loc: Option<NodeInfo>)
+                   -> Block<'blk, 'tcx> {
         apply_debug_loc(bcx.fcx, debug_loc);
 
         match self.heap {
@@ -1037,7 +1037,7 @@ pub struct FreeSlice {
     heap: Heap,
 }
 
-impl Cleanup for FreeSlice {
+impl<'tcx> Cleanup<'tcx> for FreeSlice {
     fn must_unwind(&self) -> bool {
         true
     }
@@ -1068,7 +1068,7 @@ pub struct LifetimeEnd {
     ptr: ValueRef,
 }
 
-impl Cleanup for LifetimeEnd {
+impl<'tcx> Cleanup<'tcx> for LifetimeEnd {
     fn must_unwind(&self) -> bool {
         false
     }
@@ -1166,20 +1166,20 @@ fn schedule_lifetime_end(&self,
     fn schedule_drop_mem(&self,
                          cleanup_scope: ScopeId,
                          val: ValueRef,
-                         ty: Ty);
+                         ty: Ty<'tcx>);
     fn schedule_drop_and_zero_mem(&self,
                                   cleanup_scope: ScopeId,
                                   val: ValueRef,
-                                  ty: Ty);
+                                  ty: Ty<'tcx>);
     fn schedule_drop_immediate(&self,
                                cleanup_scope: ScopeId,
                                val: ValueRef,
-                               ty: Ty);
+                               ty: Ty<'tcx>);
     fn schedule_free_value(&self,
                            cleanup_scope: ScopeId,
                            val: ValueRef,
                            heap: Heap,
-                           content_ty: Ty);
+                           content_ty: Ty<'tcx>);
     fn schedule_free_slice(&self,
                            cleanup_scope: ScopeId,
                            val: ValueRef,
@@ -1188,13 +1188,13 @@ fn schedule_free_slice(&self,
                            heap: Heap);
     fn schedule_clean(&self,
                       cleanup_scope: ScopeId,
-                      cleanup: CleanupObj);
+                      cleanup: CleanupObj<'tcx>);
     fn schedule_clean_in_ast_scope(&self,
                                    cleanup_scope: ast::NodeId,
-                                   cleanup: CleanupObj);
+                                   cleanup: CleanupObj<'tcx>);
     fn schedule_clean_in_custom_scope(&self,
                                     custom_scope: CustomScopeIndex,
-                                    cleanup: CleanupObj);
+                                    cleanup: CleanupObj<'tcx>);
     fn needs_invoke(&self) -> bool;
     fn get_landing_pad(&'blk self) -> BasicBlockRef;
 }
index f6a4e4bcf94252ed803d5e360bf5f39ea1950a3f..af4743511a6d8acfe29ef81c01da1c77fb327670 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::ClosureKind::*;
 
 use back::abi;
 use back::link::mangle_internal_name_by_path_and_seq;
 //
 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-pub struct EnvValue {
+pub struct EnvValue<'tcx> {
     action: ast::CaptureClause,
-    datum: Datum<Lvalue>
+    datum: Datum<'tcx, Lvalue>
 }
 
-impl EnvValue {
-    pub fn to_string(&self, ccx: &CrateContext) -> String {
+impl<'tcx> EnvValue<'tcx> {
+    pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
         format!("{}({})", self.action, self.datum.to_string(ccx))
     }
 }
 
 // Given a closure ty, emits a corresponding tuple ty
-pub fn mk_closure_tys(tcx: &ty::ctxt,
-                      bound_values: &[EnvValue])
-                   -> Ty {
+pub fn mk_closure_tys<'tcx>(tcx: &ty::ctxt<'tcx>,
+                            bound_values: &[EnvValue<'tcx>])
+                            -> Ty<'tcx> {
     // determine the types of the values in the env.  Note that this
     // is the actual types that will be stored in the map, not the
     // logical types as the user sees them, so by-ref upvars must be
@@ -131,14 +132,14 @@ pub fn mk_closure_tys(tcx: &ty::ctxt,
     return cdata_ty;
 }
 
-fn tuplify_box_ty(tcx: &ty::ctxt, t: Ty) -> Ty {
+fn tuplify_box_ty<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
     let ptr = ty::mk_imm_ptr(tcx, ty::mk_i8());
     ty::mk_tup(tcx, vec!(ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t))
 }
 
 fn allocate_cbox<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                              store: ty::TraitStore,
-                             cdata_ty: Ty)
+                             cdata_ty: Ty<'tcx>)
                              -> Result<'blk, 'tcx> {
     let _icx = push_ctxt("closure::allocate_cbox");
     let tcx = bcx.tcx();
@@ -157,8 +158,8 @@ fn allocate_cbox<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 }
 
 pub struct ClosureResult<'blk, 'tcx: 'blk> {
-    llbox: ValueRef,    // llvalue of ptr to closure
-    cdata_ty: Ty,    // type of the closure data
+    llbox: ValueRef,        // llvalue of ptr to closure
+    cdata_ty: Ty<'tcx>,     // type of the closure data
     bcx: Block<'blk, 'tcx>  // final bcx
 }
 
@@ -167,7 +168,7 @@ pub struct ClosureResult<'blk, 'tcx: 'blk> {
 // heap allocated closure that copies the upvars into environment.
 // Otherwise, it is stack allocated and copies pointers to the upvars.
 pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                     bound_values: Vec<EnvValue> ,
+                                     bound_values: Vec<EnvValue<'tcx>> ,
                                      store: ty::TraitStore)
                                      -> ClosureResult<'blk, 'tcx> {
     let _icx = push_ctxt("closure::store_environment");
@@ -248,17 +249,12 @@ fn build_closure<'blk, 'tcx>(bcx0: Block<'blk, 'tcx>,
 // and a list of upvars, generate code to load and populate the environment
 // with the upvars and type descriptors.
 fn load_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                cdata_ty: Ty,
-                                freevars: &Vec<ty::Freevar>,
+                                cdata_ty: Ty<'tcx>,
+                                freevars: &[ty::Freevar],
                                 store: ty::TraitStore)
                                 -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("closure::load_environment");
 
-    // Don't bother to create the block if there's nothing to load
-    if freevars.len() == 0 {
-        return bcx;
-    }
-
     // Load a pointer to the closure data, skipping over the box header:
     let llcdata = at_box_body(bcx, cdata_ty, bcx.fcx.llenv.unwrap());
 
@@ -304,16 +300,12 @@ fn load_unboxed_closure_environment<'blk, 'tcx>(
                                     bcx: Block<'blk, 'tcx>,
                                     arg_scope_id: ScopeId,
                                     freevar_mode: ast::CaptureClause,
-                                    freevars: &Vec<ty::Freevar>,
-                                    closure_id: ast::DefId)
+                                    freevars: &[ty::Freevar])
                                     -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("closure::load_environment");
 
-    if freevars.len() == 0 {
-        return bcx
-    }
-
     // Special case for small by-value selfs.
+    let closure_id = ast_util::local_def(bcx.fcx.id);
     let self_type = self_type_for_unboxed_closure(bcx.ccx(), closure_id,
                                                   node_id_type(bcx, closure_id.node));
     let kind = kind_for_unboxed_closure(bcx.ccx(), closure_id);
@@ -352,6 +344,48 @@ fn fill_fn_pair(bcx: Block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef)
     Store(bcx, llenvptr, GEPi(bcx, pair, &[0u, abi::fn_field_box]));
 }
 
+#[deriving(PartialEq)]
+pub enum ClosureKind<'tcx> {
+    NotClosure,
+    // See load_environment.
+    BoxedClosure(Ty<'tcx>, ty::TraitStore),
+    // See load_unboxed_closure_environment.
+    UnboxedClosure(ast::CaptureClause)
+}
+
+pub struct ClosureEnv<'a, 'tcx> {
+    freevars: &'a [ty::Freevar],
+    pub kind: ClosureKind<'tcx>
+}
+
+impl<'a, 'tcx> ClosureEnv<'a, 'tcx> {
+    pub fn new(freevars: &'a [ty::Freevar], kind: ClosureKind<'tcx>)
+               -> ClosureEnv<'a, 'tcx> {
+        ClosureEnv {
+            freevars: freevars,
+            kind: kind
+        }
+    }
+
+    pub fn load<'blk>(self, bcx: Block<'blk, 'tcx>, arg_scope: ScopeId)
+                      -> Block<'blk, 'tcx> {
+        // Don't bother to create the block if there's nothing to load
+        if self.freevars.is_empty() {
+            return bcx;
+        }
+
+        match self.kind {
+            NotClosure => bcx,
+            BoxedClosure(cdata_ty, store) => {
+                load_environment(bcx, cdata_ty, self.freevars, store)
+            }
+            UnboxedClosure(freevar_mode) => {
+                load_unboxed_closure_environment(bcx, arg_scope, freevar_mode, self.freevars)
+            }
+        }
+    }
+}
+
 pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                  store: ty::TraitStore,
                                  decl: &ast::FnDecl,
@@ -401,6 +435,7 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         cdata_ty,
         bcx
     } = build_closure(bcx, freevar_mode, &freevars, store);
+
     trans_closure(ccx,
                   decl,
                   body,
@@ -410,9 +445,8 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                   &[],
                   ty::ty_fn_ret(fty),
                   ty::ty_fn_abi(fty),
-                  true,
-                  NotUnboxedClosure,
-                  |bcx, _| load_environment(bcx, cdata_ty, &freevars, store));
+                  ClosureEnv::new(freevars.as_slice(),
+                                  BoxedClosure(cdata_ty, store)));
     fill_fn_pair(bcx, dest_addr, llfn, llbox);
     bcx
 }
@@ -421,7 +455,7 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 /// if necessary. If the ID does not correspond to a closure ID, returns None.
 pub fn get_or_create_declaration_if_unboxed_closure<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                                                 closure_id: ast::DefId,
-                                                                substs: &Substs)
+                                                                substs: &Substs<'tcx>)
                                                                 -> Option<ValueRef> {
     let ccx = bcx.ccx();
     if !ccx.tcx().unboxed_closures.borrow().contains_key(&closure_id) {
@@ -495,7 +529,6 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
 
     let freevars: Vec<ty::Freevar> =
         ty::with_freevars(bcx.tcx(), id, |fv| fv.iter().map(|&fv| fv).collect());
-    let freevars_ptr = &freevars;
     let freevar_mode = bcx.tcx().capture_mode(id);
 
     trans_closure(bcx.ccx(),
@@ -507,15 +540,8 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
                   &[],
                   ty::ty_fn_ret(function_type),
                   ty::ty_fn_abi(function_type),
-                  true,
-                  IsUnboxedClosure,
-                  |bcx, arg_scope| {
-                      load_unboxed_closure_environment(bcx,
-                                                       arg_scope,
-                                                       freevar_mode,
-                                                       freevars_ptr,
-                                                       closure_id)
-                  });
+                  ClosureEnv::new(freevars.as_slice(),
+                                  UnboxedClosure(freevar_mode)));
 
     // Don't hoist this to the top of the function. It's perfectly legitimate
     // to have a zero-size unboxed closure (in which case dest will be
@@ -531,7 +557,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
     let repr = adt::represent_type(bcx.ccx(), node_id_type(bcx, id));
 
     // Create the closure.
-    for (i, freevar) in freevars_ptr.iter().enumerate() {
+    for (i, freevar) in freevars.iter().enumerate() {
         let datum = expr::trans_local_var(bcx, freevar.def);
         let upvar_slot_dest = adt::trans_field_ptr(bcx,
                                                    &*repr,
@@ -552,11 +578,11 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
     bcx
 }
 
-pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
-                               closure_ty: Ty,
-                               def: def::Def,
-                               fn_ptr: ValueRef,
-                               is_local: bool) -> ValueRef {
+pub fn get_wrapper_for_bare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                         closure_ty: Ty<'tcx>,
+                                         def: def::Def,
+                                         fn_ptr: ValueRef,
+                                         is_local: bool) -> ValueRef {
 
     let def_id = match def {
         def::DefFn(did, _) | def::DefStaticMethod(did, _) |
@@ -647,7 +673,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
 }
 
 pub fn make_closure_from_bare_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                             closure_ty: Ty,
+                                             closure_ty: Ty<'tcx>,
                                              def: def::Def,
                                              fn_ptr: ValueRef)
                                              -> DatumBlock<'blk, 'tcx, Expr>  {
index fe867ed7039c4b15f37ecac1c36433668661ef33..019ea9972053d6222d67dd1b5e65a7dc8994909b 100644 (file)
@@ -55,7 +55,8 @@
 
 pub use trans::context::CrateContext;
 
-fn type_is_newtype_immediate(ccx: &CrateContext, ty: Ty) -> bool {
+fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                       ty: Ty<'tcx>) -> bool {
     match ty::get(ty).sty {
         ty::ty_struct(def_id, ref substs) => {
             let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
@@ -68,7 +69,7 @@ fn type_is_newtype_immediate(ccx: &CrateContext, ty: Ty) -> bool {
     }
 }
 
-pub fn type_is_immediate(ccx: &CrateContext, ty: Ty) -> bool {
+pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
     use trans::machine::llsize_of_alloc;
     use trans::type_of::sizing_type_of;
 
@@ -93,7 +94,7 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: Ty) -> bool {
     }
 }
 
-pub fn type_is_zero_size(ccx: &CrateContext, ty: Ty) -> bool {
+pub fn type_is_zero_size<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
     /*!
      * Identify types which have size zero at runtime.
      */
@@ -125,8 +126,8 @@ pub fn gensym_name(name: &str) -> PathElem {
     PathName(token::gensym(format!("{}:{}", name, num).as_slice()))
 }
 
-pub struct tydesc_info {
-    pub ty: Ty,
+pub struct tydesc_info<'tcx> {
+    pub ty: Ty<'tcx>,
     pub tydesc: ValueRef,
     pub size: ValueRef,
     pub align: ValueRef,
@@ -190,23 +191,23 @@ pub fn BuilderRef_res(b: BuilderRef) -> BuilderRef_res {
 
 // Here `self_ty` is the real type of the self parameter to this method. It
 // will only be set in the case of default methods.
-pub struct param_substs {
-    substs: subst::Substs,
+pub struct param_substs<'tcx> {
+    substs: subst::Substs<'tcx>,
 }
 
-impl param_substs {
-    pub fn new(substs: subst::Substs) -> param_substs {
+impl<'tcx> param_substs<'tcx> {
+    pub fn new(substs: subst::Substs<'tcx>) -> param_substs<'tcx> {
         assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
         assert!(substs.types.all(|t| !ty::type_has_params(*t)));
         assert!(substs.types.all(|t| !ty::type_has_escaping_regions(*t)));
         param_substs { substs: substs.erase_regions() }
     }
 
-    pub fn substs(&self) -> &subst::Substs {
+    pub fn substs(&self) -> &subst::Substs<'tcx> {
         &self.substs
     }
 
-    pub fn empty() -> param_substs {
+    pub fn empty() -> param_substs<'tcx> {
         param_substs {
             substs: subst::Substs::trans_empty(),
         }
@@ -217,26 +218,26 @@ pub fn validate(&self) {
     }
 }
 
-impl Repr for param_substs {
-    fn repr(&self, tcx: &ty::ctxt) -> String {
+impl<'tcx> Repr<'tcx> for param_substs<'tcx> {
+    fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         self.substs.repr(tcx)
     }
 }
 
-pub trait SubstP {
-    fn substp(&self, tcx: &ty::ctxt, param_substs: &param_substs)
+pub trait SubstP<'tcx> {
+    fn substp(&self, tcx: &ty::ctxt<'tcx>, param_substs: &param_substs<'tcx>)
               -> Self;
 }
 
-impl<T: Subst + Clone> SubstP for T {
-    fn substp(&self, tcx: &ty::ctxt, substs: &param_substs) -> T {
+impl<'tcx, T: Subst<'tcx> + Clone> SubstP<'tcx> for T {
+    fn substp(&self, tcx: &ty::ctxt<'tcx>, substs: &param_substs<'tcx>) -> T {
         self.subst(tcx, &substs.substs)
     }
 }
 
 // work around bizarre resolve errors
-pub type RvalueDatum = datum::Datum<datum::Rvalue>;
-pub type LvalueDatum = datum::Datum<datum::Lvalue>;
+pub type RvalueDatum<'tcx> = datum::Datum<'tcx, datum::Rvalue>;
+pub type LvalueDatum<'tcx> = datum::Datum<'tcx, datum::Lvalue>;
 
 // Function context.  Every LLVM function we create will have one of
 // these.
@@ -280,7 +281,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
 
     // Maps the DefId's for local variables to the allocas created for
     // them in llallocas.
-    pub lllocals: RefCell<NodeMap<LvalueDatum>>,
+    pub lllocals: RefCell<NodeMap<LvalueDatum<'tcx>>>,
 
     // Same as above, but for closure upvars
     pub llupvars: RefCell<NodeMap<ValueRef>>,
@@ -291,7 +292,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
 
     // If this function is being monomorphized, this contains the type
     // substitutions used.
-    pub param_substs: &'a param_substs,
+    pub param_substs: &'a param_substs<'tcx>,
 
     // The source span and nesting context where this function comes from, for
     // error reporting and symbol generation.
@@ -354,7 +355,9 @@ pub fn get_llreturn(&self) -> BasicBlockRef {
         self.llreturn.get().unwrap()
     }
 
-    pub fn get_ret_slot(&self, bcx: Block, output: ty::FnOutput, name: &str) -> ValueRef {
+    pub fn get_ret_slot(&self, bcx: Block<'a, 'tcx>,
+                        output: ty::FnOutput<'tcx>,
+                        name: &str) -> ValueRef {
         if self.needs_ret_allocas {
             base::alloca_no_lifetime(bcx, match output {
                 ty::FnConverging(output_type) => type_of::type_of(bcx.ccx(), output_type),
@@ -495,7 +498,7 @@ pub fn llty_str(&self, ty: Type) -> String {
         self.ccx().tn().type_to_string(ty)
     }
 
-    pub fn ty_to_string(&self, t: Ty) -> String {
+    pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
         t.repr(self.tcx())
     }
 
@@ -509,11 +512,11 @@ fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
         self.tcx()
     }
 
-    fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty> {
+    fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
         Ok(node_id_type(self, id))
     }
 
-    fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<Ty> {
+    fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<Ty<'tcx>> {
         self.tcx()
             .method_map
             .borrow()
@@ -521,7 +524,7 @@ fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<Ty> {
             .map(|method| monomorphize_type(self, method.ty))
     }
 
-    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
+    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
         &self.tcx().adjustments
     }
 
@@ -534,7 +537,7 @@ fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<ast::NodeId> {
     }
 
     fn unboxed_closures<'a>(&'a self)
-                        -> &'a RefCell<DefIdMap<ty::UnboxedClosure>> {
+                        -> &'a RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>> {
         &self.tcx().unboxed_closures
     }
 
@@ -788,28 +791,28 @@ pub fn is_null(val: ValueRef) -> bool {
     }
 }
 
-pub fn monomorphize_type(bcx: &BlockS, t: Ty) -> Ty {
+pub fn monomorphize_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
     t.subst(bcx.tcx(), &bcx.fcx.param_substs.substs)
 }
 
-pub fn node_id_type(bcx: &BlockS, id: ast::NodeId) -> Ty {
+pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty<'tcx> {
     let tcx = bcx.tcx();
     let t = ty::node_id_to_type(tcx, id);
     monomorphize_type(bcx, t)
 }
 
-pub fn expr_ty(bcx: Block, ex: &ast::Expr) -> Ty {
+pub fn expr_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
     node_id_type(bcx, ex.id)
 }
 
-pub fn expr_ty_adjusted(bcx: Block, ex: &ast::Expr) -> Ty {
+pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
     monomorphize_type(bcx, ty::expr_ty_adjusted(bcx.tcx(), ex))
 }
 
-pub fn fulfill_obligation(ccx: &CrateContext,
-                          span: Span,
-                          trait_ref: Rc<ty::TraitRef>)
-                          -> traits::Vtable<()>
+pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                    span: Span,
+                                    trait_ref: Rc<ty::TraitRef<'tcx>>)
+                                    -> traits::Vtable<'tcx, ()>
 {
     /*!
      * Attempts to resolve an obligation. The result is a shallow
@@ -923,9 +926,9 @@ pub enum ExprOrMethodCall {
     MethodCall(typeck::MethodCall)
 }
 
-pub fn node_id_substs(bcx: Block,
-                      node: ExprOrMethodCall)
-                      -> subst::Substs
+pub fn node_id_substs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                  node: ExprOrMethodCall)
+                                  -> subst::Substs<'tcx>
 {
     let tcx = bcx.tcx();
 
index 2100e57b1909ab932b1135a07085858ff04f6599..fb08b76e3d233db8cbb8ca08b044892c99e72ec9 100644 (file)
@@ -133,14 +133,15 @@ fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef {
     }
 }
 
-fn const_deref_newtype(cx: &CrateContext, v: ValueRef, t: Ty)
+fn const_deref_newtype<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, v: ValueRef, t: Ty<'tcx>)
     -> ValueRef {
     let repr = adt::represent_type(cx, t);
     adt::const_get_field(cx, &*repr, v, 0, 0)
 }
 
-fn const_deref(cx: &CrateContext, v: ValueRef, t: Ty, explicit: bool)
-    -> (ValueRef, Ty) {
+fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, v: ValueRef,
+                         t: Ty<'tcx>, explicit: bool)
+                         -> (ValueRef, Ty<'tcx>) {
     match ty::deref(t, explicit) {
         Some(ref mt) => {
             match ty::get(t).sty {
@@ -187,7 +188,8 @@ pub fn get_const_val(cx: &CrateContext,
     cx.const_values().borrow()[def_id.node].clone()
 }
 
-pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, Ty) {
+pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
+                            -> (ValueRef, Ty<'tcx>) {
     let llconst = const_expr_unadjusted(cx, e);
     let mut llconst = llconst;
     let ety = ty::expr_ty(cx.tcx(), e);
@@ -725,7 +727,8 @@ pub fn trans_static(ccx: &CrateContext, m: ast::Mutability, id: ast::NodeId) {
     }
 }
 
-fn get_static_val(ccx: &CrateContext, did: ast::DefId, ty: Ty) -> ValueRef {
+fn get_static_val<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, did: ast::DefId,
+                            ty: Ty<'tcx>) -> ValueRef {
     if ast_util::is_local(did) { return base::get_item_val(ccx, did.node) }
     base::trans_external_path(ccx, did, ty)
 }
index 1e1dd399f3e1cd5735a9521a1a559a2db5fa721d..4822299d1488614336f4b54eb77cacb52a31d522 100644 (file)
@@ -56,7 +56,7 @@ pub struct Stats {
 /// crate, so it must not contain references to any LLVM data structures
 /// (aside from metadata-related ones).
 pub struct SharedCrateContext<'tcx> {
-    local_ccxs: Vec<LocalCrateContext>,
+    local_ccxs: Vec<LocalCrateContext<'tcx>>,
 
     metadata_llmod: ModuleRef,
     metadata_llcx: ContextRef,
@@ -70,22 +70,22 @@ pub struct SharedCrateContext<'tcx> {
     stats: Stats,
 
     available_monomorphizations: RefCell<FnvHashSet<String>>,
-    available_drop_glues: RefCell<FnvHashMap<Ty, String>>,
+    available_drop_glues: RefCell<FnvHashMap<Ty<'tcx>, String>>,
 }
 
 /// The local portion of a `CrateContext`.  There is one `LocalCrateContext`
 /// per compilation unit.  Each one has its own LLVM `ContextRef` so that
 /// several compilation units may be optimized in parallel.  All other LLVM
 /// data structures in the `LocalCrateContext` are tied to that `ContextRef`.
-pub struct LocalCrateContext {
+pub struct LocalCrateContext<'tcx> {
     llmod: ModuleRef,
     llcx: ContextRef,
     td: TargetData,
     tn: TypeNames,
     externs: RefCell<ExternMap>,
     item_vals: RefCell<NodeMap<ValueRef>>,
-    drop_glues: RefCell<FnvHashMap<Ty, ValueRef>>,
-    tydescs: RefCell<FnvHashMap<Ty, Rc<tydesc_info>>>,
+    drop_glues: RefCell<FnvHashMap<Ty<'tcx>, ValueRef>>,
+    tydescs: RefCell<FnvHashMap<Ty<'tcx>, Rc<tydesc_info<'tcx>>>>,
     /// Set when running emit_tydescs to enforce that no more tydescs are
     /// created.
     finished_tydescs: Cell<bool>,
@@ -95,10 +95,10 @@ pub struct LocalCrateContext {
     /// came from)
     external_srcs: RefCell<NodeMap<ast::DefId>>,
     /// Cache instances of monomorphized functions
-    monomorphized: RefCell<FnvHashMap<MonoId, ValueRef>>,
+    monomorphized: RefCell<FnvHashMap<MonoId<'tcx>, ValueRef>>,
     monomorphizing: RefCell<DefIdMap<uint>>,
     /// Cache generated vtables
-    vtables: RefCell<FnvHashMap<(Ty, Rc<ty::TraitRef>), ValueRef>>,
+    vtables: RefCell<FnvHashMap<(Ty<'tcx>, Rc<ty::TraitRef<'tcx>>), ValueRef>>,
     /// Cache of constant strings,
     const_cstr_cache: RefCell<FnvHashMap<InternedString, ValueRef>>,
 
@@ -126,19 +126,19 @@ pub struct LocalCrateContext {
     /// Cache of closure wrappers for bare fn's.
     closure_bare_wrapper_cache: RefCell<FnvHashMap<ValueRef, ValueRef>>,
 
-    lltypes: RefCell<FnvHashMap<Ty, Type>>,
-    llsizingtypes: RefCell<FnvHashMap<Ty, Type>>,
-    adt_reprs: RefCell<FnvHashMap<Ty, Rc<adt::Repr>>>,
-    type_hashcodes: RefCell<FnvHashMap<Ty, String>>,
+    lltypes: RefCell<FnvHashMap<Ty<'tcx>, Type>>,
+    llsizingtypes: RefCell<FnvHashMap<Ty<'tcx>, Type>>,
+    adt_reprs: RefCell<FnvHashMap<Ty<'tcx>, Rc<adt::Repr<'tcx>>>>,
+    type_hashcodes: RefCell<FnvHashMap<Ty<'tcx>, String>>,
     all_llvm_symbols: RefCell<FnvHashSet<String>>,
     int_type: Type,
     opaque_vec_type: Type,
     builder: BuilderRef_res,
 
     /// Holds the LLVM values for closure IDs.
-    unboxed_closure_vals: RefCell<FnvHashMap<MonoId, ValueRef>>,
+    unboxed_closure_vals: RefCell<FnvHashMap<MonoId<'tcx>, ValueRef>>,
 
-    dbg_cx: Option<debuginfo::CrateDebugContext>,
+    dbg_cx: Option<debuginfo::CrateDebugContext<'tcx>>,
 
     eh_personality: RefCell<Option<ValueRef>>,
 
@@ -149,13 +149,13 @@ pub struct LocalCrateContext {
     /// contexts around the same size.
     n_llvm_insns: Cell<uint>,
 
-    trait_cache: RefCell<FnvHashMap<Rc<ty::TraitRef>,
-                                    traits::Vtable<()>>>,
+    trait_cache: RefCell<FnvHashMap<Rc<ty::TraitRef<'tcx>>,
+                                    traits::Vtable<'tcx, ()>>>,
 }
 
 pub struct CrateContext<'a, 'tcx: 'a> {
     shared: &'a SharedCrateContext<'tcx>,
-    local: &'a LocalCrateContext,
+    local: &'a LocalCrateContext<'tcx>,
     /// The index of `local` in `shared.local_ccxs`.  This is used in
     /// `maybe_iter(true)` to identify the original `LocalCrateContext`.
     index: uint,
@@ -367,10 +367,10 @@ pub fn stats<'a>(&'a self) -> &'a Stats {
     }
 }
 
-impl LocalCrateContext {
-    fn new(shared: &SharedCrateContext,
+impl<'tcx> LocalCrateContext<'tcx> {
+    fn new(shared: &SharedCrateContext<'tcx>,
            name: &str)
-           -> LocalCrateContext {
+           -> LocalCrateContext<'tcx> {
         unsafe {
             let (llcx, llmod) = create_context_and_module(&shared.tcx.sess, name);
 
@@ -456,8 +456,8 @@ fn new(shared: &SharedCrateContext,
     /// This is used in the `LocalCrateContext` constructor to allow calling
     /// functions that expect a complete `CrateContext`, even before the local
     /// portion is fully initialized and attached to the `SharedCrateContext`.
-    fn dummy_ccx<'a, 'tcx>(&'a self, shared: &'a SharedCrateContext<'tcx>)
-                           -> CrateContext<'a, 'tcx> {
+    fn dummy_ccx<'a>(&'a self, shared: &'a SharedCrateContext<'tcx>)
+                     -> CrateContext<'a, 'tcx> {
         CrateContext {
             shared: shared,
             local: self,
@@ -471,7 +471,7 @@ pub fn shared(&self) -> &'b SharedCrateContext<'tcx> {
         self.shared
     }
 
-    pub fn local(&self) -> &'b LocalCrateContext {
+    pub fn local(&self) -> &'b LocalCrateContext<'tcx> {
         self.local
     }
 
@@ -574,11 +574,11 @@ pub fn link_meta<'a>(&'a self) -> &'a LinkMeta {
         &self.shared.link_meta
     }
 
-    pub fn drop_glues<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty, ValueRef>> {
+    pub fn drop_glues<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, ValueRef>> {
         &self.local.drop_glues
     }
 
-    pub fn tydescs<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty, Rc<tydesc_info>>> {
+    pub fn tydescs<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, Rc<tydesc_info<'tcx>>>> {
         &self.local.tydescs
     }
 
@@ -594,7 +594,7 @@ pub fn external_srcs<'a>(&'a self) -> &'a RefCell<NodeMap<ast::DefId>> {
         &self.local.external_srcs
     }
 
-    pub fn monomorphized<'a>(&'a self) -> &'a RefCell<FnvHashMap<MonoId, ValueRef>> {
+    pub fn monomorphized<'a>(&'a self) -> &'a RefCell<FnvHashMap<MonoId<'tcx>, ValueRef>> {
         &self.local.monomorphized
     }
 
@@ -602,7 +602,8 @@ pub fn monomorphizing<'a>(&'a self) -> &'a RefCell<DefIdMap<uint>> {
         &self.local.monomorphizing
     }
 
-    pub fn vtables<'a>(&'a self) -> &'a RefCell<FnvHashMap<(Ty, Rc<ty::TraitRef>), ValueRef>> {
+    pub fn vtables<'a>(&'a self) -> &'a RefCell<FnvHashMap<(Ty<'tcx>, Rc<ty::TraitRef<'tcx>>),
+                                                            ValueRef>> {
         &self.local.vtables
     }
 
@@ -635,15 +636,15 @@ pub fn closure_bare_wrapper_cache<'a>(&'a self) -> &'a RefCell<FnvHashMap<ValueR
         &self.local.closure_bare_wrapper_cache
     }
 
-    pub fn lltypes<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty, Type>> {
+    pub fn lltypes<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, Type>> {
         &self.local.lltypes
     }
 
-    pub fn llsizingtypes<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty, Type>> {
+    pub fn llsizingtypes<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, Type>> {
         &self.local.llsizingtypes
     }
 
-    pub fn adt_reprs<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty, Rc<adt::Repr>>> {
+    pub fn adt_reprs<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, Rc<adt::Repr<'tcx>>>> {
         &self.local.adt_reprs
     }
 
@@ -651,7 +652,7 @@ pub fn symbol_hasher<'a>(&'a self) -> &'a RefCell<Sha256> {
         &self.shared.symbol_hasher
     }
 
-    pub fn type_hashcodes<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty, String>> {
+    pub fn type_hashcodes<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, String>> {
         &self.local.type_hashcodes
     }
 
@@ -667,7 +668,7 @@ pub fn available_monomorphizations<'a>(&'a self) -> &'a RefCell<FnvHashSet<Strin
         &self.shared.available_monomorphizations
     }
 
-    pub fn available_drop_glues<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty, String>> {
+    pub fn available_drop_glues<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, String>> {
         &self.shared.available_drop_glues
     }
 
@@ -679,11 +680,11 @@ pub fn opaque_vec_type(&self) -> Type {
         self.local.opaque_vec_type
     }
 
-    pub fn unboxed_closure_vals<'a>(&'a self) -> &'a RefCell<FnvHashMap<MonoId,ValueRef>> {
+    pub fn unboxed_closure_vals<'a>(&'a self) -> &'a RefCell<FnvHashMap<MonoId<'tcx>,ValueRef>> {
         &self.local.unboxed_closure_vals
     }
 
-    pub fn dbg_cx<'a>(&'a self) -> &'a Option<debuginfo::CrateDebugContext> {
+    pub fn dbg_cx<'a>(&'a self) -> &'a Option<debuginfo::CrateDebugContext<'tcx>> {
         &self.local.dbg_cx
     }
 
@@ -699,7 +700,8 @@ pub fn count_llvm_insn(&self) {
         self.local.n_llvm_insns.set(self.local.n_llvm_insns.get() + 1);
     }
 
-    pub fn trait_cache(&self) -> &RefCell<FnvHashMap<Rc<ty::TraitRef>, traits::Vtable<()>>> {
+    pub fn trait_cache(&self) -> &RefCell<FnvHashMap<Rc<ty::TraitRef<'tcx>>,
+                                                     traits::Vtable<'tcx, ()>>> {
         &self.local.trait_cache
     }
 
@@ -707,7 +709,7 @@ pub fn max_obj_size(&self) -> u64 {
         1<<31 /* FIXME #18069: select based on architecture */
     }
 
-    pub fn report_overbig_object(&self, obj: Ty) -> ! {
+    pub fn report_overbig_object(&self, obj: Ty<'tcx>) -> ! {
         self.sess().fatal(
             format!("the type `{}` is too big for the current architecture",
                     obj.repr(self.tcx())).as_slice())
index c778bc7eb27c8af98a31e291af0de87a94d4af50..b0be310becd1cac00db4aa54efd7387b64bab840 100644 (file)
  * the section on datums in `doc.rs` for more details.
  */
 #[deriving(Clone)]
-pub struct Datum<K> {
+pub struct Datum<'tcx, K> {
     /// The llvm value.  This is either a pointer to the Rust value or
     /// the value itself, depending on `kind` below.
     pub val: ValueRef,
 
     /// The rust type of the value.
-    pub ty: Ty,
+    pub ty: Ty<'tcx>,
 
     /// Indicates whether this is by-ref or by-value.
     pub kind: K,
@@ -52,7 +52,7 @@ pub struct Datum<K> {
 
 pub struct DatumBlock<'blk, 'tcx: 'blk, K> {
     pub bcx: Block<'blk, 'tcx>,
-    pub datum: Datum<K>,
+    pub datum: Datum<'tcx, K>,
 }
 
 #[deriving(Show)]
@@ -95,20 +95,20 @@ pub enum RvalueMode {
     ByValue,
 }
 
-pub fn immediate_rvalue(val: ValueRef, ty: Ty) -> Datum<Rvalue> {
+pub fn immediate_rvalue<'tcx>(val: ValueRef, ty: Ty<'tcx>) -> Datum<'tcx, Rvalue> {
     return Datum::new(val, ty, Rvalue::new(ByValue));
 }
 
 pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                         val: ValueRef,
-                                        ty: Ty)
+                                        ty: Ty<'tcx>)
                                         -> DatumBlock<'blk, 'tcx, Rvalue> {
     return DatumBlock::new(bcx, immediate_rvalue(val, ty))
 }
 
 
 pub fn lvalue_scratch_datum<'blk, 'tcx, A>(bcx: Block<'blk, 'tcx>,
-                                           ty: Ty,
+                                           ty: Ty<'tcx>,
                                            name: &str,
                                            zero: bool,
                                            scope: cleanup::ScopeId,
@@ -140,10 +140,10 @@ pub fn lvalue_scratch_datum<'blk, 'tcx, A>(bcx: Block<'blk, 'tcx>,
     DatumBlock::new(bcx, Datum::new(scratch, ty, Lvalue))
 }
 
-pub fn rvalue_scratch_datum(bcx: Block,
-                            ty: Ty,
-                            name: &str)
-                            -> Datum<Rvalue> {
+pub fn rvalue_scratch_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                        ty: Ty<'tcx>,
+                                        name: &str)
+                                        -> Datum<'tcx, Rvalue> {
     /*!
      * Allocates temporary space on the stack using alloca() and
      * returns a by-ref Datum pointing to it.  If `zero` is true, the
@@ -159,7 +159,8 @@ pub fn rvalue_scratch_datum(bcx: Block,
     Datum::new(scratch, ty, Rvalue::new(ByRef))
 }
 
-pub fn appropriate_rvalue_mode(ccx: &CrateContext, ty: Ty) -> RvalueMode {
+pub fn appropriate_rvalue_mode<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                         ty: Ty<'tcx>) -> RvalueMode {
     /*!
      * Indicates the "appropriate" mode for this value,
      * which is either by ref or by value, depending
@@ -173,11 +174,11 @@ pub fn appropriate_rvalue_mode(ccx: &CrateContext, ty: Ty) -> RvalueMode {
     }
 }
 
-fn add_rvalue_clean(mode: RvalueMode,
-                    fcx: &FunctionContext,
-                    scope: cleanup::ScopeId,
-                    val: ValueRef,
-                    ty: Ty) {
+fn add_rvalue_clean<'a, 'tcx>(mode: RvalueMode,
+                              fcx: &FunctionContext<'a, 'tcx>,
+                              scope: cleanup::ScopeId,
+                              val: ValueRef,
+                              ty: Ty<'tcx>) {
     match mode {
         ByValue => { fcx.schedule_drop_immediate(scope, val, ty); }
         ByRef => {
@@ -196,7 +197,7 @@ pub trait KindOps {
     fn post_store<'blk, 'tcx>(&self,
                               bcx: Block<'blk, 'tcx>,
                               val: ValueRef,
-                              ty: Ty)
+                              ty: Ty<'tcx>)
                               -> Block<'blk, 'tcx>;
 
     /**
@@ -216,7 +217,7 @@ impl KindOps for Rvalue {
     fn post_store<'blk, 'tcx>(&self,
                               bcx: Block<'blk, 'tcx>,
                               _val: ValueRef,
-                              _ty: Ty)
+                              _ty: Ty<'tcx>)
                               -> Block<'blk, 'tcx> {
         // No cleanup is scheduled for an rvalue, so we don't have
         // to do anything after a move to cancel or duplicate it.
@@ -236,7 +237,7 @@ impl KindOps for Lvalue {
     fn post_store<'blk, 'tcx>(&self,
                               bcx: Block<'blk, 'tcx>,
                               val: ValueRef,
-                              ty: Ty)
+                              ty: Ty<'tcx>)
                               -> Block<'blk, 'tcx> {
         /*!
          * If an lvalue is moved, we must zero out the memory in which
@@ -266,7 +267,7 @@ impl KindOps for Expr {
     fn post_store<'blk, 'tcx>(&self,
                               bcx: Block<'blk, 'tcx>,
                               val: ValueRef,
-                              ty: Ty)
+                              ty: Ty<'tcx>)
                               -> Block<'blk, 'tcx> {
         match *self {
             LvalueExpr => Lvalue.post_store(bcx, val, ty),
@@ -286,11 +287,11 @@ fn to_expr_kind(self) -> Expr {
     }
 }
 
-impl Datum<Rvalue> {
-    pub fn add_clean(self,
-                     fcx: &FunctionContext,
-                     scope: cleanup::ScopeId)
-                     -> ValueRef {
+impl<'tcx> Datum<'tcx, Rvalue> {
+    pub fn add_clean<'a>(self,
+                         fcx: &FunctionContext<'a, 'tcx>,
+                         scope: cleanup::ScopeId)
+                         -> ValueRef {
         /*!
          * Schedules a cleanup for this datum in the given scope.
          * That means that this datum is no longer an rvalue datum;
@@ -302,11 +303,11 @@ pub fn add_clean(self,
         self.val
     }
 
-    pub fn to_lvalue_datum_in_scope<'blk, 'tcx>(self,
-                                                bcx: Block<'blk, 'tcx>,
-                                                name: &str,
-                                                scope: cleanup::ScopeId)
-                                                -> DatumBlock<'blk, 'tcx, Lvalue> {
+    pub fn to_lvalue_datum_in_scope<'blk>(self,
+                                          bcx: Block<'blk, 'tcx>,
+                                          name: &str,
+                                          scope: cleanup::ScopeId)
+                                          -> DatumBlock<'blk, 'tcx, Lvalue> {
         /*!
          * Returns an lvalue datum (that is, a by ref datum with
          * cleanup scheduled). If `self` is not already an lvalue,
@@ -328,8 +329,8 @@ pub fn to_lvalue_datum_in_scope<'blk, 'tcx>(self,
         }
     }
 
-    pub fn to_ref_datum<'blk, 'tcx>(self, bcx: Block<'blk, 'tcx>)
-                                    -> DatumBlock<'blk, 'tcx, Rvalue> {
+    pub fn to_ref_datum<'blk>(self, bcx: Block<'blk, 'tcx>)
+                              -> DatumBlock<'blk, 'tcx, Rvalue> {
         let mut bcx = bcx;
         match self.kind.mode {
             ByRef => DatumBlock::new(bcx, self),
@@ -341,9 +342,8 @@ pub fn to_ref_datum<'blk, 'tcx>(self, bcx: Block<'blk, 'tcx>)
         }
     }
 
-    pub fn to_appropriate_datum<'blk, 'tcx>(self,
-                                            bcx: Block<'blk, 'tcx>)
-                                            -> DatumBlock<'blk, 'tcx, Rvalue> {
+    pub fn to_appropriate_datum<'blk>(self, bcx: Block<'blk, 'tcx>)
+                                      -> DatumBlock<'blk, 'tcx, Rvalue> {
         match self.appropriate_rvalue_mode(bcx.ccx()) {
             ByRef => {
                 self.to_ref_datum(bcx)
@@ -369,10 +369,10 @@ pub fn to_appropriate_datum<'blk, 'tcx>(self,
  * here since we can `match self.kind` rather than having to implement
  * generic methods in `KindOps`.)
  */
-impl Datum<Expr> {
+impl<'tcx> Datum<'tcx, Expr> {
     fn match_kind<R>(self,
-                     if_lvalue: |Datum<Lvalue>| -> R,
-                     if_rvalue: |Datum<Rvalue>| -> R)
+                     if_lvalue: |Datum<'tcx, Lvalue>| -> R,
+                     if_rvalue: |Datum<'tcx, Rvalue>| -> R)
                      -> R {
         let Datum { val, ty, kind } = self;
         match kind {
@@ -382,7 +382,7 @@ fn match_kind<R>(self,
     }
 
     #[allow(dead_code)] // potentially useful
-    pub fn assert_lvalue(self, bcx: Block) -> Datum<Lvalue> {
+    pub fn assert_lvalue(self, bcx: Block) -> Datum<'tcx, Lvalue> {
         /*!
          * Asserts that this datum *is* an lvalue and returns it.
          */
@@ -392,7 +392,7 @@ pub fn assert_lvalue(self, bcx: Block) -> Datum<Lvalue> {
             |_| bcx.sess().bug("assert_lvalue given rvalue"))
     }
 
-    pub fn assert_rvalue(self, bcx: Block) -> Datum<Rvalue> {
+    pub fn assert_rvalue(self, bcx: Block) -> Datum<'tcx, Rvalue> {
         /*!
          * Asserts that this datum *is* an lvalue and returns it.
          */
@@ -402,11 +402,11 @@ pub fn assert_rvalue(self, bcx: Block) -> Datum<Rvalue> {
             |r| r)
     }
 
-    pub fn store_to_dest<'blk, 'tcx>(self,
-                                     bcx: Block<'blk, 'tcx>,
-                                     dest: expr::Dest,
-                                     expr_id: ast::NodeId)
-                                     -> Block<'blk, 'tcx> {
+    pub fn store_to_dest<'blk>(self,
+                               bcx: Block<'blk, 'tcx>,
+                               dest: expr::Dest,
+                               expr_id: ast::NodeId)
+                               -> Block<'blk, 'tcx> {
         match dest {
             expr::Ignore => {
                 self.add_clean_if_rvalue(bcx, expr_id);
@@ -418,9 +418,9 @@ pub fn store_to_dest<'blk, 'tcx>(self,
         }
     }
 
-    pub fn add_clean_if_rvalue<'blk, 'tcx>(self,
-                                           bcx: Block<'blk, 'tcx>,
-                                           expr_id: ast::NodeId) {
+    pub fn add_clean_if_rvalue<'blk>(self,
+                                     bcx: Block<'blk, 'tcx>,
+                                     expr_id: ast::NodeId) {
         /*!
          * Arranges cleanup for `self` if it is an rvalue. Use when
          * you are done working with a value that may need drop.
@@ -434,11 +434,11 @@ pub fn add_clean_if_rvalue<'blk, 'tcx>(self,
             })
     }
 
-    pub fn clean<'blk, 'tcx>(self,
-                             bcx: Block<'blk, 'tcx>,
-                             name: &'static str,
-                             expr_id: ast::NodeId)
-                             -> Block<'blk, 'tcx> {
+    pub fn clean<'blk>(self,
+                       bcx: Block<'blk, 'tcx>,
+                       name: &'static str,
+                       expr_id: ast::NodeId)
+                       -> Block<'blk, 'tcx> {
         /*!
          * Ensures that `self` will get cleaned up, if it is not an lvalue
          * already.
@@ -447,11 +447,11 @@ pub fn clean<'blk, 'tcx>(self,
         self.to_lvalue_datum(bcx, name, expr_id).bcx
     }
 
-    pub fn to_lvalue_datum<'blk, 'tcx>(self,
-                                       bcx: Block<'blk, 'tcx>,
-                                       name: &str,
-                                       expr_id: ast::NodeId)
-                                       -> DatumBlock<'blk, 'tcx, Lvalue> {
+    pub fn to_lvalue_datum<'blk>(self,
+                                 bcx: Block<'blk, 'tcx>,
+                                 name: &str,
+                                 expr_id: ast::NodeId)
+                                 -> DatumBlock<'blk, 'tcx, Lvalue> {
         debug!("to_lvalue_datum self: {}", self.to_string(bcx.ccx()));
 
         assert!(ty::lltype_is_sized(bcx.tcx(), self.ty),
@@ -464,10 +464,10 @@ pub fn to_lvalue_datum<'blk, 'tcx>(self,
             })
     }
 
-    pub fn to_rvalue_datum<'blk, 'tcx>(self,
-                                       bcx: Block<'blk, 'tcx>,
-                                       name: &'static str)
-                                       -> DatumBlock<'blk, 'tcx, Rvalue> {
+    pub fn to_rvalue_datum<'blk>(self,
+                                 bcx: Block<'blk, 'tcx>,
+                                 name: &'static str)
+                                 -> DatumBlock<'blk, 'tcx, Rvalue> {
         /*!
          * Ensures that we have an rvalue datum (that is, a datum with
          * no cleanup scheduled).
@@ -500,7 +500,7 @@ pub fn to_rvalue_datum<'blk, 'tcx>(self,
  * such as extracting the field from a struct or a particular element
  * from an array.
  */
-impl Datum<Lvalue> {
+impl<'tcx> Datum<'tcx, Lvalue> {
     pub fn to_llref(self) -> ValueRef {
         /*!
          * Converts a datum into a by-ref value. The datum type must
@@ -515,9 +515,9 @@ pub fn to_llref(self) -> ValueRef {
     // datum may also be unsized _without the size information_. It is the
     // callers responsibility to package the result in some way to make a valid
     // datum in that case (e.g., by making a fat pointer or opened pair).
-    pub fn get_element(&self, bcx: Block, ty: Ty,
-                       gep: |ValueRef| -> ValueRef)
-                       -> Datum<Lvalue> {
+    pub fn get_element<'blk>(&self, bcx: Block<'blk, 'tcx>, ty: Ty<'tcx>,
+                             gep: |ValueRef| -> ValueRef)
+                             -> Datum<'tcx, Lvalue> {
         let val = match ty::get(self.ty).sty {
             _ if ty::type_is_sized(bcx.tcx(), self.ty) => gep(self.val),
             ty::ty_open(_) => {
@@ -545,20 +545,20 @@ pub fn get_vec_base_and_len(&self, bcx: Block) -> (ValueRef, ValueRef) {
 /**
  * Generic methods applicable to any sort of datum.
  */
-impl<K: KindOps + fmt::Show> Datum<K> {
-    pub fn new(val: ValueRef, ty: Ty, kind: K) -> Datum<K> {
+impl<'tcx, K: KindOps + fmt::Show> Datum<'tcx, K> {
+    pub fn new(val: ValueRef, ty: Ty<'tcx>, kind: K) -> Datum<'tcx, K> {
         Datum { val: val, ty: ty, kind: kind }
     }
 
-    pub fn to_expr_datum(self) -> Datum<Expr> {
+    pub fn to_expr_datum(self) -> Datum<'tcx, Expr> {
         let Datum { val, ty, kind } = self;
         Datum { val: val, ty: ty, kind: kind.to_expr_kind() }
     }
 
-    pub fn store_to<'blk, 'tcx>(self,
-                                bcx: Block<'blk, 'tcx>,
-                                dst: ValueRef)
-                                -> Block<'blk, 'tcx> {
+    pub fn store_to<'blk>(self,
+                          bcx: Block<'blk, 'tcx>,
+                          dst: ValueRef)
+                          -> Block<'blk, 'tcx> {
         /*!
          * Moves or copies this value into a new home, as appropriate
          * depending on the type of the datum. This method consumes
@@ -572,10 +572,10 @@ pub fn store_to<'blk, 'tcx>(self,
         self.kind.post_store(bcx, self.val, self.ty)
     }
 
-    fn shallow_copy_raw<'blk, 'tcx>(&self,
-                                    bcx: Block<'blk, 'tcx>,
-                                    dst: ValueRef)
-                                    -> Block<'blk, 'tcx> {
+    fn shallow_copy_raw<'blk>(&self,
+                              bcx: Block<'blk, 'tcx>,
+                              dst: ValueRef)
+                              -> Block<'blk, 'tcx> {
         /*!
          * Helper function that performs a shallow copy of this value
          * into `dst`, which should be a pointer to a memory location
@@ -604,10 +604,10 @@ fn shallow_copy_raw<'blk, 'tcx>(&self,
         return bcx;
     }
 
-    pub fn shallow_copy<'blk, 'tcx>(&self,
-                                    bcx: Block<'blk, 'tcx>,
-                                    dst: ValueRef)
-                                    -> Block<'blk, 'tcx> {
+    pub fn shallow_copy<'blk>(&self,
+                              bcx: Block<'blk, 'tcx>,
+                              dst: ValueRef)
+                              -> Block<'blk, 'tcx> {
         /*!
          * Copies the value into a new location. This function always
          * preserves the existing datum as a valid value. Therefore,
@@ -620,20 +620,21 @@ pub fn shallow_copy<'blk, 'tcx>(&self,
     }
 
     #[allow(dead_code)] // useful for debugging
-    pub fn to_string(&self, ccx: &CrateContext) -> String {
+    pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
         format!("Datum({}, {}, {})",
                 ccx.tn().val_to_string(self.val),
                 ty_to_string(ccx.tcx(), self.ty),
                 self.kind)
     }
 
-    pub fn appropriate_rvalue_mode(&self, ccx: &CrateContext) -> RvalueMode {
+    pub fn appropriate_rvalue_mode<'a>(&self, ccx: &CrateContext<'a, 'tcx>)
+                                       -> RvalueMode {
         /*! See the `appropriate_rvalue_mode()` function */
 
         appropriate_rvalue_mode(ccx, self.ty)
     }
 
-    pub fn to_llscalarish(self, bcx: Block) -> ValueRef {
+    pub fn to_llscalarish<'blk>(self, bcx: Block<'blk, 'tcx>) -> ValueRef {
         /*!
          * Converts `self` into a by-value `ValueRef`. Consumes this
          * datum (i.e., absolves you of responsibility to cleanup the
@@ -652,14 +653,15 @@ pub fn to_llscalarish(self, bcx: Block) -> ValueRef {
         }
     }
 
-    pub fn to_llbool(self, bcx: Block) -> ValueRef {
+    pub fn to_llbool<'blk>(self, bcx: Block<'blk, 'tcx>) -> ValueRef {
         assert!(ty::type_is_bool(self.ty))
         self.to_llscalarish(bcx)
     }
 }
 
 impl<'blk, 'tcx, K> DatumBlock<'blk, 'tcx, K> {
-    pub fn new(bcx: Block<'blk, 'tcx>, datum: Datum<K>) -> DatumBlock<'blk, 'tcx, K> {
+    pub fn new(bcx: Block<'blk, 'tcx>, datum: Datum<'tcx, K>)
+               -> DatumBlock<'blk, 'tcx, K> {
         DatumBlock { bcx: bcx, datum: datum }
     }
 }
index 6e8b3b2d915f4297443d6a57a4422357482a3613..480ac0b339f6993fe73f4ead6bf1f800cdbc0d35 100644 (file)
@@ -260,20 +260,20 @@ struct List {
 // created so far. The metadata nodes are indexed by UniqueTypeId, and, for
 // faster lookup, also by Ty. The TypeMap is responsible for creating
 // UniqueTypeIds.
-struct TypeMap {
+struct TypeMap<'tcx> {
     // The UniqueTypeIds created so far
     unique_id_interner: Interner<Rc<String>>,
     // A map from UniqueTypeId to debuginfo metadata for that type. This is a 1:1 mapping.
     unique_id_to_metadata: FnvHashMap<UniqueTypeId, DIType>,
     // A map from types to debuginfo metadata. This is a N:1 mapping.
-    type_to_metadata: FnvHashMap<Ty, DIType>,
+    type_to_metadata: FnvHashMap<Ty<'tcx>, DIType>,
     // A map from types to UniqueTypeId. This is a N:1 mapping.
-    type_to_unique_id: FnvHashMap<Ty, UniqueTypeId>
+    type_to_unique_id: FnvHashMap<Ty<'tcx>, UniqueTypeId>
 }
 
-impl TypeMap {
+impl<'tcx> TypeMap<'tcx> {
 
-    fn new() -> TypeMap {
+    fn new() -> TypeMap<'tcx> {
         TypeMap {
             unique_id_interner: Interner::new(),
             type_to_metadata: FnvHashMap::new(),
@@ -284,10 +284,10 @@ fn new() -> TypeMap {
 
     // Adds a Ty to metadata mapping to the TypeMap. The method will fail if
     // the mapping already exists.
-    fn register_type_with_metadata(&mut self,
-                                   cx: &CrateContext,
-                                   type_: Ty,
-                                   metadata: DIType) {
+    fn register_type_with_metadata<'a>(&mut self,
+                                       cx: &CrateContext<'a, 'tcx>,
+                                       type_: Ty<'tcx>,
+                                       metadata: DIType) {
         if self.type_to_metadata.insert(type_, metadata).is_some() {
             cx.sess().bug(format!("Type metadata for Ty '{}' is already in the TypeMap!",
                                    ppaux::ty_to_string(cx.tcx(), type_)).as_slice());
@@ -307,7 +307,7 @@ fn register_unique_id_with_metadata(&mut self,
         }
     }
 
-    fn find_metadata_for_type(&self, type_: Ty) -> Option<DIType> {
+    fn find_metadata_for_type(&self, type_: Ty<'tcx>) -> Option<DIType> {
         self.type_to_metadata.get(&type_).cloned()
     }
 
@@ -325,7 +325,8 @@ fn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> Rc<Strin
     // Get the UniqueTypeId for the given type. If the UniqueTypeId for the given
     // type has been requested before, this is just a table lookup. Otherwise an
     // ID will be generated and stored for later lookup.
-    fn get_unique_type_id_of_type(&mut self, cx: &CrateContext, type_: Ty) -> UniqueTypeId {
+    fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
+                                      type_: Ty<'tcx>) -> UniqueTypeId {
 
         // basic type           -> {:name of the type:}
         // tuple                -> {tuple_(:param-uid:)*}
@@ -498,11 +499,11 @@ fn get_unique_type_id_of_type(&mut self, cx: &CrateContext, type_: Ty) -> Unique
 
         return UniqueTypeId(key);
 
-        fn from_def_id_and_substs(type_map: &mut TypeMap,
-                                  cx: &CrateContext,
-                                  def_id: ast::DefId,
-                                  substs: &subst::Substs,
-                                  output: &mut String) {
+        fn from_def_id_and_substs<'a, 'tcx>(type_map: &mut TypeMap<'tcx>,
+                                            cx: &CrateContext<'a, 'tcx>,
+                                            def_id: ast::DefId,
+                                            substs: &subst::Substs<'tcx>,
+                                            output: &mut String) {
             // First, find out the 'real' def_id of the type. Items inlined from
             // other crates have to be mapped back to their source.
             let source_def_id = if def_id.krate == ast::LOCAL_CRATE {
@@ -549,10 +550,10 @@ fn from_def_id_and_substs(type_map: &mut TypeMap,
         }
     }
 
-    fn get_unique_type_id_of_closure_type(&mut self,
-                                          cx: &CrateContext,
-                                          closure_ty: ty::ClosureTy,
-                                          unique_type_id: &mut String) {
+    fn get_unique_type_id_of_closure_type<'a>(&mut self,
+                                              cx: &CrateContext<'a, 'tcx>,
+                                              closure_ty: ty::ClosureTy<'tcx>,
+                                              unique_type_id: &mut String) {
         let ty::ClosureTy { fn_style,
                             onceness,
                             store,
@@ -619,11 +620,11 @@ fn get_unique_type_id_of_closure_type(&mut self,
     // Get the UniqueTypeId for an enum variant. Enum variants are not really
     // types of their own, so they need special handling. We still need a
     // UniqueTypeId for them, since to debuginfo they *are* real types.
-    fn get_unique_type_id_of_enum_variant(&mut self,
-                                          cx: &CrateContext,
-                                          enum_type: Ty,
-                                          variant_name: &str)
-                                       -> UniqueTypeId {
+    fn get_unique_type_id_of_enum_variant<'a>(&mut self,
+                                              cx: &CrateContext<'a, 'tcx>,
+                                              enum_type: Ty<'tcx>,
+                                              variant_name: &str)
+                                              -> UniqueTypeId {
         let enum_type_id = self.get_unique_type_id_of_type(cx, enum_type);
         let enum_variant_type_id = format!("{}::{}",
                                            self.get_unique_type_id_as_string(enum_type_id)
@@ -649,14 +650,14 @@ macro_rules! return_if_metadata_created_in_meantime(
 
 
 /// A context object for maintaining all state needed by the debuginfo module.
-pub struct CrateDebugContext {
+pub struct CrateDebugContext<'tcx> {
     llcontext: ContextRef,
     builder: DIBuilderRef,
     current_debug_location: Cell<DebugLocation>,
     created_files: RefCell<FnvHashMap<String, DIFile>>,
     created_enum_disr_types: RefCell<DefIdMap<DIType>>,
 
-    type_map: RefCell<TypeMap>,
+    type_map: RefCell<TypeMap<'tcx>>,
     namespace_map: RefCell<FnvHashMap<Vec<ast::Name>, Rc<NamespaceTreeNode>>>,
 
     // This collection is used to assert that composite types (structs, enums,
@@ -664,8 +665,8 @@ pub struct CrateDebugContext {
     composite_types_completed: RefCell<FnvHashSet<DIType>>,
 }
 
-impl CrateDebugContext {
-    pub fn new(llmod: ModuleRef) -> CrateDebugContext {
+impl<'tcx> CrateDebugContext<'tcx> {
+    pub fn new(llmod: ModuleRef) -> CrateDebugContext<'tcx> {
         debug!("CrateDebugContext::new");
         let builder = unsafe { llvm::LLVMDIBuilderCreate(llmod) };
         // DIBuilder inherits context from the module, so we'd better use the same one
@@ -884,13 +885,13 @@ pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
 /// Creates debug information for a variable captured in a closure.
 ///
 /// Adds the created metadata nodes directly to the crate's IR.
-pub fn create_captured_var_metadata(bcx: Block,
-                                    node_id: ast::NodeId,
-                                    env_data_type: Ty,
-                                    env_pointer: ValueRef,
-                                    env_index: uint,
-                                    closure_store: ty::TraitStore,
-                                    span: Span) {
+pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                                node_id: ast::NodeId,
+                                                env_data_type: Ty<'tcx>,
+                                                env_pointer: ValueRef,
+                                                env_index: uint,
+                                                closure_store: ty::TraitStore,
+                                                span: Span) {
     if fn_should_be_ignored(bcx.fcx) {
         return;
     }
@@ -971,9 +972,9 @@ pub fn create_captured_var_metadata(bcx: Block,
 /// match-statement arm.
 ///
 /// Adds the created metadata nodes directly to the crate's IR.
-pub fn create_match_binding_metadata(bcx: Block,
-                                     variable_ident: ast::Ident,
-                                     binding: BindingInfo) {
+pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                                 variable_ident: ast::Ident,
+                                                 binding: BindingInfo<'tcx>) {
     if fn_should_be_ignored(bcx.fcx) {
         return;
     }
@@ -1168,10 +1169,10 @@ pub fn start_emitting_source_locations(fcx: &FunctionContext) {
 /// for debug info creation. The function may also return another variant of the
 /// FunctionDebugContext enum which indicates why no debuginfo should be created
 /// for the function.
-pub fn create_function_debug_context(cx: &CrateContext,
-                                     fn_ast_id: ast::NodeId,
-                                     param_substs: &param_substs,
-                                     llfn: ValueRef) -> FunctionDebugContext {
+pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                               fn_ast_id: ast::NodeId,
+                                               param_substs: &param_substs<'tcx>,
+                                               llfn: ValueRef) -> FunctionDebugContext {
     if cx.sess().opts.debuginfo == NoDebugInfo {
         return FunctionDebugContext { repr: DebugInfoDisabled };
     }
@@ -1369,11 +1370,11 @@ pub fn create_function_debug_context(cx: &CrateContext,
 
     return FunctionDebugContext { repr: DebugInfo(fn_debug_context) };
 
-    fn get_function_signature(cx: &CrateContext,
-                              fn_ast_id: ast::NodeId,
-                              fn_decl: &ast::FnDecl,
-                              param_substs: &param_substs,
-                              error_reporting_span: Span) -> DIArray {
+    fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                        fn_ast_id: ast::NodeId,
+                                        fn_decl: &ast::FnDecl,
+                                        param_substs: &param_substs<'tcx>,
+                                        error_reporting_span: Span) -> DIArray {
         if cx.sess().opts.debuginfo == LimitedDebugInfo {
             return create_DIArray(DIB(cx), &[]);
         }
@@ -1404,12 +1405,12 @@ fn get_function_signature(cx: &CrateContext,
         return create_DIArray(DIB(cx), signature.as_slice());
     }
 
-    fn get_template_parameters(cx: &CrateContext,
-                               generics: &ast::Generics,
-                               param_substs: &param_substs,
-                               file_metadata: DIFile,
-                               name_to_append_suffix_to: &mut String)
-                               -> DIArray {
+    fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                         generics: &ast::Generics,
+                                         param_substs: &param_substs<'tcx>,
+                                         file_metadata: DIFile,
+                                         name_to_append_suffix_to: &mut String)
+                                         -> DIArray {
         let self_type = param_substs.substs().self_ty();
 
         // Only true for static default methods:
@@ -1590,13 +1591,13 @@ fn fallback_path(cx: &CrateContext) -> CString {
     }
 }
 
-fn declare_local(bcx: Block,
-                 variable_ident: ast::Ident,
-                 variable_type: Ty,
-                 scope_metadata: DIScope,
-                 variable_access: VariableAccess,
-                 variable_kind: VariableKind,
-                 span: Span) {
+fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                             variable_ident: ast::Ident,
+                             variable_type: Ty<'tcx>,
+                             scope_metadata: DIScope,
+                             variable_access: VariableAccess,
+                             variable_kind: VariableKind,
+                             span: Span) {
     let cx: &CrateContext = bcx.ccx();
 
     let filename = span_start(cx, span).file.name.clone();
@@ -1739,7 +1740,8 @@ fn diverging_type_metadata(cx: &CrateContext) -> DIType {
     })
 }
 
-fn basic_type_metadata(cx: &CrateContext, t: Ty) -> DIType {
+fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                 t: Ty<'tcx>) -> DIType {
 
     debug!("basic_type_metadata: {}", ty::get(t));
 
@@ -1785,10 +1787,10 @@ fn basic_type_metadata(cx: &CrateContext, t: Ty) -> DIType {
     return ty_metadata;
 }
 
-fn pointer_type_metadata(cx: &CrateContext,
-                         pointer_type: Ty,
-                         pointee_type_metadata: DIType)
-                      -> DIType {
+fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                   pointer_type: Ty<'tcx>,
+                                   pointee_type_metadata: DIType)
+                                   -> DIType {
     let pointer_llvm_type = type_of::type_of(cx, pointer_type);
     let (pointer_size, pointer_align) = size_and_align_of(cx, pointer_llvm_type);
     let name = compute_debuginfo_type_name(cx, pointer_type, false);
@@ -1829,15 +1831,16 @@ struct MemberDescription {
 // for some record-like type. MemberDescriptionFactories are used to defer the
 // creation of type member descriptions in order to break cycles arising from
 // recursive type definitions.
-enum MemberDescriptionFactory {
-    StructMDF(StructMemberDescriptionFactory),
-    TupleMDF(TupleMemberDescriptionFactory),
-    EnumMDF(EnumMemberDescriptionFactory),
-    VariantMDF(VariantMemberDescriptionFactory)
+enum MemberDescriptionFactory<'tcx> {
+    StructMDF(StructMemberDescriptionFactory<'tcx>),
+    TupleMDF(TupleMemberDescriptionFactory<'tcx>),
+    EnumMDF(EnumMemberDescriptionFactory<'tcx>),
+    VariantMDF(VariantMemberDescriptionFactory<'tcx>)
 }
 
-impl MemberDescriptionFactory {
-    fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription> {
+impl<'tcx> MemberDescriptionFactory<'tcx> {
+    fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
+                                      -> Vec<MemberDescription> {
         match *self {
             StructMDF(ref this) => {
                 this.create_member_descriptions(cx)
@@ -1859,25 +1862,25 @@ fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription
 // with FinalMetadata) or it is not yet finished, but contains all information
 // needed to generate the missing parts of the description. See the documentation
 // section on Recursive Types at the top of this file for more information.
-enum RecursiveTypeDescription {
+enum RecursiveTypeDescription<'tcx> {
     UnfinishedMetadata {
-        unfinished_type: Ty,
+        unfinished_type: Ty<'tcx>,
         unique_type_id: UniqueTypeId,
         metadata_stub: DICompositeType,
         llvm_type: Type,
-        member_description_factory: MemberDescriptionFactory,
+        member_description_factory: MemberDescriptionFactory<'tcx>,
     },
     FinalMetadata(DICompositeType)
 }
 
-fn create_and_register_recursive_type_forward_declaration(
-    cx: &CrateContext,
-    unfinished_type: Ty,
+fn create_and_register_recursive_type_forward_declaration<'a, 'tcx>(
+    cx: &CrateContext<'a, 'tcx>,
+    unfinished_type: Ty<'tcx>,
     unique_type_id: UniqueTypeId,
     metadata_stub: DICompositeType,
     llvm_type: Type,
-    member_description_factory: MemberDescriptionFactory)
- -> RecursiveTypeDescription {
+    member_description_factory: MemberDescriptionFactory<'tcx>)
+ -> RecursiveTypeDescription<'tcx> {
 
     // Insert the stub into the TypeMap in order to allow for recursive references
     let mut type_map = debug_context(cx).type_map.borrow_mut();
@@ -1893,10 +1896,10 @@ fn create_and_register_recursive_type_forward_declaration(
     }
 }
 
-impl RecursiveTypeDescription {
+impl<'tcx> RecursiveTypeDescription<'tcx> {
     // Finishes up the description of the type in question (mostly by providing
     // descriptions of the fields of the given type) and returns the final type metadata.
-    fn finalize(&self, cx: &CrateContext) -> MetadataCreationResult {
+    fn finalize<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> MetadataCreationResult {
         match *self {
             FinalMetadata(metadata) => MetadataCreationResult::new(metadata, false),
             UnfinishedMetadata {
@@ -1944,14 +1947,15 @@ fn finalize(&self, cx: &CrateContext) -> MetadataCreationResult {
 //=-----------------------------------------------------------------------------
 
 // Creates MemberDescriptions for the fields of a struct
-struct StructMemberDescriptionFactory {
-    fields: Vec<ty::field>,
+struct StructMemberDescriptionFactory<'tcx> {
+    fields: Vec<ty::field<'tcx>>,
     is_simd: bool,
     span: Span,
 }
 
-impl StructMemberDescriptionFactory {
-    fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription> {
+impl<'tcx> StructMemberDescriptionFactory<'tcx> {
+    fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
+                                      -> Vec<MemberDescription> {
         if self.fields.len() == 0 {
             return Vec::new();
         }
@@ -1988,13 +1992,13 @@ fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription
 }
 
 
-fn prepare_struct_metadata(cx: &CrateContext,
-                           struct_type: Ty,
-                           def_id: ast::DefId,
-                           substs: &subst::Substs,
-                           unique_type_id: UniqueTypeId,
-                           span: Span)
-                        -> RecursiveTypeDescription {
+fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                     struct_type: Ty<'tcx>,
+                                     def_id: ast::DefId,
+                                     substs: &subst::Substs<'tcx>,
+                                     unique_type_id: UniqueTypeId,
+                                     span: Span)
+                                     -> RecursiveTypeDescription<'tcx> {
     let struct_name = compute_debuginfo_type_name(cx, struct_type, false);
     let struct_llvm_type = type_of::type_of(cx, struct_type);
 
@@ -2028,14 +2032,14 @@ fn prepare_struct_metadata(cx: &CrateContext,
 //=-----------------------------------------------------------------------------
 
 // Creates MemberDescriptions for the fields of a tuple
-struct TupleMemberDescriptionFactory {
-    component_types: Vec<Ty,
+struct TupleMemberDescriptionFactory<'tcx> {
+    component_types: Vec<Ty<'tcx>>,
     span: Span,
 }
 
-impl TupleMemberDescriptionFactory {
-    fn create_member_descriptions(&self, cx: &CrateContext)
-                                  -> Vec<MemberDescription> {
+impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
+    fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
+                                      -> Vec<MemberDescription> {
         self.component_types.iter().map(|&component_type| {
             MemberDescription {
                 name: "".to_string(),
@@ -2048,12 +2052,12 @@ fn create_member_descriptions(&self, cx: &CrateContext)
     }
 }
 
-fn prepare_tuple_metadata(cx: &CrateContext,
-                          tuple_type: Ty,
-                          component_types: &[Ty],
-                          unique_type_id: UniqueTypeId,
-                          span: Span)
-                       -> RecursiveTypeDescription {
+fn prepare_tuple_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                    tuple_type: Ty<'tcx>,
+                                    component_types: &[Ty<'tcx>],
+                                    unique_type_id: UniqueTypeId,
+                                    span: Span)
+                                    -> RecursiveTypeDescription<'tcx> {
     let tuple_name = compute_debuginfo_type_name(cx, tuple_type, false);
     let tuple_llvm_type = type_of::type_of(cx, tuple_type);
 
@@ -2084,18 +2088,19 @@ fn prepare_tuple_metadata(cx: &CrateContext,
 // the members of this union; so for every variant of the given enum, this factory
 // will produce one MemberDescription (all with no name and a fixed offset of
 // zero bytes).
-struct EnumMemberDescriptionFactory {
-    enum_type: Ty,
-    type_rep: Rc<adt::Repr>,
-    variants: Rc<Vec<Rc<ty::VariantInfo>>>,
+struct EnumMemberDescriptionFactory<'tcx> {
+    enum_type: Ty<'tcx>,
+    type_rep: Rc<adt::Repr<'tcx>>,
+    variants: Rc<Vec<Rc<ty::VariantInfo<'tcx>>>>,
     discriminant_type_metadata: Option<DIType>,
     containing_scope: DIScope,
     file_metadata: DIFile,
     span: Span,
 }
 
-impl EnumMemberDescriptionFactory {
-    fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription> {
+impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
+    fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
+                                      -> Vec<MemberDescription> {
         match *self.type_rep {
             adt::General(_, ref struct_defs, _) => {
                 let discriminant_info = RegularDiscriminant(self.discriminant_type_metadata
@@ -2286,14 +2291,15 @@ fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription
 }
 
 // Creates MemberDescriptions for the fields of a single enum variant.
-struct VariantMemberDescriptionFactory {
-    args: Vec<(String, Ty)> ,
+struct VariantMemberDescriptionFactory<'tcx> {
+    args: Vec<(String, Ty<'tcx>)>,
     discriminant_type_metadata: Option<DIType>,
     span: Span,
 }
 
-impl VariantMemberDescriptionFactory {
-    fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription> {
+impl<'tcx> VariantMemberDescriptionFactory<'tcx> {
+    fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
+                                      -> Vec<MemberDescription> {
         self.args.iter().enumerate().map(|(i, &(ref name, ty))| {
             MemberDescription {
                 name: name.to_string(),
@@ -2319,14 +2325,14 @@ enum EnumDiscriminantInfo {
 // of the variant, and (3) a MemberDescriptionFactory for producing the
 // descriptions of the fields of the variant. This is a rudimentary version of a
 // full RecursiveTypeDescription.
-fn describe_enum_variant(cx: &CrateContext,
-                         enum_type: Ty,
-                         struct_def: &adt::Struct,
-                         variant_info: &ty::VariantInfo,
-                         discriminant_info: EnumDiscriminantInfo,
-                         containing_scope: DIScope,
-                         span: Span)
-                      -> (DICompositeType, Type, MemberDescriptionFactory) {
+fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                   enum_type: Ty<'tcx>,
+                                   struct_def: &adt::Struct<'tcx>,
+                                   variant_info: &ty::VariantInfo<'tcx>,
+                                   discriminant_info: EnumDiscriminantInfo,
+                                   containing_scope: DIScope,
+                                   span: Span)
+                                   -> (DICompositeType, Type, MemberDescriptionFactory<'tcx>) {
     let variant_llvm_type =
         Type::struct_(cx, struct_def.fields
                                     .iter()
@@ -2389,12 +2395,12 @@ fn describe_enum_variant(cx: &CrateContext,
     (metadata_stub, variant_llvm_type, member_description_factory)
 }
 
-fn prepare_enum_metadata(cx: &CrateContext,
-                         enum_type: Ty,
-                         enum_def_id: ast::DefId,
-                         unique_type_id: UniqueTypeId,
-                         span: Span)
-                      -> RecursiveTypeDescription {
+fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                   enum_type: Ty<'tcx>,
+                                   enum_def_id: ast::DefId,
+                                   unique_type_id: UniqueTypeId,
+                                   span: Span)
+                                   -> RecursiveTypeDescription<'tcx> {
     let enum_name = compute_debuginfo_type_name(cx, enum_type, false);
 
     let (containing_scope, definition_span) = get_namespace_and_span_for_item(cx, enum_def_id);
@@ -2675,12 +2681,12 @@ fn create_struct_stub(cx: &CrateContext,
     return metadata_stub;
 }
 
-fn fixed_vec_metadata(cx: &CrateContext,
-                      unique_type_id: UniqueTypeId,
-                      element_type: Ty,
-                      len: uint,
-                      span: Span)
-                   -> MetadataCreationResult {
+fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                unique_type_id: UniqueTypeId,
+                                element_type: Ty<'tcx>,
+                                len: uint,
+                                span: Span)
+                                -> MetadataCreationResult {
     let element_type_metadata = type_metadata(cx, element_type, span);
 
     return_if_metadata_created_in_meantime!(cx, unique_type_id);
@@ -2708,12 +2714,12 @@ fn fixed_vec_metadata(cx: &CrateContext,
     return MetadataCreationResult::new(metadata, false);
 }
 
-fn vec_slice_metadata(cx: &CrateContext,
-                      vec_type: Ty,
-                      element_type: Ty,
-                      unique_type_id: UniqueTypeId,
-                      span: Span)
-                   -> MetadataCreationResult {
+fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                vec_type: Ty<'tcx>,
+                                element_type: Ty<'tcx>,
+                                unique_type_id: UniqueTypeId,
+                                span: Span)
+                                -> MetadataCreationResult {
     let data_ptr_type = ty::mk_ptr(cx.tcx(), ty::mt {
         ty: element_type,
         mutbl: ast::MutImmutable
@@ -2762,21 +2768,21 @@ fn vec_slice_metadata(cx: &CrateContext,
                                            span);
     return MetadataCreationResult::new(metadata, false);
 
-    fn slice_layout_is_correct(cx: &CrateContext,
-                               member_llvm_types: &[Type],
-                               element_type: Ty)
-                            -> bool {
+    fn slice_layout_is_correct<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                         member_llvm_types: &[Type],
+                                         element_type: Ty<'tcx>)
+                                         -> bool {
         member_llvm_types.len() == 2 &&
         member_llvm_types[0] == type_of::type_of(cx, element_type).ptr_to() &&
         member_llvm_types[1] == cx.int_type()
     }
 }
 
-fn subroutine_type_metadata(cx: &CrateContext,
-                            unique_type_id: UniqueTypeId,
-                            signature: &ty::FnSig,
-                            span: Span)
-                         -> MetadataCreationResult {
+fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                      unique_type_id: UniqueTypeId,
+                                      signature: &ty::FnSig<'tcx>,
+                                      span: Span)
+                                      -> MetadataCreationResult {
     let mut signature_metadata: Vec<DIType> = Vec::with_capacity(signature.inputs.len() + 1);
 
     // return type
@@ -2811,11 +2817,11 @@ fn subroutine_type_metadata(cx: &CrateContext,
 // trait_type should be the actual trait (e.g., Trait). Where the trait is part
 // of a DST struct, there is no trait_object_type and the results of this
 // function will be a little bit weird.
-fn trait_pointer_metadata(cx: &CrateContext,
-                          trait_type: Ty,
-                          trait_object_type: Option<Ty>,
-                          unique_type_id: UniqueTypeId)
-                       -> DIType {
+fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                    trait_type: Ty<'tcx>,
+                                    trait_object_type: Option<Ty<'tcx>>,
+                                    unique_type_id: UniqueTypeId)
+                                    -> DIType {
     // The implementation provided here is a stub. It makes sure that the trait
     // type is assigned the correct name, size, namespace, and source location.
     // But it does not describe the trait's methods.
@@ -2848,10 +2854,10 @@ fn trait_pointer_metadata(cx: &CrateContext,
                             codemap::DUMMY_SP)
 }
 
-fn type_metadata(cx: &CrateContext,
-                 t: Ty,
-                 usage_site_span: Span)
-              -> DIType {
+fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                           t: Ty<'tcx>,
+                           usage_site_span: Span)
+                           -> DIType {
     // Get the unique type id of this type.
     let unique_type_id = {
         let mut type_map = debug_context(cx).type_map.borrow_mut();
@@ -3111,8 +3117,9 @@ fn bytes_to_bits(bytes: u64) -> u64 {
 }
 
 #[inline]
-fn debug_context<'a>(cx: &'a CrateContext) -> &'a CrateDebugContext {
-    let debug_context: &'a CrateDebugContext = cx.dbg_cx().as_ref().unwrap();
+fn debug_context<'a, 'tcx>(cx: &'a CrateContext<'a, 'tcx>)
+                           -> &'a CrateDebugContext<'tcx> {
+    let debug_context: &'a CrateDebugContext<'tcx> = cx.dbg_cx().as_ref().unwrap();
     debug_context
 }
 
@@ -3666,10 +3673,10 @@ fn walk_expr(cx: &CrateContext,
 // any caching, i.e. calling the function twice with the same type will also do
 // the work twice. The `qualified` parameter only affects the first level of the
 // type name, further levels (i.e. type parameters) are always fully qualified.
-fn compute_debuginfo_type_name(cx: &CrateContext,
-                               t: Ty,
-                               qualified: bool)
-                            -> String {
+fn compute_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                         t: Ty<'tcx>,
+                                         qualified: bool)
+                                         -> String {
     let mut result = String::with_capacity(64);
     push_debuginfo_type_name(cx, t, qualified, &mut result);
     result
@@ -3677,10 +3684,10 @@ fn compute_debuginfo_type_name(cx: &CrateContext,
 
 // Pushes the name of the type as it should be stored in debuginfo on the
 // `output` String. See also compute_debuginfo_type_name().
-fn push_debuginfo_type_name(cx: &CrateContext,
-                            t: Ty,
-                            qualified: bool,
-                            output: &mut String) {
+fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                      t: Ty<'tcx>,
+                                      qualified: bool,
+                                      output: &mut String) {
     match ty::get(t).sty {
         ty::ty_bool              => output.push_str("bool"),
         ty::ty_char              => output.push_str("char"),
@@ -3907,9 +3914,9 @@ fn push_item_name(cx: &CrateContext,
     // reconstructed for items from non-local crates. For local crates, this
     // would be possible but with inlining and LTO we have to use the least
     // common denominator - otherwise we would run into conflicts.
-    fn push_type_params(cx: &CrateContext,
-                        substs: &subst::Substs,
-                        output: &mut String) {
+    fn push_type_params<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                  substs: &subst::Substs<'tcx>,
+                                  output: &mut String) {
         if substs.types.is_empty() {
             return;
         }
index abf1718b49886b95c474db5da6264368fee46a7d..214acaf48b67a126eaf9651d615186ed970f88bb 100644 (file)
@@ -179,7 +179,7 @@ pub fn get_dataptr(bcx: Block, fat_ptr: ValueRef) -> ValueRef {
 
 fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                  expr: &ast::Expr,
-                                 datum: Datum<Expr>)
+                                 datum: Datum<'tcx, Expr>)
                                  -> DatumBlock<'blk, 'tcx, Expr> {
     /*!
      * Helper for trans that apply adjustments from `expr` to `datum`,
@@ -253,10 +253,10 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     debug!("after adjustments, datum={}", datum.to_string(bcx.ccx()));
     return DatumBlock::new(bcx, datum);
 
-    fn apply_autoref<'blk, 'tcx>(autoref: &ty::AutoRef,
+    fn apply_autoref<'blk, 'tcx>(autoref: &ty::AutoRef<'tcx>,
                                  bcx: Block<'blk, 'tcx>,
                                  expr: &ast::Expr,
-                                 datum: Datum<Expr>)
+                                 datum: Datum<'tcx, Expr>)
                                  -> DatumBlock<'blk, 'tcx, Expr> {
         let mut bcx = bcx;
         let mut datum = datum;
@@ -291,7 +291,7 @@ fn apply_autoref<'blk, 'tcx>(autoref: &ty::AutoRef,
 
     fn ref_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                            expr: &ast::Expr,
-                           datum: Datum<Expr>)
+                           datum: Datum<'tcx, Expr>)
                            -> DatumBlock<'blk, 'tcx, Expr> {
         if !ty::type_is_sized(bcx.tcx(), datum.ty) {
             debug!("Taking address of unsized type {}",
@@ -312,10 +312,10 @@ fn ref_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     // then mk_ty should make a Box pointer (T -> Box<T>), if we want a
     // borrowed reference then it should be T -> &T.
     fn unsized_info<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                kind: &ty::UnsizeKind,
+                                kind: &ty::UnsizeKind<'tcx>,
                                 id: ast::NodeId,
-                                unsized_ty: Ty,
-                                mk_ty: |Ty| -> Ty) -> ValueRef {
+                                unsized_ty: Ty<'tcx>,
+                                mk_ty: |Ty<'tcx>| -> Ty<'tcx>) -> ValueRef {
         match kind {
             &ty::UnsizeLength(len) => C_uint(bcx.ccx(), len),
             &ty::UnsizeStruct(box ref k, tp_index) => match ty::get(unsized_ty).sty {
@@ -345,8 +345,8 @@ fn unsized_info<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     fn unsize_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                expr: &ast::Expr,
-                               datum: Datum<Expr>,
-                               k: &ty::UnsizeKind)
+                               datum: Datum<'tcx, Expr>,
+                               k: &ty::UnsizeKind<'tcx>)
                                -> DatumBlock<'blk, 'tcx, Expr> {
         let tcx = bcx.tcx();
         let datum_ty = datum.ty;
@@ -379,7 +379,7 @@ fn unsize_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     fn ref_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                expr: &ast::Expr,
-                               datum: Datum<Expr>)
+                               datum: Datum<'tcx, Expr>)
                                -> DatumBlock<'blk, 'tcx, Expr> {
         let tcx = bcx.tcx();
         let dest_ty = ty::close_type(tcx, datum.ty);
@@ -390,8 +390,8 @@ fn ref_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     fn into_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                 expr: &ast::Expr,
-                                datum: Datum<Expr>,
-                                dest_ty: Ty,
+                                datum: Datum<'tcx, Expr>,
+                                dest_ty: Ty<'tcx>,
                                 base: |Block<'blk, 'tcx>, ValueRef| -> ValueRef,
                                 info: |Block<'blk, 'tcx>, ValueRef| -> ValueRef)
                                 -> DatumBlock<'blk, 'tcx, Expr> {
@@ -412,7 +412,7 @@ fn into_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     fn unsize_unique_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                      expr: &ast::Expr,
-                                     datum: Datum<Expr>,
+                                     datum: Datum<'tcx, Expr>,
                                      len: uint)
                                      -> DatumBlock<'blk, 'tcx, Expr> {
         let mut bcx = bcx;
@@ -440,8 +440,8 @@ fn unsize_unique_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     fn unsize_unique_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                       expr: &ast::Expr,
-                                      datum: Datum<Expr>,
-                                      k: &ty::UnsizeKind)
+                                      datum: Datum<'tcx, Expr>,
+                                      k: &ty::UnsizeKind<'tcx>)
                                       -> DatumBlock<'blk, 'tcx, Expr> {
         let mut bcx = bcx;
         let tcx = bcx.tcx();
@@ -475,7 +475,7 @@ fn unsize_unique_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     fn add_env<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                            expr: &ast::Expr,
-                           datum: Datum<Expr>)
+                           datum: Datum<'tcx, Expr>)
                            -> DatumBlock<'blk, 'tcx, Expr> {
         // This is not the most efficient thing possible; since closures
         // are two words it'd be better if this were compiled in
@@ -566,7 +566,7 @@ fn trans_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         }
     };
 
-    fn nil<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ty: Ty)
+    fn nil<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ty: Ty<'tcx>)
                        -> DatumBlock<'blk, 'tcx, Expr> {
         let llval = C_undef(type_of::type_of(bcx.ccx(), ty));
         let datum = immediate_rvalue(llval, ty);
@@ -678,7 +678,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
 fn trans_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                            base: &ast::Expr,
-                           get_idx: |&'blk ty::ctxt<'tcx>, &[ty::field]| -> uint)
+                           get_idx: |&'blk ty::ctxt<'tcx>, &[ty::field<'tcx>]| -> uint)
                            -> DatumBlock<'blk, 'tcx, Expr> {
     let mut bcx = bcx;
     let _icx = push_ctxt("trans_rec_field");
@@ -858,7 +858,7 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             let const_ty = expr_ty(bcx, ref_expr);
 
             fn get_val<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, did: ast::DefId,
-                                   const_ty: Ty) -> ValueRef {
+                                   const_ty: Ty<'tcx>) -> ValueRef {
                 // For external constants, we don't inline.
                 if did.krate == ast::LOCAL_CRATE {
                     // Case 1.
@@ -1224,7 +1224,7 @@ fn trans_def_fn_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
 pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                    def: def::Def)
-                                   -> Datum<Lvalue> {
+                                   -> Datum<'tcx, Lvalue> {
     /*!
      * Translates a reference to a local variable or argument.
      * This always results in an lvalue datum.
@@ -1266,11 +1266,11 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     }
 }
 
-pub fn with_field_tys<R>(tcx: &ty::ctxt,
-                         ty: Ty,
-                         node_id_opt: Option<ast::NodeId>,
-                         op: |ty::Disr, (&[ty::field])| -> R)
-                         -> R {
+pub fn with_field_tys<'tcx, R>(tcx: &ty::ctxt<'tcx>,
+                               ty: Ty<'tcx>,
+                               node_id_opt: Option<ast::NodeId>,
+                               op: |ty::Disr, (&[ty::field<'tcx>])| -> R)
+                               -> R {
     /*!
      * Helper for enumerating the field types of structs, enums, or records.
      * The optional node ID here is the node ID of the path identifying the enum
@@ -1389,11 +1389,11 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
  * Note that `fields` may be empty; the base expression must always be
  * evaluated for side-effects.
  */
-pub struct StructBaseInfo<'a> {
+pub struct StructBaseInfo<'a, 'tcx> {
     /// The base expression; will be evaluated after all explicit fields.
     expr: &'a ast::Expr,
     /// The indices of fields to copy paired with their types.
-    fields: Vec<(uint, Ty)>
+    fields: Vec<(uint, Ty<'tcx>)>
 }
 
 /**
@@ -1406,14 +1406,14 @@ pub struct StructBaseInfo<'a> {
  * - `optbase` contains information on the base struct (if any) from
  * which remaining fields are copied; see comments on `StructBaseInfo`.
  */
-pub fn trans_adt<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
-                             ty: Ty,
-                             discr: ty::Disr,
-                             fields: &[(uint, &ast::Expr)],
-                             optbase: Option<StructBaseInfo>,
-                             dest: Dest,
-                             source_location: Option<NodeInfo>)
-                          -> Block<'blk, 'tcx> {
+pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
+                                 ty: Ty<'tcx>,
+                                 discr: ty::Disr,
+                                 fields: &[(uint, &ast::Expr)],
+                                 optbase: Option<StructBaseInfo<'a, 'tcx>>,
+                                 dest: Dest,
+                                 source_location: Option<NodeInfo>)
+                                 -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("trans_adt");
     let fcx = bcx.fcx;
     let repr = adt::represent_type(bcx.ccx(), ty);
@@ -1572,9 +1572,9 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 }
 
 fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                               box_ty: Ty,
+                               box_ty: Ty<'tcx>,
                                contents: &ast::Expr,
-                               contents_ty: Ty)
+                               contents_ty: Ty<'tcx>)
                                -> DatumBlock<'blk, 'tcx, Expr> {
     let _icx = push_ctxt("trans_uniq_expr");
     let fcx = bcx.fcx;
@@ -1635,11 +1635,11 @@ fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 // and the other not.
 fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                  binop_expr: &ast::Expr,
-                                 binop_ty: Ty,
+                                 binop_ty: Ty<'tcx>,
                                  op: ast::BinOp,
-                                 lhs_t: Ty,
+                                 lhs_t: Ty<'tcx>,
                                  lhs: ValueRef,
-                                 rhs_t: Ty,
+                                 rhs_t: Ty<'tcx>,
                                  rhs: ValueRef)
                                  -> DatumBlock<'blk, 'tcx, Expr> {
     let _icx = push_ctxt("trans_eager_binop");
@@ -1813,8 +1813,8 @@ fn trans_binary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                    expr: &ast::Expr,
                                    method_call: MethodCall,
-                                   lhs: Datum<Expr>,
-                                   rhs: Vec<(Datum<Expr>, ast::NodeId)>,
+                                   lhs: Datum<'tcx, Expr>,
+                                   rhs: Vec<(Datum<'tcx, Expr>, ast::NodeId)>,
                                    dest: Option<Dest>)
                                    -> Result<'blk, 'tcx> {
     let method_ty = (*bcx.tcx().method_map.borrow())[method_call].ty;
@@ -1907,7 +1907,7 @@ pub enum cast_kind {
     cast_other,
 }
 
-pub fn cast_type_kind(tcx: &ty::ctxt, t: Ty) -> cast_kind {
+pub fn cast_type_kind<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> cast_kind {
     match ty::get(t).sty {
         ty::ty_char        => cast_integral,
         ty::ty_float(..)   => cast_float,
@@ -1927,7 +1927,7 @@ pub fn cast_type_kind(tcx: &ty::ctxt, t: Ty) -> cast_kind {
     }
 }
 
-fn cast_is_noop(t_in: Ty, t_out: Ty) -> bool {
+fn cast_is_noop<'tcx>(t_in: Ty<'tcx>, t_out: Ty<'tcx>) -> bool {
     match (ty::deref(t_in, true), ty::deref(t_out, true)) {
         (Some(ty::mt{ ty: t_in, .. }), Some(ty::mt{ ty: t_out, .. })) => {
             t_in == t_out
@@ -2061,7 +2061,7 @@ fn trans_assign_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 }
 
 fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                        datum: Datum<Expr>,
+                        datum: Datum<'tcx, Expr>,
                         expr: &ast::Expr)
                         -> DatumBlock<'blk, 'tcx, Expr> {
     let mut bcx = bcx;
@@ -2086,7 +2086,7 @@ fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
 fn deref_multiple<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                               expr: &ast::Expr,
-                              datum: Datum<Expr>,
+                              datum: Datum<'tcx, Expr>,
                               times: uint)
                               -> DatumBlock<'blk, 'tcx, Expr> {
     let mut bcx = bcx;
@@ -2100,7 +2100,7 @@ fn deref_multiple<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
 fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                           expr: &ast::Expr,
-                          datum: Datum<Expr>,
+                          datum: Datum<'tcx, Expr>,
                           method_call: MethodCall)
                           -> DatumBlock<'blk, 'tcx, Expr> {
     let ccx = bcx.ccx();
@@ -2195,8 +2195,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     fn deref_owned_pointer<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                        expr: &ast::Expr,
-                                       datum: Datum<Expr>,
-                                       content_ty: Ty)
+                                       datum: Datum<'tcx, Expr>,
+                                       content_ty: Ty<'tcx>)
                                        -> DatumBlock<'blk, 'tcx, Expr> {
         /*!
          * We microoptimize derefs of owned pointers a bit here.
index 78a0fc08fbced0cf49b24070d874e5ea264417cb..c743f61cba5f76d66c67613ac305007854d9027c 100644 (file)
@@ -39,9 +39,9 @@
 ///////////////////////////////////////////////////////////////////////////
 // Type definitions
 
-struct ForeignTypes {
+struct ForeignTypes<'tcx> {
     /// Rust signature of the function
-    fn_sig: ty::FnSig,
+    fn_sig: ty::FnSig<'tcx>,
 
     /// Adapter object for handling native ABI rules (trust me, you
     /// don't want to know)
@@ -161,8 +161,9 @@ pub fn register_static(ccx: &CrateContext,
     }
 }
 
-pub fn register_foreign_item_fn(ccx: &CrateContext, abi: Abi, fty: Ty,
-                                name: &str) -> ValueRef {
+pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                          abi: Abi, fty: Ty<'tcx>,
+                                          name: &str) -> ValueRef {
     /*!
      * Registers a foreign function found in a library.
      * Just adds a LLVM global.
@@ -201,11 +202,11 @@ pub fn register_foreign_item_fn(ccx: &CrateContext, abi: Abi, fty: Ty,
 }
 
 pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                     callee_ty: Ty,
+                                     callee_ty: Ty<'tcx>,
                                      llfn: ValueRef,
                                      llretptr: ValueRef,
                                      llargs_rust: &[ValueRef],
-                                     passed_arg_tys: Vec<Ty)
+                                     passed_arg_tys: Vec<Ty<'tcx>>)
                                      -> Block<'blk, 'tcx> {
     /*!
      * Prepares a call to a native function. This requires adapting
@@ -483,10 +484,10 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) {
 // inline the one into the other. Of course we could just generate the
 // correct code in the first place, but this is much simpler.
 
-pub fn decl_rust_fn_with_foreign_abi(ccx: &CrateContext,
-                                     t: Ty,
-                                     name: &str)
-                                     -> ValueRef {
+pub fn decl_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                               t: Ty<'tcx>,
+                                               name: &str)
+                                               -> ValueRef {
     let tys = foreign_types_for_fn_ty(ccx, t);
     let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
     let cconv = match ty::get(t).sty {
@@ -525,14 +526,14 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
     llfn
 }
 
-pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
-                                      decl: &ast::FnDecl,
-                                      body: &ast::Block,
-                                      attrs: &[ast::Attribute],
-                                      llwrapfn: ValueRef,
-                                      param_substs: &param_substs,
-                                      id: ast::NodeId,
-                                      hash: Option<&str>) {
+pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                                decl: &ast::FnDecl,
+                                                body: &ast::Block,
+                                                attrs: &[ast::Attribute],
+                                                llwrapfn: ValueRef,
+                                                param_substs: &param_substs<'tcx>,
+                                                id: ast::NodeId,
+                                                hash: Option<&str>) {
     let _icx = push_ctxt("foreign::build_foreign_fn");
 
     let fnty = ty::node_id_to_type(ccx.tcx(), id);
@@ -547,14 +548,14 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
         return build_wrap_fn(ccx, llrustfn, llwrapfn, &tys, mty);
     }
 
-    fn build_rust_fn(ccx: &CrateContext,
-                     decl: &ast::FnDecl,
-                     body: &ast::Block,
-                     param_substs: &param_substs,
-                     attrs: &[ast::Attribute],
-                     id: ast::NodeId,
-                     hash: Option<&str>)
-                     -> ValueRef {
+    fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                               decl: &ast::FnDecl,
+                               body: &ast::Block,
+                               param_substs: &param_substs<'tcx>,
+                               attrs: &[ast::Attribute],
+                               id: ast::NodeId,
+                               hash: Option<&str>)
+                               -> ValueRef {
         let _icx = push_ctxt("foreign::foreign::build_rust_fn");
         let tcx = ccx.tcx();
         let t = ty::node_id_to_type(tcx, id).subst(
@@ -589,11 +590,11 @@ fn build_rust_fn(ccx: &CrateContext,
         llfn
     }
 
-    unsafe fn build_wrap_fn(ccx: &CrateContext,
-                            llrustfn: ValueRef,
-                            llwrapfn: ValueRef,
-                            tys: &ForeignTypes,
-                            t: Ty) {
+    unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                      llrustfn: ValueRef,
+                                      llwrapfn: ValueRef,
+                                      tys: &ForeignTypes<'tcx>,
+                                      t: Ty<'tcx>) {
         let _icx = push_ctxt(
             "foreign::trans_rust_fn_with_foreign_abi::build_wrap_fn");
         let tcx = ccx.tcx();
@@ -832,8 +833,9 @@ pub fn link_name(i: &ast::ForeignItem) -> InternedString {
     }
 }
 
-fn foreign_signature(ccx: &CrateContext, fn_sig: &ty::FnSig, arg_tys: &[Ty])
-                     -> LlvmSignature {
+fn foreign_signature<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                               fn_sig: &ty::FnSig<'tcx>, arg_tys: &[Ty<'tcx>])
+                               -> LlvmSignature {
     /*!
      * The ForeignSignature is the LLVM types of the arguments/return type
      * of a function.  Note that these LLVM types are not quite the same
@@ -856,13 +858,13 @@ fn foreign_signature(ccx: &CrateContext, fn_sig: &ty::FnSig, arg_tys: &[Ty])
     }
 }
 
-fn foreign_types_for_id(ccx: &CrateContext,
-                        id: ast::NodeId) -> ForeignTypes {
+fn foreign_types_for_id<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                  id: ast::NodeId) -> ForeignTypes<'tcx> {
     foreign_types_for_fn_ty(ccx, ty::node_id_to_type(ccx.tcx(), id))
 }
 
-fn foreign_types_for_fn_ty(ccx: &CrateContext,
-                           ty: Ty) -> ForeignTypes {
+fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                     ty: Ty<'tcx>) -> ForeignTypes<'tcx> {
     let fn_sig = match ty::get(ty).sty {
         ty::ty_bare_fn(ref fn_ty) => fn_ty.sig.clone(),
         _ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
@@ -934,7 +936,8 @@ fn lltype_for_fn_from_foreign_types(ccx: &CrateContext, tys: &ForeignTypes) -> T
     }
 }
 
-pub fn lltype_for_foreign_fn(ccx: &CrateContext, ty: Ty) -> Type {
+pub fn lltype_for_foreign_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                       ty: Ty<'tcx>) -> Type {
     lltype_for_fn_from_foreign_types(ccx, &foreign_types_for_fn_ty(ccx, ty))
 }
 
index ea17f65dd65e0e92837e08de572e97a69cf7746c..ae389663ace23cdfac5d28c15c65ebd82143e007 100644 (file)
@@ -62,7 +62,7 @@ pub fn trans_exchange_free<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef,
 }
 
 pub fn trans_exchange_free_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef,
-                                          content_ty: Ty) -> Block<'blk, 'tcx> {
+                                          content_ty: Ty<'tcx>) -> Block<'blk, 'tcx> {
     assert!(ty::type_is_sized(bcx.ccx().tcx(), content_ty));
     let sizing_type = sizing_type_of(bcx.ccx(), content_ty);
     let content_size = llsize_of_alloc(bcx.ccx(), sizing_type);
@@ -76,7 +76,8 @@ pub fn trans_exchange_free_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef,
     }
 }
 
-pub fn get_drop_glue_type(ccx: &CrateContext, t: Ty) -> Ty {
+pub fn get_drop_glue_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                    t: Ty<'tcx>) -> Ty<'tcx> {
     let tcx = ccx.tcx();
     // Even if there is no dtor for t, there might be one deeper down and we
     // might need to pass in the vtable ptr.
@@ -103,7 +104,7 @@ pub fn get_drop_glue_type(ccx: &CrateContext, t: Ty) -> Ty {
 
 pub fn drop_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                            v: ValueRef,
-                           t: Ty,
+                           t: Ty<'tcx>,
                            source_location: Option<NodeInfo>)
                            -> Block<'blk, 'tcx> {
     // NB: v is an *alias* of type t here, not a direct value.
@@ -131,7 +132,7 @@ pub fn drop_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
 pub fn drop_ty_immediate<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                      v: ValueRef,
-                                     t: Ty,
+                                     t: Ty<'tcx>,
                                      source_location: Option<NodeInfo>)
                                      -> Block<'blk, 'tcx> {
     let _icx = push_ctxt("drop_ty_immediate");
@@ -140,7 +141,7 @@ pub fn drop_ty_immediate<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     drop_ty(bcx, vp, t, source_location)
 }
 
-pub fn get_drop_glue(ccx: &CrateContext, t: Ty) -> ValueRef {
+pub fn get_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> ValueRef {
     debug!("make drop glue for {}", ppaux::ty_to_string(ccx.tcx(), t));
     let t = get_drop_glue_type(ccx, t);
     debug!("drop glue type {}", ppaux::ty_to_string(ccx.tcx(), t));
@@ -185,11 +186,11 @@ pub fn get_drop_glue(ccx: &CrateContext, t: Ty) -> ValueRef {
 }
 
 fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
-                                      t: Ty,
+                                      t: Ty<'tcx>,
                                       v0: ValueRef,
                                       dtor_did: ast::DefId,
                                       class_did: ast::DefId,
-                                      substs: &subst::Substs)
+                                      substs: &subst::Substs<'tcx>)
                                       -> Block<'blk, 'tcx> {
     let repr = adt::represent_type(bcx.ccx(), t);
     let struct_data = if ty::type_is_sized(bcx.tcx(), t) {
@@ -205,11 +206,11 @@ fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 }
 
 fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                 t: Ty,
+                                 t: Ty<'tcx>,
                                  v0: ValueRef,
                                  dtor_did: ast::DefId,
                                  class_did: ast::DefId,
-                                 substs: &subst::Substs)
+                                 substs: &subst::Substs<'tcx>)
                                  -> Block<'blk, 'tcx> {
     let repr = adt::represent_type(bcx.ccx(), t);
 
@@ -297,7 +298,8 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     })
 }
 
-fn size_and_align_of_dst(bcx: Block, t :Ty, info: ValueRef) -> (ValueRef, ValueRef) {
+fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, info: ValueRef)
+                                     -> (ValueRef, ValueRef) {
     debug!("calculate size of DST: {}; with lost info: {}",
            bcx.ty_to_string(t), bcx.val_to_string(info));
     if ty::type_is_sized(bcx.tcx(), t) {
@@ -352,7 +354,7 @@ fn size_and_align_of_dst(bcx: Block, t :Ty, info: ValueRef) -> (ValueRef, ValueR
     }
 }
 
-fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty)
+fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty<'tcx>)
                               -> Block<'blk, 'tcx> {
     // NB: v0 is an *alias* of type t here, not a direct value.
     let _icx = push_ctxt("make_drop_glue");
@@ -477,7 +479,8 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty)
 }
 
 // Generates the declaration for (but doesn't emit) a type descriptor.
-pub fn declare_tydesc(ccx: &CrateContext, t: Ty) -> tydesc_info {
+pub fn declare_tydesc<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>)
+                                -> tydesc_info<'tcx> {
     // If emit_tydescs already ran, then we shouldn't be creating any new
     // tydescs.
     assert!(!ccx.finished_tydescs().get());
@@ -514,8 +517,8 @@ pub fn declare_tydesc(ccx: &CrateContext, t: Ty) -> tydesc_info {
     }
 }
 
-fn declare_generic_glue(ccx: &CrateContext, t: Ty, llfnty: Type,
-                        name: &str) -> (String, ValueRef) {
+fn declare_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>,
+                                  llfnty: Type, name: &str) -> (String, ValueRef) {
     let _icx = push_ctxt("declare_generic_glue");
     let fn_nm = mangle_internal_name_by_type_and_seq(
         ccx,
@@ -526,13 +529,13 @@ fn declare_generic_glue(ccx: &CrateContext, t: Ty, llfnty: Type,
     return (fn_nm, llfn);
 }
 
-fn make_generic_glue(ccx: &CrateContext,
-                     t: Ty,
-                     llfn: ValueRef,
-                     helper: for<'blk, 'tcx> |Block<'blk, 'tcx>, ValueRef, Ty|
-                                              -> Block<'blk, 'tcx>,
-                     name: &str)
-                     -> ValueRef {
+fn make_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                               t: Ty<'tcx>,
+                               llfn: ValueRef,
+                               helper: for<'blk> |Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|
+                                                  -> Block<'blk, 'tcx>,
+                               name: &str)
+                               -> ValueRef {
     let _icx = push_ctxt("make_generic_glue");
     let glue_name = format!("glue {} {}", name, ty_to_short_str(ccx.tcx(), t));
     let _s = StatRecorder::new(ccx, glue_name);
index 8a523525ce1302dcc4972eec62807f3e4374d91a..d8c9b3ac9b2e83831b5416d1c5298148eaaf024b 100644 (file)
@@ -135,11 +135,15 @@ pub fn check_intrinsics(ccx: &CrateContext) {
     ccx.sess().abort_if_errors();
 }
 
-pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::NodeId,
-                                        callee_ty: Ty, cleanup_scope: cleanup::CustomScopeIndex,
-                                        args: callee::CallArgs, dest: expr::Dest,
-                                        substs: subst::Substs, call_info: NodeInfo)
-                                        -> Result<'blk, 'tcx> {
+pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
+                                            node: ast::NodeId,
+                                            callee_ty: Ty<'tcx>,
+                                            cleanup_scope: cleanup::CustomScopeIndex,
+                                            args: callee::CallArgs<'a, 'tcx>,
+                                            dest: expr::Dest,
+                                            substs: subst::Substs<'tcx>,
+                                            call_info: NodeInfo)
+                                            -> Result<'blk, 'tcx> {
 
     let fcx = bcx.fcx;
     let ccx = fcx.ccx;
@@ -553,8 +557,9 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
     Result::new(bcx, llresult)
 }
 
-fn copy_intrinsic(bcx: Block, allow_overlap: bool, volatile: bool,
-                  tp_ty: Ty, dst: ValueRef, src: ValueRef, count: ValueRef) -> ValueRef {
+fn copy_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                              allow_overlap: bool, volatile: bool, tp_ty: Ty<'tcx>,
+                              dst: ValueRef, src: ValueRef, count: ValueRef) -> ValueRef {
     let ccx = bcx.ccx();
     let lltp_ty = type_of::type_of(ccx, tp_ty);
     let align = C_i32(ccx, type_of::align_of(ccx, tp_ty) as i32);
@@ -582,8 +587,8 @@ fn copy_intrinsic(bcx: Block, allow_overlap: bool, volatile: bool,
                       C_bool(ccx, volatile)], None)
 }
 
-fn memset_intrinsic(bcx: Block, volatile: bool, tp_ty: Ty,
-                    dst: ValueRef, val: ValueRef, count: ValueRef) -> ValueRef {
+fn memset_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, volatile: bool, tp_ty: Ty<'tcx>,
+                                dst: ValueRef, val: ValueRef, count: ValueRef) -> ValueRef {
     let ccx = bcx.ccx();
     let lltp_ty = type_of::type_of(ccx, tp_ty);
     let align = C_i32(ccx, type_of::align_of(ccx, tp_ty) as i32);
@@ -607,8 +612,8 @@ fn count_zeros_intrinsic(bcx: Block, name: &'static str, val: ValueRef) -> Value
     Call(bcx, llfn, &[val, y], None)
 }
 
-fn with_overflow_intrinsic(bcx: Block, name: &'static str, t: Ty,
-                           a: ValueRef, b: ValueRef) -> ValueRef {
+fn with_overflow_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, name: &'static str,
+                                       t: Ty<'tcx>, a: ValueRef, b: ValueRef) -> ValueRef {
     let llfn = bcx.ccx().get_intrinsic(&name);
 
     // Convert `i1` to a `bool`, and write it to the out parameter
index ae36a7a26227f0d01ca6fa71e24733191a7ce6b7..73f893cd07dfb0639aa1dc6a60854fd6797cb779 100644 (file)
@@ -328,7 +328,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                           method_call: MethodCall,
                                           trait_id: ast::DefId,
                                           n_method: uint,
-                                          vtable: traits::Vtable<()>)
+                                          vtable: traits::Vtable<'tcx, ()>)
                                           -> Callee<'blk, 'tcx> {
     let _icx = push_ctxt("meth::trans_monomorphized_callee");
     match vtable {
@@ -378,10 +378,10 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     }
 }
 
-fn combine_impl_and_methods_tps(bcx: Block,
-                                node: ExprOrMethodCall,
-                                rcvr_substs: subst::Substs)
-                                -> subst::Substs
+fn combine_impl_and_methods_tps<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                            node: ExprOrMethodCall,
+                                            rcvr_substs: subst::Substs<'tcx>)
+                                            -> subst::Substs<'tcx>
 {
     /*!
      * Creates a concatenated set of substitutions which includes
@@ -424,7 +424,7 @@ fn combine_impl_and_methods_tps(bcx: Block,
 }
 
 fn trans_trait_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                  method_ty: Ty,
+                                  method_ty: Ty<'tcx>,
                                   n_method: uint,
                                   self_expr: &ast::Expr,
                                   arg_cleanup_scope: cleanup::ScopeId)
@@ -468,7 +468,7 @@ fn trans_trait_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 }
 
 pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                                 callee_ty: Ty,
+                                                 callee_ty: Ty<'tcx>,
                                                  n_method: uint,
                                                  llpair: ValueRef)
                                                  -> Callee<'blk, 'tcx> {
@@ -526,10 +526,10 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 /// `trait_ref` would map `T:Trait`, but `box_ty` would be
 /// `Foo<T>`. This `box_ty` is primarily used to encode the destructor.
 /// This will hopefully change now that DST is underway.
-pub fn get_vtable(bcx: Block,
-                  box_ty: Ty,
-                  trait_ref: Rc<ty::TraitRef>)
-                  -> ValueRef
+pub fn get_vtable<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                              box_ty: Ty<'tcx>,
+                              trait_ref: Rc<ty::TraitRef<'tcx>>)
+                              -> ValueRef
 {
     debug!("get_vtable(box_ty={}, trait_ref={})",
            box_ty.repr(bcx.tcx()),
@@ -677,10 +677,10 @@ pub fn make_vtable<I: Iterator<ValueRef>>(ccx: &CrateContext,
     }
 }
 
-fn emit_vtable_methods(bcx: Block,
-                       impl_id: ast::DefId,
-                       substs: subst::Substs)
-                       -> Vec<ValueRef> {
+fn emit_vtable_methods<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                   impl_id: ast::DefId,
+                                   substs: subst::Substs<'tcx>)
+                                   -> Vec<ValueRef> {
     let ccx = bcx.ccx();
     let tcx = ccx.tcx();
 
@@ -735,9 +735,9 @@ fn emit_vtable_methods(bcx: Block,
 }
 
 pub fn trans_trait_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                    datum: Datum<Expr>,
+                                    datum: Datum<'tcx, Expr>,
                                     id: ast::NodeId,
-                                    trait_ref: Rc<ty::TraitRef>,
+                                    trait_ref: Rc<ty::TraitRef<'tcx>>,
                                     dest: expr::Dest)
                                     -> Block<'blk, 'tcx> {
     /*!
index 3dfa3e10e2601eadbd5761f7fcdd14f4b6e35b42..218faa73e6c168302beae6174d1a4b53db47d7d1 100644 (file)
 use syntax::attr;
 use std::hash::{sip, Hash};
 
-pub fn monomorphic_fn(ccx: &CrateContext,
-                      fn_id: ast::DefId,
-                      real_substs: &subst::Substs,
-                      ref_id: Option<ast::NodeId>)
+pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                fn_id: ast::DefId,
+                                real_substs: &subst::Substs<'tcx>,
+                                ref_id: Option<ast::NodeId>)
     -> (ValueRef, bool) {
     debug!("monomorphic_fn(\
             fn_id={}, \
@@ -284,7 +284,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
 }
 
 #[deriving(PartialEq, Eq, Hash, Show)]
-pub struct MonoId {
+pub struct MonoId<'tcx> {
     pub def: ast::DefId,
-    pub params: subst::VecPerParamSpace<Ty>
+    pub params: subst::VecPerParamSpace<Ty<'tcx>>
 }
index 1d34ad29a23114781cd9d987b12fb65806975c6d..baab9b7b9a75b0b9127ca8b3d04757d9267a2ea9 100644 (file)
@@ -52,7 +52,7 @@ pub fn pointer_add_byte(bcx: Block, ptr: ValueRef, bytes: ValueRef) -> ValueRef
 
 pub fn make_drop_glue_unboxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                           vptr: ValueRef,
-                                          unit_ty: Ty,
+                                          unit_ty: Ty<'tcx>,
                                           should_deallocate: bool)
                                           -> Block<'blk, 'tcx> {
     let not_null = IsNotNull(bcx, vptr);
@@ -89,15 +89,15 @@ pub fn make_drop_glue_unboxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     })
 }
 
-pub struct VecTypes {
-    pub unit_ty: Ty,
+pub struct VecTypes<'tcx> {
+    pub unit_ty: Ty<'tcx>,
     pub llunit_ty: Type,
     pub llunit_size: ValueRef,
     pub llunit_alloc_size: u64
 }
 
-impl VecTypes {
-    pub fn to_string(&self, ccx: &CrateContext) -> String {
+impl<'tcx> VecTypes<'tcx> {
+    pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
         format!("VecTypes {{unit_ty={}, llunit_ty={}, \
                  llunit_size={}, llunit_alloc_size={}}}",
                 ty_to_string(ccx.tcx(), self.unit_ty),
@@ -240,7 +240,7 @@ pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 }
 
 pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                 vt: &VecTypes,
+                                 vt: &VecTypes<'tcx>,
                                  vstore_expr: &ast::Expr,
                                  content_expr: &ast::Expr,
                                  dest: Dest)
@@ -337,12 +337,16 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     }
 }
 
-pub fn vec_types_from_expr(bcx: Block, vec_expr: &ast::Expr) -> VecTypes {
+pub fn vec_types_from_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                                       vec_expr: &ast::Expr)
+                                       -> VecTypes<'tcx> {
     let vec_ty = node_id_type(bcx, vec_expr.id);
     vec_types(bcx, ty::sequence_element_type(bcx.tcx(), vec_ty))
 }
 
-pub fn vec_types(bcx: Block, unit_ty: Ty) -> VecTypes {
+pub fn vec_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+                             unit_ty: Ty<'tcx>)
+                             -> VecTypes<'tcx> {
     let ccx = bcx.ccx();
     let llunit_ty = type_of::type_of(ccx, unit_ty);
     let llunit_size = nonzero_llsize_of(ccx, llunit_ty);
@@ -437,11 +441,11 @@ pub fn get_base_and_len(bcx: Block,
 }
 
 pub type iter_vec_block<'a, 'blk, 'tcx> =
-    |Block<'blk, 'tcx>, ValueRef, Ty|: 'a -> Block<'blk, 'tcx>;
+    |Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|: 'a -> Block<'blk, 'tcx>;
 
 pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                      data_ptr: ValueRef,
-                                     vt: &VecTypes,
+                                     vt: &VecTypes<'tcx>,
                                      count: ValueRef,
                                      f: iter_vec_block<'a, 'blk, 'tcx>)
                                      -> Block<'blk, 'tcx> {
@@ -497,7 +501,7 @@ pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
 pub fn iter_vec_raw<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                     data_ptr: ValueRef,
-                                    unit_ty: Ty,
+                                    unit_ty: Ty<'tcx>,
                                     len: ValueRef,
                                     f: iter_vec_block<'a, 'blk, 'tcx>)
                                     -> Block<'blk, 'tcx> {
index b466aecf7bbde4f7b3895687450fc6c426cb046a..431768a94de58d3738960af042756cbaf698eefb 100644 (file)
 use syntax::ast;
 
 // LLVM doesn't like objects that are too big. Issue #17913
-fn ensure_array_fits_in_address_space(ccx: &CrateContext,
-                                      llet: Type,
-                                      size: machine::llsize,
-                                      scapegoat: Ty) {
+fn ensure_array_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                                llet: Type,
+                                                size: machine::llsize,
+                                                scapegoat: Ty<'tcx>) {
     let esz = machine::llsize_of_alloc(ccx, llet);
     match esz.checked_mul(size) {
         Some(n) if n < ccx.max_obj_size() => {}
@@ -39,15 +39,18 @@ fn ensure_array_fits_in_address_space(ccx: &CrateContext,
     }
 }
 
-pub fn arg_is_indirect(ccx: &CrateContext, arg_ty: Ty) -> bool {
+pub fn arg_is_indirect<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                 arg_ty: Ty<'tcx>) -> bool {
     !type_is_immediate(ccx, arg_ty)
 }
 
-pub fn return_uses_outptr(ccx: &CrateContext, ty: Ty) -> bool {
+pub fn return_uses_outptr<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                    ty: Ty<'tcx>) -> bool {
     !type_is_immediate(ccx, ty)
 }
 
-pub fn type_of_explicit_arg(ccx: &CrateContext, arg_ty: Ty) -> Type {
+pub fn type_of_explicit_arg<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                      arg_ty: Ty<'tcx>) -> Type {
     let llty = arg_type_of(ccx, arg_ty);
     if arg_is_indirect(ccx, arg_ty) {
         llty.ptr_to()
@@ -59,10 +62,10 @@ pub fn type_of_explicit_arg(ccx: &CrateContext, arg_ty: Ty) -> Type {
 /// Yields the types of the "real" arguments for this function. For most
 /// functions, these are simply the types of the arguments. For functions with
 /// the `RustCall` ABI, however, this untuples the arguments of the function.
-pub fn untuple_arguments_if_necessary(ccx: &CrateContext,
-                                      inputs: &[Ty],
-                                      abi: abi::Abi)
-                                      -> Vec<Ty> {
+pub fn untuple_arguments_if_necessary<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+                                                inputs: &[Ty<'tcx>],
+                                                abi: abi::Abi)
+                                                -> Vec<Ty<'tcx>> {
     if abi != abi::RustCall {
         return inputs.iter().map(|x| (*x).clone()).collect()
     }
@@ -94,12 +97,12 @@ pub fn untuple_arguments_if_necessary(ccx: &CrateContext,
     result
 }
 
-pub fn type_of_rust_fn(cx: &CrateContext,
-                       llenvironment_type: Option<Type>,
-                       inputs: &[Ty],
-                       output: ty::FnOutput,
-                       abi: abi::Abi)
-                       -> Type {
+pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                 llenvironment_type: Option<Type>,
+                                 inputs: &[Ty<'tcx>],
+                                 output: ty::FnOutput<'tcx>,
+                                 abi: abi::Abi)
+                                 -> Type {
     let mut atys: Vec<Type> = Vec::new();
 
     // First, munge the inputs, if this has the `rust-call` ABI.
@@ -138,7 +141,7 @@ pub fn type_of_rust_fn(cx: &CrateContext,
 }
 
 // Given a function type and a count of ty params, construct an llvm type
-pub fn type_of_fn_from_ty(cx: &CrateContext, fty: Ty) -> Type {
+pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>) -> Type {
     match ty::get(fty).sty {
         ty::ty_closure(ref f) => {
             type_of_rust_fn(cx,
@@ -175,7 +178,7 @@ pub fn type_of_fn_from_ty(cx: &CrateContext, fty: Ty) -> Type {
 //     type behind pointers. This can help prevent infinite loops for
 //     recursive types. For example, enum types rely on this behavior.
 
-pub fn sizing_type_of(cx: &CrateContext, t: Ty) -> Type {
+pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
     match cx.llsizingtypes().borrow().get(&t).cloned() {
         Some(t) => return t,
         None => ()
@@ -247,7 +250,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: Ty) -> Type {
     llsizingty
 }
 
-pub fn arg_type_of(cx: &CrateContext, t: Ty) -> Type {
+pub fn arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
     if ty::type_is_bool(t) {
         Type::i1(cx)
     } else {
@@ -256,8 +259,8 @@ pub fn arg_type_of(cx: &CrateContext, t: Ty) -> Type {
 }
 
 // NB: If you update this, be sure to update `sizing_type_of()` as well.
-pub fn type_of(cx: &CrateContext, t: Ty) -> Type {
-    fn type_of_unsize_info(cx: &CrateContext, t: Ty) -> Type {
+pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
+    fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
         // It is possible to end up here with a sized type. This happens with a
         // struct which might be unsized, but is monomorphised to a sized type.
         // In this case we'll fake a fat pointer with no unsize info (we use 0).
@@ -433,7 +436,8 @@ fn type_of_unsize_info(cx: &CrateContext, t: Ty) -> Type {
     return llty;
 }
 
-pub fn align_of(cx: &CrateContext, t: Ty) -> machine::llalign {
+pub fn align_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>)
+                          -> machine::llalign {
     let llty = sizing_type_of(cx, t);
     machine::llalign_of_min(cx, llty)
 }
@@ -445,11 +449,11 @@ pub enum named_ty {
     an_unboxed_closure,
 }
 
-pub fn llvm_type_name(cx: &CrateContext,
-                      what: named_ty,
-                      did: ast::DefId,
-                      tps: &[Ty])
-                      -> String
+pub fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+                                what: named_ty,
+                                did: ast::DefId,
+                                tps: &[Ty<'tcx>])
+                                -> String
 {
     let name = match what {
         a_struct => "struct",
@@ -472,7 +476,7 @@ pub fn llvm_type_name(cx: &CrateContext,
     }
 }
 
-pub fn type_of_dtor(ccx: &CrateContext, self_ty: Ty) -> Type {
+pub fn type_of_dtor<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, self_ty: Ty<'tcx>) -> Type {
     let self_ty = type_of(ccx, self_ty).ptr_to();
     Type::func(&[self_ty], &Type::void(ccx))
 }