Test cases for #985
Other restrictions on pinned kinds happened to fix this Closes #985
This commit is contained in:
parent
cb4e99b688
commit
e1ba559c03
21
src/test/compile-fail/implicit-copy-1.rs
Normal file
21
src/test/compile-fail/implicit-copy-1.rs
Normal 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;
|
||||
}
|
21
src/test/compile-fail/implicit-copy-2.rs
Normal file
21
src/test/compile-fail/implicit-copy-2.rs
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user