Skip to content

Commit 945ea5a

Browse files
committed
---
yaml --- r: 129109 b: refs/heads/master c: 77e39b0 h: refs/heads/master i: 129107: 4b27218 v: v3
1 parent e0d654c commit 945ea5a

File tree

16 files changed

+96
-373
lines changed

16 files changed

+96
-373
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: 6d9b219e6f84325ee32c70a29bf782e7ad54ebc8
2+
refs/heads/master: 77e39b0560048f6d53c42a6c9a9d14bc95e61ce5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
55
refs/heads/try: 961753763fb87ddcbbccaec4ea87648608d19a58

trunk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ To easily build on windows we can use [MSYS2](http://sourceforge.net/projects/ms
7171
3. With that now start `mingw32_shell.bat` from where you installed MSYS2 (i.e. `C:\msys`).
7272
4. From there just navigate to where you have Rust's source code, configure and build it:
7373

74-
$ ./configure
74+
$ ./configure --build=i686-pc-mingw32
7575
$ make && make install
7676

7777
[repo]: https://github.com/rust-lang/rust

trunk/configure

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,13 @@ case $CFG_OSTYPE in
299299
CFG_OSTYPE=apple-darwin
300300
;;
301301

302-
MINGW*)
303-
# msys' `uname` does not print gcc configuration, but prints msys
304-
# configuration. so we cannot believe `uname -m`:
305-
# msys1 is always i686 and msys2 is always x86_64.
306-
# instead, msys defines $MSYSTEM which is MINGW32 on i686 and
307-
# MINGW64 on x86_64.
308-
CFG_CPUTYPE=i686
302+
MINGW32*)
309303
CFG_OSTYPE=pc-mingw32
310-
if [ "$MSYSTEM" = MINGW64 ]
311-
then
312-
CFG_CPUTYPE=x86_64
313-
CFG_OSTYPE=w64-mingw32
314-
fi
304+
;;
305+
306+
MINGW64*)
307+
# msys2, MSYSTEM=MINGW64
308+
CFG_OSTYPE=w64-mingw32
315309
;;
316310

317311
# Thad's Cygwin identifers below

