move-language / move

Apache License 2.0
2.26k stars 689 forks source link

sui-move: [14/x][move-package/lock] Clean-up: Avoid explicit PackageLock::unlock #861

Closed amnn closed 1 year ago

amnn commented 1 year ago

Remove the explicit unlock function and rely on the drop handler always. The only semantic difference is the order in which the locks are unlocked, but this should not be an issue (from a deadlock perspective), because the order in which they are locked is the always the same.

Motivated by how easy (especially when using the ?/try syntax) it is to accidentally skip the explicit calls to PackageLock::unlock. The reason why this still works is that the guards that it contains automatically unlock when they are dropped, so PackageLock's drop handler should do the right thing, without need for an explicit unlock call.

Test Plan

move/language/tools/move-package$ cargo nextest

Stack

See also: #790 for main.