rust-lang/project-rfc-2229

Migrations might result in closures not being able to be more than FnOnce

Closed this issue · 2 comments

One question that remains a bit unclear from the hackmds alone (don't have time to see the recording), is the difference between the suggested let x = x;, which makes the closure not be more than FnOnce if x is not Copy, vs. if false { let _x = x; loop {} }, which just makes the closure capture x without necessarily consuming it when called (same as currently doing let _ = x; in a move closure).
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=90049afee37fc9377ca13c89523d8d4b

This was resolved by changing the migration to drop(&x) for each variable v instead of let v = v