diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 18:37:54 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 18:37:54 -0700 |
| commit | f92e7abefd0231f80d16062e5ff6aaf8cc3bc861 (patch) | |
| tree | e8c5150252807a3b65c231c338627aaaef025f92 /src/librustc | |
| parent | 05654e528d9835f5b994241970bb4b6162665750 (diff) | |
| parent | 449643301c1b30adf6b338174351219a58ffdb36 (diff) | |
| download | rust-f92e7abefd0231f80d16062e5ff6aaf8cc3bc861.tar.gz rust-f92e7abefd0231f80d16062e5ff6aaf8cc3bc861.zip | |
rollup merge of #23860: nikomatsakis/copy-requires-clone
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
Diffstat (limited to 'src/librustc')
27 files changed, 54 insertions, 51 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 9093cd00ca0..495044f9459 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -113,7 +113,7 @@ declare_lint! { } /// Does nothing as a lint pass, but registers some `Lint`s /// which are used by other parts of the compiler. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct HardwiredLints; impl LintPass for HardwiredLints { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 23f9cbc3a4b..498b2ce518c 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -41,7 +41,7 @@ pub use lint::context::{Context, LintStore, raw_emit_lint, check_crate, gather_a GatherNodeLevels}; /// Specification of a single lint. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Lint { /// A string identifier for the lint. /// diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index e4c0eda0448..cda00847686 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -116,7 +116,7 @@ pub const tag_items_data_item_reexport_def_id: usize = 0x47; pub const tag_items_data_item_reexport_name: usize = 0x48; // used to encode crate_ctxt side tables -#[derive(Copy, PartialEq, FromPrimitive)] +#[derive(Copy, Clone, PartialEq, FromPrimitive)] #[repr(usize)] pub enum astencode_tag { // Reserves 0x50 -- 0x6f tag_ast = 0x50, diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index ebc3a6fd52c..d528e38d341 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -29,7 +29,7 @@ use syntax::parse::token; use std::collections::hash_map::HashMap; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct MethodInfo { pub name: ast::Name, pub def_id: ast::DefId, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 284e76b328a..1567f4b9947 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -21,7 +21,7 @@ use std::path::{Path, PathBuf}; use util::fs as myfs; use session::search_paths::{SearchPaths, PathKind}; -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum FileMatch { FileMatches, FileDoesntMatch, diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index e2eebbfdc72..3fb128b1881 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -43,7 +43,7 @@ use syntax::parse::token; // def-id will depend on where it originated from. Therefore, the conversion // function is given an indicator of the source of the def-id. See // astencode.rs for more information. -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum DefIdSource { // Identifies a struct, trait, enum, etc. NominalType, diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 24c54b53590..cbc2ef1535e 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -25,7 +25,7 @@ struct CFGBuilder<'a, 'tcx: 'a> { loop_scopes: Vec<LoopScope>, } -#[derive(Copy)] +#[derive(Copy, Clone)] struct LoopScope { loop_id: ast::NodeId, // id of loop/while node continue_index: CFGIndex, // where to go on a `loop` diff --git a/src/librustc/middle/cfg/mod.rs b/src/librustc/middle/cfg/mod.rs index e8a99f59b1e..ad4fdcd7b83 100644 --- a/src/librustc/middle/cfg/mod.rs +++ b/src/librustc/middle/cfg/mod.rs @@ -24,7 +24,7 @@ pub struct CFG { pub exit: CFGIndex, } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum CFGNodeData { AST(ast::NodeId), Entry, diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 497022ac6ac..ce011f2561b 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -76,7 +76,7 @@ bitflags! { } } -#[derive(Copy, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq)] enum Mode { Const, Static, diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index ea584407944..bf6829d9676 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -21,7 +21,7 @@ enum Context { Normal, Loop, Closure } -#[derive(Copy)] +#[derive(Copy, Clone)] struct CheckLoopVisitor<'a> { sess: &'a Session, cx: Context diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 01692158c17..79f4d62b45e 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -128,7 +128,7 @@ enum Usefulness { NotUseful } -#[derive(Copy)] +#[derive(Copy, Clone)] enum WitnessPreference { ConstructWitness, LeaveOutWitness diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 7e436d95192..f69ac030520 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -28,7 +28,7 @@ use syntax::visit; use syntax::print::{pp, pprust}; use util::nodemap::NodeMap; -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum EntryOrExit { Entry, Exit, diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index c60bb229be1..6707a4d3fd7 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/middle/def.rs @@ -104,7 +104,7 @@ pub type DefMap = RefCell<NodeMap<PathResolution>>; // within. pub type ExportMap = NodeMap<Vec<Export>>; -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Export { pub name: ast::Name, // The name of the target. pub def_id: ast::DefId, // The definition of the target. diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index 5d970c59f63..814492cbef1 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -22,7 +22,7 @@ use syntax::codemap::Span; use syntax::visit; use syntax::visit::Visitor; -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] enum UnsafeContext { SafeContext, UnsafeFn, diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index e98b438d370..2fa9c7c8fbe 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -94,7 +94,7 @@ pub trait Delegate<'tcx> { mode: MutateMode); } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum LoanCause { ClosureCapture(Span), AddrOf, @@ -106,20 +106,20 @@ pub enum LoanCause { MatchDiscriminant } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum ConsumeMode { Copy, // reference to x where x has a type that copies Move(MoveReason), // reference to x where x has a type that moves } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum MoveReason { DirectRefMove, PatBindingMove, CaptureMove, } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum MatchMode { NonBindingMatch, BorrowingMatch, @@ -127,7 +127,7 @@ pub enum MatchMode { MovingMatch, } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] enum TrackMatchMode { Unknown, Definite(MatchMode), @@ -194,14 +194,14 @@ impl TrackMatchMode { } } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum MutateMode { Init, JustWrite, // x = y WriteAndRead, // x += y } -#[derive(Copy)] +#[derive(Copy, Clone)] enum OverloadedCallType { FnOverloadedCall, FnMutOverloadedCall, diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 8673273f9b3..a9ac61b49ec 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -66,13 +66,13 @@ pub struct NodeIndex(pub usize); #[allow(non_upper_case_globals)] pub const InvalidNodeIndex: NodeIndex = NodeIndex(usize::MAX); -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub struct EdgeIndex(pub usize); #[allow(non_upper_case_globals)] pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(usize::MAX); // Use a private field here to guarantee no more instances are created: -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Direction { repr: usize } #[allow(non_upper_case_globals)] pub const Outgoing: Direction = Direction { repr: 0 }; diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index da811c35457..b11e25c059d 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -290,7 +290,7 @@ pub enum RegionVariableOrigin { BoundRegionInCoherence(ast::Name), } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum fixup_err { unresolved_int_ty(IntVid), unresolved_float_ty(FloatVid), diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 98347e97e09..d41fdc5f09a 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -74,13 +74,13 @@ pub enum GenericKind<'tcx> { Projection(ty::ProjectionTy<'tcx>), } -#[derive(Copy, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct TwoRegions { a: Region, b: Region, } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum UndoLogEntry { OpenSnapshot, CommitedSnapshot, @@ -91,7 +91,7 @@ pub enum UndoLogEntry { AddCombination(CombineMapType, TwoRegions) } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum CombineMapType { Lub, Glb } @@ -951,10 +951,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // ______________________________________________________________________ -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] enum Classification { Expanding, Contracting } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum VarValue { NoValue, Value(Region), ErrorValue } struct VarData { diff --git a/src/librustc/middle/infer/type_variable.rs b/src/librustc/middle/infer/type_variable.rs index 553ef9afc28..03612a6c1ae 100644 --- a/src/librustc/middle/infer/type_variable.rs +++ b/src/librustc/middle/infer/type_variable.rs @@ -47,7 +47,7 @@ struct Delegate<'tcx>(PhantomData<&'tcx ()>); type Relation = (RelationDir, ty::TyVid); -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] pub enum RelationDir { SubtypeOf, SupertypeOf, EqTo, BiTo } diff --git a/src/librustc/middle/infer/unify.rs b/src/librustc/middle/infer/unify.rs index 39271d4cdc5..4bbced1d75c 100644 --- a/src/librustc/middle/infer/unify.rs +++ b/src/librustc/middle/infer/unify.rs @@ -84,7 +84,7 @@ pub struct Node<K:UnifyKey> { pub rank: usize, } -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Delegate<K>(PhantomData<K>); // We can't use V:LatticeValue, much as I would like to, diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index b9a82669f65..a08de58f909 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -46,7 +46,7 @@ macro_rules! lets_do_this { $( $variant:ident, $name:expr, $method:ident; )* ) => { -#[derive(Copy, FromPrimitive, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, FromPrimitive, PartialEq, Eq, Hash)] pub enum LangItem { $($variant),* } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 705f20559af..d7161607b61 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -139,7 +139,7 @@ enum LoopKind<'a> { WhileLoop(&'a Expr), } -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] struct Variable(usize); #[derive(Copy, PartialEq)] @@ -159,7 +159,7 @@ impl Clone for LiveNode { } } -#[derive(Copy, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Debug)] enum LiveNodeKind { FreeVarNode(Span), ExprNode(Span), @@ -245,13 +245,13 @@ struct CaptureInfo { var_nid: NodeId } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] struct LocalInfo { id: NodeId, ident: ast::Ident } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] enum VarKind { Arg(NodeId, ast::Ident), Local(LocalInfo), @@ -534,7 +534,7 @@ fn invalid_users() -> Users { } } -#[derive(Copy)] +#[derive(Copy, Clone)] struct Specials { exit_ln: LiveNode, fallthrough_ln: LiveNode, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 3738e38f687..85255d04df4 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -199,7 +199,7 @@ pub type cmt<'tcx> = Rc<cmt_<'tcx>>; // We pun on *T to mean both actual deref of a ptr as well // as accessing of components: -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum deref_kind { deref_ptr(PointerKind), deref_interior(InteriorKind), @@ -263,6 +263,9 @@ pub struct MemCategorizationContext<'t,TYPER:'t> { } impl<'t,TYPER:'t> Copy for MemCategorizationContext<'t,TYPER> {} +impl<'t,TYPER:'t> Clone for MemCategorizationContext<'t,TYPER> { + fn clone(&self) -> MemCategorizationContext<'t,TYPER> { *self } +} pub type McResult<T> = Result<T, ()>; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index b68f8fa9b98..652f6613252 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -271,7 +271,7 @@ pub struct RegionMaps { /// Carries the node id for the innermost block or match expression, /// for building up the `var_map` which maps ids to the blocks in /// which they were declared. -#[derive(PartialEq, Eq, Debug, Copy)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] enum InnermostDeclaringBlock { None, Block(ast::NodeId), @@ -296,7 +296,7 @@ impl InnermostDeclaringBlock { /// Contextual information for declarations introduced by a statement /// (i.e. `let`). It carries node-id's for statement and enclosing /// block both, as well as the statement's index within the block. -#[derive(PartialEq, Eq, Debug, Copy)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] struct DeclaringStatementContext { stmt_id: ast::NodeId, block_id: ast::NodeId, @@ -312,7 +312,7 @@ impl DeclaringStatementContext { } } -#[derive(PartialEq, Eq, Debug, Copy)] +#[derive(PartialEq, Eq, Debug, Copy, Clone)] enum InnermostEnclosingExpr { None, Some(ast::NodeId), @@ -334,7 +334,7 @@ impl InnermostEnclosingExpr { } } -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Context { /// the root of the current region tree. This is typically the id /// of the innermost fn body. Each fn forms its own disjoint tree diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index bb2d37c944c..f7e7d071f8c 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -99,7 +99,7 @@ pub enum MethodMatchResult { MethodDidNotMatch, } -#[derive(Copy, Debug)] +#[derive(Copy, Clone, Debug)] pub enum MethodMatchedData { // In the case of a precise match, we don't really need to store // how the match was found. So don't. diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 0814ec2c84e..1123c923631 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -262,7 +262,7 @@ pub struct field_ty { // Contains information needed to resolve types and (in the future) look up // the types of AST nodes. -#[derive(Copy, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct creader_cache_key { pub cnum: CrateNum, pub pos: usize, @@ -596,7 +596,7 @@ pub type ObjectCastMap<'tcx> = RefCell<NodeMap<ty::PolyTraitRef<'tcx>>>; /// will push one or more such restriction into the /// `transmute_restrictions` vector during `intrinsicck`. They are /// then checked during `trans` by the fn `check_intrinsics`. -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct TransmuteRestriction<'tcx> { /// The span whence the restriction comes. pub span: Span, @@ -886,7 +886,7 @@ macro_rules! sty_debug_print { // variable names. mod inner { use middle::ty; - #[derive(Copy)] + #[derive(Copy, Clone)] struct DebugStat { total: usize, region_infer: usize, @@ -4003,7 +4003,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { /// /// The ordering of the cases is significant. They are sorted so that cmp::max /// will keep the "more erroneous" of two values. -#[derive(Copy, PartialOrd, Ord, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Debug)] pub enum Representability { Representable, ContainsRecursive, @@ -4734,7 +4734,7 @@ pub fn expr_is_lval(tcx: &ctxt, e: &ast::Expr) -> bool { /// two kinds of rvalues is an artifact of trans which reflects how we will /// generate code for that kind of expression. See trans/expr.rs for more /// information. -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum ExprKind { LvalueExpr, RvalueDpsExpr, @@ -5430,7 +5430,7 @@ pub fn item_path_str(cx: &ctxt, id: ast::DefId) -> String { with_path(cx, id, |path| ast_map::path_to_string(path)).to_string() } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum DtorKind { NoDtor, TraitDtor(DefId, bool) @@ -7154,7 +7154,7 @@ pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref.substs.clone().with_method(meth_tps, meth_regions) } -#[derive(Copy)] +#[derive(Copy, Clone)] pub enum CopyImplementationError { FieldDoesNotImplementCopy(ast::Name), VariantDoesNotImplementCopy(ast::Name), diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 5a598921195..a7d608d2c87 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -247,7 +247,7 @@ pub fn basic_options() -> Options { // users can have their own entry // functions that don't start a // scheduler -#[derive(Copy, PartialEq)] +#[derive(Copy, Clone, PartialEq)] pub enum EntryFnType { EntryMain, EntryStart, |
