Skip to content

Commit 68fbb5d

Browse files
committed
---
yaml --- r: 161663 b: refs/heads/snap-stage3 c: cafe296 h: refs/heads/master i: 161661: 87314f4 161659: fcf7323 161655: 0b0e53c 161647: 017690a 161631: e6207f8 161599: 42f0733 161535: c3614a5 v: v3
1 parent fce97e6 commit 68fbb5d

File tree

294 files changed

+2622
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+2622
-648
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4eb72d268f337a8f117c86a2ac1b98336cab9e9d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 7176dd1c9039d7d10c0ceb694b929d094cc299e3
4+
refs/heads/snap-stage3: cafe2966770ff377aad6dd9fd808e68055587c58
55
refs/heads/try: 0f0d21c1eb5c7be04d323e0b06faf252ad790af6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/compiletest/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub enum Mode {
2525
Codegen
2626
}
2727

28+
impl Copy for Mode {}
29+
2830
impl FromStr for Mode {
2931
fn from_str(s: &str) -> Option<Mode> {
3032
match s {

branches/snap-stage3/src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
346346
desc: test::TestDesc {
347347
name: make_test_name(config, testfile),
348348
ignore: header::is_test_ignored(config, testfile),
349-
should_fail: false
349+
should_fail: test::ShouldFail::No,
350350
},
351351
testfn: f(),
352352
}

branches/snap-stage3/src/doc/guide-testing.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ fn test_out_of_bounds_failure() {
8989
}
9090
~~~
9191

92+
`#[should_fail]` tests can be fragile as it's hard to guarantee that the test
93+
didn't fail for an unexpected reason. To help with this, an optional `expected`
94+
parameter can be added to the `should_fail` attribute. The test harness will
95+
make sure that the failure message contains the provided text. A safer version
96+
of the example above would be:
97+
98+
~~~test_harness
99+
#[test]
100+
#[should_fail(expected = "index out of bounds")]
101+
fn test_out_of_bounds_failure() {
102+
let v: &[int] = &[];
103+
v[0];
104+
}
105+
~~~
106+
92107
A test runner built with the `--test` flag supports a limited set of
93108
arguments to control which tests are run:
94109

branches/snap-stage3/src/doc/guide-unsafe.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,9 @@ extern {
661661
fn abort() -> !;
662662
}
663663
664+
#[lang = "owned_box"]
665+
pub struct Box<T>(*mut T);
666+
664667
#[lang="exchange_malloc"]
665668
unsafe fn allocate(size: uint, _align: uint) -> *mut u8 {
666669
let p = libc::malloc(size as libc::size_t) as *mut u8;

branches/snap-stage3/src/doc/reference.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,7 @@ Implementations are defined with the keyword `impl`.
16601660

16611661
```
16621662
# struct Point {x: f64, y: f64};
1663+
# impl Copy for Point {}
16631664
# type Surface = int;
16641665
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
16651666
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
@@ -1669,6 +1670,8 @@ struct Circle {
16691670
center: Point,
16701671
}
16711672
1673+
impl Copy for Circle {}
1674+
16721675
impl Shape for Circle {
16731676
fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
16741677
fn bounding_box(&self) -> BoundingBox {
@@ -1791,6 +1794,7 @@ default visibility with the `priv` keyword. When an item is declared as `pub`,
17911794
it can be thought of as being accessible to the outside world. For example:
17921795

17931796
```
1797+
# #![allow(missing_copy_implementations)]
17941798
# fn main() {}
17951799
// Declare a private struct
17961800
struct Foo;

branches/snap-stage3/src/libarena/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl<T> TypedArena<T> {
466466
}
467467

468468
let ptr: &mut T = unsafe {
469-
let ptr: &mut T = mem::transmute(self.ptr);
469+
let ptr: &mut T = mem::transmute(self.ptr.clone());
470470
ptr::write(ptr, object);
471471
self.ptr.set(self.ptr.get().offset(1));
472472
ptr

branches/snap-stage3/src/libcollections/binary_heap.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
//! position: uint
3636
//! }
3737
//!
38+
//! impl Copy for State {}
39+
//!
3840
//! // The priority queue depends on `Ord`.
3941
//! // Explicitly implement the trait so the queue becomes a min-heap
4042
//! // instead of a max-heap.

branches/snap-stage3/src/libcollections/btree/map.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,12 +1068,38 @@ impl<K, V> BTreeMap<K, V> {
10681068
}
10691069

10701070
/// Gets an iterator over the keys of the map.
1071+
///
1072+
/// # Example
1073+
///
1074+
/// ```
1075+
/// use std::collections::BTreeMap;
1076+
///
1077+
/// let mut a = BTreeMap::new();
1078+
/// a.insert(1u, "a");
1079+
/// a.insert(2u, "b");
1080+
///
1081+
/// let keys: Vec<uint> = a.keys().cloned().collect();
1082+
/// assert_eq!(keys, vec![1u,2,]);
1083+
/// ```
10711084
#[unstable = "matches collection reform specification, waiting for dust to settle"]
10721085
pub fn keys<'a>(&'a self) -> Keys<'a, K, V> {
10731086
self.iter().map(|(k, _)| k)
10741087
}
10751088

10761089
/// Gets an iterator over the values of the map.
1090+
///
1091+
/// # Example
1092+
///
1093+
/// ```
1094+
/// use std::collections::BTreeMap;
1095+
///
1096+
/// let mut a = BTreeMap::new();
1097+
/// a.insert(1u, "a");
1098+
/// a.insert(2u, "b");
1099+
///
1100+
/// let values: Vec<&str> = a.values().cloned().collect();
1101+
/// assert_eq!(values, vec!["a","b"]);
1102+
/// ```
10771103
#[unstable = "matches collection reform specification, waiting for dust to settle"]
10781104
pub fn values<'a>(&'a self) -> Values<'a, K, V> {
10791105
self.iter().map(|(_, v)| v)

branches/snap-stage3/src/libcollections/dlist.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ pub struct DList<T> {
3939
}
4040

4141
type Link<T> = Option<Box<Node<T>>>;
42-
struct Rawlink<T> { p: *mut T }
42+
43+
struct Rawlink<T> {
44+
p: *mut T,
45+
}
46+
47+
impl<T> Copy for Rawlink<T> {}
4348

4449
struct Node<T> {
4550
next: Link<T>,
@@ -59,6 +64,8 @@ impl<'a, T> Clone for Items<'a, T> {
5964
fn clone(&self) -> Items<'a, T> { *self }
6065
}
6166

67+
impl<'a,T> Copy for Items<'a,T> {}
68+
6269
/// An iterator over mutable references to the items of a `DList`.
6370
pub struct MutItems<'a, T:'a> {
6471
list: &'a mut DList<T>,

branches/snap-stage3/src/libcollections/enum_set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub struct EnumSet<E> {
2727
bits: uint
2828
}
2929

30+
impl<E> Copy for EnumSet<E> {}
31+
3032
impl<E:CLike+fmt::Show> fmt::Show for EnumSet<E> {
3133
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
3234
try!(write!(fmt, "{{"));
@@ -269,6 +271,8 @@ mod test {
269271
A, B, C
270272
}
271273

274+
impl Copy for Foo {}
275+
272276
impl CLike for Foo {
273277
fn to_uint(&self) -> uint {
274278
*self as uint
@@ -477,6 +481,9 @@ mod test {
477481
V50, V51, V52, V53, V54, V55, V56, V57, V58, V59,
478482
V60, V61, V62, V63, V64, V65, V66, V67, V68, V69,
479483
}
484+
485+
impl Copy for Bar {}
486+
480487
impl CLike for Bar {
481488
fn to_uint(&self) -> uint {
482489
*self as uint

branches/snap-stage3/src/libcollections/hash/sip.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub struct SipState {
4343
ntail: uint, // how many bytes in tail are valid
4444
}
4545

46+
impl Copy for SipState {}
47+
4648
// sadly, these macro definitions can't appear later,
4749
// because they're needed in the following defs;
4850
// this design could be improved.
@@ -211,6 +213,7 @@ impl Default for SipState {
211213

212214
/// `SipHasher` computes the SipHash algorithm from a stream of bytes.
213215
#[deriving(Clone)]
216+
#[allow(missing_copy_implementations)]
214217
pub struct SipHasher {
215218
k0: u64,
216219
k1: u64,

branches/snap-stage3/src/libcollections/slice.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use self::Direction::*;
9191
use alloc::boxed::Box;
9292
use core::borrow::{BorrowFrom, BorrowFromMut, ToOwned};
9393
use core::cmp;
94-
use core::kinds::Sized;
94+
use core::kinds::{Copy, Sized};
9595
use core::mem::size_of;
9696
use core::mem;
9797
use core::prelude::{Clone, Greater, Iterator, IteratorExt, Less, None, Option};
@@ -177,12 +177,16 @@ impl ElementSwaps {
177177

178178
enum Direction { Pos, Neg }
179179

180+
impl Copy for Direction {}
181+
180182
/// An `Index` and `Direction` together.
181183
struct SizeDirection {
182184
size: uint,
183185
dir: Direction,
184186
}
185187

188+
impl Copy for SizeDirection {}
189+
186190
impl Iterator<(uint, uint)> for ElementSwaps {
187191
#[inline]
188192
fn next(&mut self) -> Option<(uint, uint)> {
@@ -1482,11 +1486,17 @@ mod tests {
14821486
fn clone(&self) -> S {
14831487
self.f.set(self.f.get() + 1);
14841488
if self.f.get() == 10 { panic!() }
1485-
S { f: self.f, boxes: self.boxes.clone() }
1489+
S {
1490+
f: self.f.clone(),
1491+
boxes: self.boxes.clone(),
1492+
}
14861493
}
14871494
}
14881495

1489-
let s = S { f: Cell::new(0), boxes: (box 0, Rc::new(0)) };
1496+
let s = S {
1497+
f: Cell::new(0),
1498+
boxes: (box 0, Rc::new(0)),
1499+
};
14901500
let _ = Vec::from_elem(100, s);
14911501
}
14921502

branches/snap-stage3/src/libcollections/str.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,32 @@ impl<'a> Iterator<char> for Decompositions<'a> {
228228
_ => self.sorted = false
229229
}
230230

231-
let decomposer = match self.kind {
232-
Canonical => unicode::char::decompose_canonical,
233-
Compatible => unicode::char::decompose_compatible
234-
};
235-
236231
if !self.sorted {
237232
for ch in self.iter {
238233
let buffer = &mut self.buffer;
239234
let sorted = &mut self.sorted;
240-
decomposer(ch, |d| {
241-
let class = unicode::char::canonical_combining_class(d);
242-
if class == 0 && !*sorted {
243-
canonical_sort(buffer.as_mut_slice());
244-
*sorted = true;
235+
{
236+
let callback = |d| {
237+
let class =
238+
unicode::char::canonical_combining_class(d);
239+
if class == 0 && !*sorted {
240+
canonical_sort(buffer.as_mut_slice());
241+
*sorted = true;
242+
}
243+
buffer.push((d, class));
244+
};
245+
match self.kind {
246+
Canonical => {
247+
unicode::char::decompose_canonical(ch, callback)
248+
}
249+
Compatible => {
250+
unicode::char::decompose_compatible(ch, callback)
251+
}
245252
}
246-
buffer.push((d, class));
247-
});
248-
if *sorted { break }
253+
}
254+
if *sorted {
255+
break
256+
}
249257
}
250258
}
251259

branches/snap-stage3/src/libcollections/vec.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,9 @@ impl<T> Vec<T> {
218218
}
219219
}
220220

221-
/// Creates a `Vec<T>` directly from the raw constituents.
221+
/// Creates a `Vec<T>` directly from the raw components of another vector.
222222
///
223-
/// This is highly unsafe:
224-
///
225-
/// - if `ptr` is null, then `length` and `capacity` should be 0
226-
/// - `ptr` must point to an allocation of size `capacity`
227-
/// - there must be `length` valid instances of type `T` at the
228-
/// beginning of that allocation
229-
/// - `ptr` must be allocated by the default `Vec` allocator
223+
/// This is highly unsafe, due to the number of invariants that aren't checked.
230224
///
231225
/// # Example
232226
///
@@ -688,11 +682,12 @@ impl<T> Vec<T> {
688682
Some(new_cap) => {
689683
let amort_cap = new_cap.next_power_of_two();
690684
// next_power_of_two will overflow to exactly 0 for really big capacities
691-
if amort_cap == 0 {
692-
self.grow_capacity(new_cap);
685+
let cap = if amort_cap == 0 {
686+
new_cap
693687
} else {
694-
self.grow_capacity(amort_cap);
695-
}
688+
amort_cap
689+
};
690+
self.grow_capacity(cap)
696691
}
697692
}
698693
}

branches/snap-stage3/src/libcore/atomic.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub use self::Ordering::*;
1717
use intrinsics;
1818
use std::kinds::marker;
1919
use cell::UnsafeCell;
20+
use kinds::Copy;
2021

2122
/// A boolean type which can be safely shared between threads.
2223
#[stable]
@@ -81,6 +82,8 @@ pub enum Ordering {
8182
SeqCst,
8283
}
8384

85+
impl Copy for Ordering {}
86+
8487
/// An `AtomicBool` initialized to `false`.
8588
#[unstable = "may be renamed, pending conventions for static initalizers"]
8689
pub const INIT_ATOMIC_BOOL: AtomicBool =

branches/snap-stage3/src/libcore/char.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,4 @@ impl Iterator<char> for DefaultEscapedChars {
519519
}
520520
}
521521
}
522+

branches/snap-stage3/src/libcore/cmp.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@
4343

4444
pub use self::Ordering::*;
4545

46-
use kinds::Sized;
47-
use option::Option;
48-
use option::Option::{Some, None};
46+
use kinds::{Copy, Sized};
47+
use option::{Option, Some, None};
4948

5049
/// Trait for values that can be compared for equality and inequality.
5150
///
@@ -106,6 +105,8 @@ pub enum Ordering {
106105
Greater = 1i,
107106
}
108107

108+
impl Copy for Ordering {}
109+
109110
impl Ordering {
110111
/// Reverse the `Ordering`, so that `Less` becomes `Greater` and
111112
/// vice versa.

0 commit comments

Comments
 (0)