@@ -139,7 +139,7 @@ impl SourceToDefCtx<'_, '_> {
139
139
let _p = tracing:: span!( tracing:: Level :: INFO , "module_to_def" ) . entered ( ) ;
140
140
let parent_declaration = src
141
141
. syntax ( )
142
- . ancestors_with_macros_skip_attr_item ( self . db . upcast ( ) )
142
+ . ancestors_with_macros ( self . db . upcast ( ) )
143
143
. find_map ( |it| it. map ( Either :: < ast:: Module , ast:: BlockExpr > :: cast) . transpose ( ) )
144
144
. map ( |it| it. transpose ( ) ) ;
145
145
@@ -366,7 +366,7 @@ impl SourceToDefCtx<'_, '_> {
366
366
}
367
367
368
368
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 ( ) ) {
370
370
if let Some ( res) = self . container_to_def ( container) {
371
371
return Some ( res) ;
372
372
}
@@ -420,7 +420,7 @@ impl SourceToDefCtx<'_, '_> {
420
420
}
421
421
422
422
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 ( ) ) ;
424
424
for InFile { file_id, value } in ancestors {
425
425
let item = match ast:: Item :: cast ( value) {
426
426
Some ( it) => it,
@@ -429,6 +429,7 @@ impl SourceToDefCtx<'_, '_> {
429
429
let res: GenericDefId = match item {
430
430
ast:: Item :: Fn ( it) => self . fn_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
431
431
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 ( ) ,
432
433
ast:: Item :: Enum ( it) => self . enum_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
433
434
ast:: Item :: Trait ( it) => self . trait_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
434
435
ast:: Item :: TraitAlias ( it) => {
@@ -446,11 +447,18 @@ impl SourceToDefCtx<'_, '_> {
446
447
}
447
448
448
449
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 ( ) ) ;
450
451
for InFile { file_id, value } in ancestors {
451
- let item = match ast:: Item :: cast ( value) {
452
+ let item = match ast:: Item :: cast ( value. clone ( ) ) {
452
453
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
+ }
454
462
} ;
455
463
let res: DefWithBodyId = match item {
456
464
ast:: Item :: Const ( it) => self . const_to_def ( InFile :: new ( file_id, it) ) ?. into ( ) ,
0 commit comments