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 {
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
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,
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)
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,
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)
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);
// 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)
})
}
-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)
}
}
}
-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);
}
}
-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());
}
}
-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| {
})
}
-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);
}).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);
}
}
-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);
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();
}
/// 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| {
}
}
-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);
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,
}
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,
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);
}
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,
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,
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,
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,
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();
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 {
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);
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,
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));
}
// 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(),
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)
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)
}
}
}
-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() {
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));
}
}
-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)),
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(),
}
}
-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 }
}
}
}
-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));
}
}
-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));
}
}
-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) != ']' {
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);
}
}
-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 {
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 => {}
}
}
-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);
}
}
}
-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() {
}
}
-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));
}
}
-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);
}
}
}
-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"),
}
}
-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);
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);
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() {
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);
// ______________________________________________________________________
// 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| {
}).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| {
}
}
-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) => {
}).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>
}
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)
}
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",
}
}
-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;
});
}
- 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(),
});
}
- 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| {
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| {
});
}
- 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| {
});
}
- 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| {
});
}
- 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| {
}
}
-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,
// 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,
}
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()
}
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(
}).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",
}
- 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
}
}
- 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,
}).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,
}).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| {
}).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,
}).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,
}).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| {
}).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| {
}).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",
}).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| {
}).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,
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);
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()),
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)
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={})",
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()));
}
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
}
}
- 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();
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;
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>
}
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
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,
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));
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(..)) |
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,
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),
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);
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()),
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)
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={})",
}
/// 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, _) => {
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) {
// }
// }
- 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 {
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,
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());
}
}
-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() {
}
}
-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(..)) |
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,
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() {
guaranteed_paths: uint
}
-pub type BckResult<T> = Result<T, BckError>;
+pub type BckResult<'tcx, T> = Result<T, BckError<'tcx>>;
///////////////////////////////////////////////////////////////////////////
// Loans and loan paths
// 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
}
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(()) => {
}
}
- 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());
}
}
- 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(..),
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 {
}
}
- 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(..) => {
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)
}
}
}
}
-impl Repr for Loan {
+impl<'tcx> Repr<'tcx> for Loan {
fn repr(&self, tcx: &ty::ctxt) -> String {
format!("Loan_{}({}, {}, {}-{}, {})",
self.index,
}
}
-impl Repr for LoanPath {
+impl<'tcx> Repr<'tcx> for LoanPath {
fn repr(&self, tcx: &ty::ctxt) -> String {
match self {
&LpVar(id) => {
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,
}
}
-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) {
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,
}
}
-impl euv::Delegate for GlobalChecker {
+impl<'tcx> euv::Delegate<'tcx> for GlobalChecker {
fn consume(&mut self,
consume_id: ast::NodeId,
_consume_span: Span,
/// 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
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);
fn mutate(&mut self,
assignment_id: ast::NodeId,
assignment_span: Span,
- assignee_cmt: mc::cmt,
+ assignee_cmt: mc::cmt<'tcx>,
mode: MutateMode);
}
// 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
)
)
-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 }
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);
}
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);
}
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;
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;
}
}
-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 }
}
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 {
}
}
- 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");
}
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, _, _) =>
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
}
// (`@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:
}
}
-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,
*/
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 {
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.
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,
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));
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);
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
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 {
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,
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(),
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(),
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),
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 {
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
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(),
// 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
}
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:
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(),
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(),
}
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
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 {
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.
}
}
- 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.
// 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 {
}
}
-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,
}
}
-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(..) |
}
}
-impl Repr for InteriorKind {
+impl<'tcx> Repr<'tcx> for InteriorKind {
fn repr(&self, _tcx: &ty::ctxt) -> String {
match *self {
InteriorField(NamedField(fld)) => {
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;
* `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,
}
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
}
}
- 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 }
}
}
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);
// `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
{
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,
}
}
- 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;
}
}
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 {
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
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 {
* 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
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,
}
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));
}
}
- 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
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
* 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,
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,
#[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,
}
* 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`
* 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>),
* 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>
}
* 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`
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:
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(),
}
}
- 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()),
}
}
- 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),
}
}
-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,
}
}
- 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,
}
}
-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 }
}
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
}
// 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 {
* 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
}
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 {
}
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 {
// 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
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()),
// we can be sure it does not.
pub fn evaluate_obligation(&mut self,
- obligation: &Obligation)
+ obligation: &Obligation<'tcx>)
-> bool
{
/*!
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(
}
}
- 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()));
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
pub fn evaluate_impl(&mut self,
impl_def_id: ast::DefId,
- obligation: &Obligation)
+ obligation: &Obligation<'tcx>)
-> bool
{
/*!
// 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
{
/*!
}
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)
{
/*!
}
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<(),()>
{
/*!
}
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>
{
/*!
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
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
{
/*!
// 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.
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));
}
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
}
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();
}
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.
}
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
}
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
}
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`.
// 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
})
}
- 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() {
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`.
// 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
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 {
}
};
- 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();
// 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()),
}
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()),
}
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()));
}
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(
}
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()),
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,
}
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()),
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) => {
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();
}
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={}",
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
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
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
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
// 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);
}
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);
}
}
-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),
}
}
-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;
}
}
-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))
}
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>
{
/*!
}
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());
}
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() {
}
}
-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() {
// 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` */
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() {
}
}
-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) => {
}
}
-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 {
}
}
-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
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),
}
}
-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),
}
}
-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"),
}
}
-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")
}
}
-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),
}
}
-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)
}
}
// 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)]
}
#[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),
}
}
- 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
}
#[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,
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,
}
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
-pub struct mt {
- pub ty: Ty,
+pub struct mt<'tcx> {
+ pub ty: Ty<'tcx>,
pub mutbl: ast::Mutability,
}
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)]
}
#[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
// 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 }, _) => {
/// 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,
}
/// 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,
/// 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>>,
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>>,
/// 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>,
/// 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>>>>,
}
#[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.
}
}
-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>
}
}
}
-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)
}
#[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!()
}
}
* 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
}
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,
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,
// 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),
/// 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
}
#[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
}
* 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>,
}
/**
// 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>),
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>),
/// 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
}
}
-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, "(...)")
}
#[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)]
/// 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() }
}
!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)),
* [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() }
}
}
}
-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
/// 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
///
/// 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 {
/// - `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,
}
}
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>,
// 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(),
};
match cx.interner.borrow().get(&st) {
- Some(ty) => return ty,
+ Some(ty) => return *ty,
_ => ()
}
cx.interner.borrow_mut().insert(InternedTy { ty: ty }, ty);
- Ty { inner: ty }
+ ty
}
struct FlagComputation {
}
#[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(),
}
}
-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(),
}
}
-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(),
}
#[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),
})
}
-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),
})
}
-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 {
}
-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,
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;
}
}
// 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)
}
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)
}
}
}
-impl ItemSubsts {
- pub fn empty() -> ItemSubsts {
+impl<'tcx> ItemSubsts<'tcx> {
+ pub fn empty() -> ItemSubsts<'tcx> {
ItemSubsts { substs: Substs::empty() }
}
}
}
-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(),
}
}
-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),
}
}
-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);
}
}
-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,
}
}
-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)
}
// 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;
}
}
-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
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)
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| {
// 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);
}
}
}
-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));
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));
/// 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))
}
}
- 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)) => {
// 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));
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),
}
// 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)
// 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) => {
//
// 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 {
}
}
-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,
}
}
-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 {}",
}
}
-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,
}
// 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
}
// 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
// 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()),
}
}
-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(
}
}
-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(
}
}
-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(),
}
}
-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(),
}
// 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(),
}
}
-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,
// 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);
}
// 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`
}
}
-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 {
};
}
-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,
// 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)) => {
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 => {
}
}
-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,
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)) => {
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,
}
}
-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
})
}
-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);
// 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 {
}
}
-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<_>>();
}
}
-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))
}
// 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")
// 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))
/// 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);
// 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 {
// 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,
// 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()),
}).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.
}
}
-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;
}
}
- 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))
}
}
/// 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;
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
}
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 {
// 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) {
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
}
}
-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")
}
}
-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
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 */
}
}
- 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={}",
}
}
- 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())
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
}
}
fn unboxed_closures<'a>(&'a self)
- -> &'a RefCell<DefIdMap<UnboxedClosure>> {
+ -> &'a RefCell<DefIdMap<UnboxedClosure<'tcx>>> {
&self.unboxed_closures
}
}
}
}
-impl AutoAdjustment {
+impl<'tcx> AutoAdjustment<'tcx> {
pub fn is_identity(&self) -> bool {
match *self {
AdjustAddEnv(..) => false,
}
}
-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
|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`.
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`.
/// 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
/// 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)
}
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)
}
}
// 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();
}
}
-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
}
}
-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)
}
}
-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);
}
}
-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),
}
}
-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,
}
}
-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,
}
}
-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),
}
}
-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),
}
}
-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),
}
}
-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),
}
}
-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) => {
}
}
-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),
}
// 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
}
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);
}
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),
}
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
}
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,
}
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),
}
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);
}
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,
}
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))
}
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),
}
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),
}
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,
/**
* 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))
}
}
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)
}
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)
}
}
}
-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);
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)
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
{
/*!
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();
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<_> =
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();
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)
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
{
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);
rscope: &RS,
did: ast::DefId,
path: &ast::Path)
- -> TypeAndSubsts
+ -> TypeAndSubsts<'tcx>
{
let tcx = this.tcx();
let ty::Polytype {
rscope: &RS,
did: ast::DefId,
path: &ast::Path)
- -> TypeAndSubsts
+ -> TypeAndSubsts<'tcx>
where AC : AstConv<'tcx>, RS : RegionScope
{
let tcx = this.tcx();
}
}
-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) {
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 => {}
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();
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={})",
// 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()));
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),
}
}
-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,
}
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");
}, 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 {
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()));
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
{
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();
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
}
}
-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,
span: Span,
builtin_bounds: ty::BuiltinBounds,
region_bounds: &[&ast::Lifetime],
- trait_bounds: &[Rc<ty::TraitRef>])
+ trait_bounds: &[Rc<ty::TraitRef<'tcx>>])
-> ty::Region
{
/*!
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;
}
}
-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(
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;
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;
/// `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.
// 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) {
}
}
-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) => {
}
// 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),
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()),
}
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);
// 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);
fn create_ty_adjustment(&mut self,
adjustment: &probe::PickAdjustment)
- -> ty::AutoDerefRef
+ -> ty::AutoDerefRef<'tcx>
{
match *adjustment {
probe::AutoDeref(num) => {
//
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*
}
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
}
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
}
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(_) => {}
//
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
}
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()),
}
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 {
}
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));
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.
}
}
-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
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 },
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
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) => {
}
}
-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,
.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();
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
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()),
})
}
-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, _) =
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>
{
}
}
- 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()));
}
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()));
}
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;
// 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();
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(),
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.
///////////////////////////////////////////////////////////////////////////
// THE ACTUAL SEARCH
- fn pick(mut self) -> PickResult {
+ fn pick(mut self) -> PickResult<'tcx> {
let steps = self.steps.clone();
for step in steps.iter() {
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) {
}
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(
}
fn pick_autorefrefd_method(&mut self,
- step: &CandidateStep)
- -> Option<PickResult>
+ step: &CandidateStep<'tcx>)
+ -> Option<PickResult<'tcx>>
{
let tcx = self.tcx();
self.search_mutabilities(
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.
.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) => {
}
}
- 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");
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))
})
}
- 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()));
})
}
- 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
///////////////////////////////////////////////////////////////////////////
// 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)
}
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()));
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);
}
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`
}
}
-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();
.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,
// 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
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),
}
}
-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)),
}
}
-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,
/// 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
// 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)]
// 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>,
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 {
-> 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),
// 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 {
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, ¶m_env.free_substs);
}
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
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,
}
}
-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.
*
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);
* - 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));
// 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
{
/*!
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
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()
}
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()
}
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 => {
}
#[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);
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,
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() {
fn register_adjustment_obligations(&self,
span: Span,
- adj: &ty::AutoAdjustment) {
+ adj: &ty::AutoAdjustment<'tcx>) {
match *adj {
ty::AdjustAddEnv(..) => { }
ty::AdjustDerefRef(ref d_r) => {
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);
fn register_unsize_obligations(&self,
span: Span,
- unsize: &ty::UnsizeKind) {
+ unsize: &ty::UnsizeKind<'tcx>) {
debug!("register_unsize_obligations: unsize={}", unsize);
match *unsize {
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
}
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(
}
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()));
.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,
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 => {
}
}
- 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.
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`
.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 => {
}
}
- 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 => { }
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),
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)
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)
{
/*!
}
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`),
}
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));
}
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());
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 =
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
}
/// 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) {
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()) {
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
}
}
-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
}
}
-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
})
}
-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
})
}
-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)
///
/// 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) => {
}
}
-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,
}
}
-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
}
}
-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()
}
// 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;
}
}
-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, || ())
}
// 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);
// 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))
/// 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);
// 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
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
}
}
- 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 {
})
}
- 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| {
.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={})",
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();
});
}
-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)
// 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
}
}
- 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,
}
}
-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({})",
}
}
-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);
/// 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.
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
}
}
- 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();
}
// 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);
// 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()),
}
}
- 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
}
}
- 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);
}
}
- 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
}
}
- 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);
// 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);
}
// 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
}
}}))
}
-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));
}
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))
}
}
}
-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),
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.
// 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>,
// 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 {
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
}
/// 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
}
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`.
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
}
}
fn unboxed_closures<'a>(&'a self)
- -> &'a RefCell<DefIdMap<ty::UnboxedClosure>> {
+ -> &'a RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>> {
&self.fcx.inh.unboxed_closures
}
}
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()));
}
}
-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
}
-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
}
}
-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)
{
}
}
-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.
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
}
}
-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`.
}
}
-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
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
}
}
-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={})",
}
}
-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`.
}
}
-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={})",
// 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
}
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));
}
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:
//
}
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` */
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.
}
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, _) => {
}
fn accumulate_from_object_ty(&mut self,
- ty: Ty,
+ ty: Ty<'tcx>,
bounds: &ty::ExistentialBounds)
{
// Imagine a type like this:
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()),
}
}
- // 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")
(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,
// 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?
}
// 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
}
}
-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.
}
}
-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(
(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);
}
}
-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 => {
}
}
-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
}
}
-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 {
pub struct CheckTypeWellFormedVisitor<'ccx, 'tcx:'ccx> {
ccx: &'ccx CrateCtxt<'ccx, 'tcx>,
- cache: HashSet<Ty>
+ cache: HashSet<Ty<'tcx>>
}
impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
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,
* 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)));
}
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 =
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));
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));
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));
}
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);
}
}
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):
}
}
- 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;
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()));
///////////////////////////////////////////////////////////////////////////
// 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()
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 {
///////////////////////////////////////////////////////////////////////////
// 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)
}
}
- 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))
}
}
///////////////////////////////////////////////////////////////////////////
// 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)
}
}
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;
}
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,
}
// 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) => {
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={})",
}
fn get_self_type_for_implementation(&self, impl_did: DefId)
- -> Polytype {
+ -> Polytype<'tcx> {
self.crate_context.tcx.tcache.borrow()[impl_did].clone()
}
}
}
-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
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);
///////////////////////////////////////////////////////////////////////////
// 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)
}
}
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)
}
}
}
- 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.
}
}
-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) => {
_ => { /* 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 {
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,
}
}
-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 */
}
}
-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
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),
.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,
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,
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> {
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
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 {
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> {
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
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
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> {
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)
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
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> {
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.
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.
}
}
-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
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
}
}
-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.
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)
}
}
}
-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) {
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 =
}
}
-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) {
}
}
-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) => {
}
}
-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,
}
}
-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(),
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,
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,
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;
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
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(¶m.id) {
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
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) {
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);
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(_, _, _) => (),
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(
/// 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)
{
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));
})
}
- 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) {
// ~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));
// 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));
// 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;
}
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;
}
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;
}
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;
}
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));
}
}
- 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
}
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));
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.
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))
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();
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();
}
}
- 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));
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),
})
}
- 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 {
}
}
- 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));
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) {
}
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
}
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>(
}
}
-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;
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 {
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))
}
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();
}
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
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
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),
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));
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 {
}
}
- 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 {
fn builtin_bounds(&self,
a: BuiltinBounds,
b: BuiltinBounds)
- -> cres<BuiltinBounds>
+ -> cres<'tcx, BuiltinBounds>
{
// More bounds is a subtype of fewer bounds.
//
}
}
- 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); }
}
}
- 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)
}
// 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,
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() {
// 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();
}
}
- 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 => {
}
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.
}
}
- 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_param_bound_failure(&self,
- origin: SubregionOrigin,
+ origin: SubregionOrigin<'tcx>,
param_ty: ty::ParamTy,
sub: Region,
_sups: Vec<Region>) {
}
fn report_concrete_failure(&self,
- origin: SubregionOrigin,
+ origin: SubregionOrigin<'tcx>,
sub: Region,
sup: Region) {
match origin {
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);
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);
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());
}
}
-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,
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 {
}
}
-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 {
}
}
-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 {
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({}, {})",
}
}
- 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)
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),
}
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)
}
}
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()));
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".
}
}
- 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()));
}
}
-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(
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())
}
}
-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 {
}
}
-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,
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));
}
}
-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));
}
}
-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(),
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({}, {})",
}
}
- 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)
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()),
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)
}
}
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>,
// 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:
/// 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
///
/// 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
// 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.
// 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),
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),
///
/// 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),
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),
}
}
-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
}
}
-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(|| {
})
}
-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 {
})
}
-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 {
}).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),
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));
}
}
-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(|| {
}
// 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))
}
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))
}
}
-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()
}
}
-pub fn uok() -> ures {
+pub fn uok<'tcx>() -> ures<'tcx> {
Ok(())
}
}
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())
}
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))
}
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(|| {
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 {
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),
.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())
}
.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)))
}
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
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
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) {
}
}
- 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()
}
}
- 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) {
}
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(),
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)
}
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| {
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.
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 {
lbrct: LateBoundRegionConversionTime,
value: &T)
-> (T, FnvHashMap<ty::BoundRegion,ty::Region>)
- where T : HigherRankedFoldable
+ where T : HigherRankedFoldable<'tcx>
{
ty::replace_late_bound_regions(
self.tcx,
}
}
-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 {
}
}
-impl Repr for TypeTrace {
+impl<'tcx> Repr<'tcx> for TypeTrace<'tcx> {
fn repr(&self, tcx: &ty::ctxt) -> String {
format!("TypeTrace({})", self.origin.repr(tcx))
}
}
}
-impl Repr for TypeOrigin {
+impl<'tcx> Repr<'tcx> for TypeOrigin {
fn repr(&self, tcx: &ty::ctxt) -> String {
match *self {
MethodCompatCheck(a) => {
}
}
-impl SubregionOrigin {
+impl<'tcx> SubregionOrigin<'tcx> {
pub fn span(&self) -> Span {
match *self {
Subtype(ref a) => a.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))
}
}
-impl RegionVariableOrigin {
+impl<'tcx> RegionVariableOrigin<'tcx> {
pub fn span(&self) -> Span {
match *self {
MiscVariable(a) => a,
}
}
-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))
// 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)]
}
#[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>),
}
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
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 };
fn add_constraint(&self,
constraint: Constraint,
- origin: SubregionOrigin) {
+ origin: SubregionOrigin<'tcx>) {
// cannot add constraints once regions are resolved
assert!(self.values_are_none());
}
fn add_verify(&self,
- verify: Verify) {
+ verify: Verify<'tcx>) {
// cannot add verifys once regions are resolved
assert!(self.values_are_none());
}
pub fn make_eqregion(&self,
- origin: SubregionOrigin,
+ origin: SubregionOrigin<'tcx>,
sub: Region,
sup: Region) {
if sub != sup {
}
pub fn make_subregion(&self,
- origin: SubregionOrigin,
+ origin: SubregionOrigin<'tcx>,
sub: Region,
sup: Region) {
// cannot add constraints once regions are resolved
}
pub fn verify_param_bound(&self,
- origin: SubregionOrigin,
+ origin: SubregionOrigin<'tcx>,
param_ty: ty::ParamTy,
sub: Region,
sups: Vec<Region>) {
}
pub fn lub_regions(&self,
- origin: SubregionOrigin,
+ origin: SubregionOrigin<'tcx>,
a: Region,
b: Region)
-> Region {
}
pub fn glb_regions(&self,
- origin: SubregionOrigin,
+ origin: SubregionOrigin<'tcx>,
a: Region,
b: Region)
-> Region {
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 {
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);
fn glb_concrete_regions(&self,
a: Region,
b: Region)
- -> cres<Region> {
+ -> cres<'tcx, Region> {
debug!("glb_concrete_regions({}, {})", a, b);
match (a, b) {
(ReLateBound(..), _) |
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,
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))
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
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();
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() {
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()");
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.
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.
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 {
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) {
}
-impl Repr for Constraint {
+impl<'tcx> Repr<'tcx> for Constraint {
fn repr(&self, tcx: &ty::ctxt) -> String {
match *self {
ConstrainVarSubVar(a, b) => {
}
}
-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))
}
}
-impl Repr for VarValue {
+impl<'tcx> Repr<'tcx> for VarValue {
fn repr(&self, tcx: &ty::ctxt) -> String {
match *self {
NoValue => format!("NoValue"),
}
}
-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))
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)
}
(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})",
}
}
- 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) {
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) {
}
}
- 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);
}
}
}
- 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);
}
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> {
}
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); }
}
}
- 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),
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()
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()),
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()));
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
}
}
- 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); }
}
}
- 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)
}
}
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>),
}
}
}
-impl TypeVariableTable {
- pub fn new() -> TypeVariableTable {
+impl<'tcx> TypeVariableTable<'tcx> {
+ pub fn new() -> TypeVariableTable<'tcx> {
TypeVariableTable { values: sv::SnapshotVec::new(Delegate) }
}
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
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) {
}
}
-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) {
*
* 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;
*
* 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 {
}
/**
// 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),
}
pub fn set(&mut self,
- tcx: &ty::ctxt,
+ tcx: &ty::ctxt<'tcx>,
key: K,
new_value: VarValue<K,V>)
{
}
pub fn unify(&mut self,
- tcx: &ty::ctxt,
+ tcx: &ty::ctxt<'tcx>,
node_a: &Node<K,V>,
node_b: &Node<K,V>)
-> (K, uint)
* 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}))
}
}
-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
a_is_expected: bool,
a_id: K,
b: V)
- -> ures
+ -> ures<'tcx>
{
/*!
* Sets the value of the key `a_id` to `b`. Because
}
}
- 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);
// 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 } }
}
}
-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 } }
}
}
-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)
}
#[deriving(Clone, Show)]
-pub enum MethodOrigin {
+pub enum MethodOrigin<'tcx> {
// fully statically resolved method
MethodStatic(ast::DefId),
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,
// 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,
}
#[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>
}
/**
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 {
// 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:
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({}:{}, {}, {})",
// 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.
}
// 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,
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()},
}
}
-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);
/// 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()));
/// 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);
/// 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() {
/// 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 => {
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,
}
}
-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))
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 => {}
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 {
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()
}
// 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(),
}
}
-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() {
}
}
-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();
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),
}
}
-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))
}
}
-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),
}
}
-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),
}
}
-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),
}
}
-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(),
}
}
-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() {
}
}
-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() {
}
}
-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.
}
}
-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),
}
}
-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={})",
}
}
-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),
}
}
-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),
}
}
-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) => {
}
}
-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,
}
}
-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
}
}
-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={})",
}
}
-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
}
}
-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),
}
}
-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(),
}
}
-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)),
}
}
-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),
}
}
-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))
}
}
-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,
}
}
-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(),
}
}
-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() {
}
}
-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
}
}
-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))
}
}
-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
}
}
-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,
}
}
-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),
}
}
-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) => {
}
}
-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;
}
}
-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))
}
}
// 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.
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 => {}
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,
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)];
/// 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();
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 {
}
}
- 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: {}",
}
}
- 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),
}
}
- 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,
})
}
- 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))
}
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())
}
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()
}
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: {}",
}
/// 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);
}
/// 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),
// 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)) => {
}
}
- 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 {
* - `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>
}
/**
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
// 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![];
}
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> {
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
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,
}
fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
- bindings_map: &BindingsMap,
+ bindings_map: &BindingsMap<'tcx>,
cs: Option<cleanup::ScopeId>)
-> 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,
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,
}
}
-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
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> {
/*!
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);
/// 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)
/**
* 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.
* 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.
*/
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
* 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>>
}
/**
* 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(),
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);
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);
}
// this should probably all be in ty
-struct Case {
+struct Case<'tcx> {
discr: Disr,
- tys: Vec<Ty>
+ tys: Vec<Ty<'tcx>>
}
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
}
}
-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)
}).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()
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),
}
}
-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)
}
// 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
(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);
* 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, .. } =>
}
}
-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),
}
}
-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()
*
* 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 { .. } => {
/// 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;
* 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);
}
/// 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.
}
}
-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<_>>();
}
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 {
}
/// 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 {
* 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);
/**
* 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;
* 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);
#![allow(non_camel_case_types)]
-pub use self::IsUnboxedClosureFlag::*;
pub use self::ValueOrigin::*;
pub use self::scalar_type::*;
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};
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 => ()
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 {
(*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)
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) {
// 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));
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) => {
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> {
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();
// 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(),
_ => { }
}
-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);
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));
}
}
-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 {
}
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");
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",
}
}
-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) => {
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.
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
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) {
}
}
-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;
// 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;
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);
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 {
}
// 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`
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> {
/// 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.
// - 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 {
}
// 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
/// 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 {
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");
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);
// 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() {
}
// 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);
}
}
-#[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: ¶m_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: ¶m_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");
let fcx = new_fn_ctxt(ccx,
llfndecl,
fn_ast_id,
- has_env,
+ closure_env.kind != closure::NotClosure,
output_type,
param_substs,
Some(body.span),
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: {}",
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,
}
};
- 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
// 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: ¶m_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: ¶m_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");
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: ¶m_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: ¶m_substs<'tcx>,
+ llfndecl: ValueRef) {
let _icx = push_ctxt("trans_enum_variant");
trans_enum_variant_or_tuple_like_struct(
}
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,
Result::new(bcx, llresult)
}
-pub fn trans_tuple_struct(ccx: &CrateContext,
- _fields: &[ast::StructField],
- ctor_id: ast::NodeId,
- param_substs: ¶m_substs,
- llfndecl: ValueRef) {
+pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+ _fields: &[ast::StructField],
+ ctor_id: ast::NodeId,
+ param_substs: ¶m_substs<'tcx>,
+ llfndecl: ValueRef) {
let _icx = push_ctxt("trans_tuple_struct");
trans_enum_variant_or_tuple_like_struct(
llfndecl);
}
-fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
- ctor_id: ast::NodeId,
- disr: ty::Disr,
- param_substs: ¶m_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: ¶m_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);
}
}
-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);
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 {
}
}
-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);
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)
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,
/// 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();
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
{
/*!
// ______________________________________________________________________
// 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)),
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);
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
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>]),
// 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.
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)
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)
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");
}
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> {
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.
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 {
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`
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`
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`
*/
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.
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),
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
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.
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;
///////////////////////////////////////////////////////////////////////////
// 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
}
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 {
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
}
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 {
heap: Heap,
}
-impl Cleanup for FreeSlice {
+impl<'tcx> Cleanup<'tcx> for FreeSlice {
fn must_unwind(&self) -> bool {
true
}
ptr: ValueRef,
}
-impl Cleanup for LifetimeEnd {
+impl<'tcx> Cleanup<'tcx> for LifetimeEnd {
fn must_unwind(&self) -> bool {
false
}
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,
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;
}
// 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
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();
}
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
}
// 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");
// 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());
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);
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,
cdata_ty,
bcx
} = build_closure(bcx, freevar_mode, &freevars, store);
+
trans_closure(ccx,
decl,
body,
&[],
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
}
/// 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) {
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(),
&[],
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
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,
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, _) |
}
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> {
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);
}
}
-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;
}
}
-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.
*/
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,
// 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(),
}
}
}
-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: ¶m_substs)
+pub trait SubstP<'tcx> {
+ fn substp(&self, tcx: &ty::ctxt<'tcx>, param_substs: ¶m_substs<'tcx>)
-> Self;
}
-impl<T: Subst + Clone> SubstP for T {
- fn substp(&self, tcx: &ty::ctxt, substs: ¶m_substs) -> T {
+impl<'tcx, T: Subst<'tcx> + Clone> SubstP<'tcx> for T {
+ fn substp(&self, tcx: &ty::ctxt<'tcx>, substs: ¶m_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.
// 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>>,
// 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.
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),
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())
}
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()
.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
}
}
fn unboxed_closures<'a>(&'a self)
- -> &'a RefCell<DefIdMap<ty::UnboxedClosure>> {
+ -> &'a RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>> {
&self.tcx().unboxed_closures
}
}
}
-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
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();
}
}
-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 {
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);
}
}
-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)
}
/// 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,
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>,
/// 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>>,
/// 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>>,
/// 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,
}
}
-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);
/// 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,
self.shared
}
- pub fn local(&self) -> &'b LocalCrateContext {
+ pub fn local(&self) -> &'b LocalCrateContext<'tcx> {
self.local
}
&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
}
&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
}
&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
}
&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
}
&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
}
&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
}
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
}
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
}
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())
* 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,
pub struct DatumBlock<'blk, 'tcx: 'blk, K> {
pub bcx: Block<'blk, 'tcx>,
- pub datum: Datum<K>,
+ pub datum: Datum<'tcx, K>,
}
#[deriving(Show)]
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,
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
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
}
}
-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 => {
fn post_store<'blk, 'tcx>(&self,
bcx: Block<'blk, 'tcx>,
val: ValueRef,
- ty: Ty)
+ ty: Ty<'tcx>)
-> Block<'blk, 'tcx>;
/**
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.
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
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),
}
}
-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;
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,
}
}
- 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),
}
}
- 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)
* 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 {
}
#[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.
*/
|_| 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.
*/
|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);
}
}
- 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.
})
}
- 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.
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),
})
}
- 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).
* 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
// 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(_) => {
/**
* 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
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
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,
}
#[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
}
}
- 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 }
}
}
// 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(),
// 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());
}
}
- 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()
}
// 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:)*}
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 {
}
}
- 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,
// 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)
/// 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,
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
/// 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;
}
/// 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;
}
/// 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: ¶m_substs,
- llfn: ValueRef) -> FunctionDebugContext {
+pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
+ fn_ast_id: ast::NodeId,
+ param_substs: ¶m_substs<'tcx>,
+ llfn: ValueRef) -> FunctionDebugContext {
if cx.sess().opts.debuginfo == NoDebugInfo {
return FunctionDebugContext { repr: DebugInfoDisabled };
}
return FunctionDebugContext { repr: DebugInfo(fn_debug_context) };
- fn get_function_signature(cx: &CrateContext,
- fn_ast_id: ast::NodeId,
- fn_decl: &ast::FnDecl,
- param_substs: ¶m_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: ¶m_substs<'tcx>,
+ error_reporting_span: Span) -> DIArray {
if cx.sess().opts.debuginfo == LimitedDebugInfo {
return create_DIArray(DIB(cx), &[]);
}
return create_DIArray(DIB(cx), signature.as_slice());
}
- fn get_template_parameters(cx: &CrateContext,
- generics: &ast::Generics,
- param_substs: ¶m_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: ¶m_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:
}
}
-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();
})
}
-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));
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);
// 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)
// 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();
}
}
-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 {
//=-----------------------------------------------------------------------------
// 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();
}
}
-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);
//=-----------------------------------------------------------------------------
// 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(),
}
}
-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);
// 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
}
// 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(),
// 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()
(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);
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);
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
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
// 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.
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();
}
#[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
}
// 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
// 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"),
// 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;
}
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`,
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;
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 {}",
// 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 {
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;
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);
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> {
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;
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();
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
}
};
- 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);
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");
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.
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.
}
}
-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
* 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>)>
}
/**
* - `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);
}
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;
// 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");
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;
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,
}
}
-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
}
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;
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;
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();
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.
///////////////////////////////////////////////////////////////////////////
// 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)
}
}
-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.
}
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
// 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 {
llfn
}
-pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
- decl: &ast::FnDecl,
- body: &ast::Block,
- attrs: &[ast::Attribute],
- llwrapfn: ValueRef,
- param_substs: ¶m_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: ¶m_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);
return build_wrap_fn(ccx, llrustfn, llwrapfn, &tys, mty);
}
- fn build_rust_fn(ccx: &CrateContext,
- decl: &ast::FnDecl,
- body: &ast::Block,
- param_substs: ¶m_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: ¶m_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(
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();
}
}
-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
}
}
-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")
}
}
-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))
}
}
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);
}
}
-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.
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.
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");
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));
}
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) {
}
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);
})
}
-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) {
}
}
-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");
}
// 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());
}
}
-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,
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);
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;
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);
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);
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
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 {
}
}
-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
}
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)
}
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> {
/// `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()),
}
}
-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();
}
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> {
/*!
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={}, \
}
#[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>>
}
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);
})
}
-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),
}
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)
}
}
-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);
}
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> {
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> {
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() => {}
}
}
-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()
/// 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()
}
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.
}
// 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,
// 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 => ()
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 {
}
// 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).
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)
}
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",
}
}
-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))
}