Skip to content

Commit 6719f7e

Browse files
committed
---
yaml --- r: 151083 b: refs/heads/try2 c: fa43f6a h: refs/heads/master i: 151081: 7fd56fd 151079: a2a734b v: v3
1 parent bd5b29f commit 6719f7e

10 files changed

+284
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: bea94993d2f3534caefb3bc1a53255869c0796e0
8+
refs/heads/try2: fa43f6a7a651f57fb0ca65a704cbaa3d75e727a9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// Verify that managed pointers scope is treated like ownoed pointers.
12+
// regresion test for #11586
13+
14+
#![feature(managed_boxes)]
15+
16+
fn foo<'a>(x: &'a @int) -> &'a int {
17+
match x {
18+
&ref y => {
19+
&**y // Do not expect an error here
20+
}
21+
}
22+
}
23+
24+
fn bar() {
25+
let a = 3;
26+
let mut y = &a;
27+
if true {
28+
let x = @3;
29+
y = &*x; //~ ERROR `*x` does not live long enough
30+
}
31+
}
32+
33+
fn main() {}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2012 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+
#![feature(managed_boxes)]
12+
13+
struct point {
14+
x: int,
15+
y: int,
16+
}
17+
18+
fn x_coord<'r>(p: &'r point) -> &'r int {
19+
return &p.x;
20+
}
21+
22+
fn foo(p: @point) -> &int {
23+
let xc = x_coord(p); //~ ERROR `*p` does not live long enough
24+
assert_eq!(*xc, 3);
25+
return xc;
26+
}
27+
28+
fn main() {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2012 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+
#![feature(managed_boxes)]
12+
13+
fn borrow<'r, T>(x: &'r T) -> &'r T {x}
14+
15+
fn foo(cond: || -> bool, make_box: || -> @int) {
16+
let mut y: &int;
17+
loop {
18+
let x = make_box();
19+
20+
// Here we complain because the resulting region
21+
// of this borrow is the fn body as a whole.
22+
y = borrow(x); //~ ERROR `*x` does not live long enough
23+
24+
assert_eq!(*x, *y);
25+
if cond() { break; }
26+
}
27+
assert!(*y != 0);
28+
}
29+
30+
fn main() {}

branches/try2/src/test/run-pass/struct-field-assignability.rs renamed to branches/try2/src/test/compile-fail/struct-field-assignability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ struct Foo<'a> {
1515
}
1616

