Skip to content

Commit 1e01735

Browse files
committed
---
yaml --- r: 211423 b: refs/heads/tmp c: 4458b5a h: refs/heads/master i: 211421: 4d05d3d 211419: 38ca013 211415: 75ae61c 211407: 5789978 211391: 7d49911 v: v3
1 parent 3c19287 commit 1e01735

File tree

34 files changed

+133
-409
lines changed

34 files changed

+133
-409
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 2d00dc3b85aaf81caa3a4e5764c5e185a4dd0a7c
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: 53941be9814f05496b3147da393c639a9d48957e
35+
refs/heads/tmp: 4458b5a9d5f11af5cfeb2201a4065131baeeec36
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: 704c2ee730d2e948d11a2edd77e3f35de8329a6e
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/doc/complement-design-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ that all delimiters be balanced.
160160
## `->` for function return type
161161

162162
This is to make the language easier to parse for humans, especially in the face
163-
of higher-order functions. `fn foo<T>(f: fn(i32): i32, fn(T): U): U` is not
163+
of higher-order functions. `fn foo<T>(f: fn(int): int, fn(T): U): U` is not
164164
particularly easy to read.
165165

166166
## Why is `let` used to introduce variables?

branches/tmp/src/doc/style/errors/ergonomics.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use std::io::{File, Open, Write, IoError};
1414

1515
struct Info {
1616
name: String,
17-
age: i32,
18-
rating: i32
17+
age: int,
18+
rating: int
1919
}
2020

