Skip to content

Commit ccaf25e

Browse files
committed
---
yaml --- r: 166460 b: refs/heads/snap-stage3 c: e840e49 h: refs/heads/master v: v3
1 parent 44bb51c commit ccaf25e

File tree

4 files changed

+94
-1
lines changed

4 files changed

+94
-1
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: 18842f89f084c52588fe7cffe07f87bf6e90796a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 17826e10a2fbaeb7e75dcfe2e8c7d243536f7d6d
4+
refs/heads/snap-stage3: e840e49b21ba5af547e8e76003312f97f13f7b4f
55
refs/heads/try: f5d619caf9f32458680fae55526b99582ca682dd
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test range syntax - type errors.
12+
13+
pub fn main() {
14+
// Mixed types.
15+
let _ = 0u..10i;
16+
//~^ ERROR mismatched types: expected `uint`, found `int`
17+
18+
// Float => does not implement iterator.
19+
for i in 0f32..42f32 {}
20+
//~^ ERROR `for` loop expression has type `core::ops::Range<f32>` which does not implement
21+
22+
// Unsized type.
23+
let arr: &[_] = &[1u, 2, 3];
24+
let range = (*arr)..;
25+
//~^ ERROR the trait `core::kinds::Sized` is not implemented
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test range syntax - borrow errors.
12+
13+
pub fn main() {
14+
let x = &42i;
15+
{
16+
let y = 42i;
17+
let r = x..&y;
18+
//~^ ERROR `y` does not live long enough
19+
}
20+
21+
let r = {
22+
(&42i)..&42
23+
//~^ ERROR borrowed value does not live long enough
24+
//~^^ ERROR borrowed value does not live long enough
25+
};
26+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test range syntax.
12+
13+
fn foo() -> int { 42 }
14+
15+
pub fn main() {
16+
let mut count = 0;
17+
for i in 0u..10 {
18+
assert!(i >= 0 && i < 10);
19+
count += i;
20+
}
21+
assert!(count == 45);
22+
23+
let mut count = 0;
24+
let mut range = 0u..10;
25+
for i in range {
26+
assert!(i >= 0 && i < 10);
27+
count += i;
28+
}
29+
assert!(count == 45);
30+
31+
let mut count = 0;
32+
let mut rf = 3u..;
33+
for i in rf.take(10) {
34+
assert!(i >= 3 && i < 13);
35+
count += i;
36+
}
37+
assert!(count == 75);
38+
39+
let _ = 0u..4+4-3;
40+
let _ = 0..foo();
41+
}

0 commit comments

Comments
 (0)