aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mbe/src/tests.rs')
-rw-r--r--crates/mbe/src/tests.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index 6da18ecf4..3698ff3f0 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -29,8 +29,7 @@ macro_rules! impl_fixture {
29 let macro_invocation = 29 let macro_invocation =
30 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 30 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
31 31
32 let (invocation_tt, _) = ast_to_token_tree(&macro_invocation.token_tree().unwrap()) 32 let (invocation_tt, _) = ast_to_token_tree(&macro_invocation.token_tree().unwrap());
33 .ok_or_else(|| ExpandError::ConversionError)?;
34 33
35 self.rules.expand(&invocation_tt).result() 34 self.rules.expand(&invocation_tt).result()
36 } 35 }
@@ -101,7 +100,7 @@ macro_rules! impl_fixture {
101 .descendants() 100 .descendants()
102 .find_map(ast::TokenTree::cast) 101 .find_map(ast::TokenTree::cast)
103 .unwrap(); 102 .unwrap();
104 let mut wrapped = ast_to_token_tree(&wrapped).unwrap().0; 103 let mut wrapped = ast_to_token_tree(&wrapped).0;
105 wrapped.delimiter = None; 104 wrapped.delimiter = None;
106 wrapped 105 wrapped
107 }; 106 };
@@ -151,7 +150,7 @@ pub(crate) fn parse_macro_error(ra_fixture: &str) -> ParseError {
151 150
152pub(crate) fn parse_to_token_tree_by_syntax(ra_fixture: &str) -> tt::Subtree { 151pub(crate) fn parse_to_token_tree_by_syntax(ra_fixture: &str) -> tt::Subtree {
153 let source_file = ast::SourceFile::parse(ra_fixture).ok().unwrap(); 152 let source_file = ast::SourceFile::parse(ra_fixture).ok().unwrap();
154 let tt = syntax_node_to_token_tree(source_file.syntax()).unwrap().0; 153 let tt = syntax_node_to_token_tree(source_file.syntax()).0;
155 154
156 let parsed = parse_to_token_tree(ra_fixture).unwrap().0; 155 let parsed = parse_to_token_tree(ra_fixture).unwrap().0;
157 assert_eq!(tt, parsed); 156 assert_eq!(tt, parsed);
@@ -164,7 +163,7 @@ fn parse_macro_rules_to_tt(ra_fixture: &str) -> tt::Subtree {
164 let macro_definition = 163 let macro_definition =
165 source_file.syntax().descendants().find_map(ast::MacroRules::cast).unwrap(); 164 source_file.syntax().descendants().find_map(ast::MacroRules::cast).unwrap();
166 165
167 let (definition_tt, _) = ast_to_token_tree(&macro_definition.token_tree().unwrap()).unwrap(); 166 let (definition_tt, _) = ast_to_token_tree(&macro_definition.token_tree().unwrap());
168 167
169 let parsed = parse_to_token_tree( 168 let parsed = parse_to_token_tree(
170 &ra_fixture[macro_definition.token_tree().unwrap().syntax().text_range()], 169 &ra_fixture[macro_definition.token_tree().unwrap().syntax().text_range()],
@@ -181,7 +180,7 @@ fn parse_macro_def_to_tt(ra_fixture: &str) -> tt::Subtree {
181 let macro_definition = 180 let macro_definition =
182 source_file.syntax().descendants().find_map(ast::MacroDef::cast).unwrap(); 181 source_file.syntax().descendants().find_map(ast::MacroDef::cast).unwrap();
183 182
184 let (definition_tt, _) = ast_to_token_tree(&macro_definition.body().unwrap()).unwrap(); 183 let (definition_tt, _) = ast_to_token_tree(&macro_definition.body().unwrap());
185 184
186 let parsed = 185 let parsed =
187 parse_to_token_tree(&ra_fixture[macro_definition.body().unwrap().syntax().text_range()]) 186 parse_to_token_tree(&ra_fixture[macro_definition.body().unwrap().syntax().text_range()])