Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCleanup region hierarchy code, especially around closures #3696
Comments
This comment has been minimized.
This comment has been minimized.
|
I had a weird idea a while ago, for a higher-order function involving returning a stack closure something like:
And then use it like:
I recall that I couldn't make it compile. This sounds like it might enable this (crazy, but cool) sort of thing. |
nikomatsakis
referenced this issue
Mar 29, 2013
Closed
Unconstrained region variables when making str-ptr-ptr hash and eq #3283
This comment has been minimized.
This comment has been minimized.
|
An example from #3283 that should not build but does (leading to segfaults):
|
nikomatsakis
referenced this issue
Apr 25, 2013
Closed
defer reasoning about region relationships until after regionck #3238
This comment has been minimized.
This comment has been minimized.
|
Could not get to compile with: fn foo<'a>(blk: &fn(p: &'a fn() -> &'a fn())) {
let mut state = 0;
let statep = &mut state;
do blk {
|| { *statep = 1; }
}
}
fn main() {
do foo |p| { p()() }
} |
This comment has been minimized.
This comment has been minimized.
|
I did fix some problems in this area though this is still an issue. I have to come up with a good representative test case. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Does #2202 subsume this, or is there still something left to do? |
nikomatsakis
added a commit
to nikomatsakis/rust
that referenced
this issue
Feb 4, 2014
This comment has been minimized.
This comment has been minimized.
|
The PR #12828 tries to apply variance rule to self type substitution, also part of #5781, but the following begins to fail: pub fn main() {
let a = ~[~""];
let b: ~[~[&str]] = a.map(|s| s.lines().collect()); // error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
}First of all, should this compile as it currently does? If yes, then how is the self type substitution intertwined with with closure lifetime inference? |
edwardw
referenced this issue
Mar 27, 2014
Closed
Lifetime inference issue when destructuring in argument list #13167
nikomatsakis
referenced this issue
Sep 23, 2014
Closed
Aliasing rules are broken for closures #17403
nikomatsakis
referenced this issue
Oct 10, 2014
Merged
Fix closure upvar soundness bug in regionck #17869
This comment has been minimized.
This comment has been minimized.
|
@bkoropoff I'd love to talk over this issue with you if you're interested in looking at something else after #17403 :) -- I think the two are related, or at least touching pretty similar code. |
nikomatsakis
referenced this issue
Nov 13, 2014
Closed
Closures in methods can return pointers with short lifetimes #18899
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix has been working on this |
steveklabnik
added
the
A-closures
label
Feb 14, 2015
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis what's the state of this with the new closure stuff? is it still relevant? |
nikomatsakis
referenced this issue
Mar 2, 2015
Merged
Remove the synthetic "region bound" from closures #22966
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Mar 2, 2015
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Mar 2, 2015
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Mar 2, 2015
bors
added a commit
that referenced
this issue
Apr 1, 2015
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Apr 1, 2015
nikomatsakis
changed the title
Define region hierarchy for closures
Cleanup region hierarchy code, especially around closures
Jul 31, 2015
This comment has been minimized.
This comment has been minimized.
|
I'm updating the title on this issue and repurposing it to also cover the fact that it would be nice if the representation of "free" regions did not always have them attached to a scope. Instead, a free region should just have a number, and we should indicate the relationship that |
brson
added
P-low
T-compiler
labels
Jan 26, 2017
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Still a bug? |
This comment has been minimized.
This comment has been minimized.
|
So this is still a bug, but I hope that we will fix it for good once we fully move borrow/region-checking to MIR. The idea is that MIR has fully desugared closures. I am going to close this bug though because it's kind of vague and I don't see how having it open is helpful in any particular way. |
nikomatsakis commentedOct 8, 2012
This is a big that's been on the back of my mind for a while but I don't think it has a bug associated with it. When we build the region hierarchy, we assume that any
||-closure argument is limited to the lifetime of the call where it appears. However, since the more general form offn&was implemented, I don't believe this is enforced. We should place an upper-bound on the||lifetime and add some tests. In an ideal world, maybe we would always infer the lifetime of an||-closure, but this is tricky to do because the region hierarchy is built before region inference (and indeed it must be, in order to compute LUB/GLB and so forth).