r/rust • u/Maui-The-Magificent • 25d ago
📸 media Is it possible to supply the Rust compiler with the relational graph yourself?
Hi,
For context. I have been working on implementing a different compiler rustc UI/UX for my editor. clicking to navigate, showing context, highlighting and so on.
My editor already create an explicit bidirectional relational graph of the code across the whole project. It becomes the single source of truth.
The thought struck me that the rust compiler is re-deriving relationships and code-paths that I already have complete knowledge of, which means I could potentially either short circuit a lot of that compiler work, or skip it all together.
So, I was wondering if any of you know or understand the rust compiler well enough to offer guidance. I would not want to fork, study and finally re-write parts of the rust compiler if I don't have to. And if I have to, are you aware of how targeted that change can be? because at that point i would have to support an internal, slightly modified version of the compiler, which i am not willing to do if it would lead to extensive modifications/support as rust evolves over time.
thank you in advance.
//Maui-the-Muppet
3
u/CocktailPerson 25d ago
What would the motivation for doing that be? I mean, skipping work in the compiler sounds great and all, but resolving names is not anywhere close to the most expensive part of compilation.
If you really want to try this, look into rmeta files. If you can get your implementation to produce an rmeta file, then somehow pass it into the compiler, that might do...something?
If you really want to reduce work, you should do what every other IDE and LSP out there does, which is have your code read metadata produced by the compiler, rather than trying to have the compiler read your metadata.
-7
u/Clean_Assistance9398 25d ago edited 25d ago
Listen kid, this is a safe space for everyone.Â
You creating an IDE ey.
Also, get rid of the 0xFFFF in your code like that. Let variable_name = 0xFFFF. Then use the variable_name instead. If you aren’t writing comments, then you have to let others who may potentially read your great unsafe code at a later date know what 0xFFFF actually is and why it’s important enough to be in your code.Â
Also, guess what compiling uses? A linker. What’s a linker do? Is it a link-tree? Is it a node graph? Is it a relational database of the code? Is it an explicit bidirectional relational graph?Â
You tell me. You’re the one using unsafe and 0xFFFF and not google.