Split TyBareFn into TyFnDef and TyFnPtr.
There's a lot of stuff wrong with the representation of these types: TyFnDef doesn't actually uniquely identify a function, TyFnPtr is used to represent method calls, TyFnDef in the sub-expression of a cast isn't correctly reified, and probably some other stuff I haven't discovered yet. Splitting them seems like the right first step, though.
This commit is contained in:
parent
4b868411af
commit
b423a0f9ef
73 changed files with 406 additions and 324 deletions
|
|
@ -472,7 +472,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
|||
variant.name,
|
||||
ctor_ty);
|
||||
let field_tys = match ctor_ty.sty {
|
||||
ty::TyBareFn(_, &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::TyBareFn(_, 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,8 @@ 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::TyBareFn(_, fn_ty) if fn_ty.abi != Abi::Rust => return no_generics,
|
||||
ty::TyFnDef(_, fn_ty) | ty::TyFnPtr(fn_ty)
|
||||
if fn_ty.abi != Abi::Rust => return no_generics,
|
||||
_ => no_generics,
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -380,10 +380,10 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
}
|
||||
'F' => {
|
||||
let def_id = self.parse_def();
|
||||
return tcx.mk_fn(Some(def_id), tcx.mk_bare_fn(self.parse_bare_fn_ty()));
|
||||
return tcx.mk_fn_def(def_id, self.parse_bare_fn_ty());
|
||||
}
|
||||
'G' => {
|
||||
return tcx.mk_fn(None, tcx.mk_bare_fn(self.parse_bare_fn_ty()));
|
||||
return tcx.mk_fn_ptr(self.parse_bare_fn_ty());
|
||||
}
|
||||
'#' => {
|
||||
// This is a hacky little caching scheme. The idea is that if we encode
|
||||
|
|
|
|||
|
|
@ -135,12 +135,12 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Cursor<Vec<u8>>, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx
|
|||
ty::TyStr => {
|
||||
write!(w, "v");
|
||||
}
|
||||
ty::TyBareFn(Some(def_id), f) => {
|
||||
ty::TyFnDef(def_id, f) => {
|
||||
write!(w, "F");
|
||||
write!(w, "{}|", (cx.ds)(def_id));
|
||||
enc_bare_fn_ty(w, cx, f);
|
||||
}
|
||||
ty::TyBareFn(None, f) => {
|
||||
ty::TyFnPtr(f) => {
|
||||
write!(w, "G");
|
||||
enc_bare_fn_ty(w, cx, f);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue