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
|
|
@ -13,7 +13,7 @@ use middle::def_id::DefId;
|
|||
use middle::subst::{self, Subst};
|
||||
use middle::ty::{BrAnon, BrEnv, BrFresh, BrNamed};
|
||||
use middle::ty::{TyBool, TyChar, TyStruct, TyEnum};
|
||||
use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyBareFn};
|
||||
use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr};
|
||||
use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple};
|
||||
use middle::ty::TyClosure;
|
||||
use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
|
||||
|
|
@ -812,7 +812,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
|
|||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
TyBareFn(opt_def_id, ref bare_fn) => {
|
||||
TyFnDef(def_id, ref bare_fn) => {
|
||||
if bare_fn.unsafety == hir::Unsafety::Unsafe {
|
||||
try!(write!(f, "unsafe "));
|
||||
}
|
||||
|
|
@ -823,12 +823,20 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
|
|||
|
||||
try!(write!(f, "{}", bare_fn.sig.0));
|
||||
|
||||
if let Some(def_id) = opt_def_id {
|
||||
try!(write!(f, " {{{}}}", ty::tls::with(|tcx| {
|
||||
tcx.item_path_str(def_id)
|
||||
})));
|
||||
write!(f, " {{{}}}", ty::tls::with(|tcx| {
|
||||
tcx.item_path_str(def_id)
|
||||
}))
|
||||
}
|
||||
TyFnPtr(ref bare_fn) => {
|
||||
if bare_fn.unsafety == hir::Unsafety::Unsafe {
|
||||
try!(write!(f, "unsafe "));
|
||||
}
|
||||
Ok(())
|
||||
|
||||
if bare_fn.abi != Abi::Rust {
|
||||
try!(write!(f, "extern {} ", bare_fn.abi));
|
||||
}
|
||||
|
||||
write!(f, "{}", bare_fn.sig.0)
|
||||
}
|
||||
TyInfer(infer_ty) => write!(f, "{}", infer_ty),
|
||||
TyError => write!(f, "[type error]"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue