Skip to content

Commit e1ba559

Browse files
committed
Test cases for #985
Other restrictions on pinned kinds happened to fix this Closes #985
1 parent cb4e99b commit e1ba559

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Diff for: src/test/compile-fail/implicit-copy-1.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// error-pattern: cannot copy pinned type r
2+
3+
resource r(i: @mutable int) {
4+
*i = *i + 1;
5+
}
6+
7+
fn movearg(i: r) {
8+
// Implicit copy to mutate reference i
9+
let j <- i;
10+
}
11+
12+
fn main() {
13+
let i = @mutable 0;
14+
{
15+
let j <- r(i);
16+
movearg(j);
17+
}
18+
log_err *i;
19+
// nooooooo. destructor ran twice
20+
assert *i == 2;
21+
}

Diff for: src/test/compile-fail/implicit-copy-2.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// error-pattern: cannot copy pinned type 'a
2+
3+
resource r(i: @mutable int) {
4+
*i = *i + 1;
5+
}
6+
7+
fn movearg<T>(i: T) {
8+
// Implicit copy to mutate reference i
9+
let j <- i;
10+
}
11+
12+
fn main() {
13+
let i = @mutable 0;
14+
{
15+
let j <- r(i);
16+
movearg(j);
17+
}
18+
log_err *i;
19+
// nooooooo. destructor ran twice
20+
assert *i == 2;
21+
}

0 commit comments

Comments
 (0)