Idea: introduce core::ptr::read_owned

If the called function takes &move, there'd of course be no move of underlying place. I'm referring instead to code which passes source-by-value, and as an optimization, replacing the fresh temporary place introduced by a "ptr::read_owned" with instead reusing the source place.

The ability to pass &move T where T is expected would be a nice way to ask for this behavior rather than relying on optimization to recover it. If place address uniqueness rules prevent observable place colocation, passing &move makes sense as a way to permit it. Though colocation depending on ABI makes it a bit awkward, it doesn't prevent it.

Even though at an ABI level an abi-by-reference can be logically understood as taking a kind of &move, it's still source-by-value and its observable semantics (e.g. place uniqueness) is derived from that.

(I opened a UCG issue to determine concretely if address uniqueness would prevent the optimization without a source hint like &move.)

1 Like