@@ -999,20 +999,33 @@ pub fn iter_fields<'tcx>(
999
999
f ( None , field. into ( ) , ty) ;
1000
1000
}
1001
1001
}
1002
- ty:: Adt ( def, args) => {
1003
- if def. is_union ( ) {
1004
- return ;
1005
- }
1006
- for ( v_index, v_def) in def. variants ( ) . iter_enumerated ( ) {
1007
- let variant = if def. is_struct ( ) { None } else { Some ( v_index) } ;
1008
- for ( f_index, f_def) in v_def. fields . iter ( ) . enumerate ( ) {
1009
- let field_ty = f_def. ty ( tcx, args) ;
1010
- let field_ty = tcx
1011
- . try_normalize_erasing_regions ( param_env, field_ty)
1012
- . unwrap_or_else ( |_| tcx. erase_regions ( field_ty) ) ;
1013
- f ( variant, f_index. into ( ) , field_ty) ;
1002
+ & ty:: Adt ( def, args) => {
1003
+ fn iter_adt_fields < ' tcx > (
1004
+ def : ty:: AdtDef < ' tcx > ,
1005
+ args : ty:: GenericArgsRef < ' tcx > ,
1006
+ tcx : TyCtxt < ' tcx > ,
1007
+ param_env : ty:: ParamEnv < ' tcx > ,
1008
+ f : & mut impl FnMut ( Option < VariantIdx > , FieldIdx , Ty < ' tcx > ) ,
1009
+ ) {
1010
+ if def. is_union ( ) {
1011
+ return ;
1012
+ }
1013
+ for ( v_index, v_def) in def. variants ( ) . iter_enumerated ( ) {
1014
+ let variant = if def. is_struct ( ) { None } else { Some ( v_index) } ;
1015
+ for ( f_index, f_def) in v_def. fields . iter ( ) . enumerate ( ) {
1016
+ if let Some ( ( def, args) ) = f_def. inner_adt ( tcx, args) {
1017
+ iter_adt_fields ( def, args, tcx, param_env, & mut * f) ;
1018
+ } else {
1019
+ let field_ty = f_def. ty ( tcx, args) ;
1020
+ let field_ty = tcx
1021
+ . try_normalize_erasing_regions ( param_env, field_ty)
1022
+ . unwrap_or_else ( |_| tcx. erase_regions ( field_ty) ) ;
1023
+ f ( variant, f_index. into ( ) , field_ty) ;
1024
+ }
1025
+ }
1014
1026
}
1015
1027
}
1028
+ iter_adt_fields ( def, args, tcx, param_env, & mut f) ;
1016
1029
}
1017
1030
ty:: Closure ( _, args) => {
1018
1031
iter_fields ( args. as_closure ( ) . tupled_upvars_ty ( ) , tcx, param_env, f) ;
0 commit comments