2121
fn write_info(info: &Info) -> Result<(), IoError> {
@@ -36,8 +36,8 @@ use std::io::{File, Open, Write, IoError};
3636

3737
struct Info {
3838
name: String,
39-
age: i32,
40-
rating: i32
39+
age: int,
40+
rating: int
4141
}
4242

4343
fn write_info(info: &Info) -> Result<(), IoError> {
@@ -63,4 +63,4 @@ for more details.
6363
### The `Result`-`impl` pattern [FIXME]
6464

6565
> **[FIXME]** Document the way that the `io` module uses trait impls
66-
> on `std::io::Result` to painlessly propagate errors.
66+
> on `IoResult` to painlessly propagate errors.

branches/tmp/src/doc/style/features/functions-and-methods/input.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ it becomes.
5757
Prefer
5858

5959
```rust
60-
fn foo<T: Iterator<i32>>(c: T) { ... }
60+
fn foo<T: Iterator<int>>(c: T) { ... }
6161
```
6262

6363
over any of
6464

6565
```rust
66-
fn foo(c: &[i32]) { ... }
67-
fn foo(c: &Vec<i32>) { ... }
68-
fn foo(c: &SomeOtherCollection<i32>) { ... }
66+
fn foo(c: &[int]) { ... }
67+
fn foo(c: &Vec<int>) { ... }
68+
fn foo(c: &SomeOtherCollection<int>) { ... }
6969
```
7070

7171
if the function only needs to iterate over the data.
@@ -121,7 +121,7 @@ The primary exception: sometimes a function is meant to modify data
121121
that the caller already owns, for example to re-use a buffer:
122122

123123
```rust
124-
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize>
124+
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>
125125
```
126126

127127
(From the [Reader trait](http://static.rust-lang.org/doc/master/std/io/trait.Reader.html#tymethod.read).)

branches/tmp/src/doc/style/features/functions-and-methods/output.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ Prefer
1919
```rust
2020
struct SearchResult {
2121
found: bool, // item in container?
22-
expected_index: usize // what would the item's index be?
22+
expected_index: uint // what would the item's index be?
2323
}
2424

2525
fn binary_search(&self, k: Key) -> SearchResult
2626
```
2727
or
2828

2929
```rust
30-
fn binary_search(&self, k: Key) -> (bool, usize)
30+
fn binary_search(&self, k: Key) -> (bool, uint)
3131
```
3232

3333
over

branches/tmp/src/doc/style/features/let.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Prefer
66

77
```rust
8-
fn use_mutex(m: sync::mutex::Mutex<i32>) {
8+
fn use_mutex(m: sync::mutex::Mutex<int>) {
99
let guard = m.lock();
1010
do_work(guard);
1111
drop(guard); // unlock the lock
@@ -16,7 +16,7 @@ fn use_mutex(m: sync::mutex::Mutex<i32>) {
1616
over
1717

1818
```rust
19-
fn use_mutex(m: sync::mutex::Mutex<i32>) {
19+
fn use_mutex(m: sync::mutex::Mutex<int>) {
2020
do_work(m.lock());
2121
// do other work
2222
}

branches/tmp/src/doc/style/features/traits/reuse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait Printable {
1515
fn print(&self) { println!("{:?}", *self) }
1616
}
1717

18-
impl Printable for i32 {}
18+
impl Printable for int {}
1919

2020
impl Printable for String {
2121
fn print(&self) { println!("{}", *self) }

branches/tmp/src/doc/style/features/types/newtype.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ promises to the client.
4343

4444
For example, consider a function `my_transform` that returns a compound iterator
4545
type `Enumerate<Skip<vec::MoveItems<T>>>`. We wish to hide this type from the
46-
client, so that the client's view of the return type is roughly `Iterator<(usize,
46+
client, so that the client's view of the return type is roughly `Iterator<(uint,
4747
T)>`. We can do so using the newtype pattern:
4848

4949
```rust
5050
struct MyTransformResult<T>(Enumerate<Skip<vec::MoveItems<T>>>);
51-
impl<T> Iterator<(usize, T)> for MyTransformResult<T> { ... }
51+
impl<T> Iterator<(uint, T)> for MyTransformResult<T> { ... }
5252

5353
fn my_transform<T, Iter: Iterator<T>>(iter: Iter) -> MyTransformResult<T> {
5454
...

branches/tmp/src/doc/style/ownership/builders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Command {
7575
}
7676

7777
/// Executes the command as a child process, which is returned.
78-
pub fn spawn(&self) -> std::io::Result<Process> {
78+
pub fn spawn(&self) -> IoResult<Process> {
7979
...
8080
}
8181
}

branches/tmp/src/doc/style/style/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Terminate `return` statements with semicolons:
44

55
``` rust
6-
fn foo(bar: i32) -> Option<i32> {
6+
fn foo(bar: int) -> Option<int> {
77
if some_condition() {
88
return None;
99
}

branches/tmp/src/doc/style/style/imports.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ For example:
4444
use option::Option;
4545
use mem;
4646

47-
let i: isize = mem::transmute(Option(0));
47+
let i: int = mem::transmute(Option(0));
4848
```
4949

5050
> **[FIXME]** Add rationale.

branches/tmp/src/doc/style/style/whitespace.md

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

1111
``` rust
1212
#[deprecated = "Use `bar` instead."]
13-
fn foo(a: usize, b: usize) -> usize {
13+
fn foo(a: uint, b: uint) -> uint {
1414
a + b
1515
}
1616
```

branches/tmp/src/doc/trpl/associated-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ trait Graph {
4343
Now, our clients can be abstract over a given `Graph`:
4444

4545
```rust,ignore
46-
fn distance<G: Graph>(graph: &G, start: &G::N, end: &G::N) -> usize { ... }
46+
fn distance<G: Graph>(graph: &G, start: &G::N, end: &G::N) -> uint { ... }
4747
```
4848

4949
No need to deal with the `E`dge type here!

branches/tmp/src/doc/trpl/box-syntax-and-patterns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() {
5858
```
5959

6060
The idea is that by passing around a box, you're only copying a pointer, rather
61-
than the hundred `i32`s that make up the `BigStruct`.
61+
than the hundred `int`s that make up the `BigStruct`.
6262

6363
This is an antipattern in Rust. Instead, write this:
6464

branches/tmp/src/doc/trpl/lifetimes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ x: &'a i32,
134134
# }
135135
```
136136

137-
uses it. So why do we need a lifetime here? We need to ensure that any
138-
reference to the contained `i32` does not outlive the containing `Foo`.
137+
uses it. So why do we need a lifetime here? We need to ensure that any reference
138+
to a `Foo` cannot outlive the reference to an `i32` it contains.
139139

140140
## Thinking in scopes
141141

branches/tmp/src/doc/trpl/references-and-borrowing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn main() {
206206
^
207207
```
208208

209-
In other words, the mutable borrow is held through the rest of our example. What
209+
In other words, the mutable borow is held through the rest of our example. What
210210
we want is for the mutable borrow to end _before_ we try to call `println!` and
211211
make an immutable borrow. In Rust, borrowing is tied to the scope that the
212212
borrow is valid for. And our scopes look like this:

branches/tmp/src/doc/trpl/traits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ print_area(5);
146146
We get a compile-time error:
147147

148148
```text
149-
error: the trait `HasArea` is not implemented for the type `_` [E0277]
149+
error: failed to find an implementation of trait main::HasArea for int
150150
```
151151

152152
So far, we’ve only added trait implementations to structs, but you can

branches/tmp/src/libcollections/binary_heap.rs

Lines changed: 25 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
use core::prelude::*;
154154

155155
use core::iter::{FromIterator};
156-
use core::mem::swap;
156+
use core::mem::{zeroed, replace, swap};
157157
use core::ptr;
158158

159159
use slice;
@@ -484,42 +484,46 @@ impl<T: Ord> BinaryHeap<T> {
484484

485485
// The implementations of sift_up and sift_down use unsafe blocks in
486486
// order to move an element out of the vector (leaving behind a
487-
// hole), shift along the others and move the removed element back into the
488-
// vector at the final location of the hole.
489-
// The `Hole` type is used to represent this, and make sure
490-
// the hole is filled back at the end of its scope, even on panic.
491-
// Using a hole reduces the constant factor compared to using swaps,
492-
// which involves twice as many moves.
493-
fn sift_up(&mut self, start: usize, pos: usize) {
487+
// zeroed element), shift along the others and move it back into the
488+
// vector over the junk element. This reduces the constant factor
489+
// compared to using swaps, which involves twice as many moves.
490+
fn sift_up(&mut self, start: usize, mut pos: usize) {
494491
unsafe {
495-
// Take out the value at `pos` and create a hole.
496-
let mut hole = Hole::new(&mut self.data, pos);
492+
let new = replace(&mut self.data[pos], zeroed());
497493

498-
while hole.pos() > start {
499-
let parent = (hole.pos() - 1) / 2;
500-
if hole.removed() <= hole.get(parent) { break }
501-
hole.move_to(parent);
494+
while pos > start {
495+
let parent = (pos - 1) >> 1;
496+
497+
if new <= self.data[parent] { break; }
498+
499+
let x = replace(&mut self.data[parent], zeroed());
500+
ptr::write(&mut self.data[pos], x);
501+
pos = parent;
502502
}
503+
ptr::write(&mut self.data[pos], new);
503504
}
504505
}
505506

506507
fn sift_down_range(&mut self, mut pos: usize, end: usize) {
507-
let start = pos;
508508
unsafe {
509-
let mut hole = Hole::new(&mut self.data, pos);
509+
let start = pos;
510+
let new = replace(&mut self.data[pos], zeroed());
511+
510512
let mut child = 2 * pos + 1;
511513
while child < end {
512514
let right = child + 1;
513-
if right < end && !(hole.get(child) > hole.get(right)) {
515+
if right < end && !(self.data[child] > self.data[right]) {
514516
child = right;
515517
}
516-
hole.move_to(child);
517-
child = 2 * hole.pos() + 1;
518+
let x = replace(&mut self.data[child], zeroed());
519+
ptr::write(&mut self.data[pos], x);
520+
pos = child;
521+
child = 2 * pos + 1;
518522
}
519523

520-
pos = hole.pos;
524+
ptr::write(&mut self.data[pos], new);
525+
self.sift_up(start, pos);
521526
}
522-
self.sift_up(start, pos);
523527
}
524528

525529
fn sift_down(&mut self, pos: usize) {
@@ -550,73 +554,6 @@ impl<T: Ord> BinaryHeap<T> {
550554
pub fn clear(&mut self) { self.drain(); }
551555
}
552556

553-
/// Hole represents a hole in a slice i.e. an index without valid value
554-
/// (because it was moved from or duplicated).
555-
/// In drop, `Hole` will restore the slice by filling the hole
556-
/// position with the value that was originally removed.
557-
struct Hole<'a, T: 'a> {
558-
data: &'a mut [T],
559-
/// `elt` is always `Some` from new until drop.
560-
elt: Option<T>,
561-
pos: usize,
562-
}
563-
564-
impl<'a, T> Hole<'a, T> {
565-
/// Create a new Hole at index `pos`.
566-
fn new(data: &'a mut [T], pos: usize) -> Self {
567-
unsafe {
568-
let elt = ptr::read(&data[pos]);
569-
Hole {
570-
data: data,
571-
elt: Some(elt),
572-
pos: pos,
573-
}
574-
}
575-
}
576-
577-
#[inline(always)]
578-
fn pos(&self) -> usize { self.pos }
579-
580-
/// Return a reference to the element removed
581-
#[inline(always)]
582-
fn removed(&self) -> &T {
583-
self.elt.as_ref().unwrap()
584-
}
585-
586-
/// Return a reference to the element at `index`.
587-
///
588-
/// Panics if the index is out of bounds.
589-
///
590-
/// Unsafe because index must not equal pos.
591-
#[inline(always)]
592-
unsafe fn get(&self, index: usize) -> &T {
593-
debug_assert!(index != self.pos);
594-
&self.data[index]
595-
}
596-
597-
/// Move hole to new location
598-
///
599-
/// Unsafe because index must not equal pos.
600-
#[inline(always)]
601-
unsafe fn move_to(&mut self, index: usize) {
602-
debug_assert!(index != self.pos);
603-
let index_ptr: *const _ = &self.data[index];
604-
let hole_ptr = &mut self.data[self.pos];
605-
ptr::copy_nonoverlapping(index_ptr, hole_ptr, 1);
606-
self.pos = index;
607-
}
608-
}
609-
610-
impl<'a, T> Drop for Hole<'a, T> {
611-
fn drop(&mut self) {
612-
// fill the hole again
613-
unsafe {
614-
let pos = self.pos;
615-
ptr::write(&mut self.data[pos], self.elt.take().unwrap());
616-
}
617-
}
618-
}
619-
620557
/// `BinaryHeap` iterator.
621558
#[stable(feature = "rust1", since = "1.0.0")]
622559
pub struct Iter <'a, T: 'a> {

branches/tmp/src/libcollections/fmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@
164164
//! provides some helper methods.
165165
//!
166166
//! Additionally, the return value of this function is `fmt::Result` which is a
167-
//! typedef to `Result<(), std::io::Error>` (also known as `std::io::Result<()>`).
168-
//! Formatting implementations should ensure that they return errors from `write!`
167+
//! typedef to `Result<(), IoError>` (also known as `IoResult<()>`). Formatting
168+
//! implementations should ensure that they return errors from `write!`
169169
//! correctly (propagating errors upward).
170170
//!
171171
//! An example of implementing the formatting traits would look

0 commit comments

Comments
 (0)