Skip to content

Commit 1ac2d74

Browse files
author
Cameron Zwarich
committed
---
yaml --- r: 153995 b: refs/heads/try2 c: 5d4d09d h: refs/heads/master i: 153993: 960f6e6 153991: 2b10d62 v: v3
1 parent ab56822 commit 1ac2d74

File tree

2 files changed

+151
-1
lines changed

2 files changed

+151
-1
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: 3607c7a982c55a165adda8056cc228acf918bc37
8+
refs/heads/try2: 5d4d09daf2e8e46839647d4e72b1cbefebad6ece
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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+
struct A {
12+
x: Box<int>,
13+
y: int,
14+
}
15+
16+
struct B {
17+
x: Box<int>,
18+
y: Box<int>,
19+
}
20+
21+
struct C {
22+
x: Box<A>,
23+
y: int,
24+
}
25+
26+
struct D {
27+
x: Box<A>,
28+
y: Box<int>,
29+
}
30+
31+
fn copy_after_move() {
32+
let a = box A { x: box 0, y: 1 };
33+
let _x = a.x;
34+
let _y = a.y; //~ ERROR use of partially moved
35+
}
36+
37+
fn move_after_move() {
38+
let a = box B { x: box 0, y: box 1 };
39+
let _x = a.x;
40+
let _y = a.y; //~ ERROR use of partially moved
41+
}
42+
43+
fn borrow_after_move() {
44+
let a = box A { x: box 0, y: 1 };
45+
let _x = a.x;
46+
let _y = &a.y; //~ ERROR use of partially moved
47+
}
48+
49+
fn move_after_borrow() {
50+
let a = box B { x: box 0, y: box 1 };
51+
let _x = &a.x;
52+
let _y = a.y; //~ ERROR cannot move
53+
}
54+
55+
fn copy_after_mut_borrow() {
56+
let mut a = box A { x: box 0, y: 1 };
57+
let _x = &mut a.x;
58+
let _y = a.y; //~ ERROR cannot use
59+
}
60+
61+
fn move_after_mut_borrow() {
62+
let mut a = box B { x: box 0, y: box 1 };
63+
let _x = &mut a.x;
64+
let _y = a.y; //~ ERROR cannot move
65+
}
66+
67+
fn borrow_after_mut_borrow() {
68+
let mut a = box A { x: box 0, y: 1 };
69+
let _x = &mut a.x;
70+
let _y = &a.y; //~ ERROR cannot borrow
71+
}
72+
73+
fn mut_borrow_after_borrow() {
74+
let mut a = box A { x: box 0, y: 1 };
75+
let _x = &a.x;
76+
let _y = &mut a.y; //~ ERROR cannot borrow
77+
}
78+
79+
fn copy_after_move_nested() {
80+
let a = box C { x: box A { x: box 0, y: 1 }, y: 2 };
81+
let _x = a.x.x;
82+
let _y = a.y; //~ ERROR use of partially moved
83+
}
84+
85+
fn move_after_move_nested() {
86+
let a = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
87+
let _x = a.x.x;
88+
let _y = a.y; //~ ERROR use of partially moved
89+
}
90+
91+
fn borrow_after_move_nested() {
92+
let a = box C { x: box A { x: box 0, y: 1 }, y: 2 };
93+
let _x = a.x.x;
94+
let _y = &a.y; //~ ERROR use of partially moved
95+
}
96+
97+
fn move_after_borrow_nested() {
98+
let a = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
99+
let _x = &a.x.x;
100+
let _y = a.y; //~ ERROR cannot move
101+
}
102+
103+
fn copy_after_mut_borrow_nested() {
104+
let mut a = box C { x: box A { x: box 0, y: 1 }, y: 2 };
105+
let _x = &mut a.x.x;
106+
let _y = a.y; //~ ERROR cannot use
107+
}
108+
109+
fn move_after_mut_borrow_nested() {
110+
let mut a = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
111+
let _x = &mut a.x.x;
112+
let _y = a.y; //~ ERROR cannot move
113+
}
114+
115+
fn borrow_after_mut_borrow_nested() {
116+
let mut a = box C { x: box A { x: box 0, y: 1 }, y: 2 };
117+
let _x = &mut a.x.x;
118+
let _y = &a.y; //~ ERROR cannot borrow
119+
}
120+
121+
fn mut_borrow_after_borrow_nested() {
122+
let mut a = box C { x: box A { x: box 0, y: 1 }, y: 2 };
123+
let _x = &a.x.x;
124+
let _y = &mut a.y; //~ ERROR cannot borrow
125+
}
126+
127+
fn main() {
128+
copy_after_move();
129+
move_after_move();
130+
borrow_after_move();
131+
132+
move_after_borrow();
133+
134+
copy_after_mut_borrow();
135+
move_after_mut_borrow();
136+
borrow_after_mut_borrow();
137+
mut_borrow_after_borrow();
138+
139+
copy_after_move_nested();
140+
move_after_move_nested();
141+
borrow_after_move_nested();
142+
143+
move_after_borrow_nested();
144+
145+
copy_after_mut_borrow_nested();
146+
move_after_mut_borrow_nested();
147+
borrow_after_mut_borrow_nested();
148+
mut_borrow_after_borrow_nested();
149+
}
150+

0 commit comments

Comments
 (0)