When ast-borrowck was implemented (in 2012), there was no hir. Once hir was added, did ast-borrowck move to make use of it? Where does typeck fit in... am I right in assuming typeck has to happen before borrowck, and if so, did it also move from using ast to using hir?
typeck moved to hir. i don't know how it was before, but after the move typeck stores inferred types in a side table, as hir is immutable. typeck indeed has to happen before borrowck as typeck may add implicit dereferences and references. eg
&self results in
(&a).foo(). borrowck has to know about this.
borrowck requires the inferred types, so yeah
when the AST/HIR split was introduced, nothing moved, it's just that post-expansion AST became HIR, roughly
so everything that worked after macros have been expanded and name resolution happened, were now using HIR
@eddyb if typeck used ast, then hir gets introduced, how does it automatically get to use hir (without changing)
@Tshepang Lekhonkhobe it's just a plain rename at first
like, some parts kept using the
ast name, the others used
hir instead of
but there wasn't anything deeper than a duplication/rename
typeck didn't change how it worked or when it ran
so, if ast-borrowck was named hir-borrowck, my confusion would not exist
that's because HIR (the rustc IR) is an AST (the concept)
rustc_hir are ASTs
ah, I see
that's where the name
hir_borrowck would've been fine
(the main reason for that name was to make it distinct from "MIR borrowck")
so, in rust terms, mir is lot different to hir, than hir is different to ast
AST -> HIR is mostly a desugaring step
mir is a (control flow) graph, while ast and hir are (abstract syntax) trees
HIR -> MIR builds a control-flow graph, and requires type-checking results
Also: HAIR is another AST
which is even more desugared and explicit than HIR, but also typed rather than using side-tables (eww)
one of the items in my colleagues' TODO list is "rename HAIR to THIR" :P
what does T mean @eddyb
the "A" in the current "HAIR" means "abstract", which is much less useful
I thought the T meant
Too High-level Intermediate Representation.
is there a reason we have both hair and hir... do we need both, or can we get away with hir users be hair users
I believe hir is lazily converted to hair:
hair::ExprRef for example refers to
hir::Expr. Also hair is always typed, which means that you can't run typeck on it.
the difference is HAIR further desugars HIR based on typeck results
it's only used to build MIR
it's only used to build MIR
And for exhaustiveness checking!
right, HAIR patterns are also used in match checking
wow, this rustc is complex
I've always liked the name HAIR. I feel that it is a big missed pun opportunity.
@mark-i-m consider this renaming as a final hair cut.