mozilla/rust — Issue #1818: Last use analysis doesn't doesn't move out results of anonymous functions
Author: brson
Created: 2012-02-12 09:07:48+00:00
State: open
Labels: bug, middle

Both of these `r`'s generate errors about copying noncopyable values, but they should be moves.

```
fn apply(s: str, f: fn(str) -> T) -> T {
g(s) {|v|
let r = f(v);
r
}
}

fn apply2(s: str, f: fn(str) -> T) -> T {
g(s, fn&(v: str) -> T {
let r = f(v);
r
})
}

fn g(s: str, f: fn(str) -> T) -> T {
f(s)
}

fn main() {
}
```