Skip to content

Commit 137faf0

Browse files
committed
---
yaml --- r: 130198 b: refs/heads/master c: 074d3da h: refs/heads/master v: v3
1 parent 54d58d2 commit 137faf0

File tree

142 files changed

+1953
-938
lines changed

Some content is hidden

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

142 files changed

+1953
-938
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: c5f66d8135f94f2014f7b8d4c5258d66fff8cd3c
2+
refs/heads/master: 074d3da7b09883658cd0d52d53ebac7ee74e9e28
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
55
refs/heads/try: 28d5878c1f0465c11c8e7a3085008b0c592d48d0

trunk/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We want to maintain the option to parametrize at runtime. We may eventually chan
8383

8484
## Why aren't values type-parametric? Why only items?
8585

86-
Doing so would make type inference much more complex, and require the implementation strategy of runtime parametrization.
86+
Doing so would make type inference much more complex, and require the implementation strategy of runtime parameterization.
8787

8888
## Why are enumerations nominal and closed?
8989

trunk/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ our code in this file. We'll talk about multiple-file projects later on in the
18081808
guide.
18091809

18101810
Before we move on, let me show you one more Cargo command: `run`. `cargo run`
1811-
is kind of like `cargo build`, but it also then runs the produced exectuable.
1811+
is kind of like `cargo build`, but it also then runs the produced executable.
18121812
Try it out:
18131813

18141814
```{notrust,ignore}

trunk/src/doc/rust.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ On `struct`s:
19541954

19551955
- `repr` - specifies the representation to use for this struct. Takes a list
19561956
of options. The currently accepted ones are `C` and `packed`, which may be
1957-
combined. `C` will use a C ABI comptible struct layout, and `packed` will
1957+
combined. `C` will use a C ABI compatible struct layout, and `packed` will
19581958
remove any padding between fields (note that this is very fragile and may
19591959
break platforms which require aligned access).
19601960

@@ -2367,7 +2367,7 @@ One can indicate the stability of an API using the following attributes:
23672367
These levels are directly inspired by
23682368
[Node.js' "stability index"](http://nodejs.org/api/documentation.html).
23692369

2370-
Stability levels are inherited, so an items's stability attribute is the
2370+
Stability levels are inherited, so an item's stability attribute is the
23712371
default stability for everything nested underneath it.
23722372

23732373
There are lints for disallowing items marked with certain levels: `deprecated`,
@@ -2444,7 +2444,7 @@ The currently implemented features of the reference compiler are:
24442444

24452445
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
24462446
ways insufficient for concatenating identifiers, and may
2447-
be removed entirely for something more wholsome.
2447+
be removed entirely for something more wholesome.
24482448

24492449
* `default_type_params` - Allows use of default type parameters. The future of
24502450
this feature is uncertain.
@@ -3604,7 +3604,7 @@ of the type.[^structtype]
36043604

36053605
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
36063606

3607-
The memory layout of a `struct` is undefined by default to allow for compiler optimziations like
3607+
The memory layout of a `struct` is undefined by default to allow for compiler optimizations like
36083608
field reordering, but it can be fixed with the `#[repr(...)]` attribute.
36093609
In either case, fields may be given in any order in a corresponding struct *expression*;
36103610
the resulting `struct` value will always have the same memory layout.
@@ -3668,32 +3668,17 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
36683668

36693669
All pointers in Rust are explicit first-class values.
36703670
They can be copied, stored into data structures, and returned from functions.
3671-
There are four varieties of pointer in Rust:
3672-
3673-
* Owning pointers (`Box`)
3674-
: These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
3675-
Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
3676-
Owning pointers are written `Box<content>`,
3677-
for example `Box<int>` means an owning pointer to an owned box containing an integer.
3678-
Copying an owned box is a "deep" operation:
3679-
it involves allocating a new owned box and copying the contents of the old box into the new box.
3680-
Releasing an owning pointer immediately releases its corresponding owned box.
3671+
There are two varieties of pointer in Rust:
36813672

36823673
* References (`&`)
36833674
: These point to memory _owned by some other value_.
3684-
References arise by (automatic) conversion from owning pointers, managed pointers,
3685-
or by applying the borrowing operator `&` to some other value,
3686-
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3687-
A borrow expression is written `&content`.
3688-
3689-
A reference type is written `&'f type` for some lifetime-variable `f`,
3690-
or just `&type` when the lifetime can be elided;
3691-
for example `&int` means a reference to an integer.
3675+
A reference type is written `&type` for some lifetime-variable `f`,
3676+
or just `&'a type` when you need an explicit lifetime.
36923677
Copying a reference is a "shallow" operation:
36933678
it involves only copying the pointer itself.
36943679
Releasing a reference typically has no effect on the value it points to,
3695-
with the exception of temporary values,
3696-
which are released when the last reference to them is released.
3680+
with the exception of temporary values, which are released when the last
3681+
reference to them is released.
36973682

36983683
* Raw pointers (`*`)
36993684
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3706,6 +3691,9 @@ There are four varieties of pointer in Rust:
37063691
they exist to support interoperability with foreign code,
37073692
and writing performance-critical or low-level functions.
37083693

3694+
The standard library contains addtional 'smart pointer' types beyond references
3695+
and raw pointers.
3696+
37093697
### Function types
37103698

37113699
The function type constructor `fn` forms new function types.
@@ -4214,7 +4202,7 @@ be ignored in favor of only building the artifacts specified by command line.
42144202
purpose of this output type is to create a static library containing all of
42154203
the local crate's code along with all upstream dependencies. The static
42164204
library is actually a `*.a` archive on linux and osx and a `*.lib` file on
4217-
windows. This format is recommended for use in situtations such as linking
4205+
windows. This format is recommended for use in situations such as linking
42184206
Rust code into an existing non-Rust application because it will not have
42194207
dynamic dependencies on other Rust code.
42204208

trunk/src/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
#[cfg(rustdoc)]
12-
extern crate this = "rustdoc";
12+
extern crate "rustdoc" as this;
1313

1414
#[cfg(rustc)]
15-
extern crate this = "rustc";
15+
extern crate "rustc" as this;
1616

1717
fn main() { this::main() }

trunk/src/libcollections/bitv.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,6 @@ fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<
9595
static TRUE: bool = true;
9696
static FALSE: bool = false;
9797

