-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
make causal tracking lazy #46590
Copy link
Copy link
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The current NLL code tracks "causal" information so that we can give nice errors (see #45988 for more information). The intention is that we will only compute this information once an error is detected. At present, though, we compute it all the time. We should not do that.
The causal tracking code can be found in
values.rs. In fact, theRegionValues::newmethod already takes a boolean parametertrack_causesindicating whether to track causes, but theRegionInferenceContext, which creates the value sets, currently always passestrue.We have to think on the best way to do this. My preference would be to package this "extended causal information" up as a kind of query, so that the MIR borrowck can perform the query only when needed. We would alter the NLL analysis so that it passes
falsefor causal information, but then this new query would re-run the NLL analysis, but passingtrue(like we do today). There are some challenges here though: what format should the result of the query be in, for example?(The reason I wanted a query is that I wanted IDEs and other things to be able to query this information for borrow visualization, and having it be "local" to the borrowck wouldn't offer any visibility for those tools.)
It may however be easier to start by having the borrowck itself just re-run the NLL analysis locally (with tracking enabled) when needed.