Skip to content

Path fragments for drop obligations #18234

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

Merged
merged 10 commits into from
Nov 25, 2014

Conversation

pnkfelix
Copy link
Member

Code to fragment paths into pieces based on subparts being moved around, e.g. moving x.1 out of a tuple (A,B,C) leaves behind the fragments x.0: A and x.2: C. Further discussion in borrowck/doc.rs.

Includes differentiation between assigned_fragments and moved_fragments, support for all-but-one array fragments, and instrumentation to print out the moved/assigned/unmmoved/parents for each function, factored out into a separate submodule.

These fragments can then be used by trans to inject stack-local dynamic drop flags. (They also can be hooked up with dataflow to reduce the expected number of injected flags.)

@rust-highfive
Copy link
Contributor

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@pnkfelix
Copy link
Member Author

r? @nikomatsakis

@nikomatsakis nikomatsakis self-assigned this Oct 30, 2014
@alexcrichton
Copy link
Member

ping @pnkfelix

@pnkfelix
Copy link
Member Author

@alexcrichton was that an implied request for me to rebase my PR based on @nikomatsakis 's feedback so far? I note that it seems like he is going through the commits (rather than the diff), so I would assume it might be better for me to wait until he is done with the initial review ...

@pnkfelix
Copy link
Member Author

@alexcrichton (oh, in case its not clear, @nikomatsakis has already noted to me in several priv msg's that he is intending to return to this review...)

@nikomatsakis
Copy link
Contributor

@pnkfelix indeed I am doing that RIGHT NOW!

@nikomatsakis
Copy link
Contributor

ok, r+ modulo the handling of _ and *x patterns. Fix nits as you feel, nothing I noted was particularly egregious, just being persnickety.

@nikomatsakis
Copy link
Contributor

This is really nice, well documented.

@alexcrichton
Copy link
Member

ah sorry didn't mean to annoy, just making sure the queue is moving!

@pnkfelix pnkfelix force-pushed the fsk-type-fragments-for-needsdrop-2 branch 3 times, most recently from afc70f3 to 52ef4e4 Compare November 21, 2014 16:50
@pnkfelix pnkfelix force-pushed the fsk-type-fragments-for-needsdrop-2 branch from 52ef4e4 to de78321 Compare November 24, 2014 13:30
`LpDowncast` carries the `DefId` of the variant itself.  To support
this, added the enum variant `DefId` to the `cat_downcast` variant in
`mem_categorization::categorization`.

(updated to fix mem_categorization to handle downcast of enum
struct-variants properly.)
To make this clean, refactored old `LoanPath` enum into a
`LoanPath` struct with a `ty::t` and a newly-added `LoanPathVariant` enum.

This enabled me to get rid of the ugly and fragile `LoanPath::to_type`
method, and I can probably also get rid of other stuff that was
supporting it, maybe.
… val now.

This is to fix a problem where I could not reliably map attach the
type for each loan-path to the loan-path itself because the same
loan-path was ending up associated with two different types, because
the cmt's had diverged in their interpretation of the path.
This is accomplished by:

1. Add `MatchMode` enum to `expr_use_visitor`.

2. Computing the match mode for each pattern via a pre-pass, and then
   passing the mode along when visiting the pattern in
   expr_use_visitor.

3. Adding a `fn matched_pat` callback to expr_use_visitor, which is
   called on interior struct and enum nodes of the pattern (as opposed
   to `fn consume_pat`, which is only invoked for identifiers at the
   leaves of the pattern), and invoking it accordingly.

Of particular interest are the `cat_downcast` instances established
when matching enum variants.
Includes differentiation between assigned_fragments and
moved_fragments, support for all-but-one array fragments, and
instrumentation to print out the moved/assigned/unmmoved/parents for
each function, factored out into separate submodule.
The tests use new "//~| ERROR" follow syntax.

Includes a test for moves involving array elements.  It was easier
than i realized to get something naive off the ground here.
@pnkfelix pnkfelix force-pushed the fsk-type-fragments-for-needsdrop-2 branch from de78321 to 5fbe0ca Compare November 25, 2014 14:26
bors added a commit that referenced this pull request Nov 25, 2014
…-2, r=nikomatsakis

Code to fragment paths into pieces based on subparts being moved around, e.g. moving `x.1` out of a tuple `(A,B,C)` leaves behind the fragments `x.0: A` and `x.2: C`.  Further discussion in borrowck/doc.rs.

Includes differentiation between assigned_fragments and moved_fragments, support for all-but-one array fragments, and instrumentation to print out the moved/assigned/unmmoved/parents for each function, factored out into a separate submodule.

These fragments can then be used by `trans` to inject stack-local dynamic drop flags.  (They also can be hooked up with dataflow to reduce the expected number of injected flags.)
@bors bors closed this Nov 25, 2014
@bors bors merged commit 5fbe0ca into rust-lang:master Nov 25, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Oct 8, 2024
…Veykril

internal: Filter out opaque tokens in some IDE feature macro descensions
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.

5 participants