98-
#[deriving(Clone)]
99-
struct SmallBitv {
100-
/// only the lowest nbits of this value are used. the rest is undefined.
101-
bits: uint
102-
}
103-
104-
#[deriving(Clone)]
105-
struct BigBitv {
106-
storage: Vec<uint>
107-
}
108-
109-
#[deriving(Clone)]
110-
enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
111-
11298
/// The bitvector type.
11399
///
114100
/// # Example
@@ -1653,6 +1639,7 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
16531639
#[cfg(test)]
16541640
mod tests {
16551641
use std::prelude::*;
1642+
use std::iter::range_step;
16561643
use std::uint;
16571644
use std::rand;
16581645
use std::rand::Rng;
@@ -2046,12 +2033,14 @@ mod tests {
20462033

20472034
#[test]
20482035
fn test_bitv_iterator() {
2049-
let bools = [true, false, true, true];
2036+
let bools = vec![true, false, true, true];
20502037
let bitv: Bitv = bools.iter().map(|n| *n).collect();
20512038

2052-
for (act, &ex) in bitv.iter().zip(bools.iter()) {
2053-
assert_eq!(ex, act);
2054-
}
2039+
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools)
2040+
2041+
let long = Vec::from_fn(10000, |i| i % 2 == 0);
2042+
let bitv: Bitv = long.iter().map(|n| *n).collect();
2043+
assert_eq!(bitv.iter().collect::<Vec<bool>>(), long)
20552044
}
20562045

20572046
#[test]
@@ -2061,6 +2050,12 @@ mod tests {
20612050

20622051
let idxs: Vec<uint> = bitv.iter().collect();
20632052
assert_eq!(idxs, vec!(0, 2, 3));
2053+
2054+
let long: BitvSet = range(0u, 10000).map(|n| n % 2 == 0).collect();
2055+
let real = range_step(0, 10000, 2).collect::<Vec<uint>>();
2056+
2057+
let idxs: Vec<uint> = long.iter().collect();
2058+
assert_eq!(idxs, real);
20642059
}
20652060

20662061
#[test]
@@ -2574,7 +2569,7 @@ mod tests {
25742569
}
25752570

25762571
#[bench]
2577-
fn bench_bitv_big(b: &mut Bencher) {
2572+
fn bench_bitv_set_big_fixed(b: &mut Bencher) {
25782573
let mut r = rng();
25792574
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25802575
b.iter(|| {
@@ -2586,7 +2581,19 @@ mod tests {
25862581
}
25872582

25882583
#[bench]
2589-
fn bench_bitv_small(b: &mut Bencher) {
2584+
fn bench_bitv_set_big_variable(b: &mut Bencher) {
2585+
let mut r = rng();
2586+
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
2587+
b.iter(|| {
2588+
for i in range(0u, 100) {
2589+
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
2590+
}
2591+
&bitv
2592+
})
2593+
}
2594+
2595+
#[bench]
2596+
fn bench_bitv_set_small(b: &mut Bencher) {
25902597
let mut r = rng();
25912598
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25922599
b.iter(|| {
@@ -2598,7 +2605,7 @@ mod tests {
25982605
}
25992606

26002607
#[bench]
2601-
fn bench_bitv_set_small(b: &mut Bencher) {
2608+
fn bench_bitvset_small(b: &mut Bencher) {
26022609
let mut r = rng();
26032610
let mut bitv = BitvSet::new();
26042611
b.iter(|| {
@@ -2610,7 +2617,7 @@ mod tests {
26102617
}
26112618

26122619
#[bench]
2613-
fn bench_bitv_set_big(b: &mut Bencher) {
2620+
fn bench_bitvset_big(b: &mut Bencher) {
26142621
let mut r = rng();
26152622
let mut bitv = BitvSet::new();
26162623
b.iter(|| {

trunk/src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<T> Rawlink<T> {
9090
/// Convert the `Rawlink` into an Option value
9191
fn resolve_immut<'a>(&self) -> Option<&'a T> {
9292
unsafe {
93-
mem::transmute(self.p.to_option())
93+
self.p.as_ref()
9494
}
9595
}
9696

trunk/src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub trait Set<T>: Collection {
289289
}
290290

291291
/// A mutable collection of values which are distinct from one another that
292-
/// can be mutaed.
292+
/// can be mutated.
293293
pub trait MutableSet<T>: Set<T> + Mutable {
294294
/// Adds a value to the set. Returns `true` if the value was not already
295295
/// present in the set.

trunk/src/libcollections/ringbuf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<T> RingBuf<T> {
132132
elts: Vec::from_fn(cmp::max(MINIMUM_CAPACITY, n), |_| None)}
133133
}
134134

135-
/// Retrieva an element in the `RingBuf` by index.
135+
/// Retrieve an element in the `RingBuf` by index.
136136
///
137137
/// Fails if there is no element with the given index.
138138
///

trunk/src/libcollections/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<V:Clone> SmallIntMap<V> {
324324
/// Updates a value in the map. If the key already exists in the map,
325325
/// modifies the value with `ff` taking `oldval, newval`.
326326
/// Otherwise, sets the value to `newval`.
327-
/// Returasn `true` if the key did not already exist in the map.
327+
/// Returns `true` if the key did not already exist in the map.
328328
///
329329
/// # Example
330330
///

trunk/src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
//!
4545
//! # Representation
4646
//!
47-
//! Rust's string type, `str`, is a sequence of unicode scalar values encoded as a
47+
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a
4848
//! stream of UTF-8 bytes. All strings are guaranteed to be validly encoded UTF-8
4949
//! sequences. Additionally, strings are not null-terminated and can contain null
5050
//! bytes.

trunk/src/libcore/char.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub fn escape_unicode(c: char, f: |char|) {
201201
/// - Tab, CR and LF are escaped as '\t', '\r' and '\n' respectively.
202202
/// - Single-quote, double-quote and backslash chars are backslash-escaped.
203203
/// - Any other chars in the range [0x20,0x7e] are not escaped.
204-
/// - Any other chars are given hex unicode escapes; see `escape_unicode`.
204+
/// - Any other chars are given hex Unicode escapes; see `escape_unicode`.
205205
///
206206
pub fn escape_default(c: char, f: |char|) {
207207
match c {
@@ -290,7 +290,7 @@ pub trait Char {
290290
/// * Single-quote, double-quote and backslash chars are backslash-
291291
/// escaped.
292292
/// * Any other chars in the range [0x20,0x7e] are not escaped.
293-
/// * Any other chars are given hex unicode escapes; see `escape_unicode`.
293+
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
294294
fn escape_default(&self, f: |char|);
295295

296296
/// Returns the amount of bytes this character would need if encoded in

trunk/src/libcore/failure.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ fn fail_bounds_check(file_line: &(&'static str, uint),
5555
unsafe { intrinsics::abort() }
5656
}
5757

58+
#[cold] #[inline(never)]
59+
pub fn begin_unwind_string(msg: &str, file: &(&'static str, uint)) -> ! {
60+
format_args!(|fmt| begin_unwind(fmt, file), "{}", msg)
61+
}
62+
5863
#[cold] #[inline(never)]
5964
pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
6065
#[allow(ctypes)]

trunk/src/libcore/fmt/mod.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,28 @@ impl<'a> Formatter<'a> {
461461
use char::Char;
462462
let align = match self.align {
463463
rt::AlignUnknown => default,
464-
rt::AlignLeft | rt::AlignRight => self.align
464+
_ => self.align
465465
};
466-
if align == rt::AlignLeft {
467-
try!(f(self));
468-
}
466+
467+
let (pre_pad, post_pad) = match align {
468+
rt::AlignLeft => (0u, padding),
469+
rt::AlignRight | rt::AlignUnknown => (padding, 0u),
470+
rt::AlignCenter => (padding / 2, (padding + 1) / 2),
471+
};
472+
469473
let mut fill = [0u8, ..4];
470474
let len = self.fill.encode_utf8(fill).unwrap_or(0);
471-
for _ in range(0, padding) {
475+
476+
for _ in range(0, pre_pad) {
472477
try!(self.buf.write(fill.slice_to(len)));
473478
}
474-
if align == rt::AlignRight {
475-
try!(f(self));
479+
480+
try!(f(self));
481+
482+
for _ in range(0, post_pad) {
483+
try!(self.buf.write(fill.slice_to(len)));
476484
}
485+
477486
Ok(())
478487
}
479488

trunk/src/libcore/fmt/rt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub enum Alignment {
4343
AlignLeft,
4444
/// Indication that contents should be right-aligned.
4545
AlignRight,
46+
/// Indication that contents should be center-aligned.
47+
AlignCenter,
4648
/// No alignment was requested.
4749
AlignUnknown,
4850
}

trunk/src/libcore/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ extern "rust-intrinsic" {
311311

312312
/// Gives the address for the return value of the enclosing function.
313313
///
314-
/// Using this instrinsic in a function that does not use an out pointer
314+
/// Using this intrinsic in a function that does not use an out pointer
315315
/// will trigger a compiler error.
316316
pub fn return_address() -> *const u8;
317317

trunk/src/libcore/macros.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ macro_rules! fail(
1616
() => (
1717
fail!("{}", "explicit failure")
1818
);
19-
($msg:expr) => (
20-
fail!("{}", $msg)
21-
);
19+
($msg:expr) => ({
20+
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
21+
::core::failure::begin_unwind_string($msg, &_FILE_LINE)
22+
});
2223
($fmt:expr, $($arg:tt)*) => ({
2324
// a closure can't have return type !, so we need a full
2425
// function to pass to format_args!, *and* we need the

0 commit comments

Comments
 (0)