Skip to content

Commit c79a757

Browse files
committed
---
yaml --- r: 49662 b: refs/heads/master c: 83aa70d h: refs/heads/master v: v3
1 parent 2786d2d commit c79a757

Some content is hidden

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

41 files changed

+563
-61
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 91cb6687a8869fa14aef8d978fb13e330c711cd3
2+
refs/heads/master: 83aa70d7e3dba557d1812fe436082098cdf90c9a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea

trunk/src/libcore/cmp.rs

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,62 @@ pub trait TotalOrd {
4545
fn cmp(&self, other: &Self) -> Ordering;
4646
}
4747

48-
macro_rules! totalord_impl(
49-
($t:ty) => {
50-
impl TotalOrd for $t {
51-
#[inline(always)]
52-
fn cmp(&self, other: &$t) -> Ordering {
53-
if *self < *other { Less }
54-
else if *self > *other { Greater }
55-
else { Equal }
56-
}
57-
}
58-
}
59-
)
48+
#[inline(always)]
49+
fn icmp<T: Ord>(a: &T, b: &T) -> Ordering {
50+
if *a < *b { Less }
51+
else if *a > *b { Greater }
52+
else { Equal }
53+
}
54+
55+
impl TotalOrd for u8 {
56+
#[inline(always)]
57+
fn cmp(&self, other: &u8) -> Ordering { icmp(self, other) }
58+
}
59+
60+
impl TotalOrd for u16 {
61+
#[inline(always)]
62+
fn cmp(&self, other: &u16) -> Ordering { icmp(self, other) }
63+
}
64+
65+
impl TotalOrd for u32 {
66+
#[inline(always)]
67+
fn cmp(&self, other: &u32) -> Ordering { icmp(self, other) }
68+
}
69+
70+
impl TotalOrd for u64 {
71+
#[inline(always)]
72+
fn cmp(&self, other: &u64) -> Ordering { icmp(self, other) }
73+
}
74+
75+
impl TotalOrd for i8 {
76+
#[inline(always)]
77+
fn cmp(&self, other: &i8) -> Ordering { icmp(self, other) }
78+
}
79+
80+
impl TotalOrd for i16 {
81+
#[inline(always)]
82+
fn cmp(&self, other: &i16) -> Ordering { icmp(self, other) }
83+
}
6084

61-
totalord_impl!(u8)
62-
totalord_impl!(u16)
63-
totalord_impl!(u32)
64-
totalord_impl!(u64)
85+
impl TotalOrd for i32 {
86+
#[inline(always)]
87+
fn cmp(&self, other: &i32) -> Ordering { icmp(self, other) }
88+
}
6589

66-
totalord_impl!(i8)
67-
totalord_impl!(i16)
68-
totalord_impl!(i32)
69-
totalord_impl!(i64)
90+
impl TotalOrd for i64 {
91+
#[inline(always)]
92+
fn cmp(&self, other: &i64) -> Ordering { icmp(self, other) }
93+
}
7094

71-
totalord_impl!(int)
72-
totalord_impl!(uint)
95+
impl TotalOrd for int {
96+
#[inline(always)]
97+
fn cmp(&self, other: &int) -> Ordering { icmp(self, other) }
98+
}
99+
100+
impl TotalOrd for uint {
101+
#[inline(always)]
102+
fn cmp(&self, other: &uint) -> Ordering { icmp(self, other) }
103+
}
73104

74105
/**
75106
* Trait for values that can be compared for a sort-order.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub trait Foo {
2+
fn bar();
3+
}

trunk/src/test/compile-fail/issue-3820.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-test
1211
struct Thing {
1312
x: int
1413
}
1514

16-
impl Mul<int, Thing>*/ for Thing/* { //~ ERROR Look ma, no Mul!
17-
fn mul(c: &int) -> Thing {
15+
impl Thing {
16+
fn mul(&self, c: &int) -> Thing {
1817
Thing {x: self.x * *c}
1918
}
2019
}
2120

2221
fn main() {
2322
let u = Thing {x: 2};
24-
let _v = u.mul(&3); // Works
25-
let w = u * 3; // Works!!
23+
let _v = u.mul(&3); // This is ok
24+
let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing`
2625
io::println(fmt!("%i", w.x));
27-
28-
/*
29-
// This doesn't work though.
30-
let u2 = u as @Mul<int, Thing>;
31-
let w2 = u2.mul(&4);
32-
io::println(fmt!("%i", w2.x));
33-
*/
3426
}

