You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//# publish
module 0xCAFE::Module0 {
public fun cannot_compile(x: u64) {
*(&mut x) = x;
}
}
//# publish
module 0xCAFE::Module1 {
public fun can_compile(x: u64) {
*(&mut x) = x + 1;
}
}
Both functions are mutating a variable and using it on the RHS expression at the same time but the first one can be compiled and the second one can be compiled.
Error message from the first one:
task 0 'publish'. lines 1-6:
Error: compilation errors:
error: cannot copy local `x` which is still mutably borrowed
┌─ TEMPFILE:4:9
│
4 │ *(&mut x) = x;
│ ^^^^^^^^^^^^^
│ ││
│ │local `x` previously mutably borrowed here
│ copy attempted here