@@ -1992,6 +1992,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
1992
1992
if ( from..to) . contains ( offset) {
1993
1993
let uninit_child =
1994
1994
self . move_data . find_in_move_path_or_its_descendants ( child_mpi, |mpi| {
1995
+ // FIXME(structural_init) you can't partially init an array element, right?
1995
1996
maybe_uninits. contains ( mpi)
1996
1997
} ) ;
1997
1998
@@ -2091,37 +2092,34 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
2091
2092
2092
2093
let path = & self . move_data . move_paths [ mpi] ;
2093
2094
2094
- let ty = path. place . ty ( self . body ( ) , tcx) . ty ;
2095
+ let field_count = match path. place . ty ( self . body ( ) , tcx) . ty . kind ( ) {
2096
+ ty:: Adt ( adt, _) if adt. is_struct ( ) => {
2097
+ let variant = adt. non_enum_variant ( ) ;
2095
2098
2096
- let ty:: Adt ( adt, _) = ty. kind ( ) else {
2097
- return true ;
2098
- } ;
2099
-
2100
- if !adt. is_struct ( ) {
2101
- return true ;
2102
- }
2099
+ if variant. field_list_has_applicable_non_exhaustive ( ) {
2100
+ return true ;
2101
+ }
2103
2102
2104
- let variant = adt. non_enum_variant ( ) ;
2103
+ variant. fields . len ( )
2104
+ }
2105
+ ty:: Tuple ( tys) => tys. len ( ) ,
2105
2106
2106
- if variant. field_list_has_applicable_non_exhaustive ( ) {
2107
- return true ;
2108
- }
2107
+ _ => return true ,
2108
+ } ;
2109
2109
2110
2110
// FIXME: destructors?
2111
2111
2112
- // A structurally initialized ADT is "uninit" but all of it's fields are init.
2112
+ // A structurally initialized type is "uninit" but all of it's fields are init.
2113
2113
// This means all of it's fields must have MovePaths
2114
2114
// because fields that are never written to will not have MovePaths.
2115
2115
// Without this check, we may not detect that unwritten fields are uninit.
2116
- for field in variant . fields . indices ( ) {
2116
+ for field in ( 0 ..field_count ) . map ( FieldIdx :: from_usize ) {
2117
2117
// FIXME WrapUnsafeBinder?
2118
2118
if self . move_data . rev_lookup . project ( mpi, ProjectionElem :: Field ( field, ( ) ) ) . is_none ( ) {
2119
2119
return true ;
2120
2120
}
2121
2121
}
2122
2122
2123
- debug ! ( "sucess!!" ) ;
2124
-
2125
2123
false
2126
2124
}
2127
2125
0 commit comments