Skip to content

Commit 518f3f4

Browse files
committed
---
yaml --- r: 155449 b: refs/heads/try2 c: ef112fe h: refs/heads/master i: 155447: 8d3d3f2 v: v3
1 parent 98c43a9 commit 518f3f4

Some content is hidden

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

89 files changed

+2003
-1411
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b6edc59413f79016a1063c2ec6bc05516bc99cb6
8+
refs/heads/try2: ef112fe185a49ad9c49722702a695d8bd6b9df47
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/crates.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5959
TOOLS := compiletest rustdoc rustc
6060

6161
DEPS_core :=
62+
DEPS_libc := core
6263
DEPS_rlibc := core
6364
DEPS_unicode := core
6465
DEPS_alloc := core libc native:jemalloc

branches/try2/src/doc/guide-pointers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ As being similar to this C code:
505505
{
506506
int *x;
507507
x = (int *)malloc(sizeof(int));
508+
*x = 5;
508509
509510
// stuff happens
510511

branches/try2/src/doc/guide-testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ is not used.
7272
Tests that should not be run can be annotated with the `ignore`
7373
attribute. The existence of these tests will be noted in the test
7474
runner output, but the test will not be run. Tests can also be ignored
75-
by configuration so, for example, to ignore a test on windows you can
76-
write `#[ignore(cfg(target_os = "win32"))]`.
75+
by configuration using the `cfg_attr` attribute so, for example, to ignore a
76+
test on windows you can write `#[cfg_attr(windows, ignore)]`.
7777

7878
Tests that are intended to fail can be annotated with the
7979
`should_fail` attribute. The test will be run, and if it causes its

branches/try2/src/doc/guide-unsafe.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ fn start(_argc: int, _argv: *const *const u8) -> int {
466466
// provided by libstd.
467467
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
468468
#[lang = "eh_personality"] extern fn eh_personality() {}
469-
#[lang = "sized"] trait Sized { }
469+
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
470470
# // fn main() {} tricked you, rustdoc!
471471
```
472472

@@ -489,32 +489,28 @@ pub extern fn main(argc: int, argv: *const *const u8) -> int {
489489
490490
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
491491
#[lang = "eh_personality"] extern fn eh_personality() {}
492-
#[lang = "sized"] trait Sized { }
492+
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
493493
# // fn main() {} tricked you, rustdoc!
494494
```
495495

496496

497497
The compiler currently makes a few assumptions about symbols which are available
498498
in the executable to call. Normally these functions are provided by the standard
499-
xlibrary, but without it you must define your own.
499+
library, but without it you must define your own.
500500

501-
The first of these two functions, `stack_exhausted`, is invoked whenever stack
501+
The first of these three functions, `stack_exhausted`, is invoked whenever stack
502502
overflow is detected. This function has a number of restrictions about how it
503503
can be called and what it must do, but if the stack limit register is not being
504504
maintained then a task always has an "infinite stack" and this function
505505
shouldn't get triggered.
506506

507-
The second of these two functions, `eh_personality`, is used by the failure
508-
mechanisms of the compiler. This is often mapped to GCC's personality function
509-
(see the [libstd implementation](std/rt/unwind/index.html) for more
510-
information), but crates which do not trigger failure can be assured that this
511-
function is never called.
512-
513-
The final item in the example is a trait called `Sized`. This a trait
514-
that represents data of a known static size: it is integral to the
515-
Rust type system, and so the compiler expects the standard library to
516-
provide it. Since you are not using the standard library, you have to
517-
provide it yourself.
507+
The second of these three functions, `eh_personality`, is used by the
508+
failure mechanisms of the compiler. This is often mapped to GCC's
509+
personality function (see the
510+
[libstd implementation](std/rt/unwind/index.html) for more
511+
information), but crates which do not trigger failure can be assured
512+
that this function is never called. The final function, `fail_fmt`, is
513+
also used by the failure mechanisms of the compiler.
518514

519515
## Using libcore
520516

@@ -694,7 +690,7 @@ fn main(argc: int, argv: *const *const u8) -> int {
694690
695691
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
696692
#[lang = "eh_personality"] extern fn eh_personality() {}
697-
#[lang = "sized"] trait Sized {}
693+
#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} }
698694
```
699695

700696
Note the use of `abort`: the `exchange_malloc` lang item is assumed to

branches/try2/src/doc/guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,8 +4489,8 @@ This will print
44894489
```
44904490

44914491
`filter()` is an adapter that takes a closure as an argument. This closure
4492-
returns `true` or `false`. The new iterator `filter()` produces returns
4493-
only the elements that that closure returned `true` for:
4492+
returns `true` or `false`. The new iterator `filter()` produces
4493+
only the elements that that closure returns `true` for:
44944494

44954495
```{rust}
44964496
for i in range(1i, 100i).filter(|x| x % 2 == 0) {

branches/try2/src/libcollections/dlist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ mod tests {
844844
}
845845

846846
#[test]
847+
#[allow(deprecated)]
847848
fn test_append() {
848849
{
849850
let mut m = DList::new();

branches/try2/src/libcollections/slice.rs

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,16 @@ mod tests {
850850
assert_eq!(a.as_slice().head().unwrap(), &11);
851851
}
852852

853+
#[test]
854+
fn test_head_mut() {
855+
let mut a = vec![];
856+
assert_eq!(a.as_mut_slice().head_mut(), None);
857+
a = vec![11i];
858+
assert_eq!(*a.as_mut_slice().head_mut().unwrap(), 11);
859+
a = vec![11i, 12];
860+
assert_eq!(*a.as_mut_slice().head_mut().unwrap(), 11);
861+
}
862+
853863
#[test]
854864
fn test_tail() {
855865
let mut a = vec![11i];
@@ -860,22 +870,39 @@ mod tests {
860870
assert_eq!(a.tail(), b);
861871
}
862872

873+
#[test]
874+
fn test_tail_mut() {
875+
let mut a = vec![11i];
876+
let b: &mut [int] = &mut [];
877+
assert!(a.as_mut_slice().tail_mut() == b);
878+
a = vec![11i, 12];
879+
let b: &mut [int] = &mut [12];
880+
assert!(a.as_mut_slice().tail_mut() == b);
881+
}
882+
863883
#[test]
864884
#[should_fail]
865885
fn test_tail_empty() {
866886
let a: Vec<int> = vec![];
867887
a.tail();
868888
}
869889

890+
#[test]
891+
#[should_fail]
892+
fn test_tail_mut_empty() {
893+
let mut a: Vec<int> = vec![];
894+
a.as_mut_slice().tail_mut();
895+
}
896+
870897
#[test]
871898
#[allow(deprecated)]
872899
fn test_tailn() {
873900
let mut a = vec![11i, 12, 13];
874-
let b: &[int] = &[11, 12, 13];
875-
assert_eq!(a.tailn(0), b);
901+
let b: &mut [int] = &mut [11, 12, 13];
902+
assert!(a.tailn(0) == b);
876903
a = vec![11i, 12, 13];
877-
let b: &[int] = &[13];
878-
assert_eq!(a.tailn(2), b);
904+
let b: &mut [int] = &mut [13];
905+
assert!(a.tailn(2) == b);
879906
}
880907

881908
#[test]
@@ -896,13 +923,30 @@ mod tests {
896923
assert_eq!(a.init(), b);
897924
}
898925

926+
#[test]
927+
fn test_init_mut() {
928+
let mut a = vec![11i];
929+
let b: &mut [int] = &mut [];
930+
assert!(a.as_mut_slice().init_mut() == b);
931+
a = vec![11i, 12];
932+
let b: &mut [int] = &mut [11];
933+
assert!(a.as_mut_slice().init_mut() == b);
934+
}
935+
899936
#[test]
900937
#[should_fail]
901938
fn test_init_empty() {
902939
let a: Vec<int> = vec![];
903940
a.init();
904941
}
905942

943+
#[test]
944+
#[should_fail]
945+
fn test_init_mut_empty() {
946+
let mut a: Vec<int> = vec![];
947+
a.as_mut_slice().init_mut();
948+
}
949+
906950
#[test]
907951
#[allow(deprecated)]
908952
fn test_initn() {
@@ -932,6 +976,16 @@ mod tests {
932976
assert_eq!(a.as_slice().last().unwrap(), &12);
933977
}
934978

979+
#[test]
980+
fn test_last_mut() {
981+
let mut a = vec![];
982+
assert_eq!(a.as_mut_slice().last_mut(), None);
983+
a = vec![11i];
984+
assert_eq!(*a.as_mut_slice().last_mut().unwrap(), 11);
985+
a = vec![11i, 12];
986+
assert_eq!(*a.as_mut_slice().last_mut().unwrap(), 12);
987+
}
988+
935989
#[test]
936990
fn test_slice() {
937991
// Test fixed length vector.
@@ -1077,6 +1131,7 @@ mod tests {
10771131
}
10781132

10791133
#[test]
1134+
#[allow(deprecated)]
10801135
fn test_grow_set() {
10811136
let mut v = vec![1i, 2, 3];
10821137
v.grow_set(4u, &4, 5);
@@ -1610,6 +1665,7 @@ mod tests {
16101665

16111666
#[test]
16121667
#[should_fail]
1668+
#[allow(deprecated)]
16131669
fn test_copy_memory_oob() {
16141670
unsafe {
16151671
let mut a = [1i, 2, 3, 4];
@@ -1793,6 +1849,26 @@ mod tests {
17931849
assert_eq!(xs.splitn(1, |x| *x == 5).collect::<Vec<&[int]>>().as_slice(), splits);
17941850
}
17951851

1852+
#[test]
1853+
fn test_splitnator_mut() {
1854+
let xs = &mut [1i,2,3,4,5];
1855+
1856+
let splits: &[&mut [int]] = &[&mut [1,2,3,4,5]];
1857+
assert_eq!(xs.splitn_mut(0, |x| *x % 2 == 0).collect::<Vec<&mut [int]>>().as_slice(),
1858+
splits);
1859+
let splits: &[&mut [int]] = &[&mut [1], &mut [3,4,5]];
1860+
assert_eq!(xs.splitn_mut(1, |x| *x % 2 == 0).collect::<Vec<&mut [int]>>().as_slice(),
1861+
splits);
1862+
let splits: &[&mut [int]] = &[&mut [], &mut [], &mut [], &mut [4,5]];
1863+
assert_eq!(xs.splitn_mut(3, |_| true).collect::<Vec<&mut [int]>>().as_slice(),
1864+
splits);
1865+
1866+
let xs: &mut [int] = &mut [];
1867+
let splits: &[&mut [int]] = &[&mut []];
1868+
assert_eq!(xs.splitn_mut(1, |x| *x == 5).collect::<Vec<&mut [int]>>().as_slice(),
1869+
splits);
1870+
}
1871+
17961872
#[test]
17971873
fn test_rsplitator() {
17981874
let xs = &[1i,2,3,4,5];

branches/try2/src/libcore/cmp.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
4040
#![stable]
4141

42-
use option::{Option, Some};
42+
use option::{Option, Some, None};
4343

4444
/// Trait for values that can be compared for equality and inequality.
4545
///
@@ -268,6 +268,32 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
268268
if v1 > v2 { v1 } else { v2 }
269269
}
270270

271+
/// Compare and return the minimum of two values if there is one.
272+
///
273+
/// Returns the first argument if the comparison determines them to be equal.
274+
#[inline]
275+
#[experimental]
276+
pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
277+
match v1.partial_cmp(&v2) {
278+
Some(Less) | Some(Equal) => Some(v1),
279+
Some(Greater) => Some(v2),
280+
None => None
281+
}
282+
}
283+
284+
/// Compare and return the maximum of two values if there is one.
285+
///
286+
/// Returns the first argument if the comparison determines them to be equal.
287+
#[inline]
288+
#[experimental]
289+
pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
290+
match v1.partial_cmp(&v2) {
291+
Some(Less) => Some(v2),
292+
Some(Equal) | Some(Greater) => Some(v1),
293+
None => None
294+
}
295+
}
296+
271297
// Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types
272298
mod impls {
273299
use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering,

0 commit comments

Comments
 (0)