Mettle

M0110Borrowed interior pointer outlives its scope

Reported by the compiler as an error or warning.

mettle explain M0110

A pointer into a stack value (a field, an array element) escapes the scope that owns the value, e.g. saved to an outer variable inside a block. When the block exits the pointee dies.

Fix: shorten the pointer's lifetime to the value's scope, or move the value itself to the outer scope / heap.

Related