trunk/src/test/compile-fail/issue-3973.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
// xfail-test
12-
1312
struct Point {
1413
x: float,
1514
y: float,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-test
12+
struct HasNested {
13+
mut nest: ~[~[int]],
14+
}
15+
16+
impl HasNested {
17+
fn method_push_local(&self) {
18+
self.nest[0].push(0);
19+
}
20+
}
21+
22+
fn main() {}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo {
12+
baz: uint
13+
}
14+
15+
impl Foo {
16+
fn bar() {
17+
Foo { baz: 0 }.bar();
18+
}
19+
20+
fn bar() { //~ ERROR duplicate definition of value bar
21+
}
22+
}
23+
24+
fn main() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-test
12+
13+
fn main() {
14+
for os::args().each |arg| {
15+
match copy *arg {
16+
s => { }
17+
}
18+
}
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-test
12+
trait I {}
13+
type K = I;
14+
impl K for int {}
15+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-test
12+
fn main() { fmt!("%?", None); } //~ ERROR can't resolve type variable
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
12+
trait B < A > { fn a() -> A { self.a} } //~ ERROR unresolved name
13+
14+
fn main() {}

trunk/src/test/run-pass/assert-eq-macro-success.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
111
#[deriving(Eq)]
212
struct Point { x : int }
313

4-
fn main() {
14+
pub fn main() {
515
assert_eq!(14,14);
616
assert_eq!(~"abc",~"abc");
717
assert_eq!(~Point{x:34},~Point{x:34});

trunk/src/test/run-pass/const-cast-ptr-int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
static a: *u8 = 0 as *u8;
1212

13-
fn main() {
13+
pub fn main() {
1414
fail_unless!(a == ptr::null());
1515
}

trunk/src/test/run-pass/const-cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static y: *libc::c_void = x as *libc::c_void;
1515
static a: &'static int = &10;
1616
static b: *int = a as *int;
1717

18-
fn main() {
18+
pub fn main() {
1919
fail_unless!(x as *libc::c_void == y);
2020
fail_unless!(a as *int == b);
2121
}

trunk/src/test/run-pass/const-cross-crate-extern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ extern mod cci_const;
1515
use cci_const::bar;
1616
static foo: *u8 = bar;
1717

18-
fn main() {
18+
pub fn main() {
1919
fail_unless!(foo == cci_const::bar);
2020
}

trunk/src/test/run-pass/const-enum-cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
enum A { A1, A2 }
1212
enum B { B1=0, B2=2 }
1313

14-
fn main () {
14+
pub fn main () {
1515
static c1: int = A2 as int;
1616
static c2: int = B2 as int;
1717
static c3: float = A2 as float;

trunk/src/test/run-pass/const-enum-structlike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum E {
1515

1616
static C: E = S1 { u: 23 };
1717

18-
fn main() {
18+
pub fn main() {
1919
match C {
2020
S0 { _ } => fail!(),
2121
S1 { u } => fail_unless!(u == 23)

trunk/src/test/run-pass/const-expr-in-fixed-length-vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Check that constant expressions can be used for declaring the
1212
// type of a fixed length vector.
1313

14-
fn main() {
14+
pub fn main() {
1515

1616
static FOO: int = 2;
1717
let _v: [int, ..FOO*3];

trunk/src/test/run-pass/const-expr-in-vec-repeat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Check that constant expressions can be used in vec repeat syntax.
1212

13-
fn main() {
13+
pub fn main() {
1414

1515
static FOO: int = 2;
1616
let _v = [0, ..FOO*3*2/2];

trunk/src/test/run-pass/const-str-ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
1212
static c: &'static [u8, ..3] = &a;
1313
static b: *u8 = c as *u8;
1414

15-
fn main() {
15+
pub fn main() {
1616
let foo = &a as *u8;
1717
fail_unless!(unsafe { str::raw::from_bytes(a) } == ~"hi\x00");
1818
fail_unless!(unsafe { str::raw::from_buf(foo) } == ~"hi");

trunk/src/test/run-pass/const-vec-syntax.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
111
fn f(_: &const [int]) {}
212

3-
fn main() {
13+
pub fn main() {
414
let v = [ 1, 2, 3 ];
515
f(v);
616
}
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
111
#[deriving(Clone)]
212
enum E {
313
A,
414
B(()),
515
C
616
}
717

8-
fn main() {}
18+
pub fn main() {}
919

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
111
#[deriving(Clone)]
212
struct S<T> {
313
foo: (),
414
bar: (),
515
baz: T,
616
}
717

8-
fn main() {}
18+
pub fn main() {}
919

0 commit comments

Comments
 (0)