trunk/src/doc/guide.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ And trying it out:
20212021
```{notrust,ignore}
20222022
$ cargo build
20232023
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2024-
$ ./target/guessing_game
2024+
$ ./target/guessing_game
20252025
Guess the number!
20262026
The secret number is: 57
20272027
Please input your guess.
@@ -2292,7 +2292,7 @@ print an error message and return. Let's give this a shot:
22922292
```{notrust,ignore}
22932293
$ cargo build
22942294
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2295-
$ ./target/guessing_game
2295+
$ ./target/guessing_game
22962296
Guess the number!
22972297
The secret number is: 17
22982298
Please input your guess.
@@ -2358,11 +2358,11 @@ Let's try it!
23582358
```{notrust,ignore}
23592359
$ cargo build
23602360
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2361-
$ ./target/guessing_game
2361+
$ ./target/guessing_game
23622362
Guess the number!
23632363
The secret number is: 58
23642364
Please input your guess.
2365-
76
2365+
76
23662366
You guessed: 76
23672367
Too big!
23682368
$
@@ -2436,7 +2436,7 @@ that `return`? If we give a non-number answer, we'll `return` and quit. Observe:
24362436
```{notrust,ignore}
24372437
$ cargo build
24382438
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2439-
$ ./target/guessing_game
2439+
$ ./target/guessing_game
24402440
Guess the number!
24412441
The secret number is: 59
24422442
Please input your guess.
@@ -2569,7 +2569,7 @@ Now we should be good! Let's try:
25692569
```{rust,ignore}
25702570
$ cargo build
25712571
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2572-
$ ./target/guessing_game
2572+
$ ./target/guessing_game
25732573
Guess the number!
25742574
The secret number is: 61
25752575
Please input your guess.
@@ -3718,18 +3718,18 @@ That's a lot to take in. It's also one of the _most_ important concepts in
37183718
all of Rust. Let's see this syntax in action:
37193719

37203720
```{rust}
3721-
{
3721+
{
37223722
let x = 5i; // x is the owner of this integer, which is memory on the stack.
37233723
37243724
// other code here...
3725-
3725+
37263726
} // privilege 1: when x goes out of scope, this memory is deallocated
37273727
37283728
/// this function borrows an integer. It's given back automatically when the
37293729
/// function returns.
3730-
fn foo(x: &int) -> &int { x }
3730+
fn foo(x: &int) -> &int { x }
37313731
3732-
{
3732+
{
37333733
let x = 5i; // x is the owner of this integer, which is memory on the stack.
37343734
37353735
// privilege 2: you may lend that resource, to as many borrowers as you'd like
@@ -3739,14 +3739,14 @@ fn foo(x: &int) -> &int { x }
37393739
foo(&x); // functions can borrow too!
37403740
37413741
let a = &x; // we can do this alllllll day!
3742-
}
3742+
}
37433743
3744-
{
3744+
{
37453745
let mut x = 5i; // x is the owner of this integer, which is memory on the stack.
37463746
37473747
let y = &mut x; // privilege 3: you may lend that resource to a single borrower,
37483748
// mutably
3749-
}
3749+
}
37503750
```
37513751

37523752
If you are a borrower, you get a few privileges as well, but must also obey a
@@ -4535,7 +4535,7 @@ let one_to_one_hundred = range(0i, 100i).collect();
45354535
```
45364536

45374537
As you can see, we call `collect()` on our iterator. `collect()` takes
4538-
as many values as the iterator will give it, and returns a collection
4538+
as many values as the iterator will give it, and returns a collection
45394539
of the results. So why won't this compile? Rust can't determine what
45404540
type of things you want to collect, and so you need to let it know.
45414541
Here's the version that does compile:
@@ -5508,7 +5508,7 @@ fn main() {
55085508
}
55095509
```
55105510

5511-
Whew! This isn't too terrible. You can see that we still `let x = 5i`,
5511+
Whew! This isn't too terrible. You can see that we still `let x = 5i`,
55125512
but then things get a little bit hairy. Three more bindings get set: a
55135513
static format string, an argument vector, and the aruments. We then
55145514
invoke the `println_args` function with the generated arguments.
@@ -5531,9 +5531,9 @@ There are two circumstances where Rust's safety provisions don't work well.
55315531
The first is when interfacing with C code, and the second is when building
55325532
certain kinds of abstractions.
55335533

5534-
Rust has support for FFI (which you can read about in the [FFI
5535-
Guide](guide-ffi.html)), but can't guarantee that the C code will be safe.
5536-
Therefore, Rust marks such functions with the `unsafe`
5534+
Rust has support for FFI, (which you can read about in the [FFI
5535+
Guide](guide-ffi.html)) but Rust can't guarantee that the C code will be safe,
5536+
like Rust's will. Therefore, Rust marks such functions with the `unsafe`
55375537
keyword, which indicates that the function may not behave properly.
55385538

55395539
Second, if you'd like to create some sort of shared-memory data structure, Rust

trunk/src/etc/maketest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
1616
# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
1717
# the value is list of paths.
18-
# (if there is only one path, it becomes `c:/real/abs/path`.)
1918
# this causes great confusion and error: shell and Makefile doesn't like
2019
# windows paths so it is really error-prone. revert it for peace.
2120
def normalize_path(v):
21+
# c:\path -> /c/path
22+
if ':\\' in v:
23+
v = '/' + v.replace(':\\', '/')
2224
v = v.replace('\\', '/')
23-
# c:/path -> /c/path
24-
if ':/' in v:
25-
v = '/' + v.replace(':/', '/')
2625
return v
2726

2827

trunk/src/liballoc/heap.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ mod imp {
208208

209209
#[cfg(not(jemalloc), unix)]
210210
mod imp {
211-
use core::cmp;
212211
use core::mem;
213212
use core::ptr;
214213
use libc;
@@ -249,7 +248,7 @@ mod imp {
249248
pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint,
250249
old_size: uint) -> *mut u8 {
251250
let new_ptr = allocate(size, align);
252-
ptr::copy_memory(new_ptr, ptr as *const u8, cmp::min(size, old_size));
251+
ptr::copy_memory(new_ptr, ptr as *const u8, old_size);
253252
deallocate(ptr, old_size, align);
254253
return new_ptr;
255254
}

trunk/src/libcore/iter.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,6 @@ pub trait ExactSize<A> : DoubleEndedIterator<A> {
728728
/// Return the exact length of the iterator.
729729
fn len(&self) -> uint {
730730
let (lower, upper) = self.size_hint();
731-
// Note: This assertion is overly defensive, but it checks the invariant
732-
// guaranteed by the trait. If this trait were rust-internal,
733-
// we could use debug_assert!; assert_eq! will check all Rust user
734-
// implementations too.
735731
assert_eq!(upper, Some(lower));
736732
lower
737733
}
@@ -1199,20 +1195,21 @@ impl<A, B, T: ExactSize<A>, U: ExactSize<B>> DoubleEndedIterator<(A, B)>
11991195
for Zip<T, U> {
12001196
#[inline]
12011197
fn next_back(&mut self) -> Option<(A, B)> {
1202-
let a_sz = self.a.len();
1203-
let b_sz = self.b.len();
1204-
if a_sz != b_sz {
1205-
// Adjust a, b to equal length
1206-
if a_sz > b_sz {
1207-
for _ in range(0, a_sz - b_sz) { self.a.next_back(); }
1208-
} else {
1209-
for _ in range(0, b_sz - a_sz) { self.b.next_back(); }
1210-
}
1211-
}
1198+
let (a_sz, a_upper) = self.a.size_hint();
1199+
let (b_sz, b_upper) = self.b.size_hint();
1200+
assert!(a_upper == Some(a_sz));
1201+
assert!(b_upper == Some(b_sz));
1202+
if a_sz < b_sz {
1203+
for _ in range(0, b_sz - a_sz) { self.b.next_back(); }
1204+
} else if a_sz > b_sz {
1205+
for _ in range(0, a_sz - b_sz) { self.a.next_back(); }
1206+
}
1207+
let (a_sz, _) = self.a.size_hint();
1208+
let (b_sz, _) = self.b.size_hint();
1209+
assert!(a_sz == b_sz);
12121210
match (self.a.next_back(), self.b.next_back()) {
12131211
(Some(x), Some(y)) => Some((x, y)),
1214-
(None, None) => None,
1215-
_ => unreachable!(),
1212+
_ => None
12161213
}
12171214
}
12181215
}
@@ -1398,8 +1395,9 @@ impl<A, T: ExactSize<A>> DoubleEndedIterator<(uint, A)> for Enumerate<T> {
13981395
fn next_back(&mut self) -> Option<(uint, A)> {
13991396
match self.iter.next_back() {
14001397
Some(a) => {
1401-
let len = self.iter.len();
1402-
Some((self.count + len, a))
1398+
let (lower, upper) = self.iter.size_hint();
1399+
assert!(upper == Some(lower));
1400+
Some((self.count + lower, a))
14031401
}
14041402
_ => None
14051403
}

trunk/src/libcore/str.rs

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,8 +1507,8 @@ pub trait StrSlice<'a> {
15071507
///
15081508
/// # Example
15091509
///
1510-
/// This example manually iterates through the characters of a
1511-
/// string; this should normally be done by `.chars()` or
1510+
/// This example manually iterate through the characters of a
1511+
/// string; this should normally by done by `.chars()` or
15121512
/// `.char_indices`.
15131513
///
15141514
/// ```rust
@@ -1717,13 +1717,6 @@ pub trait StrSlice<'a> {
17171717
fn utf16_units(&self) -> Utf16CodeUnits<'a>;
17181718
}
17191719

