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 | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 92fa76c96f..31c957175f 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -40,8 +40,8 @@ use crate::{ source_analyzer::{resolve_hir_path, SourceAnalyzer}, Access, Adjust, Adjustment, AutoBorrow, BindingMode, BuiltinAttr, Callable, ConstParam, Crate, DeriveHelper, Field, Function, HasSource, HirFileId, Impl, InFile, Label, LifetimeParam, Local, - Macro, Module, ModuleDef, Name, OverloadedDeref, Path, ScopeDef, ToolModule, Trait, Type, - TypeAlias, TypeParam, VariantDef, + Macro, Module, ModuleDef, Name, OverloadedDeref, Path, ScopeDef, Struct, ToolModule, Trait, + Type, TypeAlias, TypeParam, VariantDef, }; pub enum DescendPreference { @@ -229,6 +229,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { pub fn to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module> { self.imp.to_module_def(file) } + + pub fn to_struct_def(&self, s: &ast::Struct) -> Option<Struct> { + self.imp.to_def(s).map(Struct::from) + } + + pub fn to_impl_def(&self, i: &ast::Impl) -> Option<Impl> { + self.imp.to_def(i).map(Impl::from) + } } impl<'db> SemanticsImpl<'db> { |