1717
pub fn main() {
18-
let f = Foo { x: @3 };
18+
let f = Foo { x: @3 }; //~ ERROR borrowed value does not live long enough
1919
assert_eq!(*f.x, 3);
2020
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ignore-pretty
2+
3+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
4+
// file at the top-level directory of this distribution and at
5+
// http://rust-lang.org/COPYRIGHT.
6+
//
7+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
// option. This file may not be copied, modified, or distributed
11+
// except according to those terms.
12+
13+
// exec-env:RUST_POISON_ON_FREE=1
14+
15+
#![feature(managed_boxes)]
16+
17+
fn borrow(x: &int, f: |x: &int|) {
18+
let before = *x;
19+
f(x);
20+
let after = *x;
21+
assert_eq!(before, after);
22+
}
23+
24+
struct F { f: ~int }
25+
26+
pub fn main() {
27+
let mut x = @F {f: ~3};
28+
borrow(x.f, |b_x| {
29+
assert_eq!(*b_x, 3);
30+
assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
31+
x = @F {f: ~4};
32+
33+
println!("&*b_x = {:p}", &(*b_x));
34+
assert_eq!(*b_x, 3);
35+
assert!(&(*x.f) as *int != &(*b_x) as *int);
36+
})
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ignore-pretty
2+
3+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
4+
// file at the top-level directory of this distribution and at
5+
// http://rust-lang.org/COPYRIGHT.
6+
//
7+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
// option. This file may not be copied, modified, or distributed
11+
// except according to those terms.
12+
13+
// exec-env:RUST_POISON_ON_FREE=1
14+
15+
#![feature(managed_boxes)]
16+
17+
fn borrow(x: &int, f: |x: &int|) {
18+
let before = *x;
19+
f(x);
20+
let after = *x;
21+
assert_eq!(before, after);
22+
}
23+
24+
struct F { f: ~int }
25+
26+
pub fn main() {
27+
let mut x = ~@F{f: ~3};
28+
borrow(x.f, |b_x| {
29+
assert_eq!(*b_x, 3);
30+
assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
31+
*x = @F{f: ~4};
32+
33+
println!("&*b_x = {:p}", &(*b_x));
34+
assert_eq!(*b_x, 3);
35+
assert!(&(*x.f) as *int != &(*b_x) as *int);
36+
})
37+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ignore-pretty
2+
3+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
4+
// file at the top-level directory of this distribution and at
5+
// http://rust-lang.org/COPYRIGHT.
6+
//
7+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
// option. This file may not be copied, modified, or distributed
11+
// except according to those terms.
12+
13+
// exec-env:RUST_POISON_ON_FREE=1
14+
15+
#![feature(managed_boxes)]
16+
17+
fn borrow(x: &int, f: |x: &int|) {
18+
let before = *x;
19+
f(x);
20+
let after = *x;
21+
assert_eq!(before, after);
22+
}
23+
24+
pub fn main() {
25+
let mut x = @3;
26+
borrow(x, |b_x| {
27+
assert_eq!(*b_x, 3);
28+
assert_eq!(&(*x) as *int, &(*b_x) as *int);
29+
x = @22;
30+
31+
println!("&*b_x = {:p}", &(*b_x));
32+
assert_eq!(*b_x, 3);
33+
assert!(&(*x) as *int != &(*b_x) as *int);
34+
})
35+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2012 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+
// exec-env:RUST_POISON_ON_FREE=1
12+
13+
#![feature(managed_boxes)]
14+
15+
fn testfn(cond: bool) {
16+
let mut x = @3;
17+
let mut y = @4;
18+
19+
// borrow x and y
20+
let r_x = &*x;
21+
let r_y = &*y;
22+
let mut r = r_x;
23+
let mut exp = 3;
24+
25+
if cond {
26+
r = r_y;
27+
exp = 4;
28+
}
29+
30+
println!("*r = {}, exp = {}", *r, exp);
31+
assert_eq!(*r, exp);
32+
33+
x = @5;
34+
y = @6;
35+
36+
println!("*r = {}, exp = {}", *r, exp);
37+
assert_eq!(*r, exp);
38+
assert_eq!(x, @5);
39+
assert_eq!(y, @6);
40+
}
41+
42+
pub fn main() {
43+
testfn(true);
44+
testfn(false);
45+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ignore-pretty
2+
3+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
4+
// file at the top-level directory of this distribution and at
5+
// http://rust-lang.org/COPYRIGHT.
6+
//
7+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
// option. This file may not be copied, modified, or distributed
11+
// except according to those terms.
12+
13+
// exec-env:RUST_POISON_ON_FREE=1
14+
15+
#![feature(managed_boxes)]
16+
17+
fn borrow(x: &int, f: |x: &int|) {
18+
let before = *x;
19+
f(x);
20+
let after = *x;
21+
assert_eq!(before, after);
22+
}
23+
24+
struct F { f: ~int }
25+
26+
pub fn main() {
27+
let mut x = @F {f: ~3};
28+
borrow((*x).f, |b_x| {
29+
assert_eq!(*b_x, 3);
30+
assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
31+
x = @F {f: ~4};
32+
33+
println!("&*b_x = {:p}", &(*b_x));
34+
assert_eq!(*b_x, 3);
35+
assert!(&(*x.f) as *int != &(*b_x) as *int);
36+
})
37+
}

0 commit comments

Comments
 (0)