aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_expand/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_expand/src/db.rs')
-rw-r--r--crates/hir_expand/src/db.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs
index 5c769c1bf..e8f4af309 100644
--- a/crates/hir_expand/src/db.rs
+++ b/crates/hir_expand/src/db.rs
@@ -131,15 +131,15 @@ pub trait AstDatabase: SourceDatabase {
131/// used for completion, where we want to see what 'would happen' if we insert a 131/// used for completion, where we want to see what 'would happen' if we insert a
132/// token. The `token_to_map` mapped down into the expansion, with the mapped 132/// token. The `token_to_map` mapped down into the expansion, with the mapped
133/// token returned. 133/// token returned.
134pub fn expand_hypothetical( 134pub fn expand_speculative(
135 db: &dyn AstDatabase, 135 db: &dyn AstDatabase,
136 actual_macro_call: MacroCallId, 136 actual_macro_call: MacroCallId,
137 hypothetical_args: &ast::TokenTree, 137 speculative_args: &ast::TokenTree,
138 token_to_map: SyntaxToken, 138 token_to_map: SyntaxToken,
139) -> Option<(SyntaxNode, SyntaxToken)> { 139) -> Option<(SyntaxNode, SyntaxToken)> {
140 let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax()); 140 let (tt, tmap_1) = mbe::syntax_node_to_token_tree(speculative_args.syntax());
141 let range = 141 let range =
142 token_to_map.text_range().checked_sub(hypothetical_args.syntax().text_range().start())?; 142 token_to_map.text_range().checked_sub(speculative_args.syntax().text_range().start())?;
143 let token_id = tmap_1.token_by_range(range)?; 143 let token_id = tmap_1.token_by_range(range)?;
144 144
145 let macro_def = { 145 let macro_def = {
@@ -147,15 +147,15 @@ pub fn expand_hypothetical(
147 db.macro_def(loc.def)? 147 db.macro_def(loc.def)?
148 }; 148 };
149 149
150 let hypothetical_expansion = macro_def.expand(db, actual_macro_call, &tt); 150 let speculative_expansion = macro_def.expand(db, actual_macro_call, &tt);
151 151
152 let fragment_kind = macro_fragment_kind(db, actual_macro_call); 152 let fragment_kind = macro_fragment_kind(db, actual_macro_call);
153 153
154 let (node, tmap_2) = 154 let (node, tmap_2) =
155 mbe::token_tree_to_syntax_node(&hypothetical_expansion.value, fragment_kind).ok()?; 155 mbe::token_tree_to_syntax_node(&speculative_expansion.value, fragment_kind).ok()?;
156 156
157 let token_id = macro_def.map_id_down(token_id); 157 let token_id = macro_def.map_id_down(token_id);
158 let range = tmap_2.range_by_token(token_id)?.by_kind(token_to_map.kind())?; 158 let range = tmap_2.range_by_token(token_id, token_to_map.kind())?;
159 let token = node.syntax_node().covering_element(range).into_token()?; 159 let token = node.syntax_node().covering_element(range).into_token()?;
160 Some((node.syntax_node(), token)) 160 Some((node.syntax_node(), token))
161} 161}
@@ -186,7 +186,7 @@ fn parse_macro_expansion(
186 // The final goal we would like to make all parse_macro success, 186 // The final goal we would like to make all parse_macro success,
187 // such that the following log will not call anyway. 187 // such that the following log will not call anyway.
188 let loc: MacroCallLoc = db.lookup_intern_macro(macro_file.macro_call_id); 188 let loc: MacroCallLoc = db.lookup_intern_macro(macro_file.macro_call_id);
189 let node = loc.kind.node(db); 189 let node = loc.kind.to_node(db);
190 190
191 // collect parent information for warning log 191 // collect parent information for warning log
192 let parents = 192 let parents =
@@ -325,7 +325,7 @@ fn macro_expand_with_arg(
325 if let Some(eager) = &loc.eager { 325 if let Some(eager) = &loc.eager {
326 if arg.is_some() { 326 if arg.is_some() {
327 return ExpandResult::str_err( 327 return ExpandResult::str_err(
328 "hypothetical macro expansion not implemented for eager macro".to_owned(), 328 "speculative macro expansion not implemented for eager macro".to_owned(),
329 ); 329 );
330 } else { 330 } else {
331 return ExpandResult { 331 return ExpandResult {