Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/semantics.rs')
| -rw-r--r-- | crates/hir/src/semantics.rs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 68b52ddbc4..efe9fdec57 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -441,7 +441,7 @@ impl<'db> SemanticsImpl<'db> { .entry(file_id) .or_insert_with(|| file_id.expansion_info(self.db.upcast())) .as_ref()? - .map_token_down(token.as_ref())?; + .map_token_down(self.db.upcast(), None, token.as_ref())?; if let Some(parent) = token.value.parent() { self.cache(find_root(&parent), token.file_id); @@ -450,24 +450,21 @@ impl<'db> SemanticsImpl<'db> { return Some(token); }, ast::Item(item) => { - match self.with_ctx(|ctx| ctx.item_to_macro_call(token.with_value(item))) { - Some(call_id) => { - let file_id = call_id.as_file(); - let token = self - .expansion_info_cache - .borrow_mut() - .entry(file_id) - .or_insert_with(|| file_id.expansion_info(self.db.upcast())) - .as_ref()? - .map_token_down(token.as_ref())?; - - if let Some(parent) = token.value.parent() { - self.cache(find_root(&parent), token.file_id); - } - - return Some(token); + if let Some(call_id) = self.with_ctx(|ctx| ctx.item_to_macro_call(token.with_value(item.clone()))) { + let file_id = call_id.as_file(); + let token = self + .expansion_info_cache + .borrow_mut() + .entry(file_id) + .or_insert_with(|| file_id.expansion_info(self.db.upcast())) + .as_ref()? + .map_token_down(self.db.upcast(), Some(item), token.as_ref())?; + + if let Some(parent) = token.value.parent() { + self.cache(find_root(&parent), token.file_id); } - None => {} + + return Some(token); } }, _ => {} @@ -479,7 +476,6 @@ impl<'db> SemanticsImpl<'db> { }) .last() .unwrap(); - token.value } |