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 upenable non-lexical lifetimes in the MIR borrow checker #45538
Conversation
rust-highfive
assigned
pnkfelix
Oct 25, 2017
This comment has been minimized.
This comment has been minimized.
|
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
Congrats, both of you! Been awesome seeing you power through this. |
kennytm
added
the
S-waiting-on-author
label
Oct 26, 2017
kennytm
reviewed
Oct 26, 2017
| @@ -0,0 +1,89 @@ | |||
| use super::RegionIndex; | |||
This comment has been minimized.
This comment has been minimized.
kennytm
Oct 26, 2017
Member
Tidy error
[00:03:02] tidy error: /checkout/src/librustc_mir/transform/nll/subtype.rs: incorrect license
[00:03:02] tidy error: /checkout/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs:48: line longer than 100 chars
[00:03:03] some tidy checks failed
This comment has been minimized.
This comment has been minimized.
spastorino
Oct 26, 2017
Member
Thanks @kennytm I've already fixed this in my local machine, will push in a while :)
|
|
||
| // END RUST SOURCE | ||
| // START rustc.node12.nll.0.mir | ||
| // | R4: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1], bb2[2], bb3[0], bb4[0], bb4[1], bb4[2], bb6[0], bb7[0], bb7[1], bb8[0]} |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
referenced this pull request
Oct 26, 2017
Closed
Tracking issue for RFC #2094: non-lexical lifetimes #44928
nikomatsakis
force-pushed the
nikomatsakis:nll-liveness
branch
3 times, most recently
from
708476a
to
5d0992c
Oct 26, 2017
pnkfelix
reviewed
Oct 26, 2017
| LvalueContext::Store | | ||
|
|
||
| // We let Call defined the result in both the success and unwind cases. | ||
| // This may not be right. | ||
| // We let Call defined the result in both the success and |
This comment has been minimized.
This comment has been minimized.
kennytm
added
S-waiting-on-review
and removed
S-waiting-on-author
labels
Oct 26, 2017
pnkfelix
reviewed
Oct 26, 2017
| } | ||
|
|
||
| /////////////////////////////////////////////////////////////////////////// | ||
| // DROP USES | ||
|
|
||
| // We consider drops to always be uses of locals. | ||
| // Drop eloboration should be run before this analysis otherwise |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 26, 2017
Author
Contributor
The comment is really kind of outdated. We do not want to run drop elaboration before the check -- and we are ok with drops being considered uses.
pnkfelix
reviewed
Oct 26, 2017
|
|
||
| // END RUST SOURCE | ||
| // START rustc.node12.nll.0.mir | ||
| // | R0: {bb1[1], bb2[0], bb2[1]} |
This comment has been minimized.
This comment has been minimized.
pnkfelix
Oct 26, 2017
•
Member
would it be better to print the region identifiers here as: _#0r:, _#2r:, _#3r: (or some uniform suffix of those) to make more clear the correspondence with their appearances in the borrows?
This comment has been minimized.
This comment has been minimized.
spastorino
Oct 26, 2017
Member
To be honest, at the beginning I have a hard time figuring this output out, so ... maybe going through this and making it more clear is a good things to do. /cc @nikomatsakis
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 26, 2017
Author
Contributor
I thought about that. I guess we might as well adopt the existing _#0r, even though it's horrible.
pnkfelix
reviewed
Oct 26, 2017
|
|
||
| // END RUST SOURCE | ||
| // START rustc.node12.nll.0.mir | ||
| // | R0: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]} |
This comment has been minimized.
This comment has been minimized.
pnkfelix
Oct 26, 2017
•
Member
hmm, do we not have an explicit notation for where R0 (aka '_#0r, right?) arises, somewhere in the MIR dump?
pnkfelix
reviewed
Oct 26, 2017
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| pub struct MirBorrowckCtxt<'c, 'b, 'a: 'b+'c, 'gcx: 'a+'tcx, 'tcx: 'a> { | ||
| tcx: TyCtxt<'a, 'gcx, 'gcx>, | ||
| mir: &'b Mir<'gcx>, | ||
| tcx: TyCtxt<'a, 'gcx, 'tcx>, |
This comment has been minimized.
This comment has been minimized.
pnkfelix
Oct 26, 2017
Member
niko can i bribe you with some halloween candy to break out this semi-mechanical lifetime-parameter refactoring (or generalization, if you prefer) into a separate commit? This commt is pretty hard to digest the way it is currently set up...
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This is epic! |
pnkfelix
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Oct 26, 2017
This comment has been minimized.
This comment has been minimized.
|
my questions and nits are all pretty minor. It might be a good idea to see if @arielb1 wants to take a look too, but he might be on vacation |
kennytm
added
S-waiting-on-review
and removed
S-waiting-on-author
labels
Oct 27, 2017
spastorino
force-pushed the
nikomatsakis:nll-liveness
branch
from
738180d
to
14a078d
Oct 27, 2017
nikomatsakis
force-pushed the
nikomatsakis:nll-liveness
branch
from
4573191
to
34ebd74
Oct 30, 2017
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix addressed feedback. I also rebased and cleaned up the history, incorporating a number of changes from @spastorino. Have to figure out those travis failures though. |
nikomatsakis
force-pushed the
nikomatsakis:nll-liveness
branch
from
34ebd74
to
fd2bdeb
Oct 30, 2017
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis some of my commits are lost, related to the tests and fixes we were doing last night. Is that included in the code you've pushed? should I push that again?. |
This comment has been minimized.
This comment has been minimized.
|
@spastorino I don't believe they were lost, rather I merged them into the appropriate places. |
nikomatsakis
referenced this pull request
Oct 30, 2017
Merged
Add derive and doc comment capabilities to newtype_index macro #45605
This comment has been minimized.
This comment has been minimized.
|
Those travis failures are curious. I don't see them locally, on mac or linux. :/ |
nikomatsakis
added some commits
Oct 26, 2017
nikomatsakis
force-pushed the
nikomatsakis:nll-liveness
branch
from
bf7e83d
to
9b3af6c
Oct 31, 2017
nikomatsakis
referenced this pull request
Oct 31, 2017
Closed
NLL: refine liveness with "maybe initialized" analysis #45665
This comment has been minimized.
This comment has been minimized.
|
@bors r=pnkfelix I'm going to go ahead and land this so as to unblock further work. It ought not to deeply interact with any "enabled by default" code, so it's low risk. |
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
referenced this pull request
Oct 31, 2017
Merged
extend NLL with preliminary support for free regions on functions #45668
This comment has been minimized.
This comment has been minimized.
|
@spastorino Wuhu! Congrats on pushing this through! |
kennytm
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Nov 1, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Nov 1, 2017
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit aae3e74
into
rust-lang:master
Nov 1, 2017
This was referenced Nov 1, 2017
This comment has been minimized.
This comment has been minimized.
|
It's finally here! :D Well part of it but still! :D |
nikomatsakis commentedOct 25, 2017
•
edited
This PR, joint work with @spastorino, fills out the NLL infrastructure and integrates it with the borrow checker. Don't get too excited: it includes still a number of hacks (the subtyping code is particularly hacky). However, it does kinda' work. =)
The final commit demonstrates this by including a test that -- with both the AST borrowck and MIR borrowck -- reports an error by default. But if you pass
-Znll, you only get an error from the AST borrowck, demonstrating that the integration succeeds: