Skip to content

Commit e90d02c

Browse files
committed
---
yaml --- r: 129525 b: refs/heads/snap-stage3 c: 46cf384 h: refs/heads/master i: 129523: 12d6d96 v: v3
1 parent 912ab9a commit e90d02c

File tree

10 files changed

+47
-220
lines changed

10 files changed

+47
-220
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 566b470e138e929e8a93d613372db1ba177c494f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 17f79af31c4d413352a967b6cfe9ba7d70f66ff7
4+
refs/heads/snap-stage3: 46cf384ba9a598fe3b29d5b2fbb3b83e681ff77d
55
refs/heads/try: 80b45ddbd351f0a4a939c3a3c4e20b4defec4b35
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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

branches/snap-stage3/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
}

branches/snap-stage3/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
}

branches/snap-stage3/src/libcore/str.rs

Lines changed: 2 additions & 2 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

branches/snap-stage3/src/librustc/back/link.rs

Lines changed: 0 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

branches/snap-stage3/src/librustc/middle/const_eval.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,26 +517,29 @@ 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)),
520521
const_uint(u) => Ok(const_float(u as f64)),
521522
const_int(i) => Ok(const_float(i as f64)),
522523
const_float(f) => Ok(const_float(f)),
523-
_ => Err("can't cast float to str".to_string()),
524+
_ => Err("can't cast this type to float".to_string()),
524525
}
525526
}
526527
ty::ty_uint(_) => {
527528
match val {
529+
const_bool(b) => Ok(const_uint(b as u64)),
528530
const_uint(u) => Ok(const_uint(u)),
529531
const_int(i) => Ok(const_uint(i as u64)),
530532
const_float(f) => Ok(const_uint(f as u64)),
531-
_ => Err("can't cast str to uint".to_string()),
533+
_ => Err("can't cast this type to uint".to_string()),
532534
}
533535
}
534-
ty::ty_int(_) | ty::ty_bool => {
536+
ty::ty_int(_) => {
535537
match val {
538+
const_bool(b) => Ok(const_int(b as i64)),
536539
const_uint(u) => Ok(const_int(u as i64)),
537540
const_int(i) => Ok(const_int(i)),
538541
const_float(f) => Ok(const_int(f as i64)),
539-
_ => Err("can't cast str to int".to_string()),
542+
_ => Err("can't cast this type to int".to_string()),
540543
}
541544
}
542545
_ => Err("can't cast this type".to_string())

branches/snap-stage3/src/libstd/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ macro_rules! fail(
9696
macro_rules! assert(
9797
($cond:expr) => (
9898
if !$cond {
99-
fail!(concat!("assertion failed: ", stringify!($cond)))
99+
fail!("assertion failed: {:s}", stringify!($cond))
100100
}
101101
);
102102
($cond:expr, $($arg:expr),+) => (

branches/snap-stage3/src/test/run-pass/cast-in-array-size.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ fn main() {
1616
let _a: [bool, ..1 as uint];
1717
let _b: [int, ..SIZE as uint] = [1, ..SIZE as uint];
1818
let _c: [bool, ..'\n' as uint] = [true, ..'\n' as uint];
19+
let _d: [bool, ..true as uint] = [true, ..true as uint];
1920
}

0 commit comments

Comments
 (0)