-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[nll] make causal tracking lazy #51710
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
Comments
cc @rust-lang/wg-compiler-nll -- possible 4% win |
Here is a thread for chatting about this on zulip: https://rust-lang.zulipchat.com/#narrow/stream/122657-wg-nll/topic/issue-51710-lazy-causal-tracking |
So on Zulip @spastorino pointed out to me that we already have the BFS I described: rust/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs Lines 128 to 170 in 612c280
I think this perhaps suggests a simpler way to achieve the same goal. What I originally described was that we would use the BFS to basically "reproduce" the same return value we have now -- but that return value isn't ideal. Let's step back to explain how things work today. We have this function I can see two ways forward:
I guess I lean towards the former. Feels 'more right' -- |
Make causal tracking lazy Closes #51710 r? @nikomatsakis
This has a pending PR, marking as Preview 2. |
…tsakis Make causal tracking lazy Closes #51710 r? @nikomatsakis
Analyzing profiles on my latest branch, it appears that approximately 4% of total compilation time is spent managing the "causal hash map":
rust/src/librustc_mir/borrow_check/nll/region_infer/values.rs
Lines 187 to 191 in 01dbfda
Currently, that map is only non-None for the "liveness" set, which stores, for each region variable R, each point P where R is directly live (meaning typically that there is some local variable X that has R in its type and which may be used at some point Q reachable from P). The "cause" tracks basically this point Q. It's accessed later when constructing error messages, here:
rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Lines 1067 to 1068 in 01dbfda
We should remove the causal hashmap altogether. Instead, when constructing an error, we can do a BFS over the MIR graph from
elem
(aLocation
), looking for points that may use the regionregion_sub
that we are interested in.The text was updated successfully, but these errors were encountered: