diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index 7ee8b33b1fa..914cf451ebe 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/middle/def.rs @@ -14,7 +14,7 @@ use syntax::ast_util::local_def; use std::gc::Gc; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Def { DefFn(ast::DefId, ast::FnStyle), DefStaticMethod(/* method */ ast::DefId, MethodProvenance, ast::FnStyle), @@ -51,7 +51,7 @@ pub enum Def { DefMethod(ast::DefId /* method */, Option /* trait */), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum MethodProvenance { FromTrait(ast::DefId), FromImpl(ast::DefId), diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index d432ced5226..98aef8ca493 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -121,7 +121,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t // If this trait has builtin-kind supertraits, meet them. let self_ty: ty::t = ty::node_id_to_type(cx.tcx, it.id); - debug!("checking impl with self type {:?}", ty::get(self_ty).sty); + debug!("checking impl with self type {}", ty::get(self_ty).sty); check_builtin_bounds(cx, self_ty, trait_def.bounds, |missing| { cx.tcx.sess.span_err(self_type.span, format!("the type `{}', which does not fulfill `{}`, cannot implement this \ diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 4684bd3532e..8f7c157308e 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -15,6 +15,7 @@ use middle::ty_fold; use middle::ty_fold::{TypeFoldable, TypeFolder}; use util::ppaux::Repr; +use std::fmt; use std::mem; use std::raw; use std::slice::{Items, MutItems}; @@ -83,7 +84,7 @@ impl HomogeneousTuple3 for (T, T, T) { * space* (which indices where the parameter is defined; see * `ParamSpace`). */ -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct Substs { pub types: VecPerParamSpace, pub regions: RegionSubsts, @@ -93,7 +94,7 @@ pub struct Substs { * Represents the values to use when substituting lifetime parameters. * If the value is `ErasedRegions`, then this subst is occurring during * trans, and all region parameters will be replaced with `ty::ReStatic`. */ -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum RegionSubsts { ErasedRegions, NonerasedRegions(VecPerParamSpace) @@ -275,6 +276,17 @@ pub struct VecPerParamSpace { content: Vec, } +impl fmt::Show for VecPerParamSpace { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + try!(write!(fmt, "VecPerParamSpace {{")); + for space in ParamSpace::all().iter() { + try!(write!(fmt, "{}: {}, ", *space, self.get_slice(*space))); + } + try!(write!(fmt, "}}")); + Ok(()) + } +} + impl VecPerParamSpace { pub fn push_all(&mut self, space: ParamSpace, values: &[T]) { // FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n). diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index eee53b79763..fcc2f008fc6 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -124,7 +124,7 @@ impl Method { } } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct mt { pub ty: t, pub mutbl: ast::Mutability, @@ -138,7 +138,7 @@ pub enum TraitStore { RegionTraitStore(Region, ast::Mutability), } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct field_ty { pub name: Name, pub id: DefId, @@ -394,6 +394,7 @@ pub enum tbox_flag { pub type t_box = &'static t_box_; +#[deriving(Show)] pub struct t_box_ { pub sty: sty, pub id: uint, @@ -436,14 +437,14 @@ pub fn type_needs_infer(t: t) -> bool { } pub fn type_id(t: t) -> uint { get(t).id } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct BareFnTy { pub fn_style: ast::FnStyle, pub abi: abi::Abi, pub sig: FnSig, } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct ClosureTy { pub fn_style: ast::FnStyle, pub onceness: ast::Onceness, @@ -472,7 +473,7 @@ pub struct FnSig { pub variadic: bool } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct ParamTy { pub space: subst::ParamSpace, pub idx: uint, @@ -712,7 +713,7 @@ mod primitives { // 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)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum sty { ty_nil, ty_bot, @@ -741,14 +742,14 @@ pub enum sty { // on non-useful type error messages) } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct TyTrait { pub def_id: DefId, pub substs: Substs, pub bounds: BuiltinBounds } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub struct TraitRef { pub def_id: DefId, pub substs: Substs, @@ -808,7 +809,7 @@ pub enum type_err { terr_variadic_mismatch(expected_found) } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub struct ParamBounds { pub builtin_bounds: BuiltinBounds, pub trait_bounds: Vec> @@ -948,7 +949,7 @@ impl fmt::Show for IntVarValue { } } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct TypeParameterDef { pub ident: ast::Ident, pub def_id: ast::DefId, @@ -958,7 +959,7 @@ pub struct TypeParameterDef { pub default: Option } -#[deriving(Encodable, Decodable, Clone)] +#[deriving(Encodable, Decodable, Clone, Show)] pub struct RegionParameterDef { pub name: ast::Name, pub def_id: ast::DefId, @@ -968,7 +969,7 @@ pub struct RegionParameterDef { /// Information about the type/lifetime parameters associated with an /// item or method. Analogous to ast::Generics. -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct Generics { pub types: VecPerParamSpace, pub regions: VecPerParamSpace, @@ -1014,7 +1015,7 @@ pub struct ParameterEnvironment { /// - `generics`: the set of type parameters and their bounds /// - `ty`: the base types, which may reference the parameters defined /// in `generics` -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct Polytype { pub generics: Generics, pub ty: t diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 90331d8f434..5ed92b305be 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -141,7 +141,7 @@ pub fn opt_ast_region_to_region( } }; - debug!("opt_ast_region_to_region(opt_lifetime={:?}) yields {}", + debug!("opt_ast_region_to_region(opt_lifetime={}) yields {}", opt_lifetime.as_ref().map(|e| lifetime_to_string(e)), r.repr(this.tcx())); @@ -504,6 +504,7 @@ pub fn ast_ty_to_builtin_ty ty::t) -> ty::t { let tcx = this.tcx(); - debug!("mk_pointer(ptr_ty={:?})", ptr_ty); + debug!("mk_pointer(ptr_ty={})", ptr_ty); match a_seq_ty.ty.node { ast::TyVec(ref ty) => { diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 757b715ec93..28240686dc3 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -246,7 +246,7 @@ impl<'a> RegionVarBindings<'a> { if self.in_snapshot() { self.undo_log.borrow_mut().push(AddVar(vid)); } - debug!("created new region variable {:?} with origin {:?}", + debug!("created new region variable {} with origin {}", vid, origin.repr(self.tcx)); return vid; }