Skip to content

liveness in stack closures #2447

Closed
Closed
@nikomatsakis

Description

@nikomatsakis

The liveness pass should be extended to treat stack closures just like a loop body. This is relatively straightforward. It would allow for a couple of nice things:

  • it'd be more efficient in some cases (I believe the last_use code I replaced actually did this right) because we could move values in if there were a loop like

    let mut v = [];
    uint::range(...) { |i|
    use(v);
    v = [some new vec];
    }

  • it allows us to right fold for arbitrary iteration with only moves:

    let mut b = b0;
    for as.each { |a|
    b <- op(a, b);
    }
    ret b;

    In this case, the value in op(e, b) is actually moved out temporarily but always restored by the end of the loop. This would work today with a while loop but not with a closure-based loop.

Metadata

Metadata

Assignees

Labels

A-type-systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions