Background/Takeaways
I tried to port rust-analyzer's base-db yesterday to new Salsa. I initially expected a 1:1 mapping, but I was (very!) wrong to: some concepts in the old Salsa do not map cleanly to the new Salsa, which may lead to an overall decrease in LoC in rust-analyzer. Here are some potentially incorrect takeaways:
Old Salsa has everything in a database/trait: there are no free functions or structures. Old Salsa requires placing everything into a trait that masquarades as a query group
New Salsa is a more fine-grained: it has databases (often traits), free tracked functions, and standalone, tracked or interned structs. It is not necessary to group all queries into a single trait/query group in the new Salsa.
Comparison Between Old and New Salsa
Basic, Hello World Comparison
Given the following in old Salsa: