From 13c5e525c04c6700d2471685551b4004bfa2dd43 Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Sun, 28 Jan 2024 17:30:23 +0100 Subject: [PATCH] Improving macro expansion section The first example is rewritten to follow the style of other examples: * Using `id(foo)` instead of `expn_id_foo`. * Using a single-line with arrow instead of a multi-line indented hierarchy. If there is a diffrence and this rewritting is wrong, it would be interesting to explain it. Also, this commit replace "first hierarchy" and "third hierarchy" by their name, ensuring it's more clear what is referred here. In particular, for the first hierarchy, it can be searched easier in the page if needed. --- src/macro-expansion.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/macro-expansion.md b/src/macro-expansion.md index f3883223d..0e1c72e72 100644 --- a/src/macro-expansion.md +++ b/src/macro-expansion.md @@ -292,13 +292,8 @@ macro_rules! foo { () => { println!(); } } fn main() { foo!(); } ``` -In this code, the AST nodes that are finally generated would have hierarchy: - -``` -root - expn_id_foo - expn_id_println -``` +In this code, the AST nodes that are finally generated would have hierarchy +`root -> id(foo) -> id(println)`. ### The Macro Definition Hierarchy @@ -397,8 +392,9 @@ macro foo($i: ident) { $i } foo!(bar!(baz)); ``` -For the `baz` AST node in the final output, the first hierarchy is `ROOT -> -id(foo) -> id(bar) -> baz`, while the third hierarchy is `ROOT -> baz`. +For the `baz` AST node in the final output, the expansion-order hierarchy is +`ROOT -> id(foo) -> id(bar) -> baz`, while the call-site hierarchy is `ROOT -> +baz`. ### Macro Backtraces