Skip to content

Commit 0bfecbc

Browse files
committed
---
yaml --- r: 126335 b: refs/heads/auto c: 2a47fa7 h: refs/heads/master i: 126333: b8195a3 126331: a2ac5d9 126327: 59111c2 126319: 9e432ec 126303: 5fa1393 126271: f2a1bdf 126207: d3e12e8 v: v3
1 parent 4313e0d commit 0bfecbc

File tree

48 files changed

+423
-229
lines changed

Some content is hidden

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

48 files changed

+423
-229
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: c74d320662329922860c5cdaf8cba1797caebea4
16+
refs/heads/auto: 2a47fa708cfbf6b90a8ffacbaf00b8250bfa72cd
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/doc/guide.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,14 +1647,14 @@ $ cargo build
16471647
$
16481648
```
16491649

1650-
Excellent! Open up your `src/guessing_game.rs` again. We'll be writing all of
1650+
Excellent! Open up your `src/main.rs` again. We'll be writing all of
16511651
our code in this file. We'll talk about multiple-file projects later on in the
16521652
guide.
16531653

16541654
## Processing a Guess
16551655

16561656
Let's get to it! The first thing we need to do for our guessing game is
1657-
allow our player to input a guess. Put this in your `src/guessing_game.rs`:
1657+
allow our player to input a guess. Put this in your `src/main.rs`:
16581658

16591659
```{rust,no_run}
16601660
use std::io;
@@ -1734,9 +1734,9 @@ this using `cargo build`:
17341734
```{notrust,no_run}
17351735
$ cargo build
17361736
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
1737-
src/guessing_game.rs:7:26: 7:34 error: the type of this value must be known in this context
1738-
src/guessing_game.rs:7 let secret_number = (rand::random() % 100i) + 1i;
1739-
^~~~~~~~
1737+
src/main.rs:7:26: 7:34 error: the type of this value must be known in this context
1738+
src/main.rs:7 let secret_number = (rand::random() % 100i) + 1i;
1739+
^~~~~~~~
17401740
error: aborting due to previous error
17411741
```
17421742

@@ -1896,12 +1896,12 @@ If we try to compile, we'll get some errors:
18961896
```{notrust,ignore}
18971897
$ cargo build
18981898
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
1899-
src/guessing_game.rs:20:15: 20:20 error: mismatched types: expected `int` but found `collections::string::String` (expected int but found struct collections::string::String)
1900-
src/guessing_game.rs:20 match cmp(input, secret_number) {
1901-
^~~~~
1902-
src/guessing_game.rs:20:22: 20:35 error: mismatched types: expected `int` but found `uint` (expected int but found uint)
1903-
src/guessing_game.rs:20 match cmp(input, secret_number) {
1904-
^~~~~~~~~~~~~
1899+
src/main.rs:20:15: 20:20 error: mismatched types: expected `int` but found `collections::string::String` (expected int but found struct collections::string::String)
1900+
src/main.rs:20 match cmp(input, secret_number) {
1901+
^~~~~
1902+
src/main.rs:20:22: 20:35 error: mismatched types: expected `int` but found `uint` (expected int but found uint)
1903+
src/main.rs:20 match cmp(input, secret_number) {
1904+
^~~~~~~~~~~~~
19051905
error: aborting due to 2 previous errors
19061906
```
19071907

@@ -1950,9 +1950,9 @@ And try compiling again:
19501950
```{notrust,ignore}
19511951
$ cargo build
19521952
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
1953-
src/guessing_game.rs:20:15: 20:20 error: mismatched types: expected `uint` but found `collections::string::String` (expected uint but found struct collections::string::String)
1954-
src/guessing_game.rs:20 match cmp(input, secret_number) {
1955-
^~~~~
1953+
src/main.rs:20:15: 20:20 error: mismatched types: expected `uint` but found `collections::string::String` (expected uint but found struct collections::string::String)
1954+
src/main.rs:20 match cmp(input, secret_number) {
1955+
^~~~~
19561956
error: aborting due to previous error
19571957
```
19581958

@@ -2053,9 +2053,9 @@ Let's try it out!
20532053
```{notrust,ignore}
20542054
$ cargo build
20552055
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2056-
src/guessing_game.rs:22:15: 22:24 error: mismatched types: expected `uint` but found `core::option::Option<uint>` (expected uint but found enum core::option::Option)
2057-
src/guessing_game.rs:22 match cmp(input_num, secret_number) {
2058-
^~~~~~~~~
2056+
src/main.rs:22:15: 22:24 error: mismatched types: expected `uint` but found `core::option::Option<uint>` (expected uint but found enum core::option::Option)
2057+
src/main.rs:22 match cmp(input_num, secret_number) {
2058+
^~~~~~~~~
20592059
error: aborting due to previous error
20602060
```
20612061

branches/auto/src/doc/intro.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,11 @@ fn main() {
359359
// Take the lock, along with exclusive access to the underlying array
360360
let mut numbers = numbers_lock.lock();
361361
362-
// This is ugly for now, but will be replaced by
363-
// `numbers[num as uint] += 1` in the near future.
362+
// This is ugly for now because of the need for `get_mut`, but
363+
// will be replaced by `numbers[num as uint] += 1`
364+
// in the near future.
364365
// See: https://github.com/rust-lang/rust/issues/6515
365-
*numbers.get_mut(num as uint) = *numbers.get_mut(num as uint) + 1;
366+
*numbers.get_mut(num as uint) += 1;
366367
367368
println!("{}", (*numbers)[num as uint]);
368369

branches/auto/src/doc/rust.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ production. See [tokens](#tokens) for more information.
112112

113113
## Input format
114114

115-
Rust input is interpreted as a sequence of Unicode codepoints encoded in UTF-8,
116-
normalized to Unicode normalization form NFKC.
115+
Rust input is interpreted as a sequence of Unicode codepoints encoded in UTF-8.
117116
Most Rust grammar rules are defined in terms of printable ASCII-range codepoints,
118117
but a small number are defined in terms of Unicode properties or explicit
119118
codepoint lists. [^inputformat]

branches/auto/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ and may not be overridden:
21962196
Types are sendable
21972197
unless they contain references.
21982198

2199-
* `Share` - Types that are *threadsafe*
2199+
* `Share` - Types that are *threadsafe*.
22002200
These are types that are safe to be used across several threads with access to
22012201
a `&T` pointer. `Mutex<T>` is an example of a *sharable* type with internal mutable data.
22022202

branches/auto/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<style id="number" _name="Number" map-to="def:number"/>
2323
<style id="scope" _name="Scope" map-to="def:preprocessor"/>
2424
<style id="attribute" _name="Attribute" map-to="def:preprocessor"/>
25+
<style id="macro" _name="Macro" map-to="def:preprocessor"/>
2526
</styles>
2627

2728
<definitions>
@@ -251,6 +252,12 @@
251252
</match>
252253
</context>
253254

255+
<context id="macro" style-ref="macro">
256+
<match extended="true">
257+
\%{ident}!
258+
</match>
259+
</context>
260+
254261
<context id="lifetime" style-ref="keyword">
255262
<match extended="true">
256263
'\%{ident}
@@ -308,6 +315,7 @@
308315
<context ref="types"/>
309316
<context ref="ctypes"/>
310317
<context ref="self"/>
318+
<context ref="macro"/>
311319
<context ref="constants"/>
312320
<context ref="cconstants"/>
313321
<context ref="line-comment"/>

branches/auto/src/liballoc/heap.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ mod imp {
136136
use libc::{c_char, c_int, c_void, size_t};
137137

138138
#[link(name = "jemalloc", kind = "static")]
139+
#[cfg(not(test))]
140+
extern {}
141+
139142
extern {
140143
fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
141144
fn je_rallocx(ptr: *mut c_void, size: size_t,

branches/auto/src/libcore/fmt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ impl<'a> Arguments<'a> {
127127
/// to prevent modification.
128128
///
129129
/// The `format_args!` macro will safely create an instance of this structure
130-
/// and pass it to a user-supplied function. The macro validates the format
131-
/// string at compile-time so usage of the `write` and `format` functions can
132-
/// be safely performed.
130+
/// and pass it to a function or closure, passed as the first argument. The
131+
/// macro validates the format string at compile-time so usage of the `write`
132+
/// and `format` functions can be safely performed.
133133
pub struct Arguments<'a> {
134134
fmt: &'a [rt::Piece<'a>],
135135
args: &'a [Argument<'a>],

branches/auto/src/libcore/slice.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ pub trait ImmutableVector<'a, T> {
7676
* Fails when `end` points outside the bounds of self.
7777
*/
7878
fn slice_to(&self, end: uint) -> &'a [T];
79+
80+
/// Divides one slice into two at an index.
81+
///
82+
/// The first will contain all indices from `[0, mid)` (excluding
83+
/// the index `mid` itself) and the second will contain all
84+
/// indices from `[mid, len)` (excluding the index `len` itself).
85+
///
86+
/// Fails if `mid > len`.
87+
fn split_at(&self, mid: uint) -> (&'a [T], &'a [T]);
88+
7989
/// Returns an iterator over the vector
8090
fn iter(self) -> Items<'a, T>;
8191
/// Returns an iterator over the subslices of the vector which are
@@ -247,6 +257,11 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] {
247257
self.slice(0, end)
248258
}
249259

260+
#[inline]
261+
fn split_at(&self, mid: uint) -> (&'a [T], &'a [T]) {
262+
(self.slice(0, mid), self.slice(mid, self.len()))
263+
}
264+
250265
#[inline]
251266
fn iter(self) -> Items<'a, T> {
252267
unsafe {
@@ -1192,8 +1207,7 @@ impl<'a, T> Iterator<&'a [T]> for Chunks<'a, T> {
11921207
None
11931208
} else {
11941209
let chunksz = cmp::min(self.v.len(), self.size);
1195-
let (fst, snd) = (self.v.slice_to(chunksz),
1196-
self.v.slice_from(chunksz));
1210+
let (fst, snd) = self.v.split_at(chunksz);
11971211
self.v = snd;
11981212
Some(fst)
11991213
}
@@ -1219,8 +1233,7 @@ impl<'a, T> DoubleEndedIterator<&'a [T]> for Chunks<'a, T> {
12191233
} else {
12201234
let remainder = self.v.len() % self.size;
12211235
let chunksz = if remainder != 0 { remainder } else { self.size };
1222-
let (fst, snd) = (self.v.slice_to(self.v.len() - chunksz),
1223-
self.v.slice_from(self.v.len() - chunksz));
1236+
let (fst, snd) = self.v.split_at(self.v.len() - chunksz);
12241237
self.v = fst;
12251238
Some(snd)
12261239
}

branches/auto/src/libfourcc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
124124
(val << 8) | (byte as u32)
125125
};
126126
}
127-
let e = cx.expr_lit(sp, ast::LitUint(val as u64, ast::TyU32));
127+
let e = cx.expr_lit(sp, ast::LitInt(val as u64, ast::UnsignedIntLit(ast::TyU32)));
128128
MacExpr::new(e)
129129
}
130130

branches/auto/src/libnative/io/file_win32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ pub fn lstat(_p: &CString) -> IoResult<rtio::FileStat> {
516516

517517
pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
518518
let mut buf = libc::utimbuf {
519-
actime: (atime / 1000) as libc::time64_t,
520-
modtime: (mtime / 1000) as libc::time64_t,
519+
actime: atime as libc::time64_t,
520+
modtime: mtime as libc::time64_t,
521521
};
522522
let p = try!(to_utf16(p));
523523
super::mkerr_libc(unsafe {

branches/auto/src/libnative/io/net.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,27 @@ fn ip_to_inaddr(ip: rtio::IpAddr) -> InAddr {
6666
}
6767
}
6868

69-
fn addr_to_sockaddr(addr: rtio::SocketAddr) -> (libc::sockaddr_storage, uint) {
69+
fn addr_to_sockaddr(addr: rtio::SocketAddr,
70+
storage: &mut libc::sockaddr_storage)
71+
-> libc::socklen_t {
7072
unsafe {
71-
let storage: libc::sockaddr_storage = mem::zeroed();
7273
let len = match ip_to_inaddr(addr.ip) {
7374
InAddr(inaddr) => {
74-
let storage: *mut libc::sockaddr_in = mem::transmute(&storage);
75+
let storage = storage as *mut _ as *mut libc::sockaddr_in;
7576
(*storage).sin_family = libc::AF_INET as libc::sa_family_t;
7677
(*storage).sin_port = htons(addr.port);
7778
(*storage).sin_addr = inaddr;
7879
mem::size_of::<libc::sockaddr_in>()
7980
}
8081
In6Addr(inaddr) => {
81-
let storage: *mut libc::sockaddr_in6 = mem::transmute(&storage);
82+
let storage = storage as *mut _ as *mut libc::sockaddr_in6;
8283
(*storage).sin6_family = libc::AF_INET6 as libc::sa_family_t;
8384
(*storage).sin6_port = htons(addr.port);
8485
(*storage).sin6_addr = inaddr;
8586
mem::size_of::<libc::sockaddr_in6>()
8687
}
8788
};
88-
return (storage, len);
89+
return len as libc::socklen_t;
8990
}
9091
}
9192

@@ -277,9 +278,9 @@ impl TcpStream {
277278
let fd = try!(socket(addr, libc::SOCK_STREAM));
278279
let ret = TcpStream::new(Inner::new(fd));
279280

280-
let (addr, len) = addr_to_sockaddr(addr);
281-
let addrp = &addr as *const _ as *const libc::sockaddr;
282-
let len = len as libc::socklen_t;
281+
let mut storage = unsafe { mem::zeroed() };
282+
let len = addr_to_sockaddr(addr, &mut storage);
283+
let addrp = &storage as *const _ as *const libc::sockaddr;
283284

284285
match timeout {
285286
Some(timeout) => {
@@ -457,9 +458,9 @@ impl TcpListener {
457458
let fd = try!(socket(addr, libc::SOCK_STREAM));
458459
let ret = TcpListener { inner: Inner::new(fd) };
459460

460-
let (addr, len) = addr_to_sockaddr(addr);
461-
let addrp = &addr as *const _ as *const libc::sockaddr;
462-
let len = len as libc::socklen_t;
461+
let mut storage = unsafe { mem::zeroed() };
462+
let len = addr_to_sockaddr(addr, &mut storage);
463+
let addrp = &storage as *const _ as *const libc::sockaddr;
463464

464465
// On platforms with Berkeley-derived sockets, this allows
465466
// to quickly rebind a socket, without needing to wait for
@@ -566,9 +567,9 @@ impl UdpSocket {
566567
write_deadline: 0,
567568
};
568569

569-
let (addr, len) = addr_to_sockaddr(addr);
570-
let addrp = &addr as *const _ as *const libc::sockaddr;
571-
let len = len as libc::socklen_t;
570+
let mut storage = unsafe { mem::zeroed() };
571+
let len = addr_to_sockaddr(addr, &mut storage);
572+
let addrp = &storage as *const _ as *const libc::sockaddr;
572573

573574
match unsafe { libc::bind(fd, addrp, len) } {
574575
-1 => Err(last_error()),
@@ -656,9 +657,9 @@ impl rtio::RtioUdpSocket for UdpSocket {
656657
}
657658

658659
fn send_to(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> IoResult<()> {
659-
let (dst, dstlen) = addr_to_sockaddr(dst);
660-
let dstp = &dst as *const _ as *const libc::sockaddr;
661-
let dstlen = dstlen as libc::socklen_t;
660+
let mut storage = unsafe { mem::zeroed() };
661+
let dstlen = addr_to_sockaddr(dst, &mut storage);
662+
let dstp = &storage as *const _ as *const libc::sockaddr;
662663

663664
let fd = self.fd();
664665
let dolock = || self.lock_nonblocking();

branches/auto/src/libnative/io/pipe_unix.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ fn unix_socket(ty: libc::c_int) -> IoResult<fd_t> {
2929
}
3030
}
3131

32-
fn addr_to_sockaddr_un(addr: &CString) -> IoResult<(libc::sockaddr_storage, uint)> {
32+
fn addr_to_sockaddr_un(addr: &CString,
33+
storage: &mut libc::sockaddr_storage)
34+
-> IoResult<libc::socklen_t> {
3335
// the sun_path length is limited to SUN_LEN (with null)
3436
assert!(mem::size_of::<libc::sockaddr_storage>() >=
3537
mem::size_of::<libc::sockaddr_un>());
36-
let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
37-
let s: &mut libc::sockaddr_un = unsafe { mem::transmute(&mut storage) };
38+
let s = unsafe { &mut *(storage as *mut _ as *mut libc::sockaddr_un) };
3839

3940
let len = addr.len();
4041
if len > s.sun_path.len() - 1 {
@@ -53,7 +54,7 @@ fn addr_to_sockaddr_un(addr: &CString) -> IoResult<(libc::sockaddr_storage, uint
5354

5455
// count the null terminator
5556
let len = mem::size_of::<libc::sa_family_t>() + len + 1;
56-
return Ok((storage, len));
57+
return Ok(len as libc::socklen_t);
5758
}
5859

5960
struct Inner {
@@ -76,10 +77,10 @@ impl Drop for Inner {
7677

7778
fn connect(addr: &CString, ty: libc::c_int,
7879
timeout: Option<u64>) -> IoResult<Inner> {
79-
let (addr, len) = try!(addr_to_sockaddr_un(addr));
80+
let mut storage = unsafe { mem::zeroed() };
81+
let len = try!(addr_to_sockaddr_un(addr, &mut storage));
8082
let inner = Inner::new(try!(unix_socket(ty)));
81-
let addrp = &addr as *const _ as *const libc::sockaddr;
82-
let len = len as libc::socklen_t;
83+
let addrp = &storage as *const _ as *const libc::sockaddr;
8384

8485
match timeout {
8586
None => {
@@ -96,11 +97,12 @@ fn connect(addr: &CString, ty: libc::c_int,
9697
}
9798

9899
fn bind(addr: &CString, ty: libc::c_int) -> IoResult<Inner> {
99-
let (addr, len) = try!(addr_to_sockaddr_un(addr));
100+
let mut storage = unsafe { mem::zeroed() };
101+
let len = try!(addr_to_sockaddr_un(addr, &mut storage));
100102
let inner = Inner::new(try!(unix_socket(ty)));
101-
let addrp = &addr as *const _;
103+
let addrp = &storage as *const _ as *const libc::sockaddr;
102104
match unsafe {
103-
libc::bind(inner.fd, addrp as *const _, len as libc::socklen_t)
105+
libc::bind(inner.fd, addrp, len)
104106
} {
105107
-1 => Err(super::last_error()),
106108
_ => Ok(inner)

0 commit comments

Comments
 (0)