Last use analysis doesn't doesn't move out results of anonymous functions #1818

brson opened this Issue Feb 12, 2012 · 0 comments


None yet

2 participants


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

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

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

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

fn main() {                                                                                                                                                                   
@marijnh marijnh was assigned Feb 12, 2012
@marijnh marijnh added a commit that closed this issue Feb 13, 2012
@marijnh marijnh Fix bug in handling of block functions in last-use analysis
It would fail to start out with a fresh scope when going over
a loop or block function for the second time, and thus not
recognize last uses of locals defined inside the block.

Closes #1818
@marijnh marijnh closed this in 94d4dcd Feb 13, 2012
@marijnh marijnh was unassigned by brson Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment