Test cases for #985

Other restrictions on pinned kinds happened to fix this

Closes #985
This commit is contained in:
Brian Anderson 2011-09-28 14:39:57 -07:00
parent cb4e99b688
commit e1ba559c03
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// error-pattern: cannot copy pinned type r
resource r(i: @mutable int) {
*i = *i + 1;
}
fn movearg(i: r) {
// Implicit copy to mutate reference i
let j <- i;
}
fn main() {
let i = @mutable 0;
{
let j <- r(i);
movearg(j);
}
log_err *i;
// nooooooo. destructor ran twice
assert *i == 2;
}

View File

@ -0,0 +1,21 @@
// error-pattern: cannot copy pinned type 'a
resource r(i: @mutable int) {
*i = *i + 1;
}
fn movearg<T>(i: T) {
// Implicit copy to mutate reference i
let j <- i;
}
fn main() {
let i = @mutable 0;
{
let j <- r(i);
movearg(j);
}
log_err *i;
// nooooooo. destructor ran twice
assert *i == 2;
}