@Jonas Schievink , here's a sketch of name-res API I've been investigating over the weekend: https://gist.github.com/matklad/145c88131282e8392e64d088ee8a50e4
I think this subset can be shared between rustc & ra in theory
The set of scopes which store
Map<Name, PerNs<Def>>, imports (
(Vec<Name>, glob or name or alias)) and has operations for:
This thing should be enough to run the fixed-point loop (the most interesting part)
It doesn't know anything about AST (scopes are just bags of names, defs are opaque), hygiene (which is encapsulated into
== of names) and which def belongs to which namespaces (the client specifies namespaces explicitely)
Cool! I guess a good first step would be to make r-a always pass the scope to resolve names in then?
Not sure, I might be overlooking things. My plan for this was to create an ires.rs module in hir_def, with the constraint that it doesnt import db directly, and see how much of name resolution can we spill there.
One open question is how to use this thing after names are resolved ? Should we drain scopes back into ModuleDats, or should we use them as is?
Should this module extraction succeeded, it would be fun to think about moving this to a crate, with the usual tradeoff: