Rustc uses arena and interning.

This helps fast comparison since interned objects can just compare pointers.

for each interned type X, we implemented PartialEq for X, so we can just compare pointers. The CtxtInterners type contains a bunch of maps of interned types and the arena itself.

Each time when we want to construct an interned object, the compiler check whether it exists.

At the beginning of compilation we get a buffer (arena) to allocate memory. If we exhaust this buffer, we get another one. The lifetime of that buffer is 'tcx (Remember that tcx is the central data structure in Rustc). My question: Is each kind of objects getting their own arena?

Thread-local storage is also used pervasively in Rustc.

References