@@ -38,10 +38,11 @@ use crate::{
3838 db:: HirDatabase ,
3939 semantics:: source_to_def:: { ChildContainer , SourceToDefCache , SourceToDefCtx } ,
4040 source_analyzer:: { resolve_hir_path, SourceAnalyzer } ,
41- Access , Adjust , Adjustment , AutoBorrow , BindingMode , BuiltinAttr , Callable , ConstParam , Crate ,
42- DeriveHelper , Field , Function , HasSource , HirFileId , Impl , InFile , Label , LifetimeParam , Local ,
43- Macro , Module , ModuleDef , Name , OverloadedDeref , Path , ScopeDef , Struct , ToolModule , Trait ,
44- TupleField , Type , TypeAlias , TypeParam , VariantDef ,
41+ Access , Adjust , Adjustment , Adt , AutoBorrow , BindingMode , BuiltinAttr , Callable , Const ,
42+ ConstParam , Crate , DeriveHelper , Enum , Field , Function , HasSource , HirFileId , Impl , InFile ,
43+ Label , LifetimeParam , Local , Macro , Module , ModuleDef , Name , OverloadedDeref , Path , ScopeDef ,
44+ Static , Struct , ToolModule , Trait , TraitAlias , TupleField , Type , TypeAlias , TypeParam , Union ,
45+ Variant , VariantDef ,
4546} ;
4647
4748pub enum DescendPreference {
@@ -231,13 +232,61 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
231232 self . imp . file_to_module_defs ( file)
232233 }
233234
234- pub fn to_struct_def ( & self , s : & ast:: Struct ) -> Option < Struct > {
235- self . imp . to_def ( s) . map ( Struct :: from)
235+ pub fn to_adt_def ( & self , a : & ast:: Adt ) -> Option < Adt > {
236+ self . imp . to_def ( a) . map ( Adt :: from)
237+ }
238+
239+ pub fn to_const_def ( & self , c : & ast:: Const ) -> Option < Const > {
240+ self . imp . to_def ( c) . map ( Const :: from)
241+ }
242+
243+ pub fn to_enum_def ( & self , e : & ast:: Enum ) -> Option < Enum > {
244+ self . imp . to_def ( e) . map ( Enum :: from)
245+ }
246+
247+ pub fn to_enum_variant_def ( & self , v : & ast:: Variant ) -> Option < Variant > {
248+ self . imp . to_def ( v) . map ( Variant :: from)
249+ }
250+
251+ pub fn to_fn_def ( & self , f : & ast:: Fn ) -> Option < Function > {
252+ self . imp . to_def ( f) . map ( Function :: from)
236253 }
237254
238255 pub fn to_impl_def ( & self , i : & ast:: Impl ) -> Option < Impl > {
239256 self . imp . to_def ( i) . map ( Impl :: from)
240257 }
258+
259+ pub fn to_macro_def ( & self , m : & ast:: Macro ) -> Option < Macro > {
260+ self . imp . to_def ( m) . map ( Macro :: from)
261+ }
262+
263+ pub fn to_module_def ( & self , m : & ast:: Module ) -> Option < Module > {
264+ self . imp . to_def ( m) . map ( Module :: from)
265+ }
266+
267+ pub fn to_static_def ( & self , s : & ast:: Static ) -> Option < Static > {
268+ self . imp . to_def ( s) . map ( Static :: from)
269+ }
270+
271+ pub fn to_struct_def ( & self , s : & ast:: Struct ) -> Option < Struct > {
272+ self . imp . to_def ( s) . map ( Struct :: from)
273+ }
274+
275+ pub fn to_trait_alias_def ( & self , t : & ast:: TraitAlias ) -> Option < TraitAlias > {
276+ self . imp . to_def ( t) . map ( TraitAlias :: from)
277+ }
278+
279+ pub fn to_trait_def ( & self , t : & ast:: Trait ) -> Option < Trait > {
280+ self . imp . to_def ( t) . map ( Trait :: from)
281+ }
282+
283+ pub fn to_type_alias_def ( & self , t : & ast:: TypeAlias ) -> Option < TypeAlias > {
284+ self . imp . to_def ( t) . map ( TypeAlias :: from)
285+ }
286+
287+ pub fn to_union_def ( & self , u : & ast:: Union ) -> Option < Union > {
288+ self . imp . to_def ( u) . map ( Union :: from)
289+ }
241290}
242291
243292impl < ' db > SemanticsImpl < ' db > {
0 commit comments