Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/body.rs')
| -rw-r--r-- | crates/hir-def/src/body.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/hir-def/src/body.rs b/crates/hir-def/src/body.rs index c9f1add275..d2f4d7b7e5 100644 --- a/crates/hir-def/src/body.rs +++ b/crates/hir-def/src/body.rs @@ -10,9 +10,10 @@ use std::ops::Index; use base_db::CrateId; use cfg::{CfgExpr, CfgOptions}; -use hir_expand::{name::Name, HirFileId, InFile}; +use hir_expand::{name::Name, InFile}; use la_arena::{Arena, ArenaMap}; use rustc_hash::FxHashMap; +use span::MacroFileId; use syntax::{ast, AstPtr, SyntaxNodePtr}; use triomphe::Arc; @@ -98,7 +99,7 @@ pub struct BodySourceMap { format_args_template_map: FxHashMap<ExprId, Vec<(syntax::TextRange, Name)>>, - expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, + expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, MacroFileId>, /// Diagnostics accumulated during body lowering. These contain `AstPtr`s and so are stored in /// the source map (since they're just as volatile). @@ -349,11 +350,17 @@ impl BodySourceMap { self.expr_map.get(&src).cloned() } - pub fn node_macro_file(&self, node: InFile<&ast::MacroCall>) -> Option<HirFileId> { + pub fn node_macro_file(&self, node: InFile<&ast::MacroCall>) -> Option<MacroFileId> { let src = node.map(AstPtr::new); self.expansions.get(&src).cloned() } + pub fn macro_calls( + &self, + ) -> impl Iterator<Item = (InFile<AstPtr<ast::MacroCall>>, MacroFileId)> + '_ { + self.expansions.iter().map(|(&a, &b)| (a, b)) + } + pub fn pat_syntax(&self, pat: PatId) -> Result<PatSource, SyntheticSyntax> { self.pat_map_back.get(pat).cloned().ok_or(SyntheticSyntax) } |