1720-
#[inline(never)]
1721-
fn slice_error_fail(s: &str, begin: uint, end: uint) -> ! {
1722-
assert!(begin <= end);
1723-
fail!("index {} and/or {} in `{}` do not lie on character boundary",
1724-
begin, end, s);
1725-
}
1726-
17271720
impl<'a> StrSlice<'a> for &'a str {
17281721
#[inline]
17291722
fn contains<'a>(&self, needle: &'a str) -> bool {
@@ -1827,34 +1820,22 @@ impl<'a> StrSlice<'a> for &'a str {
18271820

18281821
#[inline]
18291822
fn slice(&self, begin: uint, end: uint) -> &'a str {
1830-
// is_char_boundary checks that the index is in [0, .len()]
1831-
if begin <= end &&
1832-
self.is_char_boundary(begin) &&
1833-
self.is_char_boundary(end) {
1834-
unsafe { raw::slice_unchecked(*self, begin, end) }
1835-
} else {
1836-
slice_error_fail(*self, begin, end)
1837-
}
1823+
assert!(self.is_char_boundary(begin) && self.is_char_boundary(end),
1824+
"index {} and/or {} in `{}` do not lie on character boundary", begin,
1825+
end, *self);
1826+
unsafe { raw::slice_bytes(*self, begin, end) }
18381827
}
18391828

18401829
#[inline]
18411830
fn slice_from(&self, begin: uint) -> &'a str {
1842-
// is_char_boundary checks that the index is in [0, .len()]
1843-
if self.is_char_boundary(begin) {
1844-
unsafe { raw::slice_unchecked(*self, begin, self.len()) }
1845-
} else {
1846-
slice_error_fail(*self, begin, self.len())
1847-
}
1831+
self.slice(begin, self.len())
18481832
}
18491833

18501834
#[inline]
18511835
fn slice_to(&self, end: uint) -> &'a str {
1852-
// is_char_boundary checks that the index is in [0, .len()]
1853-
if self.is_char_boundary(end) {
1854-
unsafe { raw::slice_unchecked(*self, 0, end) }
1855-
} else {
1856-
slice_error_fail(*self, 0, end)
1857-
}
1836+
assert!(self.is_char_boundary(end), "index {} in `{}` does not lie on \
1837+
a character boundary", end, *self);
1838+
unsafe { raw::slice_bytes(*self, 0, end) }
18581839
}
18591840

18601841
fn slice_chars(&self, begin: uint, end: uint) -> &'a str {
@@ -1929,10 +1910,9 @@ impl<'a> StrSlice<'a> for &'a str {
19291910
#[inline]
19301911
fn is_char_boundary(&self, index: uint) -> bool {
19311912
if index == self.len() { return true; }
1932-
match self.as_bytes().get(index) {
1933-
None => false,
1934-
Some(&b) => b < 128u8 || b >= 192u8,
1935-
}
1913+
if index > self.len() { return false; }
1914+
let b = self.as_bytes()[index];
1915+
return b < 128u8 || b >= 192u8;
19361916
}
19371917

19381918
#[inline]

trunk/src/librustc/back/link.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,6 @@ pub mod write {
536536
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
537537
llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
538538
llvm::LLVMPassManagerBuilderDispose(builder);
539-
540-
match opt {
541-
llvm::CodeGenLevelDefault | llvm::CodeGenLevelAggressive => {
542-
"mergefunc".with_c_str(|s| llvm::LLVMRustAddPass(mpm, s));
543-
}
544-
_ => {}
545-
};
546539
}
547540
}
548541

@@ -1312,6 +1305,8 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
13121305
sess.note(str::from_utf8(output.as_slice()).unwrap());
13131306
sess.abort_if_errors();
13141307
}
1308+
debug!("linker stderr:\n{}", str::from_utf8_owned(prog.error).unwrap());
1309+
debug!("linker stdout:\n{}", str::from_utf8_owned(prog.output).unwrap());
13151310
},
13161311
Err(e) => {
13171312
sess.err(format!("could not exec the linker `{}`: {}",

trunk/src/librustc/middle/const_eval.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,29 +517,26 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
517517
match ty::get(ety).sty {
518518
ty::ty_float(_) => {
519519
match val {
520-
const_bool(b) => Ok(const_float(b as f64)),
521520
const_uint(u) => Ok(const_float(u as f64)),
522521
const_int(i) => Ok(const_float(i as f64)),
523522
const_float(f) => Ok(const_float(f)),
524-
_ => Err("can't cast this type to float".to_string()),
523+
_ => Err("can't cast float to str".to_string()),
525524
}
526525
}
527526
ty::ty_uint(_) => {
528527
match val {
529-
const_bool(b) => Ok(const_uint(b as u64)),
530528
const_uint(u) => Ok(const_uint(u)),
531529
const_int(i) => Ok(const_uint(i as u64)),
532530
const_float(f) => Ok(const_uint(f as u64)),
533-
_ => Err("can't cast this type to uint".to_string()),
531+
_ => Err("can't cast str to uint".to_string()),
534532
}
535533
}
536-
ty::ty_int(_) => {
534+
ty::ty_int(_) | ty::ty_bool => {
537535
match val {
538-
const_bool(b) => Ok(const_int(b as i64)),
539536
const_uint(u) => Ok(const_int(u as i64)),
540537
const_int(i) => Ok(const_int(i)),
541538
const_float(f) => Ok(const_int(f as i64)),
542-
_ => Err("can't cast this type to int".to_string()),
539+
_ => Err("can't cast str to int".to_string()),
543540
}
544541
}
545542
_ => Err("can't cast this type".to_string())

0 commit comments

Comments
 (0)