@@ -70,7 +70,6 @@ fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId) {
70
70
71
71
check_transparent ( tcx, def) ;
72
72
check_packed ( tcx, span, def) ;
73
- check_unsafe_fields ( tcx, def_id) ;
74
73
}
75
74
76
75
fn check_union ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
@@ -144,36 +143,6 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
144
143
true
145
144
}
146
145
147
- /// Check that the unsafe fields do not need dropping.
148
- fn check_unsafe_fields ( tcx : TyCtxt < ' _ > , item_def_id : LocalDefId ) {
149
- let span = tcx. def_span ( item_def_id) ;
150
- let def = tcx. adt_def ( item_def_id) ;
151
-
152
- let typing_env = ty:: TypingEnv :: non_body_analysis ( tcx, item_def_id) ;
153
- let args = ty:: GenericArgs :: identity_for_item ( tcx, item_def_id) ;
154
-
155
- for field in def. all_fields ( ) {
156
- if !field. safety . is_unsafe ( ) {
157
- continue ;
158
- }
159
-
160
- if !allowed_union_or_unsafe_field ( tcx, field. ty ( tcx, args) , typing_env, span) {
161
- let hir:: Node :: Field ( field) = tcx. hir_node_by_def_id ( field. did . expect_local ( ) ) else {
162
- unreachable ! ( "field has to correspond to hir field" )
163
- } ;
164
- let ty_span = field. ty . span ;
165
- tcx. dcx ( ) . emit_err ( errors:: InvalidUnsafeField {
166
- field_span : field. span ,
167
- sugg : errors:: InvalidUnsafeFieldSuggestion {
168
- lo : ty_span. shrink_to_lo ( ) ,
169
- hi : ty_span. shrink_to_hi ( ) ,
170
- } ,
171
- note : ( ) ,
172
- } ) ;
173
- }
174
- }
175
- }
176
-
177
146
/// Check that a `static` is inhabited.
178
147
fn check_static_inhabited ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
179
148
// Make sure statics are inhabited.
@@ -1512,7 +1481,6 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
1512
1481
1513
1482
detect_discriminant_duplicate ( tcx, def) ;
1514
1483
check_transparent ( tcx, def) ;
1515
- check_unsafe_fields ( tcx, def_id) ;
1516
1484
}
1517
1485
1518
1486
/// Part of enum check. Given the discriminants of an enum, errors if two or more discriminants are equal
0 commit comments