1
Fork 0

libsyntax::ast: Derive Show impls

This commit is contained in:
Ben Gamari 2014-07-12 00:50:57 -04:00
parent de111e69a8
commit 69ffcdcccf
2 changed files with 82 additions and 70 deletions

View file

@ -152,7 +152,7 @@ impl<D:Decoder<E>, E> Decodable<D, E> for Ident {
/// Function name (not all functions have names) /// Function name (not all functions have names)
pub type FnIdent = Option<Ident>; pub type FnIdent = Option<Ident>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Lifetime { pub struct Lifetime {
pub id: NodeId, pub id: NodeId,
pub span: Span, pub span: Span,
@ -162,7 +162,7 @@ pub struct Lifetime {
/// A "Path" is essentially Rust's notion of a name; for instance: /// A "Path" is essentially Rust's notion of a name; for instance:
/// std::cmp::PartialEq . It's represented as a sequence of identifiers, /// std::cmp::PartialEq . It's represented as a sequence of identifiers,
/// along with a bunch of supporting information. /// along with a bunch of supporting information.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Path { pub struct Path {
pub span: Span, pub span: Span,
/// A `::foo` path, is relative to the crate root rather than current /// A `::foo` path, is relative to the crate root rather than current
@ -174,7 +174,7 @@ pub struct Path {
/// A segment of a path: an identifier, an optional lifetime, and a set of /// A segment of a path: an identifier, an optional lifetime, and a set of
/// types. /// types.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct PathSegment { pub struct PathSegment {
/// The identifier portion of this path segment. /// The identifier portion of this path segment.
pub identifier: Ident, pub identifier: Ident,
@ -208,7 +208,7 @@ pub static DUMMY_NODE_ID: NodeId = -1;
/// typeck::collect::compute_bounds matches these against /// typeck::collect::compute_bounds matches these against
/// the "special" built-in traits (see middle::lang_items) and /// the "special" built-in traits (see middle::lang_items) and
/// detects Copy, Send and Share. /// detects Copy, Send and Share.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum TyParamBound { pub enum TyParamBound {
TraitTyParamBound(TraitRef), TraitTyParamBound(TraitRef),
StaticRegionTyParamBound, StaticRegionTyParamBound,
@ -216,7 +216,7 @@ pub enum TyParamBound {
OtherRegionTyParamBound(Span) // FIXME -- just here until work for #5723 lands OtherRegionTyParamBound(Span) // FIXME -- just here until work for #5723 lands
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct TyParam { pub struct TyParam {
pub ident: Ident, pub ident: Ident,
pub id: NodeId, pub id: NodeId,
@ -228,7 +228,7 @@ pub struct TyParam {
/// Represents lifetimes and type parameters attached to a declaration /// Represents lifetimes and type parameters attached to a declaration
/// of a function, enum, trait, etc. /// of a function, enum, trait, etc.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Generics { pub struct Generics {
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
pub ty_params: OwnedSlice<TyParam>, pub ty_params: OwnedSlice<TyParam>,
@ -250,7 +250,7 @@ impl Generics {
/// used to drive conditional compilation /// used to drive conditional compilation
pub type CrateConfig = Vec<Gc<MetaItem>> ; pub type CrateConfig = Vec<Gc<MetaItem>> ;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Crate { pub struct Crate {
pub module: Mod, pub module: Mod,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -261,7 +261,7 @@ pub struct Crate {
pub type MetaItem = Spanned<MetaItem_>; pub type MetaItem = Spanned<MetaItem_>;
#[deriving(Clone, Encodable, Decodable, Eq, Hash)] #[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
pub enum MetaItem_ { pub enum MetaItem_ {
MetaWord(InternedString), MetaWord(InternedString),
MetaList(InternedString, Vec<Gc<MetaItem>>), MetaList(InternedString, Vec<Gc<MetaItem>>),
@ -293,7 +293,7 @@ impl PartialEq for MetaItem_ {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Block { pub struct Block {
pub view_items: Vec<ViewItem>, pub view_items: Vec<ViewItem>,
pub stmts: Vec<Gc<Stmt>>, pub stmts: Vec<Gc<Stmt>>,
@ -303,26 +303,26 @@ pub struct Block {
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Pat { pub struct Pat {
pub id: NodeId, pub id: NodeId,
pub node: Pat_, pub node: Pat_,
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct FieldPat { pub struct FieldPat {
pub ident: Ident, pub ident: Ident,
pub pat: Gc<Pat>, pub pat: Gc<Pat>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum BindingMode { pub enum BindingMode {
BindByRef(Mutability), BindByRef(Mutability),
BindByValue(Mutability), BindByValue(Mutability),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Pat_ { pub enum Pat_ {
PatWild, PatWild,
PatWildMulti, PatWildMulti,
@ -354,7 +354,7 @@ pub enum Mutability {
MutImmutable, MutImmutable,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum ExprVstore { pub enum ExprVstore {
/// ~[1, 2, 3, 4] /// ~[1, 2, 3, 4]
ExprVstoreUniq, ExprVstoreUniq,
@ -364,7 +364,7 @@ pub enum ExprVstore {
ExprVstoreMutSlice, ExprVstoreMutSlice,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum BinOp { pub enum BinOp {
BiAdd, BiAdd,
BiSub, BiSub,
@ -386,7 +386,7 @@ pub enum BinOp {
BiGt, BiGt,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum UnOp { pub enum UnOp {
UnBox, UnBox,
UnUniq, UnUniq,
@ -397,7 +397,7 @@ pub enum UnOp {
pub type Stmt = Spanned<Stmt_>; pub type Stmt = Spanned<Stmt_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Stmt_ { pub enum Stmt_ {
/// Could be an item or a local (let) binding: /// Could be an item or a local (let) binding:
StmtDecl(Gc<Decl>, NodeId), StmtDecl(Gc<Decl>, NodeId),
@ -414,7 +414,7 @@ pub enum Stmt_ {
/// Where a local declaration came from: either a true `let ... = /// Where a local declaration came from: either a true `let ... =
/// ...;`, or one desugared from the pattern of a for loop. /// ...;`, or one desugared from the pattern of a for loop.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum LocalSource { pub enum LocalSource {
LocalLet, LocalLet,
LocalFor, LocalFor,
@ -423,7 +423,7 @@ pub enum LocalSource {
// FIXME (pending discussion of #1697, #2178...): local should really be // FIXME (pending discussion of #1697, #2178...): local should really be
// a refinement on pat. // a refinement on pat.
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;` /// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Local { pub struct Local {
pub ty: P<Ty>, pub ty: P<Ty>,
pub pat: Gc<Pat>, pub pat: Gc<Pat>,
@ -435,7 +435,7 @@ pub struct Local {
pub type Decl = Spanned<Decl_>; pub type Decl = Spanned<Decl_>;
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Decl_ { pub enum Decl_ {
/// A local (let) binding: /// A local (let) binding:
DeclLocal(Gc<Local>), DeclLocal(Gc<Local>),
@ -444,7 +444,7 @@ pub enum Decl_ {
} }
/// represents one arm of a 'match' /// represents one arm of a 'match'
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Arm { pub struct Arm {
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub pats: Vec<Gc<Pat>>, pub pats: Vec<Gc<Pat>>,
@ -452,7 +452,7 @@ pub struct Arm {
pub body: Gc<Expr>, pub body: Gc<Expr>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Field { pub struct Field {
pub ident: SpannedIdent, pub ident: SpannedIdent,
pub expr: Gc<Expr>, pub expr: Gc<Expr>,
@ -461,26 +461,26 @@ pub struct Field {
pub type SpannedIdent = Spanned<Ident>; pub type SpannedIdent = Spanned<Ident>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum BlockCheckMode { pub enum BlockCheckMode {
DefaultBlock, DefaultBlock,
UnsafeBlock(UnsafeSource), UnsafeBlock(UnsafeSource),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum UnsafeSource { pub enum UnsafeSource {
CompilerGenerated, CompilerGenerated,
UserProvided, UserProvided,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Expr { pub struct Expr {
pub id: NodeId, pub id: NodeId,
pub node: Expr_, pub node: Expr_,
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Expr_ { pub enum Expr_ {
ExprVstore(Gc<Expr>, ExprVstore), ExprVstore(Gc<Expr>, ExprVstore),
/// First expr is the place; second expr is the value. /// First expr is the place; second expr is the value.
@ -547,7 +547,7 @@ pub enum Expr_ {
/// makes any real sense. You could write them elsewhere but nothing /// makes any real sense. You could write them elsewhere but nothing
/// else knows what to do with them, so you'll probably get a syntax /// else knows what to do with them, so you'll probably get a syntax
/// error. /// error.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[doc="For macro invocations; parsing is delegated to the macro"] #[doc="For macro invocations; parsing is delegated to the macro"]
pub enum TokenTree { pub enum TokenTree {
/// A single token /// A single token
@ -621,7 +621,7 @@ pub enum TokenTree {
// macro system. Congratulations. // macro system. Congratulations.
pub type Matcher = Spanned<Matcher_>; pub type Matcher = Spanned<Matcher_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Matcher_ { pub enum Matcher_ {
/// Match one token /// Match one token
MatchTok(::parse::token::Token), MatchTok(::parse::token::Token),
@ -638,7 +638,7 @@ pub type Mac = Spanned<Mac_>;
/// is being invoked, and the vector of token-trees contains the source /// is being invoked, and the vector of token-trees contains the source
/// of the macro invocation. /// of the macro invocation.
/// There's only one flavor, now, so this could presumably be simplified. /// There's only one flavor, now, so this could presumably be simplified.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Mac_ { pub enum Mac_ {
// NB: the additional ident for a macro_rules-style macro is actually // NB: the additional ident for a macro_rules-style macro is actually
// stored in the enclosing item. Oog. // stored in the enclosing item. Oog.
@ -670,13 +670,13 @@ pub enum Lit_ {
// NB: If you change this, you'll probably want to change the corresponding // NB: If you change this, you'll probably want to change the corresponding
// type structure in middle/ty.rs as well. // type structure in middle/ty.rs as well.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct MutTy { pub struct MutTy {
pub ty: P<Ty>, pub ty: P<Ty>,
pub mutbl: Mutability, pub mutbl: Mutability,
} }
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct TypeField { pub struct TypeField {
pub ident: Ident, pub ident: Ident,
pub mt: MutTy, pub mt: MutTy,
@ -685,7 +685,7 @@ pub struct TypeField {
/// Represents a required method in a trait declaration, /// Represents a required method in a trait declaration,
/// one without a default implementation /// one without a default implementation
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct TypeMethod { pub struct TypeMethod {
pub ident: Ident, pub ident: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -702,7 +702,7 @@ pub struct TypeMethod {
/// a default implementation A trait method is either required (meaning it /// a default implementation A trait method is either required (meaning it
/// doesn't have an implementation, just a signature) or provided (meaning it /// doesn't have an implementation, just a signature) or provided (meaning it
/// has a default implementation). /// has a default implementation).
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum TraitMethod { pub enum TraitMethod {
Required(TypeMethod), Required(TypeMethod),
Provided(Gc<Method>), Provided(Gc<Method>),
@ -779,7 +779,7 @@ impl FloatTy {
} }
// NB PartialEq method appears below. // NB PartialEq method appears below.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Ty { pub struct Ty {
pub id: NodeId, pub id: NodeId,
pub node: Ty_, pub node: Ty_,
@ -787,7 +787,7 @@ pub struct Ty {
} }
/// Not represented directly in the AST, referred to by name through a ty_path. /// Not represented directly in the AST, referred to by name through a ty_path.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum PrimTy { pub enum PrimTy {
TyInt(IntTy), TyInt(IntTy),
TyUint(UintTy), TyUint(UintTy),
@ -813,7 +813,7 @@ impl fmt::Show for Onceness {
} }
/// Represents the type of a closure /// Represents the type of a closure
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct ClosureTy { pub struct ClosureTy {
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
pub fn_style: FnStyle, pub fn_style: FnStyle,
@ -826,7 +826,7 @@ pub struct ClosureTy {
pub bounds: Option<OwnedSlice<TyParamBound>>, pub bounds: Option<OwnedSlice<TyParamBound>>,
} }
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct BareFnTy { pub struct BareFnTy {
pub fn_style: FnStyle, pub fn_style: FnStyle,
pub abi: Abi, pub abi: Abi,
@ -834,12 +834,12 @@ pub struct BareFnTy {
pub decl: P<FnDecl> pub decl: P<FnDecl>
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct UnboxedFnTy { pub struct UnboxedFnTy {
pub decl: P<FnDecl>, pub decl: P<FnDecl>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Ty_ { pub enum Ty_ {
TyNil, TyNil,
TyBot, /* bottom type */ TyBot, /* bottom type */
@ -863,13 +863,13 @@ pub enum Ty_ {
TyInfer, TyInfer,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum AsmDialect { pub enum AsmDialect {
AsmAtt, AsmAtt,
AsmIntel AsmIntel
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct InlineAsm { pub struct InlineAsm {
pub asm: InternedString, pub asm: InternedString,
pub asm_str_style: StrStyle, pub asm_str_style: StrStyle,
@ -882,7 +882,7 @@ pub struct InlineAsm {
} }
/// represents an argument in a function header /// represents an argument in a function header
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Arg { pub struct Arg {
pub ty: P<Ty>, pub ty: P<Ty>,
pub pat: Gc<Pat>, pub pat: Gc<Pat>,
@ -910,7 +910,7 @@ impl Arg {
} }
/// represents the header (not the body) of a function declaration /// represents the header (not the body) of a function declaration
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct FnDecl { pub struct FnDecl {
pub inputs: Vec<Arg>, pub inputs: Vec<Arg>,
pub output: P<Ty>, pub output: P<Ty>,
@ -935,7 +935,7 @@ impl fmt::Show for FnStyle {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum RetStyle { pub enum RetStyle {
/// Functions with return type ! that always /// Functions with return type ! that always
/// raise an error or exit (i.e. never return to the caller) /// raise an error or exit (i.e. never return to the caller)
@ -945,7 +945,7 @@ pub enum RetStyle {
} }
/// Represents the kind of 'self' associated with a method /// Represents the kind of 'self' associated with a method
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum ExplicitSelf_ { pub enum ExplicitSelf_ {
/// No self /// No self
SelfStatic, SelfStatic,
@ -959,7 +959,7 @@ pub enum ExplicitSelf_ {
pub type ExplicitSelf = Spanned<ExplicitSelf_>; pub type ExplicitSelf = Spanned<ExplicitSelf_>;
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Method { pub struct Method {
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub id: NodeId, pub id: NodeId,
@ -967,7 +967,7 @@ pub struct Method {
pub node: Method_ pub node: Method_
} }
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Method_ { pub enum Method_ {
/// Represents a method declaration /// Represents a method declaration
MethDecl(Ident, Generics, ExplicitSelf, FnStyle, P<FnDecl>, P<Block>, Visibility), MethDecl(Ident, Generics, ExplicitSelf, FnStyle, P<FnDecl>, P<Block>, Visibility),
@ -975,7 +975,7 @@ pub enum Method_ {
MethMac(Mac), MethMac(Mac),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Mod { pub struct Mod {
/// A span from the first token past `{` to the last token until `}`. /// A span from the first token past `{` to the last token until `}`.
/// For `mod foo;`, the inner span ranges from the first token /// For `mod foo;`, the inner span ranges from the first token
@ -985,31 +985,31 @@ pub struct Mod {
pub items: Vec<Gc<Item>>, pub items: Vec<Gc<Item>>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct ForeignMod { pub struct ForeignMod {
pub abi: Abi, pub abi: Abi,
pub view_items: Vec<ViewItem>, pub view_items: Vec<ViewItem>,
pub items: Vec<Gc<ForeignItem>>, pub items: Vec<Gc<ForeignItem>>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct VariantArg { pub struct VariantArg {
pub ty: P<Ty>, pub ty: P<Ty>,
pub id: NodeId, pub id: NodeId,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum VariantKind { pub enum VariantKind {
TupleVariantKind(Vec<VariantArg>), TupleVariantKind(Vec<VariantArg>),
StructVariantKind(Gc<StructDef>), StructVariantKind(Gc<StructDef>),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct EnumDef { pub struct EnumDef {
pub variants: Vec<P<Variant>>, pub variants: Vec<P<Variant>>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Variant_ { pub struct Variant_ {
pub name: Ident, pub name: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1021,7 +1021,7 @@ pub struct Variant_ {
pub type Variant = Spanned<Variant_>; pub type Variant = Spanned<Variant_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct PathListIdent_ { pub struct PathListIdent_ {
pub name: Ident, pub name: Ident,
pub id: NodeId, pub id: NodeId,
@ -1031,7 +1031,7 @@ pub type PathListIdent = Spanned<PathListIdent_>;
pub type ViewPath = Spanned<ViewPath_>; pub type ViewPath = Spanned<ViewPath_>;
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum ViewPath_ { pub enum ViewPath_ {
/// `quux = foo::bar::baz` /// `quux = foo::bar::baz`
@ -1048,7 +1048,7 @@ pub enum ViewPath_ {
ViewPathList(Path, Vec<PathListIdent> , NodeId) ViewPathList(Path, Vec<PathListIdent> , NodeId)
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct ViewItem { pub struct ViewItem {
pub node: ViewItem_, pub node: ViewItem_,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1056,7 +1056,7 @@ pub struct ViewItem {
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum ViewItem_ { pub enum ViewItem_ {
/// Ident: name used to refer to this crate in the code /// Ident: name used to refer to this crate in the code
/// optional (InternedString,StrStyle): if present, this is a location /// optional (InternedString,StrStyle): if present, this is a location
@ -1072,17 +1072,17 @@ pub type Attribute = Spanned<Attribute_>;
/// Distinguishes between Attributes that decorate items and Attributes that /// Distinguishes between Attributes that decorate items and Attributes that
/// are contained as statements within items. These two cases need to be /// are contained as statements within items. These two cases need to be
/// distinguished for pretty-printing. /// distinguished for pretty-printing.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum AttrStyle { pub enum AttrStyle {
AttrOuter, AttrOuter,
AttrInner, AttrInner,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct AttrId(pub uint); pub struct AttrId(pub uint);
/// Doc-comments are promoted to attributes that have is_sugared_doc = true /// Doc-comments are promoted to attributes that have is_sugared_doc = true
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Attribute_ { pub struct Attribute_ {
pub id: AttrId, pub id: AttrId,
pub style: AttrStyle, pub style: AttrStyle,
@ -1096,13 +1096,13 @@ pub struct Attribute_ {
/// that the ref_id is for. The impl_id maps to the "self type" of this impl. /// that the ref_id is for. The impl_id maps to the "self type" of this impl.
/// If this impl is an ItemImpl, the impl_id is redundant (it could be the /// If this impl is an ItemImpl, the impl_id is redundant (it could be the
/// same as the impl's node id). /// same as the impl's node id).
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct TraitRef { pub struct TraitRef {
pub path: Path, pub path: Path,
pub ref_id: NodeId, pub ref_id: NodeId,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Visibility { pub enum Visibility {
Public, Public,
Inherited, Inherited,
@ -1117,7 +1117,7 @@ impl Visibility {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct StructField_ { pub struct StructField_ {
pub kind: StructFieldKind, pub kind: StructFieldKind,
pub id: NodeId, pub id: NodeId,
@ -1136,7 +1136,7 @@ impl StructField_ {
pub type StructField = Spanned<StructField_>; pub type StructField = Spanned<StructField_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum StructFieldKind { pub enum StructFieldKind {
NamedField(Ident, Visibility), NamedField(Ident, Visibility),
/// Element of a tuple-like struct /// Element of a tuple-like struct
@ -1152,7 +1152,7 @@ impl StructFieldKind {
} }
} }
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct StructDef { pub struct StructDef {
/// Fields, not including ctor /// Fields, not including ctor
pub fields: Vec<StructField>, pub fields: Vec<StructField>,
@ -1169,7 +1169,7 @@ pub struct StructDef {
FIXME (#3300): Should allow items to be anonymous. Right now FIXME (#3300): Should allow items to be anonymous. Right now
we just use dummy names for anon items. we just use dummy names for anon items.
*/ */
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Item { pub struct Item {
pub ident: Ident, pub ident: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1179,7 +1179,7 @@ pub struct Item {
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Item_ { pub enum Item_ {
ItemStatic(P<Ty>, Mutability, Gc<Expr>), ItemStatic(P<Ty>, Mutability, Gc<Expr>),
ItemFn(P<FnDecl>, FnStyle, Abi, Generics, P<Block>), ItemFn(P<FnDecl>, FnStyle, Abi, Generics, P<Block>),
@ -1202,7 +1202,7 @@ pub enum Item_ {
ItemMac(Mac), ItemMac(Mac),
} }
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct ForeignItem { pub struct ForeignItem {
pub ident: Ident, pub ident: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1212,7 +1212,7 @@ pub struct ForeignItem {
pub vis: Visibility, pub vis: Visibility,
} }
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum ForeignItem_ { pub enum ForeignItem_ {
ForeignItemFn(P<FnDecl>, Generics), ForeignItemFn(P<FnDecl>, Generics),
ForeignItemStatic(P<Ty>, /* is_mutbl */ bool), ForeignItemStatic(P<Ty>, /* is_mutbl */ bool),
@ -1221,7 +1221,7 @@ pub enum ForeignItem_ {
/// The data we save and restore about an inlined item or method. This is not /// The data we save and restore about an inlined item or method. This is not
/// part of the AST that we parse from a file, but it becomes part of the tree /// part of the AST that we parse from a file, but it becomes part of the tree
/// that we trans. /// that we trans.
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum InlinedItem { pub enum InlinedItem {
IIItem(Gc<Item>), IIItem(Gc<Item>),
IIMethod(DefId /* impl id */, bool /* is provided */, Gc<Method>), IIMethod(DefId /* impl id */, bool /* is provided */, Gc<Method>),

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use std::fmt;
use std::default::Default; use std::default::Default;
use std::hash; use std::hash;
use std::{mem, raw, ptr, slice}; use std::{mem, raw, ptr, slice};
@ -22,6 +23,17 @@ pub struct OwnedSlice<T> {
len: uint, len: uint,
} }
impl<T:fmt::Show> fmt::Show for OwnedSlice<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!("OwnedSlice {{".fmt(fmt));
for i in self.iter() {
try!(i.fmt(fmt));
}
try!("}}".fmt(fmt));
Ok(())
}
}
#[unsafe_destructor] #[unsafe_destructor]
impl<T> Drop for OwnedSlice<T> { impl<T> Drop for OwnedSlice<T> {
fn drop(&mut self) { fn drop(&mut self) {