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

NLL and Borrowck dataflow disagree on the meaning of a location #46875

Closed
nikomatsakis opened this issue Dec 20, 2017 · 3 comments · Fixed by #46984
Closed

NLL and Borrowck dataflow disagree on the meaning of a location #46875

nikomatsakis opened this issue Dec 20, 2017 · 3 comments · Fixed by #46984
Labels
A-NLL Area: Non-lexical lifetimes (NLL) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

In the NLL regions, if a region contains a location L, that means that the region contains the entry point to that location. In the borrow dataflow, however, when we apply statement effects, they take place on the exit from a location. The end result is that kills for borrows are applied slightly too late. Consider something like:

L1: P = &X;
L2: use(P); // last use
L3: X = 1;

The region for P would be inferred to {L1, L2}. Therefore, the kill of L2 needs to include the borrow on line 1. However, what we actually do is to insert the kill after L3.

I noticed this because I was trying to stop emitting EndRegion statements when using NLL. However, this caused false errors to be omitted. For now, there is a FIXME in the code.

@nikomatsakis nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-nll labels Dec 20, 2017
@nikomatsakis
Copy link
Contributor Author

Sample test case that was failing: src/test/ui/nll/ty-outlives/projection-implied-bound.rs

@nikomatsakis
Copy link
Contributor Author

After some review of the code and discussion with @pnkfelix, we proposed generalizing the dataflow API slightly to handle this. The idea is to have:

  • statement_effect(statement) means the effect a statement has
  • terminator_effect(terminator) means the effect of the terminator up to -- but not including! -- the branches (also kind of as today)
  • edge_effect(terminator, successor index) means the effect of a particular outgoing edge
    • today we have this, but only for one edge -- the "non-unwind" edge of a call

@arielb1
Copy link
Contributor

arielb1 commented Dec 21, 2017

In addition to adding edge effects, another possible fix would be to make the "out of scope" effect a "pre-statement" effect, that is evaluated by FlowAtLocation for the location.

@pnkfelix pnkfelix added the A-NLL Area: Non-lexical lifetimes (NLL) label Dec 21, 2017
This was referenced Dec 24, 2017
bors added a commit that referenced this issue Jan 3, 2018
NLL fixes

First, introduce pre-statement effects to dataflow to fix #46875. Edge dataflow effects might make that redundant, but I'm not sure of the best way to integrate them with liveness etc., and if this is a hack, this is one of the cleanest hacks I've seen.

And I want a small fix to avoid the torrent of bug reports.

Second, fix linking of projections to fix #46974

r? @pnkfelix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants