Skip to content

Commit f46174a

Browse files
committed
---
yaml --- r: 135807 b: refs/heads/try c: e04e081 h: refs/heads/master i: 135805: 80b0474 135803: f1b4b8f 135799: dbc01b8 135791: 88fb849 135775: 500aa94 135743: cdc45e1 135679: 6eeed66 v: v3
1 parent 4c5963d commit f46174a

File tree

139 files changed

+2747
-2203
lines changed

Some content is hidden

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

139 files changed

+2747
-2203
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 8794107f74682607f368776cc8b78820629778e6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ae81c89f34f1ac2cdb596cf216612e94822a8466
5-
refs/heads/try: 88a8def0a373348e18cf4ce98f256da063618be1
5+
refs/heads/try: e04e081fa7f0cd31911a6a2cc1c98aed066a7647
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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/try/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/try/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/try/src/doc/guide-unsafe.md

Lines changed: 16 additions & 20 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,7 +489,7 @@ 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

@@ -498,23 +498,19 @@ 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
499499
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

@@ -573,8 +569,8 @@ pub extern fn dot_product(a: *const u32, a_len: u32,
573569
return ret;
574570
}
575571
576-
#[lang = "begin_unwind"]
577-
extern fn begin_unwind(args: &core::fmt::Arguments,
572+
#[lang = "fail_fmt"]
573+
extern fn fail_fmt(args: &core::fmt::Arguments,
578574
file: &str,
579575
line: uint) -> ! {
580576
loop {}
@@ -587,8 +583,8 @@ extern fn begin_unwind(args: &core::fmt::Arguments,
587583
```
588584

589585
Note that there is one extra lang item here which differs from the examples
590-
above, `begin_unwind`. This must be defined by consumers of libcore because the
591-
core library declares failure, but it does not define it. The `begin_unwind`
586+
above, `fail_fmt`. This must be defined by consumers of libcore because the
587+
core library declares failure, but it does not define it. The `fail_fmt`
592588
lang item is this crate's definition of failure, and it must be guaranteed to
593589
never return.
594590

@@ -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
@@ -706,7 +702,7 @@ Other features provided by lang items include:
706702
`==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
707703
marked with lang items; those specific four are `eq`, `ord`,
708704
`deref`, and `add` respectively.
709-
- stack unwinding and general failure; the `eh_personality`, `fail_`
705+
- stack unwinding and general failure; the `eh_personality`, `fail`
710706
and `fail_bounds_checks` lang items.
711707
- the traits in `std::kinds` used to indicate types that satisfy
712708
various kinds; lang items `send`, `sync` and `copy`.

branches/try/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/try/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/try/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)