diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-12-05 17:01:33 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-08 13:47:44 -0500 |
| commit | 096a28607fb80c91e6e2ca64d9ef44c4e550e96c (patch) | |
| tree | 82c4ee8f20df133305959d507ec76adb4db5e324 /src/libsyntax | |
| parent | c7a9b49d1b5d4e520f25355f26a93dfac4ffa146 (diff) | |
| download | rust-096a28607fb80c91e6e2ca64d9ef44c4e550e96c.tar.gz rust-096a28607fb80c91e6e2ca64d9ef44c4e550e96c.zip | |
librustc: Make `Copy` opt-in.
This change makes the compiler no longer infer whether types (structures
and enumerations) implement the `Copy` trait (and thus are implicitly
copyable). Rather, you must implement `Copy` yourself via `impl Copy for
MyType {}`.
A new warning has been added, `missing_copy_implementations`, to warn
you if a non-generic public type has been added that could have
implemented `Copy` but didn't.
For convenience, you may *temporarily* opt out of this behavior by using
`#![feature(opt_out_copy)]`. Note though that this feature gate will never be
accepted and will be removed by the time that 1.0 is released, so you should
transition your code away from using it.
This breaks code like:
#[deriving(Show)]
struct Point2D {
x: int,
y: int,
}
fn main() {
let mypoint = Point2D {
x: 1,
y: 1,
};
let otherpoint = mypoint;
println!("{}{}", mypoint, otherpoint);
}
Change this code to:
#[deriving(Show)]
struct Point2D {
x: int,
y: int,
}
impl Copy for Point2D {}
fn main() {
let mypoint = Point2D {
x: 1,
y: 1,
};
let otherpoint = mypoint;
println!("{}{}", mypoint, otherpoint);
}
This is the backwards-incompatible part of #13231.
Part of RFC #3.
[breaking-change]
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 65 | ||||
| -rw-r--r-- | src/libsyntax/ast_map/blocks.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/ord.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/mtwt.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/print/pp.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 2 |
19 files changed, 176 insertions, 7 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 87693f39bbd..71d29bca401 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -16,8 +16,17 @@ pub use self::AbiArchitecture::*; use std::fmt; #[deriving(PartialEq)] -pub enum Os { OsWindows, OsMacos, OsLinux, OsAndroid, OsFreebsd, OsiOS, - OsDragonfly } +pub enum Os { + OsWindows, + OsMacos, + OsLinux, + OsAndroid, + OsFreebsd, + OsiOS, + OsDragonfly, +} + +impl Copy for Os {} #[deriving(PartialEq, Eq, Hash, Encodable, Decodable, Clone)] pub enum Abi { @@ -39,6 +48,8 @@ pub enum Abi { RustCall, } +impl Copy for Abi {} + #[allow(non_camel_case_types)] #[deriving(PartialEq)] pub enum Architecture { @@ -49,6 +60,8 @@ pub enum Architecture { Mipsel } +impl Copy for Architecture {} + pub struct AbiData { abi: Abi, @@ -56,6 +69,8 @@ pub struct AbiData { name: &'static str, } +impl Copy for AbiData {} + pub enum AbiArchitecture { /// Not a real ABI (e.g., intrinsic) RustArch, @@ -66,6 +81,9 @@ pub enum AbiArchitecture { } #[allow(non_upper_case_globals)] +impl Copy for AbiArchitecture {} + +#[allow(non_upper_case_globals)] static AbiDatas: &'static [AbiData] = &[ // Platform-specific ABIs AbiData {abi: Cdecl, name: "cdecl" }, 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. diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs index 8db12fbd835..639a33a8063 100644 --- a/src/libsyntax/ast_map/blocks.rs +++ b/src/libsyntax/ast_map/blocks.rs @@ -43,6 +43,8 @@ use visit; /// To construct one, use the `Code::from_node` function. 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; } @@ -85,6 +87,8 @@ pub enum Code<'a> { BlockCode(&'a Block), } +impl<'a> Copy for Code<'a> {} + impl<'a> Code<'a> { pub fn id(&self) -> ast::NodeId { match *self { diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index ce2fe6e7220..2c985f403f8 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -38,6 +38,8 @@ pub enum PathElem { PathName(Name) } +impl Copy for PathElem {} + impl PathElem { pub fn name(&self) -> Name { match *self { @@ -120,6 +122,8 @@ 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)] @@ -147,6 +151,8 @@ enum MapEntry<'ast> { RootInlinedParent(&'ast InlinedParent) } +impl<'ast> Copy for MapEntry<'ast> {} + impl<'ast> Clone for MapEntry<'ast> { fn clone(&self) -> MapEntry<'ast> { *self diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 68bb7ecfb85..7dba6a57fc4 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -315,6 +315,8 @@ pub struct IdRange { pub max: NodeId, } +impl Copy for IdRange {} + impl IdRange { pub fn max() -> IdRange { IdRange { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index a2811681efd..5894a88ece6 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -282,6 +282,8 @@ 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] @@ -354,6 +356,8 @@ pub enum StabilityLevel { Locked } +impl Copy for StabilityLevel {} + pub fn find_stability_generic<'a, AM: AttrMetaMethods, I: Iterator<&'a AM>> @@ -469,6 +473,8 @@ pub enum ReprAttr { ReprPacked, } +impl Copy for ReprAttr {} + impl ReprAttr { pub fn is_ffi_safe(&self) -> bool { match *self { @@ -486,6 +492,8 @@ pub enum IntType { UnsignedInt(ast::UintTy) } +impl Copy for IntType {} + impl IntType { #[inline] pub fn is_signed(self) -> bool { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6bcf562204b..50b4f342368 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -34,12 +34,16 @@ pub trait Pos { #[deriving(Clone, 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)] 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 @@ -90,6 +94,8 @@ 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)] @@ -98,6 +104,8 @@ pub struct Spanned<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; @@ -183,6 +191,8 @@ 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 @@ -221,6 +231,8 @@ pub struct ExpnInfo { #[deriving(PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)] pub struct ExpnId(u32); +impl Copy for ExpnId {} + pub const NO_EXPANSION: ExpnId = ExpnId(-1); impl ExpnId { @@ -249,6 +261,8 @@ 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 diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 293c1b3a953..bbda80bd96c 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -40,6 +40,8 @@ pub enum RenderSpan { FileLine(Span), } +impl Copy for RenderSpan {} + impl RenderSpan { fn span(self) -> Span { match self { @@ -61,6 +63,8 @@ pub enum ColorConfig { Never } +impl Copy for ColorConfig {} + pub trait Emitter { fn emit(&mut self, cmsp: Option<(&codemap::CodeMap, Span)>, msg: &str, code: Option<&str>, lvl: Level); @@ -73,10 +77,14 @@ pub trait Emitter { /// how a rustc task died (if so desired). 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. pub struct ExplicitBug; +impl Copy for ExplicitBug {} + /// A span-handler is like a handler but also /// accepts span information for source-location /// reporting. @@ -230,6 +238,8 @@ 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; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 0787518f04f..3c7a4a81d20 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -57,7 +57,7 @@ impl ItemDecorator for fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, |P<ast meta_item: &ast::MetaItem, item: &ast::Item, push: |P<ast::Item>|) { - (*self)(ecx, sp, meta_item, item, push) + self.clone()(ecx, sp, meta_item, item, push) } } @@ -77,7 +77,7 @@ impl ItemModifier for fn(&mut ExtCtxt, Span, &ast::MetaItem, P<ast::Item>) -> P< meta_item: &ast::MetaItem, item: P<ast::Item>) -> P<ast::Item> { - (*self)(ecx, span, meta_item, item) + self.clone()(ecx, span, meta_item, item) } } @@ -99,7 +99,7 @@ impl TTMacroExpander for MacroExpanderFn { span: Span, token_tree: &[ast::TokenTree]) -> Box<MacResult+'cx> { - (*self)(ecx, span, token_tree) + self.clone()(ecx, span, token_tree) } } @@ -122,7 +122,7 @@ impl IdentMacroExpander for IdentMacroExpanderFn { ident: ast::Ident, token_tree: Vec<ast::TokenTree> ) -> Box<MacResult+'cx> { - (*self)(cx, sp, ident, token_tree) + self.clone()(cx, sp, ident, token_tree) } } @@ -228,6 +228,8 @@ pub struct DummyResult { span: Span } +impl Copy for DummyResult {} + impl DummyResult { /// Create a default MacResult that can be anything. /// diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 787c6e844d5..1bd55b5d504 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -85,6 +85,8 @@ pub enum OrderingOp { PartialCmpOp, LtOp, LeOp, GtOp, GeOp, } +impl Copy for OrderingOp {} + pub fn some_ordering_collapsed(cx: &mut ExtCtxt, span: Span, op: OrderingOp, diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index 6ba90bbebed..48120b575ac 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -56,6 +56,8 @@ pub enum SyntaxContext_ { IllegalCtxt } +impl Copy for SyntaxContext_ {} + /// A list of ident->name renamings pub type RenameList = Vec<(Ident, Name)>; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4af7b35079a..ac36e508f3b 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -103,6 +103,8 @@ pub struct Features { pub quote: bool, } +impl Copy for Features {} + impl Features { pub fn new() -> Features { Features { diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index aeec6ee13fd..a17d66476c0 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -36,6 +36,8 @@ pub enum CommentStyle { BlankLine, } +impl Copy for CommentStyle {} + #[deriving(Clone)] pub struct Comment { pub style: CommentStyle, diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 650f8295d01..2a2bb42cef0 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -34,6 +34,8 @@ pub enum ObsoleteSyntax { ObsoleteExternCrateRenaming, } +impl Copy for ObsoleteSyntax {} + pub trait ParserObsoleteMethods { /// Reports an obsolete syntax non-fatal error. fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bb3d28ce2bb..4929ee885ac 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -98,6 +98,8 @@ bitflags! { } } +impl Copy for Restrictions {} + type ItemInfo = (Ident, Item_, Option<Vec<Attribute> >); /// How to parse a path. There are four different kinds of paths, all of which @@ -114,6 +116,8 @@ pub enum PathParsingMode { LifetimeAndTypesWithColons, } +impl Copy for PathParsingMode {} + enum ItemOrViewItem { /// Indicates a failure to parse any kind of item. The attributes are /// returned. diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 52b54bc7f2d..4b1e9482a7d 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -42,6 +42,8 @@ pub enum BinOpToken { Shr, } +impl Copy for BinOpToken {} + /// A delimeter token #[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)] pub enum DelimToken { @@ -53,6 +55,8 @@ pub enum DelimToken { Brace, } +impl Copy for DelimToken {} + #[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)] pub enum IdentStyle { /// `::` follows the identifier with no whitespace in-between. @@ -85,6 +89,12 @@ impl Lit { } } +#[cfg(not(stage0))] +impl Copy for Lit {} + +#[cfg(not(stage0))] +impl Copy for IdentStyle {} + #[allow(non_camel_case_types)] #[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)] pub enum Token { @@ -435,6 +445,8 @@ macro_rules! declare_special_idents_and_keywords {( $( $rk_variant, )* } + impl Copy for Keyword {} + impl Keyword { pub fn to_name(&self) -> ast::Name { match *self { diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 7ab3d5dbcd1..c4e040a0f7c 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -72,18 +72,24 @@ pub enum Breaks { Inconsistent, } +impl Copy for Breaks {} + #[deriving(Clone)] pub struct BreakToken { offset: int, blank_space: int } +impl Copy for BreakToken {} + #[deriving(Clone)] pub struct BeginToken { offset: int, breaks: Breaks } +impl Copy for BeginToken {} + #[deriving(Clone)] pub enum Token { String(string::String, int), @@ -152,11 +158,15 @@ pub enum PrintStackBreak { Broken(Breaks), } +impl Copy for PrintStackBreak {} + 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 { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 6ce0ee79c62..eab03f73091 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -47,6 +47,8 @@ pub trait PpAnn { pub struct NoAnn; +impl Copy for NoAnn {} + impl PpAnn for NoAnn {} pub struct CurrentCommentAndLiteral { @@ -54,6 +56,8 @@ pub struct CurrentCommentAndLiteral { cur_lit: uint, } +impl Copy for CurrentCommentAndLiteral {} + pub struct State<'a> { pub s: pp::Printer, cm: Option<&'a CodeMap>, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 18623ca2a81..f5e89dd61ff 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -44,6 +44,8 @@ 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; |
