Track fn type and lifetime parameters in TyFnDef.

This commit is contained in:
Eduard Burtescu 2016-02-16 18:36:41 +02:00
parent b423a0f9ef
commit ffa0860467
44 changed files with 130 additions and 116 deletions

View file

@ -472,7 +472,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
variant.name,
ctor_ty);
let field_tys = match ctor_ty.sty {
ty::TyFnDef(_, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
ty::TyFnDef(_, _, &ty::BareFnTy { sig: ty::Binder(ty::FnSig {
ref inputs, ..
}), ..}) => {
// tuple-struct constructors don't have escaping regions
@ -988,7 +988,7 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
let predicates = doc_predicates(item_doc, tcx, cdata, tag_method_ty_generics);
let ity = tcx.lookup_item_type(def_id).ty;
let fty = match ity.sty {
ty::TyFnDef(_, fty) => fty.clone(),
ty::TyFnDef(_, _, fty) => fty.clone(),
_ => tcx.sess.bug(&format!(
"the type {:?} of the method {:?} is not a function?",
ity, name))
@ -1582,7 +1582,7 @@ pub fn is_extern_item(cdata: Cmd, id: DefIndex, tcx: &TyCtxt) -> bool {
let ty::TypeScheme { generics, ty } = get_type(cdata, id, tcx);
let no_generics = generics.types.is_empty();
match ty.sty {
ty::TyFnDef(_, fn_ty) | ty::TyFnPtr(fn_ty)
ty::TyFnDef(_, _, fn_ty) | ty::TyFnPtr(fn_ty)
if fn_ty.abi != Abi::Rust => return no_generics,
_ => no_generics,
}

View file

@ -380,7 +380,8 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
}
'F' => {
let def_id = self.parse_def();
return tcx.mk_fn_def(def_id, self.parse_bare_fn_ty());
let substs = self.tcx.mk_substs(self.parse_substs());
return tcx.mk_fn_def(def_id, substs, self.parse_bare_fn_ty());
}
'G' => {
return tcx.mk_fn_ptr(self.parse_bare_fn_ty());

View file

@ -135,9 +135,10 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Cursor<Vec<u8>>, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx
ty::TyStr => {
write!(w, "v");
}
ty::TyFnDef(def_id, f) => {
ty::TyFnDef(def_id, substs, f) => {
write!(w, "F");
write!(w, "{}|", (cx.ds)(def_id));
enc_substs(w, cx, substs);
enc_bare_fn_ty(w, cx, f);
}
ty::TyFnPtr(f) => {