diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-20 10:59:10 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-20 10:59:10 +0100 |
commit | 6b352ffeb346eb7c7e46e00e790c2f395907eaa6 (patch) | |
tree | f19271365126259a7975dda9ee3e1e1496a299dd /crates/ra_mbe | |
parent | 2830d1376b05794c7bf1467fe52ad3bc0eb4ca41 (diff) | |
parent | f3bdbec1b68fa0e20f0b7b6c6ef64e1507970b0d (diff) |
Merge #1560
1560: move debug_dump to fmt::Debug r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 6 | ||||
-rw-r--r-- | crates/ra_mbe/src/tests.rs | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 64ed6a517..7ff0fc472 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -19,7 +19,7 @@ pub struct TokenMap { | |||
19 | pub fn ast_to_token_tree(ast: &ast::TokenTree) -> Option<(tt::Subtree, TokenMap)> { | 19 | pub fn ast_to_token_tree(ast: &ast::TokenTree) -> Option<(tt::Subtree, TokenMap)> { |
20 | let mut token_map = TokenMap::default(); | 20 | let mut token_map = TokenMap::default(); |
21 | let node = ast.syntax(); | 21 | let node = ast.syntax(); |
22 | let tt = convert_tt(&mut token_map, node.range().start(), node)?; | 22 | let tt = convert_tt(&mut token_map, node.text_range().start(), node)?; |
23 | Some((tt, token_map)) | 23 | Some((tt, token_map)) |
24 | } | 24 | } |
25 | 25 | ||
@@ -27,7 +27,7 @@ pub fn ast_to_token_tree(ast: &ast::TokenTree) -> Option<(tt::Subtree, TokenMap) | |||
27 | /// will consume). | 27 | /// will consume). |
28 | pub fn syntax_node_to_token_tree(node: &SyntaxNode) -> Option<(tt::Subtree, TokenMap)> { | 28 | pub fn syntax_node_to_token_tree(node: &SyntaxNode) -> Option<(tt::Subtree, TokenMap)> { |
29 | let mut token_map = TokenMap::default(); | 29 | let mut token_map = TokenMap::default(); |
30 | let tt = convert_tt(&mut token_map, node.range().start(), node)?; | 30 | let tt = convert_tt(&mut token_map, node.text_range().start(), node)?; |
31 | Some((tt, token_map)) | 31 | Some((tt, token_map)) |
32 | } | 32 | } |
33 | 33 | ||
@@ -229,7 +229,7 @@ fn convert_tt( | |||
229 | || token.kind() == IDENT | 229 | || token.kind() == IDENT |
230 | || token.kind() == LIFETIME | 230 | || token.kind() == LIFETIME |
231 | { | 231 | { |
232 | let relative_range = token.range() - global_offset; | 232 | let relative_range = token.text_range() - global_offset; |
233 | let id = token_map.alloc(relative_range); | 233 | let id = token_map.alloc(relative_range); |
234 | let text = token.text().clone(); | 234 | let text = token.text().clone(); |
235 | tt::Leaf::from(tt::Ident { text, id }).into() | 235 | tt::Leaf::from(tt::Ident { text, id }).into() |
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 38a31109d..9151b6ecd 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs | |||
@@ -412,7 +412,7 @@ fn test_expand_to_item_list() { | |||
412 | let expansion = expand(&rules, "structs!(Foo, Bar);"); | 412 | let expansion = expand(&rules, "structs!(Foo, Bar);"); |
413 | let tree = token_tree_to_macro_items(&expansion).unwrap().tree(); | 413 | let tree = token_tree_to_macro_items(&expansion).unwrap().tree(); |
414 | assert_eq!( | 414 | assert_eq!( |
415 | tree.syntax().debug_dump().trim(), | 415 | format!("{:#?}", tree.syntax()).trim(), |
416 | r#" | 416 | r#" |
417 | MACRO_ITEMS@[0; 40) | 417 | MACRO_ITEMS@[0; 40) |
418 | STRUCT_DEF@[0; 20) | 418 | STRUCT_DEF@[0; 20) |
@@ -531,7 +531,7 @@ fn test_tt_to_stmts() { | |||
531 | let stmts = token_tree_to_macro_stmts(&expanded).unwrap().tree(); | 531 | let stmts = token_tree_to_macro_stmts(&expanded).unwrap().tree(); |
532 | 532 | ||
533 | assert_eq!( | 533 | assert_eq!( |
534 | stmts.syntax().debug_dump().trim(), | 534 | format!("{:#?}", stmts.syntax()).trim(), |
535 | r#"MACRO_STMTS@[0; 15) | 535 | r#"MACRO_STMTS@[0; 15) |
536 | LET_STMT@[0; 7) | 536 | LET_STMT@[0; 7) |
537 | LET_KW@[0; 3) "let" | 537 | LET_KW@[0; 3) "let" |
@@ -669,7 +669,7 @@ fn test_expr_order() { | |||
669 | ); | 669 | ); |
670 | 670 | ||
671 | assert_eq!( | 671 | assert_eq!( |
672 | expand_to_items(&rules, "foo! { 1 + 1 }").syntax().debug_dump().trim(), | 672 | format!("{:#?}", expand_to_items(&rules, "foo! { 1 + 1 }").syntax()).trim(), |
673 | r#"MACRO_ITEMS@[0; 15) | 673 | r#"MACRO_ITEMS@[0; 15) |
674 | FN_DEF@[0; 15) | 674 | FN_DEF@[0; 15) |
675 | FN_KW@[0; 2) "fn" | 675 | FN_KW@[0; 2) "fn" |
@@ -1013,7 +1013,7 @@ fn test_vec() { | |||
1013 | ); | 1013 | ); |
1014 | 1014 | ||
1015 | assert_eq!( | 1015 | assert_eq!( |
1016 | expand_to_expr(&rules, r#"vec![1u32,2];"#).syntax().debug_dump().trim(), | 1016 | format!("{:#?}", expand_to_expr(&rules, r#"vec![1u32,2];"#).syntax()).trim(), |
1017 | r#"BLOCK_EXPR@[0; 45) | 1017 | r#"BLOCK_EXPR@[0; 45) |
1018 | BLOCK@[0; 45) | 1018 | BLOCK@[0; 45) |
1019 | L_CURLY@[0; 1) "{" | 1019 | L_CURLY@[0; 1) "{" |