-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #18137 - ShoyuVanilla:expr-2021, r=Veykril
feat: Implement `expr_2021` Resolves #18062
- Loading branch information
Showing
5 changed files
with
192 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,3 +177,149 @@ fn main() { | |
}"#]], | ||
); | ||
} | ||
|
||
#[test] | ||
fn expr_2021() { | ||
check( | ||
Edition::Edition2024, | ||
Edition::Edition2024, | ||
r#" | ||
($($e:expr),* $(,)?) => { | ||
$($e);* ; | ||
}; | ||
"#, | ||
r#" | ||
_, | ||
const { 1 }, | ||
"#, | ||
expect![[r#" | ||
SUBTREE $$ 1:[email protected]#0 1:[email protected]#0 | ||
IDENT _ 1:[email protected]#0 | ||
PUNCH ; [joint] 0:[email protected]#0 | ||
SUBTREE () 0:[email protected]#0 0:[email protected]#0 | ||
IDENT const 1:[email protected]#0 | ||
SUBTREE {} 1:[email protected]#0 1:[email protected]#0 | ||
LITERAL Integer 1 1:[email protected]#0 | ||
PUNCH ; [alone] 0:[email protected]#0 | ||
_; | ||
(const { | ||
1 | ||
});"#]], | ||
); | ||
check( | ||
Edition::Edition2021, | ||
Edition::Edition2024, | ||
r#" | ||
($($e:expr),* $(,)?) => { | ||
$($e);* ; | ||
}; | ||
"#, | ||
r#" | ||
_, | ||
"#, | ||
expect![[r#" | ||
ExpandError { | ||
inner: ( | ||
1:[email protected]#0, | ||
NoMatchingRule, | ||
), | ||
} | ||
SUBTREE $$ 1:[email protected]#0 1:[email protected]#0 | ||
PUNCH ; [alone] 0:[email protected]#0 | ||
;"#]], | ||
); | ||
check( | ||
Edition::Edition2021, | ||
Edition::Edition2024, | ||
r#" | ||
($($e:expr),* $(,)?) => { | ||
$($e);* ; | ||
}; | ||
"#, | ||
r#" | ||
const { 1 }, | ||
"#, | ||
expect![[r#" | ||
ExpandError { | ||
inner: ( | ||
1:[email protected]#0, | ||
NoMatchingRule, | ||
), | ||
} | ||
SUBTREE $$ 1:[email protected]#0 1:[email protected]#0 | ||
PUNCH ; [alone] 0:[email protected]#0 | ||
;"#]], | ||
); | ||
check( | ||
Edition::Edition2024, | ||
Edition::Edition2024, | ||
r#" | ||
($($e:expr_2021),* $(,)?) => { | ||
$($e);* ; | ||
}; | ||
"#, | ||
r#" | ||
4, | ||
"literal", | ||
funcall(), | ||
future.await, | ||
break 'foo bar, | ||
"#, | ||
expect![[r#" | ||
SUBTREE $$ 1:[email protected]#0 1:[email protected]#0 | ||
LITERAL Integer 4 1:[email protected]#0 | ||
PUNCH ; [joint] 0:[email protected]#0 | ||
LITERAL Str literal 1:[email protected]#0 | ||
PUNCH ; [joint] 0:[email protected]#0 | ||
SUBTREE () 0:[email protected]#0 0:[email protected]#0 | ||
IDENT funcall 1:[email protected]#0 | ||
SUBTREE () 1:[email protected]#0 1:[email protected]#0 | ||
PUNCH ; [joint] 0:[email protected]#0 | ||
SUBTREE () 0:[email protected]#0 0:[email protected]#0 | ||
IDENT future 1:[email protected]#0 | ||
PUNCH . [alone] 1:[email protected]#0 | ||
IDENT await 1:[email protected]#0 | ||
PUNCH ; [joint] 0:[email protected]#0 | ||
SUBTREE () 0:[email protected]#0 0:[email protected]#0 | ||
IDENT break 1:[email protected]#0 | ||
PUNCH ' [joint] 1:[email protected]#0 | ||
IDENT foo 1:[email protected]#0 | ||
IDENT bar 1:[email protected]#0 | ||
PUNCH ; [alone] 0:[email protected]#0 | ||
4; | ||
"literal"; | ||
(funcall()); | ||
(future.await); | ||
(break 'foo bar);"#]], | ||
); | ||
check( | ||
Edition::Edition2024, | ||
Edition::Edition2024, | ||
r#" | ||
($($e:expr_2021),* $(,)?) => { | ||
$($e);* ; | ||
}; | ||
"#, | ||
r#" | ||
_, | ||
"#, | ||
expect![[r#" | ||
ExpandError { | ||
inner: ( | ||
1:[email protected]#0, | ||
NoMatchingRule, | ||
), | ||
} | ||
SUBTREE $$ 1:[email protected]#0 1:[email protected]#0 | ||
PUNCH ; [alone] 0:[email protected]#0 | ||
;"#]], | ||
); | ||
} |