Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New scoping rules for safe destruction; not ready to land #20539

Closed
wants to merge 65 commits into from

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Jan 4, 2015

Not ready to land, in any way.

This is a resurrection and heavy revision/expansion of a PR that pcwalton did to resolve #8861.

I am just putting this up to get some early review feedback from Niko.

I put in some commits today that address some necessary fallout that I had been missing. I had previously overlooked a number of tests that were not being run because the test suite was getting hung up on a case of exponential time blowup (I think) in the dropck code for which I put in a quick work-around. (I think pcwalton’s original branch was the one that introduced the “breadcrumbs” field to avoid non-termination; the workaround further exploits the breadcrumbs structure to try to avoid unnecessary retraversals. It seems to have done the trick.

There may still be yet more fallout to be addressed; pnkfelix@31cec27 is an example of the kind of fix that I hope will be the most that will be required on a case-by-case basis. (The more extreme kind of fix is illustrated by pnkfelix@5dd63c1 but I really hope there are not many occurrences of that sort of thing in the tests.)

Also obviously the src/libst2/ stuff was just a skeletal clone of libstd to help me track down some issues when I was getting this bootstrapped; it obviously will be deleted in the real PR.

…er::SubregionOrigin`.

Must rename breadcrumbs, or at least improve its documentation.
…ope`.

This version has a debug statement that I should remove.

also adds lifetime param to mem_categorization::scope to get repr working.
…_expr.

includes still more debug instrumentation, as well as a span_note in
the case that use to return prematurely.
dropck handling of relationship of a closure to its enclosed block.
parent-scope of closure's block.

This is (hopefully) temporary fix for boot-strapping pcwalton's old
8861 work, since my goal is to eventually get rid of `ReFunction`
entirely.
includes debug output noting that we could have produced ReFunction here.
Namely, `BlockS` used to carry an `fcx: &'blk FunctionContext`, while
the `FunctionContext` carries a reference to the arena that holds the
blocks, and thus there was a chicken/egg problem where we are
attempting to assign the lifetime `'blk` to both the `FunctionContext`
and to the arena's blocks, which does not work under the new lifetime
rules for `Drop`, since there has to be some order in which the two
are torn down.

To work around this, I removed the `fcx` from the `BlockS`, and
instead turn the `Block` type (which was formerly `&'blk BlockS`) into
a tuple carrying both the pointer to the `BlockS` as well as the
`fcx`.
Accomodate new lifetime restrictions by ensuring `type_arena` outlives
`ast_map`.
Accomodate new lifetime restrictions by ensuring `type_arena` outlives
`ast_map`.
(I often run `compiletest` by hand by cut-and-pasting from what `make`
runs, but then I need to tweak it (cut out options) and its useful to
be told when I have removed an option that is actually required, such
as `--android-cross-path=path`.)
… branch.

This needs investigation: What did pnkfelix do that caused this to
change?
In particular, ensure that both of the thread objects created for
nlist and clist both outlive nlist and clist themselves.
It is very unfortunate that the destruction scopes are not printed in
some distinguished way here.

It is also unfortunate that the graphviz tests are so hard to maintain
-- it would probably be better to just have a flowgraph graphviz mode
that does not include the exiting-scope edge labels, and then only
test in that mode.
…that borrows it.

(part of fallout from new destructor lifetime rules.)
@rust-highfive
Copy link
Collaborator

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 4, 2015

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned huonw Jan 4, 2015
@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 4, 2015

@nikomatsakis just a reminder: I am hoping to get feedback on the parts that would actually land in the end. If it is too much trouble to filter out the wheat from the chaff here with your eyes, just say so, and I can either try to provide you with some direction as to which commits to focus on, or I might just spend the time to make a slightly more focused PR.

@pythonesque
Copy link
Contributor

Just wanted to make sure #8861 (comment) gets seen here, since I think this is a safe generalization that will make the transition less painful (specifically: I think equal lifetime references can only cause an issue with explicit Drop implementations).

@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 5, 2015

@nikomatsakis (the diff may be a bit more manageable now. this seems likely to pass make check, since I got to the point where I had to placate make tidy)

@pnkfelix
Copy link
Member Author

closing; the new version is PR #21022

@pnkfelix pnkfelix closed this Jan 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New destructor semantics
5 participants