@@ -216,30 +216,25 @@ fn true_significant_drop_ty<'tcx>(
216
216
217
217
/// Returns the list of types with a "potentially sigificant" that may be dropped
218
218
/// by dropping a value of type `ty`.
219
- #[ instrument( level = "debug" , skip( tcx, param_env ) ) ]
219
+ #[ instrument( level = "debug" , skip( tcx, typing_env ) ) ]
220
220
fn extract_component_raw < ' tcx > (
221
221
tcx : TyCtxt < ' tcx > ,
222
- param_env : ty:: ParamEnv < ' tcx > ,
222
+ typing_env : ty:: TypingEnv < ' tcx > ,
223
223
ty : Ty < ' tcx > ,
224
224
ty_seen : & mut UnordSet < Ty < ' tcx > > ,
225
225
) -> SmallVec < [ Ty < ' tcx > ; 4 ] > {
226
226
// Droppiness does not depend on regions, so let us erase them.
227
- let ty = tcx
228
- . try_normalize_erasing_regions (
229
- ty:: TypingEnv { param_env, typing_mode : ty:: TypingMode :: PostAnalysis } ,
230
- ty,
231
- )
232
- . unwrap_or ( ty) ;
233
-
234
- let tys = tcx. list_significant_drop_tys ( param_env. and ( ty) ) ;
227
+ let ty = tcx. try_normalize_erasing_regions ( typing_env, ty) . unwrap_or ( ty) ;
228
+
229
+ let tys = tcx. list_significant_drop_tys ( typing_env. as_query_input ( ty) ) ;
235
230
debug ! ( ?ty, "components" ) ;
236
231
let mut out_tys = smallvec ! [ ] ;
237
232
for ty in tys {
238
233
if let Some ( tys) = true_significant_drop_ty ( tcx, ty) {
239
234
// Some types can be further opened up because the drop is simply delegated
240
235
for ty in tys {
241
236
if ty_seen. insert ( ty) {
242
- out_tys. extend ( extract_component_raw ( tcx, param_env , ty, ty_seen) ) ;
237
+ out_tys. extend ( extract_component_raw ( tcx, typing_env , ty, ty_seen) ) ;
243
238
}
244
239
}
245
240
} else {
@@ -251,13 +246,13 @@ fn extract_component_raw<'tcx>(
251
246
out_tys
252
247
}
253
248
254
- #[ instrument( level = "debug" , skip( tcx, param_env ) ) ]
249
+ #[ instrument( level = "debug" , skip( tcx, typing_env ) ) ]
255
250
fn extract_component_with_significant_dtor < ' tcx > (
256
251
tcx : TyCtxt < ' tcx > ,
257
- param_env : ty:: ParamEnv < ' tcx > ,
252
+ typing_env : ty:: TypingEnv < ' tcx > ,
258
253
ty : Ty < ' tcx > ,
259
254
) -> SmallVec < [ Ty < ' tcx > ; 4 ] > {
260
- let mut tys = extract_component_raw ( tcx, param_env , ty, & mut Default :: default ( ) ) ;
255
+ let mut tys = extract_component_raw ( tcx, typing_env , ty, & mut Default :: default ( ) ) ;
261
256
let mut deduplicate = FxHashSet :: default ( ) ;
262
257
tys. retain ( |oty| deduplicate. insert ( * oty) ) ;
263
258
tys. into_iter ( ) . collect ( )
@@ -359,15 +354,15 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
359
354
// We group them per-block because they tend to scheduled in the same drop ladder block.
360
355
let mut bid_per_block = IndexMap :: default ( ) ;
361
356
let mut bid_places = UnordSet :: new ( ) ;
362
- let param_env = tcx . param_env ( def_id ) . with_reveal_all_normalized ( tcx) ;
357
+ let typing_env = ty :: TypingEnv :: post_analysis ( tcx, def_id ) ;
363
358
let mut ty_dropped_components = UnordMap :: default ( ) ;
364
359
for ( block, data) in body. basic_blocks . iter_enumerated ( ) {
365
360
for ( statement_index, stmt) in data. statements . iter ( ) . enumerate ( ) {
366
361
if let StatementKind :: BackwardIncompatibleDropHint { place, reason : _ } = & stmt. kind {
367
362
let ty = place. ty ( body, tcx) . ty ;
368
363
if ty_dropped_components
369
364
. entry ( ty)
370
- . or_insert_with ( || extract_component_with_significant_dtor ( tcx, param_env , ty) )
365
+ . or_insert_with ( || extract_component_with_significant_dtor ( tcx, typing_env , ty) )
371
366
. is_empty ( )
372
367
{
373
368
continue ;
@@ -479,7 +474,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
479
474
if ty_dropped_components
480
475
. entry ( observer_ty)
481
476
. or_insert_with ( || {
482
- extract_component_with_significant_dtor ( tcx, param_env , observer_ty)
477
+ extract_component_with_significant_dtor ( tcx, typing_env , observer_ty)
483
478
} )
484
479
. is_empty ( )
485
480
{
@@ -575,7 +570,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
575
570
let name = name. as_str ( ) ;
576
571
577
572
let mut seen_dyn = false ;
578
- let destructors = extract_component_with_significant_dtor ( tcx, param_env , observer_ty)
573
+ let destructors = extract_component_with_significant_dtor ( tcx, typing_env , observer_ty)
579
574
. into_iter ( )
580
575
. filter_map ( |ty| {
581
576
if let Some ( span) = ty_dtor_span ( tcx, ty) {
0 commit comments