@@ -415,18 +415,24 @@ impl ModuleDef {
415415 def. diagnostics ( db, & mut acc) ;
416416 }
417417
418- let fields = match self {
419- ModuleDef :: Adt ( Adt :: Struct ( it) ) => Some ( it. fields ( db) ) ,
420- ModuleDef :: Adt ( Adt :: Union ( it) ) => Some ( it. fields ( db) ) ,
421- ModuleDef :: Variant ( it) => Some ( it. fields ( db) ) ,
418+ let vd: Option < ( VariantDef , Arc < VariantData > ) > = match self {
419+ ModuleDef :: Adt ( Adt :: Struct ( it) ) => {
420+ Some ( ( it. into ( ) , db. struct_data ( it. id ) . variant_data . clone ( ) ) )
421+ }
422+ ModuleDef :: Adt ( Adt :: Union ( it) ) => {
423+ Some ( ( it. into ( ) , db. union_data ( it. id ) . variant_data . clone ( ) ) )
424+ }
425+ ModuleDef :: Variant ( it) => {
426+ Some ( ( it. into ( ) , db. enum_variant_data ( it. id ) . variant_data . clone ( ) ) )
427+ }
422428 _ => None ,
423429 } ;
424- if let Some ( fields ) = fields {
425- for field in fields {
426- if !field . has_default {
430+ if let Some ( ( parent , vd ) ) = vd {
431+ for ( id , fd ) in vd . fields ( ) . iter ( ) {
432+ if !fd . has_default {
427433 continue ;
428434 }
429- let def: DefWithBody = field . into ( ) ;
435+ let def: DefWithBody = DefWithBody :: Field ( Field { parent , id } ) ;
430436 def. diagnostics ( db, & mut acc, style_lints) ;
431437 }
432438 }
@@ -1252,7 +1258,6 @@ impl From<&Field> for DefWithBodyId {
12521258pub struct Field {
12531259 pub ( crate ) parent : VariantDef ,
12541260 pub ( crate ) id : LocalFieldId ,
1255- pub ( crate ) has_default : bool ,
12561261}
12571262
12581263#[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash ) ]
@@ -1418,7 +1423,7 @@ impl Struct {
14181423 . variant_data
14191424 . fields ( )
14201425 . iter ( )
1421- . map ( |( id, d ) | Field { parent : self . into ( ) , id, has_default : d . has_default } )
1426+ . map ( |( id, _ ) | Field { parent : self . into ( ) , id } )
14221427 . collect ( )
14231428 }
14241429
@@ -1480,7 +1485,7 @@ impl Union {
14801485 . variant_data
14811486 . fields ( )
14821487 . iter ( )
1483- . map ( |( id, d ) | Field { parent : self . into ( ) , id, has_default : d . has_default } )
1488+ . map ( |( id, _ ) | Field { parent : self . into ( ) , id } )
14841489 . collect ( )
14851490 }
14861491
@@ -1610,7 +1615,7 @@ impl Variant {
16101615 self . variant_data ( db)
16111616 . fields ( )
16121617 . iter ( )
1613- . map ( |( id, d ) | Field { parent : self . into ( ) , id, has_default : d . has_default } )
1618+ . map ( |( id, _ ) | Field { parent : self . into ( ) , id } )
16141619 . collect ( )
16151620 }
16161621
@@ -5166,13 +5171,10 @@ impl Type {
51665171 _ => return Vec :: new ( ) ,
51675172 } ;
51685173
5169- let var_data = db. variant_data ( variant_id) ;
5170- let fields = var_data. fields ( ) ;
51715174 db. field_types ( variant_id)
51725175 . iter ( )
51735176 . map ( |( local_id, ty) | {
5174- let has_default = fields[ local_id] . has_default ;
5175- let def = Field { parent : variant_id. into ( ) , id : local_id, has_default } ;
5177+ let def = Field { parent : variant_id. into ( ) , id : local_id } ;
51765178 let ty = ty. clone ( ) . substitute ( Interner , substs) ;
51775179 ( def, self . derived ( ty) )
51785180 } )
0 commit comments