Hello! Is there any simplification pass done on the AST before lowering to HIR? I am trying to debug something and i don't understand most of it but would it be possible that an
kind: Closure be transformed in its inner block? Or if you look at differently, that the
Closure level is removed and its inner block left instead in the tree?
Besides regular macro expansion and a couple of extra expansion passes like test harness generation, all AST transformations and simplifications are happening during lowering to HIR.
However, some side tables later used from HIR are built as if AST were modified, e.g.
DefId hierarchies (
Ok. So its during
def_collector that i can see the
kind: Closure and then later during during lowering i can only see the block of the cloure
def_collector i can see: main function -> block -> closure expr -> block -> macrodef
But during lowering i can see: main function -> block -> block -> macrodef
Because the closure expr is gone, its not lowered properly and the macrodef (which is properly lowered) has a parent def id that does not have an associated hir id
And i printed the AST at the beginning of the lower_crate function and the closure expr is already gone at this point so something must happen before
Hmm, is this happening in rustdoc by chance?
Because rustdoc does have a pass removing parts of AST unnecessary for documentation purposes.
Oh yes its during a rustdoc test
The relevant pass is
AFAIK, it was modified in the past to not strip "things with items inside them", perhaps this is a missing case.
thank you very much for the help, i'll look for that and try to understand what is happening!
Something definitely happens in
So i managed to do a PR that fixes the issue: https://github.com/rust-lang/rust/pull/72088
This is kind of a nightmare because fixing in one place, make other places fail :(