You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #51457 - petrochenkov:hygnoparent, r=<try>
hygiene: Eliminate expansion hierarchy in favor of call-site hierarchy
"Expansion hierarchy" and "call-site hierarchy" are two slightly different ways to nest macro invocations and answer the question "who is the parent" for a given invocation.
For example, here both hierarchies coincide
```rust
macro inner() { ... }
macro outer() { inner!() }
outer!();
// expansions: root -> outer -> inner
// call-sites: root -> outer -> inner
```
but here they are different
```rust
macro inner() { ... }
macro outer($stuff: stuff) { $stuff }
// expansions: root -> outer -> inner (`inner` is expanded as a part of `outer`'s output)
// call-sites: root -> outer; root -> inner
outer!(inner!())
```
All our talk about hygiene was in terms of "def-site" and "call-site" name resolution so far and the "expansion hierarchy" is an internal detail, but it was actually used in few places in the way affecting resolution results. For example, in the attached test case the structure `S` itself was previously resolved succesfully, but resolution of its field `field` failed due to use of "expansion hierarchy".
This PR eliminates expansion hierarchy from hygiene algorithm and uses call-site hierarchy instead.
This is also a nice simplification of the model.
Instead of growing in *three* dimensions in similar but subtly different ways (def-site, call-site, expansion) hygiene hierarchies now grow in *two* dimensions in similar but subtly different ways (def-site, call-site).
0 commit comments