diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0c367f3a9a4..d98bbe4dd3d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -16,13 +16,12 @@ use ast_util; use owned_slice::OwnedSlice; use parse::token::{InternedString, str_to_ident}; use parse::token; +use ptr::P; use std::fmt; use std::num::Zero; use std::fmt::Show; -use std::option::Option; use std::rc::Rc; -use std::gc::{Gc, GC}; use serialize::{Encodable, Decodable, Encoder, Decoder}; // FIXME #6993: in librustc, uses of "ident" should be replaced @@ -267,7 +266,7 @@ pub struct WherePredicate { /// The set of MetaItems that define the compilation environment of the crate, /// used to drive conditional compilation -pub type CrateConfig = Vec>; +pub type CrateConfig = Vec> ; #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Crate { @@ -275,7 +274,7 @@ pub struct Crate { pub attrs: Vec, pub config: CrateConfig, pub span: Span, - pub exported_macros: Vec> + pub exported_macros: Vec> } pub type MetaItem = Spanned; @@ -283,7 +282,7 @@ pub type MetaItem = Spanned; #[deriving(Clone, Eq, Encodable, Decodable, Hash, Show)] pub enum MetaItem_ { MetaWord(InternedString), - MetaList(InternedString, Vec>), + MetaList(InternedString, Vec>), MetaNameValue(InternedString, Lit), } @@ -315,8 +314,8 @@ impl PartialEq for MetaItem_ { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Block { pub view_items: Vec, - pub stmts: Vec>, - pub expr: Option>, + pub stmts: Vec>, + pub expr: Option>, pub id: NodeId, pub rules: BlockCheckMode, pub span: Span, @@ -332,7 +331,7 @@ pub struct Pat { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct FieldPat { pub ident: Ident, - pub pat: Gc, + pub pat: P, } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] @@ -362,20 +361,20 @@ pub enum Pat_ { /// which it is. The resolver determines this, and /// records this pattern's NodeId in an auxiliary /// set (of "PatIdents that refer to nullary enums") - PatIdent(BindingMode, SpannedIdent, Option>), + PatIdent(BindingMode, SpannedIdent, Option>), /// "None" means a * pattern where we don't bind the fields to names. - PatEnum(Path, Option>>), + PatEnum(Path, Option>>), PatStruct(Path, Vec, bool), - PatTup(Vec>), - PatBox(Gc), - PatRegion(Gc), // reference pattern - PatLit(Gc), - PatRange(Gc, Gc), + PatTup(Vec>), + PatBox(P), + PatRegion(P), // reference pattern + PatLit(P), + PatRange(P, P), /// [a, b, ..i, y, z] is represented as: /// PatVec(~[a, b], Some(i), ~[y, z]) - PatVec(Vec>, Option>, Vec>), + PatVec(Vec>, Option>, Vec>), PatMac(Mac), } @@ -421,13 +420,13 @@ pub type Stmt = Spanned; #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Stmt_ { /// Could be an item or a local (let) binding: - StmtDecl(Gc, NodeId), + StmtDecl(P, NodeId), /// Expr without trailing semi-colon (must have unit type): - StmtExpr(Gc, NodeId), + StmtExpr(P, NodeId), /// Expr with trailing semi-colon (may have any type): - StmtSemi(Gc, NodeId), + StmtSemi(P, NodeId), /// bool: is there a trailing sem-colon? StmtMac(Mac, bool), @@ -447,8 +446,8 @@ pub enum LocalSource { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Local { pub ty: P, - pub pat: Gc, - pub init: Option>, + pub pat: P, + pub init: Option>, pub id: NodeId, pub span: Span, pub source: LocalSource, @@ -459,24 +458,24 @@ pub type Decl = Spanned; #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Decl_ { /// A local (let) binding: - DeclLocal(Gc), + DeclLocal(P), /// An item binding: - DeclItem(Gc), + DeclItem(P), } /// represents one arm of a 'match' #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Arm { pub attrs: Vec, - pub pats: Vec>, - pub guard: Option>, - pub body: Gc, + pub pats: Vec>, + pub guard: Option>, + pub body: P, } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Field { pub ident: SpannedIdent, - pub expr: Gc, + pub expr: P, pub span: Span, } @@ -504,56 +503,56 @@ pub struct Expr { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Expr_ { /// First expr is the place; second expr is the value. - ExprBox(Gc, Gc), - ExprVec(Vec>), - ExprCall(Gc, Vec>), - ExprMethodCall(SpannedIdent, Vec>, Vec>), - ExprTup(Vec>), - ExprBinary(BinOp, Gc, Gc), - ExprUnary(UnOp, Gc), - ExprLit(Gc), - ExprCast(Gc, P), - ExprIf(Gc, P, Option>), + ExprBox(P, P), + ExprVec(Vec>), + ExprCall(P, Vec>), + ExprMethodCall(SpannedIdent, Vec>, Vec>), + ExprTup(Vec>), + ExprBinary(BinOp, P, P), + ExprUnary(UnOp, P), + ExprLit(P), + ExprCast(P, P), + ExprIf(P, P, Option>), // FIXME #6993: change to Option ... or not, if these are hygienic. - ExprWhile(Gc, P, Option), + ExprWhile(P, P, Option), // FIXME #6993: change to Option ... or not, if these are hygienic. - ExprForLoop(Gc, Gc, P, Option), + ExprForLoop(P, P, P, Option), // Conditionless loop (can be exited with break, cont, or ret) // FIXME #6993: change to Option ... or not, if these are hygienic. ExprLoop(P, Option), - ExprMatch(Gc, Vec), + ExprMatch(P, Vec), ExprFnBlock(CaptureClause, P, P), ExprProc(P, P), ExprUnboxedFn(CaptureClause, UnboxedClosureKind, P, P), ExprBlock(P), - ExprAssign(Gc, Gc), - ExprAssignOp(BinOp, Gc, Gc), - ExprField(Gc, SpannedIdent, Vec>), - ExprTupField(Gc, Spanned, Vec>), - ExprIndex(Gc, Gc), + ExprAssign(P, P), + ExprAssignOp(BinOp, P, P), + ExprField(P, SpannedIdent, Vec>), + ExprTupField(P, Spanned, Vec>), + ExprIndex(P, P), /// Variable reference, possibly containing `::` and/or /// type parameters, e.g. foo::bar:: ExprPath(Path), - ExprAddrOf(Mutability, Gc), + ExprAddrOf(Mutability, P), ExprBreak(Option), ExprAgain(Option), - ExprRet(Option>), + ExprRet(Option>), ExprInlineAsm(InlineAsm), ExprMac(Mac), /// A struct literal expression. - ExprStruct(Path, Vec , Option> /* base */), + ExprStruct(Path, Vec, Option> /* base */), /// A vector literal constructed from one repeated element. - ExprRepeat(Gc /* element */, Gc /* count */), + ExprRepeat(P /* element */, P /* count */), /// No-op: used solely so we can pretty-print faithfully - ExprParen(Gc) + ExprParen(P) } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] @@ -766,12 +765,12 @@ pub struct TypeMethod { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum TraitItem { RequiredMethod(TypeMethod), - ProvidedMethod(Gc), + ProvidedMethod(P), } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum ImplItem { - MethodImplItem(Gc), + MethodImplItem(P), } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] @@ -879,7 +878,7 @@ impl fmt::Show for Onceness { } /// Represents the type of a closure -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct ClosureTy { pub lifetimes: Vec, pub fn_style: FnStyle, @@ -888,7 +887,7 @@ pub struct ClosureTy { pub bounds: TyParamBounds, } -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct BareFnTy { pub fn_style: FnStyle, pub abi: Abi, @@ -909,18 +908,18 @@ pub enum Ty_ { TyBox(P), TyUniq(P), TyVec(P), - TyFixedLengthVec(P, Gc), + TyFixedLengthVec(P, P), TyPtr(MutTy), TyRptr(Option, MutTy), - TyClosure(Gc), - TyProc(Gc), - TyBareFn(Gc), - TyUnboxedFn(Gc), + TyClosure(P), + TyProc(P), + TyBareFn(P), + TyUnboxedFn(P), TyTup(Vec> ), TyPath(Path, Option, NodeId), // for #7264; see above /// No-op; kept solely so that we can pretty-print faithfully TyParen(P), - TyTypeof(Gc), + TyTypeof(P), /// TyInfer means the type should be inferred instead of it having been /// specified. This can appear anywhere in a type. TyInfer, @@ -936,8 +935,8 @@ pub enum AsmDialect { pub struct InlineAsm { pub asm: InternedString, pub asm_str_style: StrStyle, - pub outputs: Vec<(InternedString, Gc, bool)>, - pub inputs: Vec<(InternedString, Gc)>, + pub outputs: Vec<(InternedString, P, bool)>, + pub inputs: Vec<(InternedString, P)>, pub clobbers: InternedString, pub volatile: bool, pub alignstack: bool, @@ -948,7 +947,7 @@ pub struct InlineAsm { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Arg { pub ty: P, - pub pat: Gc, + pub pat: P, pub id: NodeId, } @@ -962,11 +961,11 @@ impl Arg { node: TyInfer, span: DUMMY_SP, }), - pat: box(GC) Pat { + pat: P(Pat { id: DUMMY_NODE_ID, node: PatIdent(BindByValue(mutability), path, None), span: span - }, + }), id: DUMMY_NODE_ID } } @@ -1052,14 +1051,14 @@ pub struct Mod { /// to the last token in the external file. pub inner: Span, pub view_items: Vec, - pub items: Vec>, + pub items: Vec>, } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct ForeignMod { pub abi: Abi, pub view_items: Vec, - pub items: Vec>, + pub items: Vec>, } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] @@ -1071,7 +1070,7 @@ pub struct VariantArg { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum VariantKind { TupleVariantKind(Vec), - StructVariantKind(Gc), + StructVariantKind(P), } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] @@ -1085,7 +1084,7 @@ pub struct Variant_ { pub attrs: Vec, pub kind: VariantKind, pub id: NodeId, - pub disr_expr: Option>, + pub disr_expr: Option>, pub vis: Visibility, } @@ -1141,7 +1140,7 @@ pub enum ViewItem_ { /// (containing arbitrary characters) from which to fetch the crate sources /// For example, extern crate whatever = "github.com/rust-lang/rust" ViewItemExternCrate(Ident, Option<(InternedString,StrStyle)>, NodeId), - ViewItemUse(Gc), + ViewItemUse(P), } /// Meta-data associated with an item @@ -1164,7 +1163,7 @@ pub struct AttrId(pub uint); pub struct Attribute_ { pub id: AttrId, pub style: AttrStyle, - pub value: Gc, + pub value: P, pub is_sugared_doc: bool, } @@ -1259,13 +1258,13 @@ pub struct Item { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Item_ { - ItemStatic(P, Mutability, Gc), + ItemStatic(P, Mutability, P), ItemFn(P, FnStyle, Abi, Generics, P), ItemMod(Mod), ItemForeignMod(ForeignMod), ItemTy(P, Generics), ItemEnum(EnumDef, Generics), - ItemStruct(Gc, Generics), + ItemStruct(P, Generics), /// Represents a Trait Declaration ItemTrait(Generics, Option, // (optional) default bound not required for Self. @@ -1308,15 +1307,15 @@ pub enum UnboxedClosureKind { /// that we trans. #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum InlinedItem { - IIItem(Gc), + IIItem(P), IITraitItem(DefId /* impl id */, InlinedTraitItem), - IIForeign(Gc), + IIForeign(P), } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum InlinedTraitItem { - ProvidedInlinedTraitItem(Gc), - RequiredInlinedTraitItem(Gc), + ProvidedInlinedTraitItem(P), + RequiredInlinedTraitItem(P), } #[cfg(test)]