diff options
Diffstat (limited to 'src/libsyntax/ast.rs')
| -rw-r--r-- | src/libsyntax/ast.rs | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 7e421df505d..0a04a953b31 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -86,6 +86,8 @@ pub struct Ident { pub ctxt: SyntaxContext } +impl Copy for Ident {} + impl Ident { /// Construct an identifier with the given name and an empty context: pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: EMPTY_CTXT}} @@ -161,6 +163,8 @@ pub const ILLEGAL_CTXT : SyntaxContext = 1; #[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone)] pub struct Name(pub u32); +impl Copy for Name {} + impl Name { pub fn as_str<'a>(&'a self) -> &'a str { unsafe { @@ -204,6 +208,8 @@ pub struct Lifetime { pub name: Name } +impl Copy for Lifetime {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct LifetimeDef { pub lifetime: Lifetime, @@ -338,6 +344,8 @@ pub struct DefId { pub node: NodeId, } +impl Copy for DefId {} + /// Item definitions in the currently-compiled crate would have the CrateNum /// LOCAL_CRATE in their DefId. pub const LOCAL_CRATE: CrateNum = 0; @@ -482,6 +490,8 @@ pub enum BindingMode { BindByValue(Mutability), } +impl Copy for BindingMode {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum PatWildKind { /// Represents the wildcard pattern `_` @@ -491,6 +501,8 @@ pub enum PatWildKind { PatWildMulti, } +impl Copy for PatWildKind {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Pat_ { /// Represents a wildcard pattern (either `_` or `..`) @@ -526,6 +538,8 @@ pub enum Mutability { MutImmutable, } +impl Copy for Mutability {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum BinOp { BiAdd, @@ -548,6 +562,9 @@ pub enum BinOp { BiGt, } +#[cfg(not(stage0))] +impl Copy for BinOp {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum UnOp { UnUniq, @@ -556,6 +573,8 @@ pub enum UnOp { UnNeg } +impl Copy for UnOp {} + pub type Stmt = Spanned<Stmt_>; #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] @@ -581,6 +600,8 @@ pub enum LocalSource { LocalFor, } +impl Copy for LocalSource {} + // FIXME (pending discussion of #1697, #2178...): local should really be // a refinement on pat. /// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;` @@ -628,12 +649,16 @@ pub enum BlockCheckMode { UnsafeBlock(UnsafeSource), } +impl Copy for BlockCheckMode {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum UnsafeSource { CompilerGenerated, UserProvided, } +impl Copy for UnsafeSource {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Expr { pub id: NodeId, @@ -718,12 +743,16 @@ pub enum MatchSource { MatchWhileLetDesugar, } +impl Copy for MatchSource {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum CaptureClause { CaptureByValue, CaptureByRef, } +impl Copy for CaptureClause {} + /// A delimited sequence of token trees #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Delimited { @@ -780,6 +809,8 @@ pub enum KleeneOp { OneOrMore, } +impl Copy for KleeneOp {} + /// When the main rust parser encounters a syntax-extension invocation, it /// parses the arguments to the invocation as a token-tree. This is a very /// loose structure, such that all sorts of different AST-fragments can @@ -895,6 +926,8 @@ pub enum StrStyle { RawStr(uint) } +impl Copy for StrStyle {} + pub type Lit = Spanned<Lit_>; #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] @@ -903,7 +936,9 @@ pub enum Sign { Plus } -impl<T: Int> Sign { +impl Copy for Sign {} + +impl<T> Sign where T: Int { pub fn new(n: T) -> Sign { if n < Int::zero() { Minus @@ -920,6 +955,8 @@ pub enum LitIntType { UnsuffixedIntLit(Sign) } +impl Copy for LitIntType {} + impl LitIntType { pub fn suffix_len(&self) -> uint { match *self { @@ -1015,6 +1052,8 @@ pub enum IntTy { TyI64, } +impl Copy for IntTy {} + impl fmt::Show for IntTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", ast_util::int_ty_to_string(*self, None)) @@ -1040,6 +1079,8 @@ pub enum UintTy { TyU64, } +impl Copy for UintTy {} + impl UintTy { pub fn suffix_len(&self) -> uint { match *self { @@ -1062,6 +1103,8 @@ pub enum FloatTy { TyF64, } +impl Copy for FloatTy {} + impl fmt::Show for FloatTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", ast_util::float_ty_to_string(*self)) @@ -1095,12 +1138,16 @@ pub enum PrimTy { TyChar } +impl Copy for PrimTy {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] pub enum Onceness { Once, Many } +impl Copy for Onceness {} + impl fmt::Show for Onceness { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { @@ -1171,6 +1218,8 @@ pub enum AsmDialect { AsmIntel } +impl Copy for AsmDialect {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct InlineAsm { pub asm: InternedString, @@ -1228,6 +1277,8 @@ pub enum FnStyle { NormalFn, } +impl Copy for FnStyle {} + impl fmt::Show for FnStyle { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { @@ -1345,6 +1396,8 @@ pub enum PathListItem_ { PathListMod { id: NodeId } } +impl Copy for PathListItem_ {} + impl PathListItem_ { pub fn id(&self) -> NodeId { match *self { @@ -1404,9 +1457,13 @@ pub enum AttrStyle { AttrInner, } +impl Copy for AttrStyle {} + #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct AttrId(pub uint); +impl Copy for AttrId {} + /// Doc-comments are promoted to attributes that have is_sugared_doc = true #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Attribute_ { @@ -1442,6 +1499,8 @@ pub enum Visibility { Inherited, } +impl Copy for Visibility {} + impl Visibility { pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility { match self { @@ -1477,6 +1536,8 @@ pub enum StructFieldKind { UnnamedField(Visibility), } +impl Copy for StructFieldKind {} + impl StructFieldKind { pub fn is_unnamed(&self) -> bool { match *self { @@ -1583,6 +1644,8 @@ pub enum UnboxedClosureKind { FnOnceUnboxedClosureKind, } +impl Copy for UnboxedClosureKind {} + /// 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 /// that we trans. |
