1
Fork 0

libsyntax: use #[deriving(Copy)]

This commit is contained in:
Jorge Aparicio 2014-12-14 23:32:24 -05:00
parent a77e8a63d5
commit 86f8c127dd
19 changed files with 77 additions and 216 deletions

View file

@ -15,7 +15,7 @@ pub use self::AbiArchitecture::*;
use std::fmt;
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
pub enum Os {
OsWindows,
OsMacos,
@ -26,9 +26,7 @@ pub enum Os {
OsDragonfly,
}
impl Copy for Os {}
#[deriving(PartialEq, Eq, Hash, Encodable, Decodable, Clone)]
#[deriving(Copy, PartialEq, Eq, Hash, Encodable, Decodable, Clone)]
pub enum Abi {
// NB: This ordering MUST match the AbiDatas array below.
// (This is ensured by the test indices_are_correct().)
@ -48,10 +46,8 @@ pub enum Abi {
RustCall,
}
impl Copy for Abi {}
#[allow(non_camel_case_types)]
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
pub enum Architecture {
X86,
X86_64,
@ -60,8 +56,7 @@ pub enum Architecture {
Mipsel
}
impl Copy for Architecture {}
#[deriving(Copy)]
pub struct AbiData {
abi: Abi,
@ -69,8 +64,7 @@ pub struct AbiData {
name: &'static str,
}
impl Copy for AbiData {}
#[deriving(Copy)]
pub enum AbiArchitecture {
/// Not a real ABI (e.g., intrinsic)
RustArch,
@ -80,9 +74,6 @@ pub enum AbiArchitecture {
Archs(u32)
}
#[allow(non_upper_case_globals)]
impl Copy for AbiArchitecture {}
#[allow(non_upper_case_globals)]
static AbiDatas: &'static [AbiData] = &[
// Platform-specific ABIs

View file

@ -80,14 +80,12 @@ use serialize::{Encodable, Decodable, Encoder, Decoder};
/// table) and a SyntaxContext to track renaming and
/// macro expansion per Flatt et al., "Macros
/// That Work Together"
#[deriving(Clone, Hash, PartialOrd, Eq, Ord)]
#[deriving(Clone, Copy, Hash, PartialOrd, Eq, Ord)]
pub struct Ident {
pub name: Name,
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}}
@ -160,11 +158,9 @@ pub const ILLEGAL_CTXT : SyntaxContext = 1;
/// A name is a part of an identifier, representing a string or gensym. It's
/// the result of interning.
#[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone)]
#[deriving(Copy, 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 {
@ -201,15 +197,13 @@ impl<D:Decoder<E>, E> Decodable<D, E> for Ident {
/// Function name (not all functions have names)
pub type FnIdent = Option<Ident>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Lifetime {
pub id: NodeId,
pub span: Span,
pub name: Name
}
impl Copy for Lifetime {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct LifetimeDef {
pub lifetime: Lifetime,
@ -353,14 +347,12 @@ pub type CrateNum = u32;
pub type NodeId = u32;
#[deriving(Clone, Eq, Ord, PartialOrd, PartialEq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, Eq, Ord, PartialOrd, PartialEq, Encodable, Decodable, Hash, Show)]
pub struct DefId {
pub krate: CrateNum,
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;
@ -513,15 +505,13 @@ pub struct FieldPat {
pub is_shorthand: bool,
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum BindingMode {
BindByRef(Mutability),
BindByValue(Mutability),
}
impl Copy for BindingMode {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum PatWildKind {
/// Represents the wildcard pattern `_`
PatWildSingle,
@ -530,8 +520,6 @@ 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 `..`)
@ -561,15 +549,13 @@ pub enum Pat_ {
PatMac(Mac),
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Mutability {
MutMutable,
MutImmutable,
}
impl Copy for Mutability {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum BinOp {
BiAdd,
BiSub,
@ -591,9 +577,7 @@ pub enum BinOp {
BiGt,
}
impl Copy for BinOp {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum UnOp {
UnUniq,
UnDeref,
@ -601,8 +585,6 @@ pub enum UnOp {
UnNeg
}
impl Copy for UnOp {}
pub type Stmt = Spanned<Stmt_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
@ -634,14 +616,12 @@ pub enum MacStmtStyle {
/// Where a local declaration came from: either a true `let ... =
/// ...;`, or one desugared from the pattern of a for loop.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum LocalSource {
LocalLet,
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>;`
@ -683,22 +663,18 @@ pub struct Field {
pub type SpannedIdent = Spanned<Ident>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum BlockCheckMode {
DefaultBlock,
UnsafeBlock(UnsafeSource),
}
impl Copy for BlockCheckMode {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, 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,
@ -775,23 +751,19 @@ pub struct QPath {
pub item_name: Ident,
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum MatchSource {
MatchNormal,
MatchIfLetDesugar,
MatchWhileLetDesugar,
}
impl Copy for MatchSource {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, 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 {
@ -842,14 +814,12 @@ pub struct SequenceRepetition {
/// A Kleene-style [repetition operator](http://en.wikipedia.org/wiki/Kleene_star)
/// for token sequences.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum KleeneOp {
ZeroOrMore,
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
@ -959,24 +929,20 @@ pub enum Mac_ {
MacInvocTT(Path, Vec<TokenTree> , SyntaxContext), // new macro-invocation
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum StrStyle {
CookedStr,
RawStr(uint)
}
impl Copy for StrStyle {}
pub type Lit = Spanned<Lit_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Sign {
Minus,
Plus
}
impl Copy for Sign {}
impl<T> Sign where T: Int {
pub fn new(n: T) -> Sign {
if n < Int::zero() {
@ -987,15 +953,13 @@ impl<T> Sign where T: Int {
}
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum LitIntType {
SignedIntLit(IntTy, Sign),
UnsignedIntLit(UintTy),
UnsuffixedIntLit(Sign)
}
impl Copy for LitIntType {}
impl LitIntType {
pub fn suffix_len(&self) -> uint {
match *self {
@ -1082,7 +1046,7 @@ pub struct Typedef {
pub typ: P<Ty>,
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)]
pub enum IntTy {
TyI,
TyI8,
@ -1091,8 +1055,6 @@ 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))
@ -1109,7 +1071,7 @@ impl IntTy {
}
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)]
pub enum UintTy {
TyU,
TyU8,
@ -1118,8 +1080,6 @@ pub enum UintTy {
TyU64,
}
impl Copy for UintTy {}
impl UintTy {
pub fn suffix_len(&self) -> uint {
match *self {
@ -1136,14 +1096,12 @@ impl fmt::Show for UintTy {
}
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)]
pub enum FloatTy {
TyF32,
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))
@ -1177,7 +1135,7 @@ pub struct Ty {
}
/// Not represented directly in the AST, referred to by name through a ty_path.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum PrimTy {
TyInt(IntTy),
TyUint(UintTy),
@ -1187,16 +1145,12 @@ pub enum PrimTy {
TyChar
}
impl Copy for PrimTy {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
#[deriving(Clone, Copy, 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 {
@ -1259,14 +1213,12 @@ pub enum Ty_ {
TyInfer,
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum AsmDialect {
AsmAtt,
AsmIntel
}
impl Copy for AsmDialect {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct InlineAsm {
pub asm: InternedString,
@ -1433,14 +1385,12 @@ pub struct Variant_ {
pub type Variant = Spanned<Variant_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum PathListItem_ {
PathListIdent { name: Ident, id: NodeId },
PathListMod { id: NodeId }
}
impl Copy for PathListItem_ {}
impl PathListItem_ {
pub fn id(&self) -> NodeId {
match *self {
@ -1494,19 +1444,15 @@ pub type Attribute = Spanned<Attribute_>;
/// Distinguishes between Attributes that decorate items and Attributes that
/// are contained as statements within items. These two cases need to be
/// distinguished for pretty-printing.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum AttrStyle {
AttrOuter,
AttrInner,
}
impl Copy for AttrStyle {}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, 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_ {
@ -1536,14 +1482,12 @@ pub struct PolyTraitRef {
pub trait_ref: TraitRef
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Visibility {
Public,
Inherited,
}
impl Copy for Visibility {}
impl Visibility {
pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
match self {
@ -1572,15 +1516,13 @@ impl StructField_ {
pub type StructField = Spanned<StructField_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum StructFieldKind {
NamedField(Ident, Visibility),
/// Element of a tuple-like struct
UnnamedField(Visibility),
}
impl Copy for StructFieldKind {}
impl StructFieldKind {
pub fn is_unnamed(&self) -> bool {
match *self {
@ -1682,15 +1624,13 @@ impl ForeignItem_ {
}
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum UnboxedClosureKind {
FnUnboxedClosureKind,
FnMutUnboxedClosureKind,
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.

View file

@ -41,10 +41,9 @@ use visit;
/// - The default implementation for a trait method.
///
/// To construct one, use the `Code::from_node` function.
#[deriving(Copy)]
pub struct FnLikeNode<'a> { node: ast_map::Node<'a> }
impl<'a> Copy for FnLikeNode<'a> {}
/// MaybeFnLike wraps a method that indicates if an object
/// corresponds to some FnLikeNode.
pub trait MaybeFnLike { fn is_fn_like(&self) -> bool; }
@ -82,13 +81,12 @@ impl MaybeFnLike for ast::Expr {
/// Carries either an FnLikeNode or a Block, as these are the two
/// constructs that correspond to "code" (as in, something from which
/// we can construct a control-flow graph).
#[deriving(Copy)]
pub enum Code<'a> {
FnLikeCode(FnLikeNode<'a>),
BlockCode(&'a Block),
}
impl<'a> Copy for Code<'a> {}
impl<'a> Code<'a> {
pub fn id(&self) -> ast::NodeId {
match *self {

View file

@ -32,14 +32,12 @@ use std::slice;
pub mod blocks;
#[deriving(Clone, PartialEq)]
#[deriving(Clone, Copy, PartialEq)]
pub enum PathElem {
PathMod(Name),
PathName(Name)
}
impl Copy for PathElem {}
impl PathElem {
pub fn name(&self) -> Name {
match *self {
@ -102,7 +100,7 @@ pub fn path_to_string<PI: Iterator<PathElem>>(path: PI) -> String {
}).to_string()
}
#[deriving(Show)]
#[deriving(Copy, Show)]
pub enum Node<'ast> {
NodeItem(&'ast Item),
NodeForeignItem(&'ast ForeignItem),
@ -122,11 +120,9 @@ pub enum Node<'ast> {
NodeLifetime(&'ast Lifetime),
}
impl<'ast> Copy for Node<'ast> {}
/// Represents an entry and its parent Node ID
/// The odd layout is to bring down the total size.
#[deriving(Show)]
#[deriving(Copy, Show)]
enum MapEntry<'ast> {
/// Placeholder for holes in the map.
NotPresent,
@ -151,8 +147,6 @@ enum MapEntry<'ast> {
RootInlinedParent(&'ast InlinedParent)
}
impl<'ast> Copy for MapEntry<'ast> {}
impl<'ast> Clone for MapEntry<'ast> {
fn clone(&self) -> MapEntry<'ast> {
*self

View file

@ -343,14 +343,12 @@ pub fn empty_generics() -> Generics {
// ______________________________________________________________________
// Enumerating the IDs which appear in an AST
#[deriving(Encodable, Decodable, Show)]
#[deriving(Copy, Encodable, Decodable, Show)]
pub struct IdRange {
pub min: NodeId,
pub max: NodeId,
}
impl Copy for IdRange {}
impl IdRange {
pub fn max() -> IdRange {
IdRange {

View file

@ -277,7 +277,7 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option<InternedString> {
first_attr_value_str_by_name(attrs, "crate_name")
}
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
pub enum InlineAttr {
InlineNone,
InlineHint,
@ -285,8 +285,6 @@ pub enum InlineAttr {
InlineNever,
}
impl Copy for InlineAttr {}
/// Determine what `#[inline]` attribute is present in `attrs`, if any.
pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr {
// FIXME (#2809)---validate the usage of #[inline] and #[inline]
@ -349,7 +347,7 @@ pub struct Stability {
}
/// The available stability levels.
#[deriving(Encodable,Decodable,PartialEq,PartialOrd,Clone,Show)]
#[deriving(Copy,Encodable,Decodable,PartialEq,PartialOrd,Clone,Show)]
pub enum StabilityLevel {
Deprecated,
Experimental,
@ -359,8 +357,6 @@ pub enum StabilityLevel {
Locked
}
impl Copy for StabilityLevel {}
pub fn find_stability_generic<'a,
AM: AttrMetaMethods,
I: Iterator<&'a AM>>
@ -468,7 +464,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
}
}
#[deriving(PartialEq, Show, Encodable, Decodable)]
#[deriving(Copy, PartialEq, Show, Encodable, Decodable)]
pub enum ReprAttr {
ReprAny,
ReprInt(Span, IntType),
@ -476,8 +472,6 @@ pub enum ReprAttr {
ReprPacked,
}
impl Copy for ReprAttr {}
impl ReprAttr {
pub fn is_ffi_safe(&self) -> bool {
match *self {
@ -489,14 +483,12 @@ impl ReprAttr {
}
}
#[deriving(Eq, Hash, PartialEq, Show, Encodable, Decodable)]
#[deriving(Copy, Eq, Hash, PartialEq, Show, Encodable, Decodable)]
pub enum IntType {
SignedInt(ast::IntTy),
UnsignedInt(ast::UintTy)
}
impl Copy for IntType {}
impl IntType {
#[inline]
pub fn is_signed(self) -> bool {

View file

@ -31,19 +31,15 @@ pub trait Pos {
/// A byte offset. Keep this small (currently 32-bits), as AST contains
/// a lot of them.
#[deriving(Clone, PartialEq, Eq, Hash, PartialOrd, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Show)]
pub struct BytePos(pub u32);
impl Copy for BytePos {}
/// A character offset. Because of multibyte utf8 characters, a byte offset
/// is not equivalent to a character offset. The CodeMap will convert BytePos
/// values to CharPos values as necessary.
#[deriving(PartialEq, Hash, PartialOrd, Show)]
#[deriving(Copy, PartialEq, Hash, PartialOrd, Show)]
pub struct CharPos(pub uint);
impl Copy for CharPos {}
// FIXME: Lots of boilerplate in these impls, but so far my attempts to fix
// have been unsuccessful
@ -121,7 +117,7 @@ impl Sub<CharPos, CharPos> for CharPos {
/// are *absolute* positions from the beginning of the codemap, not positions
/// relative to FileMaps. Methods on the CodeMap can be used to relate spans back
/// to the original source.
#[deriving(Clone, Show, Hash)]
#[deriving(Clone, Copy, Show, Hash)]
pub struct Span {
pub lo: BytePos,
pub hi: BytePos,
@ -130,18 +126,14 @@ pub struct Span {
pub expn_id: ExpnId
}
impl Copy for Span {}
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Spanned<T> {
pub node: T,
pub span: Span,
}
impl<T:Copy> Copy for Spanned<T> {}
impl PartialEq for Span {
fn eq(&self, other: &Span) -> bool {
return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
@ -219,7 +211,7 @@ pub struct FileMapAndLine { pub fm: Rc<FileMap>, pub line: uint }
pub struct FileMapAndBytePos { pub fm: Rc<FileMap>, pub pos: BytePos }
/// The syntax with which a macro was invoked.
#[deriving(Clone, Hash, Show)]
#[deriving(Clone, Copy, Hash, Show)]
pub enum MacroFormat {
/// e.g. #[deriving(...)] <item>
MacroAttribute,
@ -227,8 +219,6 @@ pub enum MacroFormat {
MacroBang
}
impl Copy for MacroFormat {}
#[deriving(Clone, Hash, Show)]
pub struct NameAndSpan {
/// The name of the macro that was invoked to create the thing
@ -264,11 +254,9 @@ pub struct ExpnInfo {
pub callee: NameAndSpan
}
#[deriving(PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)]
#[deriving(Copy, PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)]
pub struct ExpnId(u32);
impl Copy for ExpnId {}
pub const NO_EXPANSION: ExpnId = ExpnId(-1);
impl ExpnId {
@ -290,6 +278,7 @@ pub struct FileLines {
}
/// Identifies an offset of a multi-byte character in a FileMap
#[deriving(Copy)]
pub struct MultiByteChar {
/// The absolute offset of the character in the CodeMap
pub pos: BytePos,
@ -297,8 +286,6 @@ pub struct MultiByteChar {
pub bytes: uint,
}
impl Copy for MultiByteChar {}
/// A single source in the CodeMap
pub struct FileMap {
/// The name of the file that the source came from, source that doesn't

View file

@ -28,7 +28,7 @@ use term;
/// maximum number of lines we will print for each error; arbitrary.
static MAX_LINES: uint = 6u;
#[deriving(Clone)]
#[deriving(Clone, Copy)]
pub enum RenderSpan {
/// A FullSpan renders with both with an initial line for the
/// message, prefixed by file:linenum, followed by a summary of
@ -40,8 +40,6 @@ pub enum RenderSpan {
FileLine(Span),
}
impl Copy for RenderSpan {}
impl RenderSpan {
fn span(self) -> Span {
match self {
@ -56,15 +54,13 @@ impl RenderSpan {
}
}
#[deriving(Clone)]
#[deriving(Clone, Copy)]
pub enum ColorConfig {
Auto,
Always,
Never
}
impl Copy for ColorConfig {}
pub trait Emitter {
fn emit(&mut self, cmsp: Option<(&codemap::CodeMap, Span)>,
msg: &str, code: Option<&str>, lvl: Level);
@ -75,16 +71,14 @@ pub trait Emitter {
/// This structure is used to signify that a task has panicked with a fatal error
/// from the diagnostics. You can use this with the `Any` trait to figure out
/// how a rustc task died (if so desired).
#[deriving(Copy)]
pub struct FatalError;
impl Copy for FatalError {}
/// Signifies that the compiler died with an explicit call to `.bug`
/// or `.span_bug` rather than a failed assertion, etc.
#[deriving(Copy)]
pub struct ExplicitBug;
impl Copy for ExplicitBug {}
/// A span-handler is like a handler but also
/// accepts span information for source-location
/// reporting.
@ -228,7 +222,7 @@ pub fn mk_handler(e: Box<Emitter + Send>) -> Handler {
}
}
#[deriving(PartialEq, Clone)]
#[deriving(Copy, PartialEq, Clone)]
pub enum Level {
Bug,
Fatal,
@ -238,8 +232,6 @@ pub enum Level {
Help,
}
impl Copy for Level {}
impl fmt::Show for Level {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use std::fmt::Show;

View file

@ -223,13 +223,12 @@ impl MacResult for MacItems {
/// Fill-in macro expansion result, to allow compilation to continue
/// after hitting errors.
#[deriving(Copy)]
pub struct DummyResult {
expr_only: bool,
span: Span
}
impl Copy for DummyResult {}
impl DummyResult {
/// Create a default MacResult that can be anything.
///

View file

@ -83,12 +83,11 @@ pub fn expand_deriving_ord<F>(cx: &mut ExtCtxt,
trait_def.expand(cx, mitem, item, push)
}
#[deriving(Copy)]
pub enum OrderingOp {
PartialCmpOp, LtOp, LeOp, GtOp, GeOp,
}
impl Copy for OrderingOp {}
pub fn some_ordering_collapsed(cx: &mut ExtCtxt,
span: Span,
op: OrderingOp,

View file

@ -39,7 +39,7 @@ pub struct SCTable {
rename_memo: RefCell<HashMap<(SyntaxContext,Ident,Name),SyntaxContext>>,
}
#[deriving(PartialEq, Encodable, Decodable, Hash, Show)]
#[deriving(Copy, PartialEq, Encodable, Decodable, Hash, Show)]
pub enum SyntaxContext_ {
EmptyCtxt,
Mark (Mrk,SyntaxContext),
@ -56,8 +56,6 @@ pub enum SyntaxContext_ {
IllegalCtxt
}
impl Copy for SyntaxContext_ {}
/// A list of ident->name renamings
pub type RenameList = Vec<(Ident, Name)>;

View file

@ -97,6 +97,7 @@ enum Status {
}
/// A set of features to be used by later passes.
#[deriving(Copy)]
pub struct Features {
pub default_type_params: bool,
pub unboxed_closures: bool,
@ -107,8 +108,6 @@ pub struct Features {
pub opt_out_copy: bool,
}
impl Copy for Features {}
impl Features {
pub fn new() -> Features {
Features {

View file

@ -24,7 +24,7 @@ use std::str;
use std::string::String;
use std::uint;
#[deriving(Clone, PartialEq)]
#[deriving(Clone, Copy, PartialEq)]
pub enum CommentStyle {
/// No code on either side of each line of the comment
Isolated,
@ -36,8 +36,6 @@ pub enum CommentStyle {
BlankLine,
}
impl Copy for CommentStyle {}
#[deriving(Clone)]
pub struct Comment {
pub style: CommentStyle,

View file

@ -22,7 +22,7 @@ use parse::token;
use ptr::P;
/// The specific types of unsupported syntax
#[deriving(PartialEq, Eq, Hash)]
#[deriving(Copy, PartialEq, Eq, Hash)]
pub enum ObsoleteSyntax {
ObsoleteOwnedType,
ObsoleteOwnedExpr,
@ -36,8 +36,6 @@ pub enum ObsoleteSyntax {
ObsoleteProcExpr,
}
impl Copy for ObsoleteSyntax {}
pub trait ParserObsoleteMethods {
/// Reports an obsolete syntax non-fatal error.
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax);

View file

@ -104,7 +104,7 @@ type ItemInfo = (Ident, Item_, Option<Vec<Attribute> >);
/// How to parse a path. There are four different kinds of paths, all of which
/// are parsed somewhat differently.
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
pub enum PathParsingMode {
/// A path with no type parameters; e.g. `foo::bar::Baz`
NoTypesAllowed,
@ -116,8 +116,6 @@ pub enum PathParsingMode {
LifetimeAndTypesWithColons,
}
impl Copy for PathParsingMode {}
enum ItemOrViewItem {
/// Indicates a failure to parse any kind of item. The attributes are
/// returned.

View file

@ -28,7 +28,7 @@ use std::path::BytesContainer;
use std::rc::Rc;
#[allow(non_camel_case_types)]
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
pub enum BinOpToken {
Plus,
Minus,
@ -42,10 +42,8 @@ pub enum BinOpToken {
Shr,
}
impl Copy for BinOpToken {}
/// A delimeter token
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
pub enum DelimToken {
/// A round parenthesis: `(` or `)`
Paren,
@ -55,16 +53,14 @@ pub enum DelimToken {
Brace,
}
impl Copy for DelimToken {}
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
pub enum IdentStyle {
/// `::` follows the identifier with no whitespace in-between.
ModName,
Plain,
}
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
pub enum Lit {
Byte(ast::Name),
Char(ast::Name),
@ -89,10 +85,6 @@ impl Lit {
}
}
impl Copy for Lit {}
impl Copy for IdentStyle {}
#[allow(non_camel_case_types)]
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)]
pub enum Token {
@ -438,13 +430,12 @@ macro_rules! declare_special_idents_and_keywords {(
pub use self::Keyword::*;
use ast;
#[deriving(Copy)]
pub enum Keyword {
$( $sk_variant, )*
$( $rk_variant, )*
}
impl Copy for Keyword {}
impl Keyword {
pub fn to_name(&self) -> ast::Name {
match *self {

View file

@ -66,30 +66,24 @@ pub use self::Token::*;
use std::io;
use std::string;
#[deriving(Clone, PartialEq)]
#[deriving(Clone, Copy, PartialEq)]
pub enum Breaks {
Consistent,
Inconsistent,
}
impl Copy for Breaks {}
#[deriving(Clone)]
#[deriving(Clone, Copy)]
pub struct BreakToken {
offset: int,
blank_space: int
}
impl Copy for BreakToken {}
#[deriving(Clone)]
#[deriving(Clone, Copy)]
pub struct BeginToken {
offset: int,
breaks: Breaks
}
impl Copy for BeginToken {}
#[deriving(Clone)]
pub enum Token {
String(string::String, int),
@ -153,20 +147,18 @@ pub fn buf_str(toks: Vec<Token>,
return s.into_string();
}
#[deriving(Copy)]
pub enum PrintStackBreak {
Fits,
Broken(Breaks),
}
impl Copy for PrintStackBreak {}
#[deriving(Copy)]
pub struct PrintStackElem {
offset: int,
pbreak: PrintStackBreak
}
impl Copy for PrintStackElem {}
static SIZE_INFINITY: int = 0xffff;
pub fn mk_printer(out: Box<io::Writer+'static>, linewidth: uint) -> Printer {

View file

@ -45,19 +45,17 @@ pub trait PpAnn {
fn post(&self, _state: &mut State, _node: AnnNode) -> IoResult<()> { Ok(()) }
}
#[deriving(Copy)]
pub struct NoAnn;
impl Copy for NoAnn {}
impl PpAnn for NoAnn {}
#[deriving(Copy)]
pub struct CurrentCommentAndLiteral {
cur_cmnt: uint,
cur_lit: uint,
}
impl Copy for CurrentCommentAndLiteral {}
pub struct State<'a> {
pub s: pp::Printer,
cm: Option<&'a CodeMap>,

View file

@ -32,6 +32,7 @@ use codemap::Span;
use ptr::P;
use owned_slice::OwnedSlice;
#[deriving(Copy)]
pub enum FnKind<'a> {
/// fn foo() or extern "Abi" fn foo()
FkItemFn(Ident, &'a Generics, Unsafety, Abi),
@ -44,8 +45,6 @@ pub enum FnKind<'a> {
FkFnBlock,
}
impl<'a> Copy for FnKind<'a> {}
/// Each method of the Visitor trait is a hook to be potentially
/// overridden. Each method's default implementation recursively visits
/// the substructure of the input via the corresponding `walk` method;