internal: Render root syntax contexts more clearly

This commit is contained in:
Lukas Wirth 2025-03-14 13:54:17 +01:00
parent c28b80c321
commit a06aadb9f0
8 changed files with 177 additions and 164 deletions

View file

@ -109,8 +109,8 @@ fn unbalanced_brace() {
"#,
r#""#,
expect![[r#"
SUBTREE $$ 1:0@0..0#4294967037 1:0@0..0#4294967037
SUBTREE {} 0:0@9..10#4294967037 0:0@11..12#4294967037
SUBTREE $$ 1:0@0..0#ROOT2021 1:0@0..0#ROOT2021
SUBTREE {} 0:0@9..10#ROOT2021 0:0@11..12#ROOT2021
{}"#]],
);
@ -132,25 +132,25 @@ fn token_mapping_smoke_test() {
struct MyTraitMap2
"#,
expect![[r#"
SUBTREE $$ 1:0@0..20#4294967037 1:0@0..20#4294967037
IDENT struct 0:0@34..40#4294967037
IDENT MyTraitMap2 1:0@8..19#4294967037
SUBTREE {} 0:0@48..49#4294967037 0:0@100..101#4294967037
IDENT map 0:0@58..61#4294967037
PUNCH : [alone] 0:0@61..62#4294967037
PUNCH : [joint] 0:0@63..64#4294967037
PUNCH : [alone] 0:0@64..65#4294967037
IDENT std 0:0@65..68#4294967037
PUNCH : [joint] 0:0@68..69#4294967037
PUNCH : [alone] 0:0@69..70#4294967037
IDENT collections 0:0@70..81#4294967037
PUNCH : [joint] 0:0@81..82#4294967037
PUNCH : [alone] 0:0@82..83#4294967037
IDENT HashSet 0:0@83..90#4294967037
PUNCH < [alone] 0:0@90..91#4294967037
SUBTREE () 0:0@91..92#4294967037 0:0@92..93#4294967037
PUNCH > [joint] 0:0@93..94#4294967037
PUNCH , [alone] 0:0@94..95#4294967037
SUBTREE $$ 1:0@0..20#ROOT2021 1:0@0..20#ROOT2021
IDENT struct 0:0@34..40#ROOT2021
IDENT MyTraitMap2 1:0@8..19#ROOT2021
SUBTREE {} 0:0@48..49#ROOT2021 0:0@100..101#ROOT2021
IDENT map 0:0@58..61#ROOT2021
PUNCH : [alone] 0:0@61..62#ROOT2021
PUNCH : [joint] 0:0@63..64#ROOT2021
PUNCH : [alone] 0:0@64..65#ROOT2021
IDENT std 0:0@65..68#ROOT2021
PUNCH : [joint] 0:0@68..69#ROOT2021
PUNCH : [alone] 0:0@69..70#ROOT2021
IDENT collections 0:0@70..81#ROOT2021
PUNCH : [joint] 0:0@81..82#ROOT2021
PUNCH : [alone] 0:0@82..83#ROOT2021
IDENT HashSet 0:0@83..90#ROOT2021
PUNCH < [alone] 0:0@90..91#ROOT2021
SUBTREE () 0:0@91..92#ROOT2021 0:0@92..93#ROOT2021
PUNCH > [joint] 0:0@93..94#ROOT2021
PUNCH , [alone] 0:0@94..95#ROOT2021
struct MyTraitMap2 {
map: ::std::collections::HashSet<()>,
@ -179,28 +179,28 @@ fn main() {
}
"#,
expect![[r#"
SUBTREE $$ 1:0@0..63#4294967037 1:0@0..63#4294967037
IDENT fn 1:0@1..3#4294967037
IDENT main 1:0@4..8#4294967037
SUBTREE () 1:0@8..9#4294967037 1:0@9..10#4294967037
SUBTREE {} 1:0@11..12#4294967037 1:0@61..62#4294967037
LITERAL Integer 1 1:0@17..18#4294967037
PUNCH ; [alone] 1:0@18..19#4294967037
LITERAL Float 1.0 1:0@24..27#4294967037
PUNCH ; [alone] 1:0@27..28#4294967037
SUBTREE () 1:0@33..34#4294967037 1:0@39..40#4294967037
SUBTREE () 1:0@34..35#4294967037 1:0@37..38#4294967037
LITERAL Integer 1 1:0@35..36#4294967037
PUNCH , [alone] 1:0@36..37#4294967037
PUNCH , [alone] 1:0@38..39#4294967037
PUNCH . [alone] 1:0@40..41#4294967037
LITERAL Float 0.0 1:0@41..44#4294967037
PUNCH ; [alone] 1:0@44..45#4294967037
IDENT let 1:0@50..53#4294967037
IDENT x 1:0@54..55#4294967037
PUNCH = [alone] 1:0@56..57#4294967037
LITERAL Integer 1 1:0@58..59#4294967037
PUNCH ; [alone] 1:0@59..60#4294967037
SUBTREE $$ 1:0@0..63#ROOT2021 1:0@0..63#ROOT2021
IDENT fn 1:0@1..3#ROOT2021
IDENT main 1:0@4..8#ROOT2021
SUBTREE () 1:0@8..9#ROOT2021 1:0@9..10#ROOT2021
SUBTREE {} 1:0@11..12#ROOT2021 1:0@61..62#ROOT2021
LITERAL Integer 1 1:0@17..18#ROOT2021
PUNCH ; [alone] 1:0@18..19#ROOT2021
LITERAL Float 1.0 1:0@24..27#ROOT2021
PUNCH ; [alone] 1:0@27..28#ROOT2021
SUBTREE () 1:0@33..34#ROOT2021 1:0@39..40#ROOT2021
SUBTREE () 1:0@34..35#ROOT2021 1:0@37..38#ROOT2021
LITERAL Integer 1 1:0@35..36#ROOT2021
PUNCH , [alone] 1:0@36..37#ROOT2021
PUNCH , [alone] 1:0@38..39#ROOT2021
PUNCH . [alone] 1:0@40..41#ROOT2021
LITERAL Float 0.0 1:0@41..44#ROOT2021
PUNCH ; [alone] 1:0@44..45#ROOT2021
IDENT let 1:0@50..53#ROOT2021
IDENT x 1:0@54..55#ROOT2021
PUNCH = [alone] 1:0@56..57#ROOT2021
LITERAL Integer 1 1:0@58..59#ROOT2021
PUNCH ; [alone] 1:0@59..60#ROOT2021
fn main(){
1;
@ -226,14 +226,14 @@ fn expr_2021() {
const { 1 },
"#,
expect![[r#"
SUBTREE $$ 1:0@0..25#4294967037 1:0@0..25#4294967037
IDENT _ 1:0@5..6#4294967037
PUNCH ; [joint] 0:0@36..37#4294967037
SUBTREE () 0:0@34..35#4294967037 0:0@34..35#4294967037
IDENT const 1:0@12..17#4294967037
SUBTREE {} 1:0@18..19#4294967037 1:0@22..23#4294967037
LITERAL Integer 1 1:0@20..21#4294967037
PUNCH ; [alone] 0:0@39..40#4294967037
SUBTREE $$ 1:0@0..25#ROOT2021 1:0@0..25#ROOT2021
IDENT _ 1:0@5..6#ROOT2021
PUNCH ; [joint] 0:0@36..37#ROOT2021
SUBTREE () 0:0@34..35#ROOT2021 0:0@34..35#ROOT2021
IDENT const 1:0@12..17#ROOT2021
SUBTREE {} 1:0@18..19#ROOT2021 1:0@22..23#ROOT2021
LITERAL Integer 1 1:0@20..21#ROOT2021
PUNCH ; [alone] 0:0@39..40#ROOT2021
_;
(const {
@ -254,13 +254,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
1:0@5..6#4294967037,
1:0@5..6#ROOT2021,
NoMatchingRule,
),
}
SUBTREE $$ 1:0@0..8#4294967037 1:0@0..8#4294967037
PUNCH ; [alone] 0:0@39..40#4294967037
SUBTREE $$ 1:0@0..8#ROOT2021 1:0@0..8#ROOT2021
PUNCH ; [alone] 0:0@39..40#ROOT2021
;"#]],
);
@ -278,13 +278,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
1:0@5..10#4294967037,
1:0@5..10#ROOT2021,
NoMatchingRule,
),
}
SUBTREE $$ 1:0@0..18#4294967037 1:0@0..18#4294967037
PUNCH ; [alone] 0:0@39..40#4294967037
SUBTREE $$ 1:0@0..18#ROOT2021 1:0@0..18#ROOT2021
PUNCH ; [alone] 0:0@39..40#ROOT2021
;"#]],
);
@ -304,26 +304,26 @@ fn expr_2021() {
break 'foo bar,
"#,
expect![[r#"
SUBTREE $$ 1:0@0..76#4294967037 1:0@0..76#4294967037
LITERAL Integer 4 1:0@5..6#4294967037
PUNCH ; [joint] 0:0@41..42#4294967037
LITERAL Str literal 1:0@12..21#4294967037
PUNCH ; [joint] 0:0@41..42#4294967037
SUBTREE () 0:0@39..40#4294967037 0:0@39..40#4294967037
IDENT funcall 1:0@27..34#4294967037
SUBTREE () 1:0@34..35#4294967037 1:0@35..36#4294967037
PUNCH ; [joint] 0:0@41..42#4294967037
SUBTREE () 0:0@39..40#4294967037 0:0@39..40#4294967037
IDENT future 1:0@42..48#4294967037
PUNCH . [alone] 1:0@48..49#4294967037
IDENT await 1:0@49..54#4294967037
PUNCH ; [joint] 0:0@41..42#4294967037
SUBTREE () 0:0@39..40#4294967037 0:0@39..40#4294967037
IDENT break 1:0@60..65#4294967037
PUNCH ' [joint] 1:0@66..67#4294967037
IDENT foo 1:0@67..70#4294967037
IDENT bar 1:0@71..74#4294967037
PUNCH ; [alone] 0:0@44..45#4294967037
SUBTREE $$ 1:0@0..76#ROOT2021 1:0@0..76#ROOT2021
LITERAL Integer 4 1:0@5..6#ROOT2021
PUNCH ; [joint] 0:0@41..42#ROOT2021
LITERAL Str literal 1:0@12..21#ROOT2021
PUNCH ; [joint] 0:0@41..42#ROOT2021
SUBTREE () 0:0@39..40#ROOT2021 0:0@39..40#ROOT2021
IDENT funcall 1:0@27..34#ROOT2021
SUBTREE () 1:0@34..35#ROOT2021 1:0@35..36#ROOT2021
PUNCH ; [joint] 0:0@41..42#ROOT2021
SUBTREE () 0:0@39..40#ROOT2021 0:0@39..40#ROOT2021
IDENT future 1:0@42..48#ROOT2021
PUNCH . [alone] 1:0@48..49#ROOT2021
IDENT await 1:0@49..54#ROOT2021
PUNCH ; [joint] 0:0@41..42#ROOT2021
SUBTREE () 0:0@39..40#ROOT2021 0:0@39..40#ROOT2021
IDENT break 1:0@60..65#ROOT2021
PUNCH ' [joint] 1:0@66..67#ROOT2021
IDENT foo 1:0@67..70#ROOT2021
IDENT bar 1:0@71..74#ROOT2021
PUNCH ; [alone] 0:0@44..45#ROOT2021
4;
"literal";
@ -345,13 +345,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
1:0@5..6#4294967037,
1:0@5..6#ROOT2021,
NoMatchingRule,
),
}
SUBTREE $$ 1:0@0..8#4294967037 1:0@0..8#4294967037
PUNCH ; [alone] 0:0@44..45#4294967037
SUBTREE $$ 1:0@0..8#ROOT2021 1:0@0..8#ROOT2021
PUNCH ; [alone] 0:0@44..45#ROOT2021
;"#]],
);