aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-08 11:49:43 +0000
committerAleksey Kladov <[email protected]>2019-02-08 11:49:43 +0000
commit12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch)
tree71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_mbe/src/lib.rs
parent5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff)
reformat the world
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r--crates/ra_mbe/src/lib.rs28
1 files changed, 8 insertions, 20 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index 2c8ad4429..b09837831 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -137,18 +137,12 @@ impl_froms!(TokenTree: Leaf, Subtree);
137"#; 137"#;
138 138
139 let source_file = ast::SourceFile::parse(macro_definition); 139 let source_file = ast::SourceFile::parse(macro_definition);
140 let macro_definition = source_file 140 let macro_definition =
141 .syntax() 141 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
142 .descendants()
143 .find_map(ast::MacroCall::cast)
144 .unwrap();
145 142
146 let source_file = ast::SourceFile::parse(macro_invocation); 143 let source_file = ast::SourceFile::parse(macro_invocation);
147 let macro_invocation = source_file 144 let macro_invocation =
148 .syntax() 145 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
149 .descendants()
150 .find_map(ast::MacroCall::cast)
151 .unwrap();
152 146
153 let definition_tt = ast_to_token_tree(macro_definition.token_tree().unwrap()).unwrap(); 147 let definition_tt = ast_to_token_tree(macro_definition.token_tree().unwrap()).unwrap();
154 let invocation_tt = ast_to_token_tree(macro_invocation.token_tree().unwrap()).unwrap(); 148 let invocation_tt = ast_to_token_tree(macro_invocation.token_tree().unwrap()).unwrap();
@@ -163,11 +157,8 @@ impl_froms!(TokenTree: Leaf, Subtree);
163 157
164 fn create_rules(macro_definition: &str) -> MacroRules { 158 fn create_rules(macro_definition: &str) -> MacroRules {
165 let source_file = ast::SourceFile::parse(macro_definition); 159 let source_file = ast::SourceFile::parse(macro_definition);
166 let macro_definition = source_file 160 let macro_definition =
167 .syntax() 161 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
168 .descendants()
169 .find_map(ast::MacroCall::cast)
170 .unwrap();
171 162
172 let definition_tt = ast_to_token_tree(macro_definition.token_tree().unwrap()).unwrap(); 163 let definition_tt = ast_to_token_tree(macro_definition.token_tree().unwrap()).unwrap();
173 crate::MacroRules::parse(&definition_tt).unwrap() 164 crate::MacroRules::parse(&definition_tt).unwrap()
@@ -175,11 +166,8 @@ impl_froms!(TokenTree: Leaf, Subtree);
175 166
176 fn assert_expansion(rules: &MacroRules, invocation: &str, expansion: &str) { 167 fn assert_expansion(rules: &MacroRules, invocation: &str, expansion: &str) {
177 let source_file = ast::SourceFile::parse(invocation); 168 let source_file = ast::SourceFile::parse(invocation);
178 let macro_invocation = source_file 169 let macro_invocation =
179 .syntax() 170 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
180 .descendants()
181 .find_map(ast::MacroCall::cast)
182 .unwrap();
183 171
184 let invocation_tt = ast_to_token_tree(macro_invocation.token_tree().unwrap()).unwrap(); 172 let invocation_tt = ast_to_token_tree(macro_invocation.token_tree().unwrap()).unwrap();
185 173