Skip to content

Commit 074f3d3

Browse files
committed
---
yaml --- r: 49098 b: refs/heads/snap-stage3 c: 30b1957 h: refs/heads/master v: v3
1 parent 0cc810f commit 074f3d3

Some content is hidden

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

79 files changed

+824
-453
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: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d2b267bcb5ac1adbc20bca0c170106ae3b3538ab
4+
refs/heads/snap-stage3: 30b1957cd447f91d206513d909f564d270410e82
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -21,82 +21,86 @@ and `Eq` to overload the `==` and `!=` operators.
2121
*/
2222

2323
/**
24-
* Trait for values that can be compared for equality and inequality.
24+
* Trait for values that can be compared for equality
25+
* and inequality.
2526
*
26-
* This trait allows partial equality, where types can be unordered instead of strictly equal or
27-
* unequal. For example, with the built-in floating-point types `a == b` and `a != b` will both
28-
* evaluate to false if either `a` or `b` is NaN (cf. IEEE 754-2008 section 5.11).
29-
*
30-
* Eventually, this will be implemented by default for types that implement `TotalEq`.
27+
* Eventually this may be simplified to only require
28+
* an `eq` method, with the other generated from
29+
* a default implementation. However it should
30+
* remain possible to implement `ne` separately, for
31+
* compatibility with floating-point NaN semantics
32+
* (cf. IEEE 754-2008 section 5.11).
3133
*/
3234
#[lang="eq"]
3335
pub trait Eq {
3436
fn eq(&self, other: &Self) -> bool;
3537
fn ne(&self, other: &Self) -> bool;
3638
}
3739

38-
/// Trait for equality comparisons where `a == b` and `a != b` are strict inverses.
39-
pub trait TotalEq {
40-
fn equals(&self, other: &Self) -> bool;
40+
#[deriving(Eq)]
41+
pub enum Ordering { Less, Equal, Greater }
42+
43+
/// Trait for types that form a total order
44+
pub trait TotalOrd {
45+
fn cmp(&self, other: &Self) -> Ordering;
4146
}
4247

43-
macro_rules! totaleq_impl(
44-
($t:ty) => {
45-
impl TotalEq for $t {
46-
#[inline(always)]
47-
fn equals(&self, other: &$t) -> bool { *self == *other }
48-
}
49-
}
50-
)
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+
}
5154

52-
totaleq_impl!(bool)
55+
impl TotalOrd for u8 {
56+
#[inline(always)]
57+
fn cmp(&self, other: &u8) -> Ordering { icmp(self, other) }
58+
}
5359

54-
totaleq_impl!(u8)
55-
totaleq_impl!(u16)
56-
totaleq_impl!(u32)
57-
totaleq_impl!(u64)
60+
impl TotalOrd for u16 {
61+
#[inline(always)]
62+
fn cmp(&self, other: &u16) -> Ordering { icmp(self, other) }
63+
}
5864

59-
totaleq_impl!(i8)
60-
totaleq_impl!(i16)
61-
totaleq_impl!(i32)
62-
totaleq_impl!(i64)
65+
impl TotalOrd for u32 {
66+
#[inline(always)]
67+
fn cmp(&self, other: &u32) -> Ordering { icmp(self, other) }
68+
}
6369

64-
totaleq_impl!(int)
65-
totaleq_impl!(uint)
70+
impl TotalOrd for u64 {
71+
#[inline(always)]
72+
fn cmp(&self, other: &u64) -> Ordering { icmp(self, other) }
73+
}
6674

67-
#[deriving(Eq)]
68-
pub enum Ordering { Less, Equal, Greater }
75+
impl TotalOrd for i8 {
76+
#[inline(always)]
77+
fn cmp(&self, other: &i8) -> Ordering { icmp(self, other) }
78+
}
6979

