@@ -139,7 +139,7 @@ impl SourceToDefCtx<'_, '_> {
139139 let _p = tracing:: span!( tracing:: Level :: INFO , "module_to_def" ) . entered ( ) ;
140140 let parent_declaration = src
141141 . syntax ( )
142- . ancestors_with_macros_skip_attr_item ( self . db . upcast ( ) )
142+ . ancestors_with_macros ( self . db . upcast ( ) )
143143 . find_map ( |it| it. map ( Either :: < ast:: Module , ast:: BlockExpr > :: cast) . transpose ( ) )
144144 . map ( |it| it. transpose ( ) ) ;
145145
@@ -366,7 +366,7 @@ impl SourceToDefCtx<'_, '_> {
366366 }
367367
368368 pub ( super ) fn find_container ( & mut self , src : InFile < & SyntaxNode > ) -> Option < ChildContainer > {
369- for container in src. ancestors_with_macros_skip_attr_item ( self . db . upcast ( ) ) {
369+ for container in src. ancestors_with_macros ( self . db . upcast ( ) ) {
370370 if let Some ( res) = self . container_to_def ( container) {
371371 return Some ( res) ;
372372 }
@@ -420,7 +420,7 @@ impl SourceToDefCtx<'_, '_> {
420420 }
421421
422422 fn find_generic_param_container ( & mut self , src : InFile < & SyntaxNode > ) -> Option < GenericDefId > {
423- let ancestors = src. ancestors_with_macros_skip_attr_item ( self . db . upcast ( ) ) ;
423+ let ancestors = src. ancestors_with_macros ( self . db . upcast ( ) ) ;
424424 for InFile { file_id, value } in ancestors {
425425 let item = match ast:: Item :: cast ( value) {
426426 Some ( it) => it,
@@ -429,6 +429,7 @@ impl SourceToDefCtx<'_, '_> {
429429 let res: GenericDefId = match item {
430430 ast:: Item :: Fn ( it) => self . fn_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
431431 ast:: Item :: Struct ( it) => self . struct_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
432+ ast:: Item :: Union ( it) => self . union_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
432433 ast:: Item :: Enum ( it) => self . enum_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
433434 ast:: Item :: Trait ( it) => self . trait_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
434435 ast:: Item :: TraitAlias ( it) => {
@@ -446,11 +447,18 @@ impl SourceToDefCtx<'_, '_> {
446447 }
447448
448449 fn find_pat_or_label_container ( & mut self , src : InFile < & SyntaxNode > ) -> Option < DefWithBodyId > {
449- let ancestors = src. ancestors_with_macros_skip_attr_item ( self . db . upcast ( ) ) ;
450+ let ancestors = src. ancestors_with_macros ( self . db . upcast ( ) ) ;
450451 for InFile { file_id, value } in ancestors {
451- let item = match ast:: Item :: cast ( value) {
452+ let item = match ast:: Item :: cast ( value. clone ( ) ) {
452453 Some ( it) => it,
453- None => continue ,
454+ None => {
455+ if let Some ( variant) = ast:: Variant :: cast ( value. clone ( ) ) {
456+ return self
457+ . enum_variant_to_def ( InFile :: new ( file_id, variant) )
458+ . map ( Into :: into) ;
459+ }
460+ continue ;
461+ }
454462 } ;
455463 let res: DefWithBodyId = match item {
456464 ast:: Item :: Const ( it) => self . const_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
0 commit comments