Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/tests.rs')
-rw-r--r--crates/mbe/src/tests.rs177
1 files changed, 93 insertions, 84 deletions
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index e63ad113ff..fb68d35a4c 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -26,7 +26,7 @@ fn check_(
file_id: EditionedFileId::new(FileId::from_raw(0), def_edition),
ast_id: ErasedFileAstId::from_raw(0),
},
- SyntaxContextId::ROOT,
+ SyntaxContextId::root(Edition::CURRENT),
decl,
)
.unwrap();
@@ -39,16 +39,20 @@ fn check_(
file_id: EditionedFileId::new(FileId::from_raw(1), call_edition),
ast_id: ErasedFileAstId::from_raw(0),
};
- let arg_tt =
- syntax_bridge::parse_to_token_tree(call_edition, call_anchor, SyntaxContextId::ROOT, arg)
- .unwrap();
+ let arg_tt = syntax_bridge::parse_to_token_tree(
+ call_edition,
+ call_anchor,
+ SyntaxContextId::root(Edition::CURRENT),
+ arg,
+ )
+ .unwrap();
let res = mac.expand(
&arg_tt,
|_| (),
Span {
range: TextRange::up_to(TextSize::of(arg)),
anchor: call_anchor,
- ctx: SyntaxContextId::ROOT,
+ ctx: SyntaxContextId::root(Edition::CURRENT),
},
def_edition,
);
@@ -59,7 +63,12 @@ fn check_(
if render_debug {
format_to!(expect_res, "{:#?}\n\n", res.value.0);
}
- let (node, _) = syntax_bridge::token_tree_to_syntax_node(&res.value.0, parse, def_edition);
+ let (node, _) = syntax_bridge::token_tree_to_syntax_node(
+ &res.value.0,
+ parse,
+ &mut |_| def_edition,
+ def_edition,
+ );
format_to!(
expect_res,
"{}",
@@ -106,25 +115,25 @@ fn token_mapping_smoke_test() {
struct MyTraitMap2
"#,
expect![[r#"
- IDENT struct 0:[email protected]#0
- IDENT MyTraitMap2 1:[email protected]#0
- IDENT map 0:[email protected]#0
- PUNCH : [alone] 0:[email protected]#0
- PUNCH : [joint] 0:[email protected]#0
- PUNCH : [alone] 0:[email protected]#0
- IDENT std 0:[email protected]#0
- PUNCH : [joint] 0:[email protected]#0
- PUNCH : [alone] 0:[email protected]#0
- IDENT collections 0:[email protected]#0
- PUNCH : [joint] 0:[email protected]#0
- PUNCH : [alone] 0:[email protected]#0
- IDENT HashSet 0:[email protected]#0
- PUNCH < [alone] 0:[email protected]#0
- PUNCH > [joint] 0:[email protected]#0
- PUNCH , [alone] 0:[email protected]#0
+ IDENT struct 0:[email protected]#2
+ IDENT MyTraitMap2 1:[email protected]#2
+ IDENT map 0:[email protected]#2
+ PUNCH : [alone] 0:[email protected]#2
+ PUNCH : [joint] 0:[email protected]#2
+ PUNCH : [alone] 0:[email protected]#2
+ IDENT std 0:[email protected]#2
+ PUNCH : [joint] 0:[email protected]#2
+ PUNCH : [alone] 0:[email protected]#2
+ IDENT collections 0:[email protected]#2
+ PUNCH : [joint] 0:[email protected]#2
+ PUNCH : [alone] 0:[email protected]#2
+ IDENT HashSet 0:[email protected]#2
+ PUNCH < [alone] 0:[email protected]#2
+ PUNCH > [joint] 0:[email protected]#2
+ PUNCH , [alone] 0:[email protected]#2
struct MyTraitMap2 {
map: ::std::collections::HashSet<()>,
@@ -153,28 +162,28 @@ fn main() {
}
"#,
expect![[r#"
- IDENT fn 1:[email protected]#0
- IDENT main 1:[email protected]#0
- LITERAL Integer 1 1:[email protected]#0
- PUNCH ; [alone] 1:[email protected]#0
- LITERAL Float 1.0 1:[email protected]#0
- PUNCH ; [alone] 1:[email protected]#0
- LITERAL Integer 1 1:[email protected]#0
- PUNCH , [alone] 1:[email protected]#0
- PUNCH , [alone] 1:[email protected]#0
- PUNCH . [alone] 1:[email protected]#0
- LITERAL Float 0.0 1:[email protected]#0
- PUNCH ; [alone] 1:[email protected]#0
- IDENT let 1:[email protected]#0
- IDENT x 1:[email protected]#0
- PUNCH = [alone] 1:[email protected]#0
- LITERAL Integer 1 1:[email protected]#0
- PUNCH ; [alone] 1:[email protected]#0
+ IDENT fn 1:[email protected]#2
+ IDENT main 1:[email protected]#2
+ LITERAL Integer 1 1:[email protected]#2
+ PUNCH ; [alone] 1:[email protected]#2
+ LITERAL Float 1.0 1:[email protected]#2
+ PUNCH ; [alone] 1:[email protected]#2
+ LITERAL Integer 1 1:[email protected]#2
+ PUNCH , [alone] 1:[email protected]#2
+ PUNCH , [alone] 1:[email protected]#2
+ PUNCH . [alone] 1:[email protected]#2
+ LITERAL Float 0.0 1:[email protected]#2
+ PUNCH ; [alone] 1:[email protected]#2
+ IDENT let 1:[email protected]#2
+ IDENT x 1:[email protected]#2
+ PUNCH = [alone] 1:[email protected]#2
+ LITERAL Integer 1 1:[email protected]#2
+ PUNCH ; [alone] 1:[email protected]#2
fn main(){
1;
@@ -200,14 +209,14 @@ fn expr_2021() {
const { 1 },
"#,
expect![[r#"
- IDENT _ 1:[email protected]#0
- PUNCH ; [joint] 0:[email protected]#0
- IDENT const 1:[email protected]#0
- LITERAL Integer 1 1:[email protected]#0
- PUNCH ; [alone] 0:[email protected]#0
+ IDENT _ 1:[email protected]#2
+ PUNCH ; [joint] 0:[email protected]#2
+ IDENT const 1:[email protected]#2
+ LITERAL Integer 1 1:[email protected]#2
+ PUNCH ; [alone] 0:[email protected]#2
_;
(const {
@@ -228,13 +237,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
NoMatchingRule,
),
}
- PUNCH ; [alone] 0:[email protected]#0
+ PUNCH ; [alone] 0:[email protected]#2
;"#]],
);
@@ -252,13 +261,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
NoMatchingRule,
),
}
- PUNCH ; [alone] 0:[email protected]#0
+ PUNCH ; [alone] 0:[email protected]#2
;"#]],
);
@@ -278,26 +287,26 @@ fn expr_2021() {
break 'foo bar,
"#,
expect![[r#"
- 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
- IDENT funcall 1:[email protected]#0
- PUNCH ; [joint] 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
- 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
+ LITERAL Integer 4 1:[email protected]#2
+ PUNCH ; [joint] 0:[email protected]#2
+ LITERAL Str literal 1:[email protected]#2
+ PUNCH ; [joint] 0:[email protected]#2
+ IDENT funcall 1:[email protected]#2
+ PUNCH ; [joint] 0:[email protected]#2
+ IDENT future 1:[email protected]#2
+ PUNCH . [alone] 1:[email protected]#2
+ IDENT await 1:[email protected]#2
+ PUNCH ; [joint] 0:[email protected]#2
+ IDENT break 1:[email protected]#2
+ PUNCH ' [joint] 1:[email protected]#2
+ IDENT foo 1:[email protected]#2
+ IDENT bar 1:[email protected]#2
+ PUNCH ; [alone] 0:[email protected]#2
4;
"literal";
@@ -319,13 +328,13 @@ fn expr_2021() {
expect![[r#"
ExpandError {
inner: (
NoMatchingRule,
),
}
- PUNCH ; [alone] 0:[email protected]#0
+ PUNCH ; [alone] 0:[email protected]#2
;"#]],
);