Instead of having hir::Declarations inside hir::{Module, Data}, use HIRIndex/HIRIdentifier and store all declarations linearly in CrateScope. This would make iterating over declarations easier. We can and should then also store the parent for each declaration.
This would get rid of our Index/Environment "hack" in the typer (and resolver(?)) we currently require in some cases for handling constructors and need some data from the parent data declaration — in the new system, we can simply look up the parent by HIRIndex (plus some "downcasting"). Maybe this would also allow us to throw out the typer::Registration system by just having a list of those indices. I don't know.
This might also help finding unused declarations, implementing privacy and printing relative paths but maybe it does not but only if we also do this change to lowered_ast::Declaration b.c. the resolver needs it. I dunno.
Instead of having
hir::Declaration
s insidehir::{Module, Data}
, useHIRIndex
/HIRIdentifier
and store all declarations linearly inCrateScope
. This would make iterating over declarations easier. We can and should then also store the parent for each declaration. This would get rid of ourIndex
/Environment
"hack" in the typer (and resolver(?)) we currently require in some cases for handling constructors and need some data from the parent data declaration — in the new system, we can simply look up the parent byHIRIndex
(plus some "downcasting"). Maybe this would also allow us to throw out thetyper::Registration
system by just having a list of those indices. I don't know.This might also help finding unused declarations, implementing privacy and printing relative paths but maybe it does not but only if we also do this change to
lowered_ast::Declaration
b.c. the resolver needs it. I dunno.