Skip to content

Commit f7a958b

Browse files
committed
---
yaml --- r: 126399 b: refs/heads/master c: 84782c4 h: refs/heads/master i: 126397: d4286bd 126395: cc66724 126391: 61a286b 126383: 032bdd4 126367: 683dc83 126335: 0bfecbc v: v3
1 parent b6423e6 commit f7a958b

File tree

48 files changed

+412
-189
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

+412
-189
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: 68bde0a07396efb415d61047c6b2a8183f47ef30
2+
refs/heads/master: 84782c4e2681496d57f1ac91468d21df085b7782
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
55
refs/heads/try: cd2003ffd8dd976342f9e8fc1429ae93d6780e81

trunk/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

trunk/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

trunk/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]

trunk/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

trunk/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"/>

trunk/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,

trunk/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>],

trunk/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
}

trunk/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

trunk/src/libgetopts/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ pub enum Name {
115115
pub enum HasArg {
116116
/// The option requires an argument.
117117
Yes,
118-
/// The option is just a flag, therefore no argument.
118+
/// The option takes no argument.
119119
No,
120-
/// The option argument is optional and it could or not exist.
120+
/// The option argument is optional.
121121
Maybe,
122122
}
123123

@@ -126,9 +126,9 @@ pub enum HasArg {
126126
pub enum Occur {
127127
/// The option occurs once.
128128
Req,
129-
/// The option could or not occur.
129+
/// The option occurs at most once.
130130
Optional,
131-
/// The option occurs once or multiple times.
131+
/// The option occurs zero or more times.
132132
Multi,
133133
}
134134

trunk/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 {

trunk/src/librustc/back/link.rs

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

1111
use super::archive::{Archive, ArchiveBuilder, ArchiveConfig, METADATA_FILENAME};
12+
use super::archive;
1213
use super::rpath;
1314
use super::rpath::RPathConfig;
1415
use super::svh::Svh;
@@ -1597,29 +1598,61 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
15971598
// For those that support this, we ensure we pass the option if the library
15981599
// was flagged "static" (most defaults are dynamic) to ensure that if
15991600
// libfoo.a and libfoo.so both exist that the right one is chosen.
1600-
let takes_hints = sess.targ_cfg.os != abi::OsMacos && sess.targ_cfg.os != abi::OsiOS;
1601+
let takes_hints = sess.targ_cfg.os != abi::OsMacos &&
1602+
sess.targ_cfg.os != abi::OsiOS;
1603+
1604+
let libs = sess.cstore.get_used_libraries();
1605+
let libs = libs.borrow();
1606+
1607+
let mut staticlibs = libs.iter().filter_map(|&(ref l, kind)| {
1608+
if kind == cstore::NativeStatic {Some(l)} else {None}
1609+
});
1610+
let mut others = libs.iter().filter(|&&(_, kind)| {
1611+
kind != cstore::NativeStatic
1612+
});
1613+
1614+
// Platforms that take hints generally also support the --whole-archive
1615+
// flag. We need to pass this flag when linking static native libraries to
1616+
// ensure the entire library is included.
1617+
//
1618+
// For more details see #15460, but the gist is that the linker will strip
1619+
// away any unused objects in the archive if we don't otherwise explicitly
1620+
// reference them. This can occur for libraries which are just providing
1621+
// bindings, libraries with generic functions, etc.
1622+
if takes_hints {
1623+
cmd.arg("-Wl,--whole-archive").arg("-Wl,-Bstatic");
1624+
}
1625+
let search_path = archive_search_paths(sess);
1626+
for l in staticlibs {
1627+
if takes_hints {
1628+
cmd.arg(format!("-l{}", l));
1629+
} else {
1630+
// -force_load is the OSX equivalent of --whole-archive, but it
1631+
// involves passing the full path to the library to link.
1632+
let lib = archive::find_library(l.as_slice(),
1633+
sess.targ_cfg.os,
1634+
search_path.as_slice(),
1635+
&sess.diagnostic().handler);
1636+
let mut v = b"-Wl,-force_load,".to_vec();
1637+
v.push_all(lib.as_vec());
1638+
cmd.arg(v.as_slice());
1639+
}
1640+
}
1641+
if takes_hints {
1642+
cmd.arg("-Wl,--no-whole-archive").arg("-Wl,-Bdynamic");
1643+
}
16011644

1602-
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
1645+
for &(ref l, kind) in others {
16031646
match kind {
1604-
cstore::NativeUnknown | cstore::NativeStatic => {
1605-
if takes_hints {
1606-
if kind == cstore::NativeStatic {
1607-
cmd.arg("-Wl,-Bstatic");
1608-
} else {
1609-
cmd.arg("-Wl,-Bdynamic");
1610-
}
1611-
}
1612-
cmd.arg(format!("-l{}", *l));
1647+
cstore::NativeUnknown => {
1648+
cmd.arg(format!("-l{}", l));
16131649
}
16141650
cstore::NativeFramework => {
1615-
cmd.arg("-framework");
1616-
cmd.arg(l.as_slice());
1651+
cmd.arg("-framework").arg(l.as_slice());
16171652
}
1653+
cstore::NativeStatic => unreachable!(),
16181654
}
16191655
}
1620-
if takes_hints {
1621-
cmd.arg("-Wl,-Bdynamic");
1622-
}
16231656
}
16241657

16251658
// # Rust Crate linking

0 commit comments

Comments
 (0)