70-
/// Trait for types that form a total order
71-
pub trait TotalOrd: TotalEq {
72-
fn cmp(&self, other: &Self) -> Ordering;
80+
impl TotalOrd for i16 {
81+
#[inline(always)]
82+
fn cmp(&self, other: &i16) -> Ordering { icmp(self, other) }
7383
}
7484

75-
macro_rules! totalord_impl(
76-
($t:ty) => {
77-
impl TotalOrd for $t {
78-
#[inline(always)]
79-
fn cmp(&self, other: &$t) -> Ordering {
80-
if *self < *other { Less }
81-
else if *self > *other { Greater }
82-
else { Equal }
83-
}
84-
}
85-
}
86-
)
85+
impl TotalOrd for i32 {
86+
#[inline(always)]
87+
fn cmp(&self, other: &i32) -> Ordering { icmp(self, other) }
88+
}
8789

88-
totalord_impl!(u8)
89-
totalord_impl!(u16)
90-
totalord_impl!(u32)
91-
totalord_impl!(u64)
90+
impl TotalOrd for i64 {
91+
#[inline(always)]
92+
fn cmp(&self, other: &i64) -> Ordering { icmp(self, other) }
93+
}
9294

93-
totalord_impl!(i8)
94-
totalord_impl!(i16)
95-
totalord_impl!(i32)
96-
totalord_impl!(i64)
95+
impl TotalOrd for int {
96+
#[inline(always)]
97+
fn cmp(&self, other: &int) -> Ordering { icmp(self, other) }
98+
}
9799

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

101105
/**
102106
* Trait for values that can be compared for a sort-order.
@@ -167,17 +171,11 @@ pub fn max<T:Ord>(v1: T, v2: T) -> T {
167171
#[cfg(test)]
168172
mod test {
169173
#[test]
170-
fn test_int_totalord() {
174+
fn test_int() {
171175
assert_eq!(5.cmp(&10), Less);
172176
assert_eq!(10.cmp(&5), Greater);
173177
assert_eq!(5.cmp(&5), Equal);
174178
assert_eq!((-5).cmp(&12), Less);
175179
assert_eq!(12.cmp(-5), Greater);
176180
}
177-
178-
#[test]
179-
fn test_int_totaleq() {
180-
fail_unless!(5.equals(&5));
181-
fail_unless!(!2.equals(&17));
182-
}
183181
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -15,7 +15,7 @@ Functions for the unit type.
1515
*/
1616

1717
#[cfg(notest)]
18-
use prelude::*;
18+
use cmp::{Eq, Ord, TotalOrd, Ordering, Equal};
1919

2020
#[cfg(notest)]
2121
impl Eq for () {
@@ -42,9 +42,3 @@ impl TotalOrd for () {
4242
#[inline(always)]
4343
fn cmp(&self, _other: &()) -> Ordering { Equal }
4444
}
45-
46-
#[cfg(notest)]
47-
impl TotalEq for () {
48-
#[inline(always)]
49-
fn equals(&self, _other: &()) -> bool { true }
50-
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ pub trait Shr<RHS,Result> {
7777

7878
#[lang="index"]
7979
pub trait Index<Index,Result> {
80-
fn index(&self, index: Index) -> Result;
80+
fn index(&self, index: &Index) -> Result;
8181
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub use result::{Result, Ok, Err};
2424
/* Reexported types and traits */
2525

2626
pub use clone::Clone;
27-
pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
27+
pub use cmp::{Eq, Ord, TotalOrd, Ordering, Less, Equal, Greater};
2828
pub use container::{Container, Mutable, Map, Set};
2929
pub use hash::Hash;
3030
pub use iter::{BaseIter, ReverseIter, MutableIter, ExtendedIter, EqIter};

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use at_vec;
2121
use cast;
2222
use char;
2323
use clone::Clone;
24-
use cmp::{Equiv, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
24+
use cmp::{Equiv, TotalOrd, Ordering, Less, Equal, Greater};
2525
use libc;
2626
use option::{None, Option, Some};
2727
use ptr;
@@ -930,30 +930,6 @@ impl Eq for @str {
930930
fn ne(&self, other: &@str) -> bool { !(*self).eq(other) }
931931
}
932932
933-
#[cfg(notest)]
934-
impl<'self> TotalEq for &'self str {
935-
#[inline(always)]
936-
fn equals(&self, other: & &'self str) -> bool {
937-
eq_slice((*self), (*other))
938-
}
939-
}
940-
941-
#[cfg(notest)]
942-
impl TotalEq for ~str {
943-
#[inline(always)]
944-
fn equals(&self, other: &~str) -> bool {
945-
eq_slice((*self), (*other))
946-
}
947-
}
948-
949-
#[cfg(notest)]
950-
impl TotalEq for @str {
951-
#[inline(always)]
952-
fn equals(&self, other: &@str) -> bool {
953-
eq_slice((*self), (*other))
954-
}
955-
}
956-
957933
#[cfg(notest)]
958934
impl Ord for ~str {
959935
#[inline(always)]

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

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use container::{Container, Mutable};
1616
use cast;
17-
use cmp::{Eq, Equiv, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
17+
use cmp::{Eq, Equiv, Ord, TotalOrd, Ordering, Less, Equal, Greater};
1818
use clone::Clone;
1919
use iter::BaseIter;
2020
use iter;
@@ -1547,7 +1547,7 @@ pub fn as_mut_buf<T,U>(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U {
15471547

15481548
// Equality
15491549

1550-
fn eq<T: Eq>(a: &[T], b: &[T]) -> bool {
1550+
fn eq<T:Eq>(a: &[T], b: &[T]) -> bool {
15511551
let (a_len, b_len) = (a.len(), b.len());
15521552
if a_len != b_len { return false; }
15531553

@@ -1556,61 +1556,33 @@ fn eq<T: Eq>(a: &[T], b: &[T]) -> bool {
15561556
if a[i] != b[i] { return false; }
15571557
i += 1;
15581558
}
1559-
true
1560-
}
1561-
1562-
fn equals<T: TotalEq>(a: &[T], b: &[T]) -> bool {
1563-
let (a_len, b_len) = (a.len(), b.len());
1564-
if a_len != b_len { return false; }
15651559

1566-
let mut i = 0;
1567-
while i < a_len {
1568-
if !a[i].equals(&b[i]) { return false; }
1569-
i += 1;
1570-
}
15711560
true
15721561
}
15731562

15741563
#[cfg(notest)]
15751564
impl<'self,T:Eq> Eq for &'self [T] {
15761565
#[inline(always)]
1577-
fn eq(&self, other: & &'self [T]) -> bool { eq(*self, *other) }
1566+
fn eq(&self, other: & &'self [T]) -> bool { eq((*self), (*other)) }
15781567
#[inline(always)]
1579-
fn ne(&self, other: & &'self [T]) -> bool { !self.eq(other) }
1568+
fn ne(&self, other: & &'self [T]) -> bool { !(*self).eq(other) }
15801569
}
15811570

1571+
15821572
#[cfg(notest)]
15831573
impl<T:Eq> Eq for ~[T] {
15841574
#[inline(always)]
1585-
fn eq(&self, other: &~[T]) -> bool { eq(*self, *other) }
1575+
fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) }
15861576
#[inline(always)]
1587-
fn ne(&self, other: &~[T]) -> bool { !self.eq(other) }
1577+
fn ne(&self, other: &~[T]) -> bool { !(*self).eq(other) }
15881578
}
15891579

15901580
#[cfg(notest)]
15911581
impl<T:Eq> Eq for @[T] {
15921582
#[inline(always)]
1593-
fn eq(&self, other: &@[T]) -> bool { eq(*self, *other) }
1594-
#[inline(always)]
1595-
fn ne(&self, other: &@[T]) -> bool { !self.eq(other) }
1596-
}
1597-
1598-
#[cfg(notest)]
1599-
impl<'self,T:TotalEq> TotalEq for &'self [T] {
1600-
#[inline(always)]
1601-
fn equals(&self, other: & &'self [T]) -> bool { equals(*self, *other) }
1602-
}
1603-
1604-
#[cfg(notest)]
1605-
impl<T:TotalEq> TotalEq for ~[T] {
1606-
#[inline(always)]
1607-
fn equals(&self, other: &~[T]) -> bool { equals(*self, *other) }
1608-
}
1609-
1610-
#[cfg(notest)]
1611-
impl<T:TotalEq> TotalEq for @[T] {
1583+
fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) }
16121584
#[inline(always)]
1613-
fn equals(&self, other: &@[T]) -> bool { equals(*self, *other) }
1585+
fn ne(&self, other: &@[T]) -> bool { !(*self).eq(other) }
16141586
}
16151587

16161588
#[cfg(notest)]

branches/snap-stage3/src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,6 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
630630
let self_ty_kind = string[0];
631631
match self_ty_kind as char {
632632
's' => { return ast::sty_static; }
633-
'r' => { return ast::sty_by_ref; }
634633
'v' => { return ast::sty_value; }
635634
'@' => { return ast::sty_box(get_mutability(string[1])); }
636635
'~' => { return ast::sty_uniq(get_mutability(string[1])); }

branches/snap-stage3/src/librustc/metadata/encoder.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ fn encode_self_type(ebml_w: writer::Encoder, self_type: ast::self_ty_) {
410410
sty_static => {
411411
ebml_w.writer.write(&[ 's' as u8 ]);
412412
}
413-
sty_by_ref => {
414-
ebml_w.writer.write(&[ 'r' as u8 ]);
415-
}
416413
sty_value => {
417414
ebml_w.writer.write(&[ 'v' as u8 ]);
418415
}

branches/snap-stage3/src/librustc/metadata/tydecode.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use core::vec;
2424
use syntax::ast;
2525
use syntax::ast::*;
2626
use syntax::codemap::{respan, dummy_sp};
27+
use syntax::opt_vec;
2728

2829
// Compact string representation for ty::t values. API ty_str &
2930
// parse_from_str. Extra parameters are for converting to/from def_ids in the
@@ -479,7 +480,9 @@ fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
479480
}
480481
st.pos += 1u; // eat the ']'
481482
let ret_ty = parse_ty(st, conv);
482-
ty::FnSig {inputs: inputs, output: ret_ty}
483+
ty::FnSig {bound_lifetime_names: opt_vec::Empty, // FIXME(#4846)
484+
inputs: inputs,
485+
output: ret_ty}
483486
}
484487
485488
// Rust metadata parsing

0 commit comments

Comments
 (0)