Skip to content

Some fixes to mir-borrowck - #44736

Merged
bors merged 3 commits into
rust-lang:masterfrom
pnkfelix:mir-borrowck4
Sep 26, 2017
Merged

Some fixes to mir-borrowck#44736
bors merged 3 commits into
rust-lang:masterfrom
pnkfelix:mir-borrowck4

Conversation

@pnkfelix

@pnkfelixpnkfelix commented Sep 21, 2017

Copy link
Copy Markdown
Contributor

Make the code more closely match the NLL RFC (updated description).

(The biggest visible fix the addition of the Shallow/Deep distinction, which means mir-borrowck stops falsely thinking that StorageDeads need deep access to their input L-value.)

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @eddyb

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

@eddyb

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Sep 21, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 6438c7f has been approved by eddyb

@pnkfelix

Copy link
Copy Markdown
ContributorAuthor

@bors r-

I want to investigate the StorageDead change more after pushback from @arielb1

@pnkfelixpnkfelix added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 21, 2017
@pnkfelix
pnkfelixforce-pushed the mir-borrowck4 branch 2 times, most recently from 54068fd to bf1c691CompareSeptember 22, 2017 13:41
@pnkfelixpnkfelix changed the title Some small fixes to mir-borrowckSome fixes to mir-borrowckSep 22, 2017
@pnkfelix

Copy link
Copy Markdown
ContributorAuthor

r? @arielb1

@rust-highfiverust-highfive assigned arielb1 and unassigned eddybSep 22, 2017
@pnkfelix

Copy link
Copy Markdown
ContributorAuthor

(one further refactoring that I am considering is to fold the calls to check_if_path_is_movedinto the body of access_lvalue. There is one case makes that a non-trivial refactoring, however, so I am leaving it for later work.)

@bors

bors commented Sep 23, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #44784) made this pull request unmergeable. Please resolve the merge conflicts.

Comment threadsrc/librustc_mir/borrow_check.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AST borrowck basically does a Deep write here and we might want to stay in sync with it. Also, if you leave this as Shallow without erasing borrows in dataflow::impls::borrows you'll have some very confusing diagnostics.

Comment threadsrc/librustc_mir/borrow_check.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In AST borrowck, this is "borrow does not live long enough" for both Drop and StorageDead. ofc. you can match on the context instead if you want.

Comment threadsrc/librustc_mir/borrow_check.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check somewhere that you have sufficient permissions to do the access - aka no mutable borrows of immutable references or moves through a non-Box reference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave that to a different PR through.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(added a fixme-comment noting that we need to have this.)

@arielb1

Copy link
Copy Markdown
Contributor

Basically r=me after a rebase. There are a few comments, but you can leave them to me or to a follow-up PR.

Comment threadsrc/librustc_mir/borrow_check.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This includes a "drive-by" fix to #38899. I think we might have a "legacy compatibility mode" that does not include this drive-by fix, so we can get a good summary of real issues in a crater.

At least add a comment // DIFFERENCE FROM BORROWCK.

@pnkfelix

pnkfelix commented Sep 25, 2017

Copy link
Copy Markdown
ContributorAuthor

Thanks for taking time over your weekend for that review @arielb1 ! Rebasing now!

@pnkfelix

pnkfelix commented Sep 25, 2017

Copy link
Copy Markdown
ContributorAuthor

I think my approach to the AST-/MIR-borrrowck discrepancies that @arielb1 has pointed out will be to just put in comments for now. Haven't decided 100% about that yet, but since one has to opt in to using MIR-borrowck in the first place via a -Z switch, it seems reasonable to delay porting the AST-borrowck "bugs", at least until we have things like two-phase borrows implemented.

Update: I decided in some cases to switch immediately to the AST-compatible mode. In either case I added comments in each instance pointing out that this particular piece of code is responsible for some planned discrepancy between AST- and (eventual) MIR-borrowck.

In particular:
* introduce the shallow/deep distinction for read/write accesses
* use the notions of prefixes, shallow prefixes, and supporting prefixes
rather than trying to recreate the restricted sets from ast-borrowck.
* Add shallow reads of Discriminant and ArrayLength, and treat them
as artificial fields when doing prefix traversals.
@arielb1

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Sep 25, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit e319f40 has been approved by arielb1

@pnkfelixpnkfelix added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 25, 2017
@bors

bors commented Sep 26, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e319f40 with merge 1c4510a...

bors added a commit that referenced this pull request Sep 26, 2017
Some fixes to mir-borrowck
Make the code more closely match the NLL RFC (updated description).
(The biggest visible fix the addition of the Shallow/Deep distinction, which means mir-borrowck stops falsely thinking that StorageDeads need deep access to their input L-value.)
@bors

bors commented Sep 26, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: arielb1
Pushing 1c4510a to master...

@bors
bors merged commit e319f40 into rust-lang:masterSep 26, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@pnkfelix@rust-highfive@eddyb@bors@arielb1