How complicated is the code of the borrow checker?

60 points servermeta_net 6 comments

In my quest to improve my rust skills I would like to understand more about the inner working of the borrow checker. It seems the code resides here, and from a quick read it feels like a graph traversal library:

- We try to build a graph representing regions of code and memory

- We apply some logic to make some cases easier to deal with

- Then a decisional tree is applied to this "denormalized" graph to infer if the rules of borrow has been broken

Obviously the devil is in the details, but how close am I to the truth?
Is the borrow checker something extremely complex like a compiler, or something much simpler? I would bet the latter, given I could follow the code a bit, unlike with the compiler

Where can I learn more? Would it be crazy to think to try to implement a (very simplified) borrow checker myself?