@@ -70,7 +70,6 @@ fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId) {
7070
7171 check_transparent ( tcx, def) ;
7272 check_packed ( tcx, span, def) ;
73- check_unsafe_fields ( tcx, def_id) ;
7473}
7574
7675fn check_union ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
@@ -144,36 +143,6 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
144143 true
145144}
146145
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-
177146/// Check that a `static` is inhabited.
178147fn check_static_inhabited ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
179148 // Make sure statics are inhabited.
@@ -1512,7 +1481,6 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
15121481
15131482 detect_discriminant_duplicate ( tcx, def) ;
15141483 check_transparent ( tcx, def) ;
1515- check_unsafe_fields ( tcx, def_id) ;
15161484}
15171485
15181486/// Part of enum check. Given the discriminants of an enum, errors if two or more discriminants are equal
0 commit comments