Description
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, the RegionValues::new
method already takes a boolean parameter track_causes
indicating whether to track causes, but the RegionInferenceContext
, which creates the value sets, currently always passes true
.
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 false
for causal information, but then this new query would re-run the NLL analysis, but passing true
(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.