Values that must be finished
A type that implements the prelude’s marker trait Finish (impl Finish for Process {}) holds something that has to be ended on purpose: a
started program, a transaction, a lock to hand back. The compiler reports
a forgotten one:
- a variable of such a type that reaches the normal end of its block
without being handed on (to a method that takes
self, likewait, to a function, a return, or another variable); - one finished on only one branch of an
if; - overwriting it, discarding it with
let _ =, or making one only as part of a statement (procs.spawn(&cmd).id()); - keeping it in a
Vec,Map,Set,ChannelorMutex, which would drop it without anyone finishing it.
A struct, tuple, Option or Box holding one must be finished too. Early
exits (return, a failing try, break) are not errors; a Finish type
that needs cleanup there implements Drop as well, as os.Process does
(it kills the program).