Skip to content

Commit 60a43f9

Browse files
committed
auto merge of #14534 : alexcrichton/rust/snapshots, r=sfackler
This is part 2 of the saga of renaming the Partial/Total equality and comparison traits.
2 parents cc45132 + bb96ee6 commit 60a43f9

File tree

267 files changed

+858
-2102
lines changed

Some content is hidden

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

267 files changed

+858
-2102
lines changed

src/compiletest/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::from_str::FromStr;
1212
use std::fmt;
1313
use regex::Regex;
1414

15-
#[deriving(Clone, Eq)]
15+
#[deriving(Clone, PartialEq)]
1616
pub enum Mode {
1717
CompileFail,
1818
RunFail,

src/doc/rust.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ trait Circle : Shape { fn radius() -> f64; }
14361436
~~~~
14371437

14381438
the syntax `Circle : Shape` means that types that implement `Circle` must also have an implementation for `Shape`.
1439-
Multiple supertraits are separated by `+`, `trait Circle : Shape + Eq { }`.
1439+
Multiple supertraits are separated by `+`, `trait Circle : Shape + PartialEq { }`.
14401440
In an implementation of `Circle` for a given type `T`, methods can refer to `Shape` methods,
14411441
since the typechecker checks that any type with an implementation of `Circle` also has an implementation of `Shape`.
14421442

@@ -2159,23 +2159,23 @@ There are three different types of inline attributes:
21592159

21602160
The `deriving` attribute allows certain traits to be automatically
21612161
implemented for data structures. For example, the following will
2162-
create an `impl` for the `Eq` and `Clone` traits for `Foo`, the type
2163-
parameter `T` will be given the `Eq` or `Clone` constraints for the
2162+
create an `impl` for the `PartialEq` and `Clone` traits for `Foo`, the type
2163+
parameter `T` will be given the `PartialEq` or `Clone` constraints for the
21642164
appropriate `impl`:
21652165

21662166
~~~~
2167-
#[deriving(Eq, Clone)]
2167+
#[deriving(PartialEq, Clone)]
21682168
struct Foo<T> {
21692169
a: int,
21702170
b: T
21712171
}
21722172
~~~~
21732173

2174-
The generated `impl` for `Eq` is equivalent to
2174+
The generated `impl` for `PartialEq` is equivalent to
21752175

21762176
~~~~
21772177
# struct Foo<T> { a: int, b: T }
2178-
impl<T: Eq> Eq for Foo<T> {
2178+
impl<T: PartialEq> PartialEq for Foo<T> {
21792179
fn eq(&self, other: &Foo<T>) -> bool {
21802180
self.a == other.a && self.b == other.b
21812181
}
@@ -2188,7 +2188,7 @@ impl<T: Eq> Eq for Foo<T> {
21882188

21892189
Supported traits for `deriving` are:
21902190

2191-
* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`.
2191+
* Comparison traits: `PartialEq`, `TotalEq`, `PartialOrd`, `TotalOrd`.
21922192
* Serialization: `Encodable`, `Decodable`. These require `serialize`.
21932193
* `Clone`, to create `T` from `&T` via a copy.
21942194
* `Hash`, to iterate over the bytes in a data type.
@@ -2734,22 +2734,22 @@ The default meaning of the operators on standard types is given here.
27342734

27352735
* `==`
27362736
: Equal to.
2737-
Calls the `eq` method on the `std::cmp::Eq` trait.
2737+
Calls the `eq` method on the `std::cmp::PartialEq` trait.
27382738
* `!=`
27392739
: Unequal to.
2740-
Calls the `ne` method on the `std::cmp::Eq` trait.
2740+
Calls the `ne` method on the `std::cmp::PartialEq` trait.
27412741
* `<`
27422742
: Less than.
2743-
Calls the `lt` method on the `std::cmp::Ord` trait.
2743+
Calls the `lt` method on the `std::cmp::PartialOrd` trait.
27442744
* `>`
27452745
: Greater than.
2746-
Calls the `gt` method on the `std::cmp::Ord` trait.
2746+
Calls the `gt` method on the `std::cmp::PartialOrd` trait.
27472747
* `<=`
27482748
: Less than or equal.
2749-
Calls the `le` method on the `std::cmp::Ord` trait.
2749+
Calls the `le` method on the `std::cmp::PartialOrd` trait.
27502750
* `>=`
27512751
: Greater than or equal.
2752-
Calls the `ge` method on the `std::cmp::Ord` trait.
2752+
Calls the `ge` method on the `std::cmp::PartialOrd` trait.
27532753

27542754
#### Type cast expressions
27552755

src/doc/tutorial.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ There are two ways to install the Rust compiler: by building from source or
6161
by downloading prebuilt binaries or installers for your platform. The
6262
[install page][rust-install] contains links to download binaries for both
6363
the nightly build and the most current Rust major release. For Windows and
64-
OS X, the install page provides links to native installers.
64+
OS X, the install page provides links to native installers.
6565

6666
> *Note:* Windows users should read the detailed
6767
> [Getting started][wiki-start] notes on the wiki. Even when using
6868
> the binary installer, the Windows build requires a MinGW installation,
6969
> the precise details of which are not discussed here.
7070
7171
For Linux and OS X, the install page provides links to binary tarballs.
72-
To install the Rust compiler from the from a binary tarball, download
73-
the binary package, extract it, and execute the `install.sh` script in
72+
To install the Rust compiler from the from a binary tarball, download
73+
the binary package, extract it, and execute the `install.sh` script in
7474
the root directory of the package.
7575

7676
To build the Rust compiler from source, you will need to obtain the source through
@@ -1303,15 +1303,15 @@ be specified up-front. Our previous definition of list equality relied on the el
13031303
the `==` operator available, and took advantage of the lack of a destructor on `u32` to copy it
13041304
without a move of ownership.
13051305

1306-
We can add a *trait bound* on the `Eq` trait to require that the type implement the `==` operator.
1306+
We can add a *trait bound* on the `PartialEq` trait to require that the type implement the `==` operator.
13071307
Two more `ref` annotations need to be added to avoid attempting to move out the element types:
13081308

13091309
~~~
13101310
# enum List<T> {
13111311
# Cons(T, Box<List<T>>),
13121312
# Nil
13131313
# }
1314-
fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool {
1314+
fn eq<T: PartialEq>(xs: &List<T>, ys: &List<T>) -> bool {
13151315
// Match on the next node in both lists.
13161316
match (xs, ys) {
13171317
// If we have reached the end of both lists, they are equal.
@@ -1329,8 +1329,8 @@ let ys = Cons('c', box Cons('a', box Cons('t', box Nil)));
13291329
assert!(eq(&xs, &ys));
13301330
~~~
13311331

1332-
This would be a good opportunity to implement the `Eq` trait for our list type, making the `==` and
1333-
`!=` operators available. We'll need to provide an `impl` for the `Eq` trait and a definition of the
1332+
This would be a good opportunity to implement the `PartialEq` trait for our list type, making the `==` and
1333+
`!=` operators available. We'll need to provide an `impl` for the `PartialEq` trait and a definition of the
13341334
`eq` method. In a method, the `self` parameter refers to an instance of the type we're implementing
13351335
on.
13361336

@@ -1339,7 +1339,7 @@ on.
13391339
# Cons(T, Box<List<T>>),
13401340
# Nil
13411341
# }
1342-
impl<T: Eq> Eq for List<T> {
1342+
impl<T: PartialEq> PartialEq for List<T> {
13431343
fn eq(&self, ys: &List<T>) -> bool {
13441344
// Match on the next node in both lists.
13451345
match (self, ys) {
@@ -1356,12 +1356,12 @@ impl<T: Eq> Eq for List<T> {
13561356
13571357
let xs = Cons(5, box Cons(10, box Nil));
13581358
let ys = Cons(5, box Cons(10, box Nil));
1359-
// The methods below are part of the Eq trait,
1359+
// The methods below are part of the PartialEq trait,
13601360
// which we implemented on our linked list.
13611361
assert!(xs.eq(&ys));
13621362
assert!(!xs.ne(&ys));
13631363
1364-
// The Eq trait also allows us to use the shorthand infix operators.
1364+
// The PartialEq trait also allows us to use the shorthand infix operators.
13651365
assert!(xs == ys); // `xs == ys` is short for `xs.eq(&ys)`
13661366
assert!(!(xs != ys)); // `xs != ys` is short for `xs.ne(&ys)`
13671367
~~~
@@ -2345,12 +2345,12 @@ trait describes types that support an equality operation:
23452345
~~~~
23462346
// In a trait, `self` refers to the self argument.
23472347
// `Self` refers to the type implementing the trait.
2348-
trait Eq {
2348+
trait PartialEq {
23492349
fn equals(&self, other: &Self) -> bool;
23502350
}
23512351
23522352
// In an impl, `self` refers just to the value of the receiver
2353-
impl Eq for int {
2353+
impl PartialEq for int {
23542354
fn equals(&self, other: &int) -> bool { *other == *self }
23552355
}
23562356
~~~~
@@ -2600,13 +2600,13 @@ A small number of traits in `std` and `extra` can have implementations
26002600
that can be automatically derived. These instances are specified by
26012601
placing the `deriving` attribute on a data type declaration. For
26022602
example, the following will mean that `Circle` has an implementation
2603-
for `Eq` and can be used with the equality operators, and that a value
2603+
for `PartialEq` and can be used with the equality operators, and that a value
26042604
of type `ABC` can be randomly generated and converted to a string:
26052605

26062606
~~~
26072607
extern crate rand;
26082608
2609-
#[deriving(Eq)]
2609+
#[deriving(PartialEq)]
26102610
struct Circle { radius: f64 }
26112611
26122612
#[deriving(Rand, Show)]
@@ -2618,7 +2618,7 @@ fn main() {
26182618
}
26192619
~~~
26202620

2621-
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
2621+
The full list of derivable traits is `PartialEq`, `TotalEq`, `Ord`,
26222622
`TotalOrd`, `Encodable`, `Decodable`, `Clone`,
26232623
`Hash`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
26242624

src/etc/generate-deriving-span-tests.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// option. This file may not be copied, modified, or distributed
3636
// except according to those terms.
3737
38-
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
38+
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
3939
4040
#![feature(struct_variant)]
4141
extern crate rand;
@@ -117,8 +117,10 @@ def write_file(name, string):
117117

118118
for (trait, supers, errs) in [('Rand', [], 1),
119119
('Clone', [], 1),
120-
('Eq', [], 2), ('Ord', [], 8),
121-
('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1),
120+
('PartialEq', [], 2),
121+
('PartialOrd', ['PartialEq'], 8),
122+
('TotalEq', ['PartialEq'], 1),
123+
('TotalOrd', ['TotalEq', 'PartialOrd', 'PartialEq'], 1),
122124
('Show', [], 1),
123125
('Hash', [], 1)]:
124126
traits[trait] = (ALL, supers, errs)

src/liballoc/heap.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,7 @@ unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
133133
}
134134
}
135135

136-
#[cfg(not(test), stage0)]
137-
#[lang="exchange_free"]
138-
#[inline]
139-
unsafe fn exchange_free(ptr: *mut u8) {
140-
deallocate(ptr, 0, 8);
141-
}
142-
143-
#[cfg(not(test), not(stage0))]
136+
#[cfg(not(test))]
144137
#[lang="exchange_free"]
145138
#[inline]
146139
unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {

src/liballoc/owned.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use core::any::{Any, AnyRefExt};
1414
use core::clone::Clone;
15-
use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
15+
use core::cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd, Ordering};
1616
use core::default::Default;
1717
use core::fmt;
1818
use core::intrinsics;
@@ -51,13 +51,13 @@ impl<T: Clone> Clone for Box<T> {
5151
}
5252

5353
// box pointers
54-
impl<T:Eq> Eq for Box<T> {
54+
impl<T:PartialEq> PartialEq for Box<T> {
5555
#[inline]
5656
fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
5757
#[inline]
5858
fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) }
5959
}
60-
impl<T:Ord> Ord for Box<T> {
60+
impl<T:PartialOrd> PartialOrd for Box<T> {
6161
#[inline]
6262
fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
6363
#[inline]

src/liballoc/rc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pointers, and then storing the parent pointers as `Weak` pointers.
2626
use core::mem::transmute;
2727
use core::cell::Cell;
2828
use core::clone::Clone;
29-
use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
29+
use core::cmp::{PartialEq, PartialOrd, TotalEq, TotalOrd, Ordering};
3030
use core::kinds::marker;
3131
use core::ops::{Deref, Drop};
3232
use core::option::{Option, Some, None};
@@ -150,7 +150,7 @@ impl<T> Clone for Rc<T> {
150150
}
151151
}
152152

153-
impl<T: Eq> Eq for Rc<T> {
153+
impl<T: PartialEq> PartialEq for Rc<T> {
154154
#[inline(always)]
155155
fn eq(&self, other: &Rc<T>) -> bool { **self == **other }
156156
#[inline(always)]
@@ -159,7 +159,7 @@ impl<T: Eq> Eq for Rc<T> {
159159

160160
impl<T: TotalEq> TotalEq for Rc<T> {}
161161

162-
impl<T: Ord> Ord for Rc<T> {
162+
impl<T: PartialOrd> PartialOrd for Rc<T> {
163163
#[inline(always)]
164164
fn lt(&self, other: &Rc<T>) -> bool { **self < **other }
165165

src/libarena/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use std::rt::heap::allocate;
4343
// The way arena uses arrays is really deeply awful. The arrays are
4444
// allocated, and have capacities reserved, but the fill for the array
4545
// will always stay at 0.
46-
#[deriving(Clone, Eq)]
46+
#[deriving(Clone, PartialEq)]
4747
struct Chunk {
4848
data: Rc<RefCell<Vec<u8> >>,
4949
fill: Cell<uint>,

src/libcollections/bitv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl BitvSet {
796796
}
797797
}
798798

799-
impl cmp::Eq for BitvSet {
799+
impl cmp::PartialEq for BitvSet {
800800
fn eq(&self, other: &BitvSet) -> bool {
801801
if self.size != other.size {
802802
return false;

0 commit comments

Comments
 (0)