diff options
Diffstat (limited to 'crates/ra_mbe/src/tests.rs')
-rw-r--r-- | crates/ra_mbe/src/tests.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 5a1494fee..419b2c099 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs | |||
@@ -72,7 +72,7 @@ pub(crate) fn expand_to_items( | |||
72 | invocation: &str, | 72 | invocation: &str, |
73 | ) -> ra_syntax::TreeArc<ast::MacroItems> { | 73 | ) -> ra_syntax::TreeArc<ast::MacroItems> { |
74 | let expanded = expand(rules, invocation); | 74 | let expanded = expand(rules, invocation); |
75 | token_tree_to_macro_items(&expanded).unwrap() | 75 | token_tree_to_macro_items(&expanded).unwrap().tree().to_owned() |
76 | } | 76 | } |
77 | 77 | ||
78 | #[allow(unused)] | 78 | #[allow(unused)] |
@@ -81,7 +81,7 @@ pub(crate) fn expand_to_stmts( | |||
81 | invocation: &str, | 81 | invocation: &str, |
82 | ) -> ra_syntax::TreeArc<ast::MacroStmts> { | 82 | ) -> ra_syntax::TreeArc<ast::MacroStmts> { |
83 | let expanded = expand(rules, invocation); | 83 | let expanded = expand(rules, invocation); |
84 | token_tree_to_macro_stmts(&expanded).unwrap() | 84 | token_tree_to_macro_stmts(&expanded).unwrap().tree().to_owned() |
85 | } | 85 | } |
86 | 86 | ||
87 | pub(crate) fn expand_to_expr( | 87 | pub(crate) fn expand_to_expr( |
@@ -89,7 +89,7 @@ pub(crate) fn expand_to_expr( | |||
89 | invocation: &str, | 89 | invocation: &str, |
90 | ) -> ra_syntax::TreeArc<ast::Expr> { | 90 | ) -> ra_syntax::TreeArc<ast::Expr> { |
91 | let expanded = expand(rules, invocation); | 91 | let expanded = expand(rules, invocation); |
92 | token_tree_to_expr(&expanded).unwrap() | 92 | token_tree_to_expr(&expanded).unwrap().tree().to_owned() |
93 | } | 93 | } |
94 | 94 | ||
95 | pub(crate) fn text_to_tokentree(text: &str) -> tt::Subtree { | 95 | pub(crate) fn text_to_tokentree(text: &str) -> tt::Subtree { |
@@ -164,22 +164,22 @@ pub(crate) fn assert_expansion( | |||
164 | 164 | ||
165 | let (expanded_tree, expected_tree) = match kind { | 165 | let (expanded_tree, expected_tree) = match kind { |
166 | MacroKind::Items => { | 166 | MacroKind::Items => { |
167 | let expanded_tree = token_tree_to_macro_items(&expanded); | 167 | let expanded_tree = token_tree_to_macro_items(&expanded).unwrap().tree().to_owned(); |
168 | let expected_tree = token_tree_to_macro_items(&expected); | 168 | let expected_tree = token_tree_to_macro_items(&expected).unwrap().tree().to_owned(); |
169 | 169 | ||
170 | ( | 170 | ( |
171 | debug_dump_ignore_spaces(expanded_tree.unwrap().syntax()).trim().to_string(), | 171 | debug_dump_ignore_spaces(expanded_tree.syntax()).trim().to_string(), |
172 | debug_dump_ignore_spaces(expected_tree.unwrap().syntax()).trim().to_string(), | 172 | debug_dump_ignore_spaces(expected_tree.syntax()).trim().to_string(), |
173 | ) | 173 | ) |
174 | } | 174 | } |
175 | 175 | ||
176 | MacroKind::Stmts => { | 176 | MacroKind::Stmts => { |
177 | let expanded_tree = token_tree_to_macro_stmts(&expanded); | 177 | let expanded_tree = token_tree_to_macro_stmts(&expanded).unwrap().tree().to_owned(); |
178 | let expected_tree = token_tree_to_macro_stmts(&expected); | 178 | let expected_tree = token_tree_to_macro_stmts(&expected).unwrap().tree().to_owned(); |
179 | 179 | ||
180 | ( | 180 | ( |
181 | debug_dump_ignore_spaces(expanded_tree.unwrap().syntax()).trim().to_string(), | 181 | debug_dump_ignore_spaces(expanded_tree.syntax()).trim().to_string(), |
182 | debug_dump_ignore_spaces(expected_tree.unwrap().syntax()).trim().to_string(), | 182 | debug_dump_ignore_spaces(expected_tree.syntax()).trim().to_string(), |
183 | ) | 183 | ) |
184 | } | 184 | } |
185 | }; | 185 | }; |
@@ -419,9 +419,9 @@ fn test_expand_to_item_list() { | |||
419 | ", | 419 | ", |
420 | ); | 420 | ); |
421 | let expansion = expand(&rules, "structs!(Foo, Bar);"); | 421 | let expansion = expand(&rules, "structs!(Foo, Bar);"); |
422 | let tree = token_tree_to_macro_items(&expansion); | 422 | let tree = token_tree_to_macro_items(&expansion).unwrap().tree().to_owned(); |
423 | assert_eq!( | 423 | assert_eq!( |
424 | tree.unwrap().syntax().debug_dump().trim(), | 424 | tree.syntax().debug_dump().trim(), |
425 | r#" | 425 | r#" |
426 | MACRO_ITEMS@[0; 40) | 426 | MACRO_ITEMS@[0; 40) |
427 | STRUCT_DEF@[0; 20) | 427 | STRUCT_DEF@[0; 20) |
@@ -537,10 +537,10 @@ fn test_tt_to_stmts() { | |||
537 | ); | 537 | ); |
538 | 538 | ||
539 | let expanded = expand(&rules, "foo!{}"); | 539 | let expanded = expand(&rules, "foo!{}"); |
540 | let stmts = token_tree_to_macro_stmts(&expanded); | 540 | let stmts = token_tree_to_macro_stmts(&expanded).unwrap().tree().to_owned(); |
541 | 541 | ||
542 | assert_eq!( | 542 | assert_eq!( |
543 | stmts.unwrap().syntax().debug_dump().trim(), | 543 | stmts.syntax().debug_dump().trim(), |
544 | r#"MACRO_STMTS@[0; 15) | 544 | r#"MACRO_STMTS@[0; 15) |
545 | LET_STMT@[0; 7) | 545 | LET_STMT@[0; 7) |
546 | LET_KW@[0; 3) "let" | 546 | LET_KW@[0; 3) "let" |