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.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 09470bed9c..c9145f7d21 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -1998,6 +1998,7 @@ to_def_impls![
(crate::Adt, ast::Adt, adt_to_def),
(crate::ExternCrateDecl, ast::ExternCrate, extern_crate_to_def),
(crate::InlineAsmOperand, ast::AsmOperandNamed, asm_operand_to_def),
+ (crate::ExternBlock, ast::ExternBlock, extern_block_to_def),
(MacroCallId, ast::MacroCall, macro_call_to_macro_call),
];
@@ -2040,6 +2041,13 @@ impl SemanticsScope<'_> {
Crate { id: self.resolver.krate() }
}
+ pub fn containing_function(&self) -> Option<Function> {
+ self.resolver.body_owner().and_then(|owner| match owner {
+ DefWithBodyId::FunctionId(id) => Some(id.into()),
+ _ => None,
+ })
+ }
+
pub(crate) fn resolver(&self) -> &Resolver {
&self.resolver
}