Skip to content

Commit c35c468

Browse files
committed
Fallout in public-facing and semi-public-facing libs
1 parent 49b76a0 commit c35c468

File tree

39 files changed

+273
-242
lines changed

39 files changed

+273
-242
lines changed

src/doc/reference.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ specific type.
16481648
Implementations are defined with the keyword `impl`.
16491649

16501650
```
1651-
# #[derive(Copy)]
1651+
# #[derive(Copy, Clone)]
16521652
# struct Point {x: f64, y: f64};
16531653
# type Surface = i32;
16541654
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
@@ -1661,6 +1661,10 @@ struct Circle {
16611661
16621662
impl Copy for Circle {}
16631663
1664+
impl Clone for Circle {
1665+
fn clone(&self) -> Circle { *self }
1666+
}
1667+
16641668
impl Shape for Circle {
16651669
fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
16661670
fn bounding_box(&self) -> BoundingBox {

src/libcollections/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//! use std::collections::BinaryHeap;
3131
//! use std::usize;
3232
//!
33-
//! #[derive(Copy, Eq, PartialEq)]
33+
//! #[derive(Copy, Clone, Eq, PartialEq)]
3434
//! struct State {
3535
//! cost: usize,
3636
//! position: usize,

src/libcollections/btree/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> {
526526
/// println!("Uninitialized memory: {:?}", handle.into_kv());
527527
/// }
528528
/// ```
529-
#[derive(Copy)]
529+
#[derive(Copy, Clone)]
530530
pub struct Handle<NodeRef, Type, NodeType> {
531531
node: NodeRef,
532532
index: usize,

src/libcollections/enum_set.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::ops::{Sub, BitOr, BitAnd, BitXor};
2121

2222
// FIXME(contentions): implement union family of methods? (general design may be wrong here)
2323

24-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
24+
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
2525
/// A specialized set implementation to use enum types.
2626
///
2727
/// It is a logic error for an item to be modified in such a way that the transformation of the
@@ -37,6 +37,10 @@ pub struct EnumSet<E> {
3737

3838
impl<E> Copy for EnumSet<E> {}
3939

40+
impl<E> Clone for EnumSet<E> {
41+
fn clone(&self) -> EnumSet<E> { *self }
42+
}
43+
4044
#[stable(feature = "rust1", since = "1.0.0")]
4145
impl<E:CLike + fmt::Debug> fmt::Debug for EnumSet<E> {
4246
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {

src/libcollectionstest/enum_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use collections::enum_set::{CLike, EnumSet};
1414

1515
use self::Foo::*;
1616

17-
#[derive(Copy, PartialEq, Debug)]
17+
#[derive(Copy, Clone, PartialEq, Debug)]
1818
#[repr(usize)]
1919
enum Foo {
2020
A, B, C
@@ -218,7 +218,7 @@ fn test_operators() {
218218
#[should_panic]
219219
fn test_overflow() {
220220
#[allow(dead_code)]
221-
#[derive(Copy)]
221+
#[derive(Copy, Clone)]
222222
#[repr(usize)]
223223
enum Bar {
224224
V00, V01, V02, V03, V04, V05, V06, V07, V08, V09,

src/libcore/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
122122
/// Rust's memory orderings are [the same as
123123
/// C++'s](http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync).
124124
#[stable(feature = "rust1", since = "1.0.0")]
125-
#[derive(Copy)]
125+
#[derive(Copy, Clone)]
126126
pub enum Ordering {
127127
/// No ordering constraints, only atomic operations.
128128
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/fmt/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use any;
1616
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
1717
use char::CharExt;
18+
use clone::Clone;
1819
use iter::Iterator;
1920
use marker::{Copy, PhantomData, Sized};
2021
use mem;
@@ -54,7 +55,7 @@ pub type Result = result::Result<(), Error>;
5455
/// occurred. Any extra information must be arranged to be transmitted through
5556
/// some other means.
5657
#[stable(feature = "rust1", since = "1.0.0")]
57-
#[derive(Copy, Debug)]
58+
#[derive(Copy, Clone, Debug)]
5859
pub struct Error;
5960

6061
/// A collection of methods that are required to format a message into a stream.
@@ -141,6 +142,12 @@ pub struct ArgumentV1<'a> {
141142
formatter: fn(&Void, &mut Formatter) -> Result,
142143
}
143144

145+
impl<'a> Clone for ArgumentV1<'a> {
146+
fn clone(&self) -> ArgumentV1<'a> {
147+
*self
148+
}
149+
}
150+
144151
impl<'a> ArgumentV1<'a> {
145152
#[inline(never)]
146153
fn show_usize(x: &usize, f: &mut Formatter) -> Result {
@@ -175,7 +182,7 @@ impl<'a> ArgumentV1<'a> {
175182
}
176183

177184
// flags available in the v1 format of format_args
178-
#[derive(Copy)]
185+
#[derive(Copy, Clone)]
179186
#[allow(dead_code)] // SignMinus isn't currently used
180187
enum FlagV1 { SignPlus, SignMinus, Alternate, SignAwareZeroPad, }
181188

@@ -222,7 +229,7 @@ impl<'a> Arguments<'a> {
222229
/// macro validates the format string at compile-time so usage of the `write`
223230
/// and `format` functions can be safely performed.
224231
#[stable(feature = "rust1", since = "1.0.0")]
225-
#[derive(Copy)]
232+
#[derive(Copy, Clone)]
226233
pub struct Arguments<'a> {
227234
// Format string pieces to print.
228235
pieces: &'a [&'a str],

src/libcore/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl GenericRadix for Radix {
139139
/// A helper type for formatting radixes.
140140
#[unstable(feature = "core",
141141
reason = "may be renamed or move to a different module")]
142-
#[derive(Copy)]
142+
#[derive(Copy, Clone)]
143143
pub struct RadixFmt<T, R>(T, R);
144144

145145
/// Constructs a radix formatter in the range of `2..36`.

src/libcore/fmt/rt/v1.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
#![stable(feature = "rust1", since = "1.0.0")]
1818

19-
#[derive(Copy)]
19+
#[derive(Copy, Clone)]
2020
#[stable(feature = "rust1", since = "1.0.0")]
2121
pub struct Argument {
2222
#[stable(feature = "rust1", since = "1.0.0")]
@@ -25,7 +25,7 @@ pub struct Argument {
2525
pub format: FormatSpec,
2626
}
2727

28-
#[derive(Copy)]
28+
#[derive(Copy, Clone)]
2929
#[stable(feature = "rust1", since = "1.0.0")]
3030
pub struct FormatSpec {
3131
#[stable(feature = "rust1", since = "1.0.0")]
@@ -41,7 +41,7 @@ pub struct FormatSpec {
4141
}
4242

4343
/// Possible alignments that can be requested as part of a formatting directive.
44-
#[derive(Copy, PartialEq)]
44+
#[derive(Copy, Clone, PartialEq)]
4545
#[stable(feature = "rust1", since = "1.0.0")]
4646
pub enum Alignment {
4747
/// Indication that contents should be left-aligned.
@@ -58,7 +58,7 @@ pub enum Alignment {
5858
Unknown,
5959
}
6060

61-
#[derive(Copy)]
61+
#[derive(Copy, Clone)]
6262
#[stable(feature = "rust1", since = "1.0.0")]
6363
pub enum Count {
6464
#[stable(feature = "rust1", since = "1.0.0")]
@@ -71,7 +71,7 @@ pub enum Count {
7171
Implied,
7272
}
7373

74-
#[derive(Copy)]
74+
#[derive(Copy, Clone)]
7575
#[stable(feature = "rust1", since = "1.0.0")]
7676
pub enum Position {
7777
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/marker.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub trait Sized : MarkerTrait {
7575
///
7676
/// ```
7777
/// // we can just derive a `Copy` implementation
78-
/// #[derive(Debug, Copy)]
78+
/// #[derive(Debug, Copy, Clone)]
7979
/// struct Foo;
8080
///
8181
/// let x = Foo;
@@ -124,7 +124,7 @@ pub trait Sized : MarkerTrait {
124124
/// There are two ways to implement `Copy` on your type:
125125
///
126126
/// ```
127-
/// #[derive(Copy)]
127+
/// #[derive(Copy, Clone)]
128128
/// struct MyStruct;
129129
/// ```
130130
///
@@ -133,6 +133,7 @@ pub trait Sized : MarkerTrait {
133133
/// ```
134134
/// struct MyStruct;
135135
/// impl Copy for MyStruct {}
136+
/// impl Clone for MyStruct { fn clone(&self) -> MyStruct { *self } }
136137
/// ```
137138
///
138139
/// There is a small difference between the two: the `derive` strategy will also place a `Copy`

0 commit comments

Comments
 (0)