Rust Engine: global identifiers: add view and rendering#1624
Conversation
e9be012 to
ee36444
Compare
639ca93 to
f63c0c7
Compare
|
Generally looks good. I mostly looked at documentation (and it looks great!). I tested on a Lean example and it seems to produce weird stuff. |
|
Thanks for the review, ah indeed, I was mainly using Lean to test my rendering mechanism. |
|
(just noticed @keks is out, since @jschneider-bensch is out as well, I'm asking you @franziskuskiefer) |
franziskuskiefer
left a comment
There was a problem hiding this comment.
generally lgtm but there are panics in here again.
franziskuskiefer
left a comment
There was a problem hiding this comment.
Thanks for addressing the panic issue. That solution sounds good to me.
Maybe clearly separating out the binary and library use case would also help.
But I just want to avoid pushing the problem up the stack by crashing without offering a good way of handling this for the caller.
|
Sounds good. |
9c1b598 to
bb2ce7d
Compare
Identifiers in hax are wrapper around
DefIds from rustc.DefIdconsists in flat paths from crate name to the item name.Printing such names in a consistent way across backend is a bit difficult. Names are not actually flat: a field for instance, always has a parent constructor, which always has a parent type.
When printing names, this is very handy to have: various backend have different namespace, and different requirements.
This PR introduces the concept of a View: a strongly-typed, hierarchical representation of a Rust path.
A View is a list of path segments, where each segment carries:
This makes paths robust to traversal, disambiguation, and rendering, while directly encoding rustc's invariants about what can appear where.
The PR also provides nice traits to deal with per-backend name printing, but those are a bit rough for now.
They don't handle a lot for you out of the box (e.g. name clashes, reserved names, etc.).
I will address that in a follow up PR.
This PR fixes #1599.