diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2015-06-13 13:15:03 -0700 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-03-09 16:45:28 +0200 |
| commit | b423a0f9ef488ca4cd9ff620a44566bb441eb21f (patch) | |
| tree | ae43c17551512f743c1de53035a7f523b32aa6fa /src/librustc/util | |
| parent | 4b868411afee1208cfb18f7440df991b9f94265f (diff) | |
| download | rust-b423a0f9ef488ca4cd9ff620a44566bb441eb21f.tar.gz rust-b423a0f9ef488ca4cd9ff620a44566bb441eb21f.zip | |
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.
Diffstat (limited to 'src/librustc/util')
| -rw-r--r-- | src/librustc/util/ppaux.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 9c92208191e..2bf8879f3a0 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -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]"), |
