aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/lib.rs
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-18 21:03:22 +0100
committerEdwin Cheng <[email protected]>2019-04-18 21:03:22 +0100
commita6d51e09610989821aaf79871bcab0661c9b0f74 (patch)
tree0647a51eb3c1cf28466c44884da21fc98bc51f19 /crates/ra_mbe/src/lib.rs
parentc0f19d70056fada5f381019694d893e0ffe8360a (diff)
Return Result for token_tree_to_xx functions
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r--crates/ra_mbe/src/lib.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index a29b07aba..3a9db7835 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -204,7 +204,7 @@ impl_froms!(TokenTree: Leaf, Subtree);
204 invocation: &str, 204 invocation: &str,
205 ) -> ra_syntax::TreeArc<ast::MacroItems> { 205 ) -> ra_syntax::TreeArc<ast::MacroItems> {
206 let expanded = expand(rules, invocation); 206 let expanded = expand(rules, invocation);
207 token_tree_to_macro_items(&expanded) 207 token_tree_to_macro_items(&expanded).unwrap()
208 } 208 }
209 209
210 pub(crate) fn assert_expansion(rules: &MacroRules, invocation: &str, expansion: &str) { 210 pub(crate) fn assert_expansion(rules: &MacroRules, invocation: &str, expansion: &str) {
@@ -218,7 +218,10 @@ impl_froms!(TokenTree: Leaf, Subtree);
218 let expansion = syntax_node_to_token_tree(expansion.syntax()).unwrap().0; 218 let expansion = syntax_node_to_token_tree(expansion.syntax()).unwrap().0;
219 let file = token_tree_to_macro_items(&expansion); 219 let file = token_tree_to_macro_items(&expansion);
220 220
221 assert_eq!(tree.syntax().debug_dump().trim(), file.syntax().debug_dump().trim()); 221 assert_eq!(
222 tree.unwrap().syntax().debug_dump().trim(),
223 file.unwrap().syntax().debug_dump().trim()
224 );
222 } 225 }
223 226
224 #[test] 227 #[test]
@@ -358,7 +361,7 @@ impl_froms!(TokenTree: Leaf, Subtree);
358 let expansion = expand(&rules, "structs!(Foo, Bar)"); 361 let expansion = expand(&rules, "structs!(Foo, Bar)");
359 let tree = token_tree_to_macro_items(&expansion); 362 let tree = token_tree_to_macro_items(&expansion);
360 assert_eq!( 363 assert_eq!(
361 tree.syntax().debug_dump().trim(), 364 tree.unwrap().syntax().debug_dump().trim(),
362 r#" 365 r#"
363MACRO_ITEMS@[0; 40) 366MACRO_ITEMS@[0; 40)
364 STRUCT_DEF@[0; 20) 367 STRUCT_DEF@[0; 20)
@@ -472,7 +475,7 @@ MACRO_ITEMS@[0; 40)
472 let stmts = token_tree_to_macro_stmts(&expanded); 475 let stmts = token_tree_to_macro_stmts(&expanded);
473 476
474 assert_eq!( 477 assert_eq!(
475 stmts.syntax().debug_dump().trim(), 478 stmts.unwrap().syntax().debug_dump().trim(),
476 r#"MACRO_STMTS@[0; 15) 479 r#"MACRO_STMTS@[0; 15)
477 LET_STMT@[0; 7) 480 LET_STMT@[0; 7)
478 LET_KW@[0; 3) "let" 481 LET_KW@[0; 3) "let"