@@ -216,30 +216,25 @@ fn true_significant_drop_ty<'tcx>(
216216
217217/// Returns the list of types with a "potentially sigificant" that may be dropped
218218/// by dropping a value of type `ty`.
219- #[ instrument( level = "debug" , skip( tcx, param_env ) ) ]
219+ #[ instrument( level = "debug" , skip( tcx, typing_env ) ) ]
220220fn extract_component_raw < ' tcx > (
221221 tcx : TyCtxt < ' tcx > ,
222- param_env : ty:: ParamEnv < ' tcx > ,
222+ typing_env : ty:: TypingEnv < ' tcx > ,
223223 ty : Ty < ' tcx > ,
224224 ty_seen : & mut UnordSet < Ty < ' tcx > > ,
225225) -> SmallVec < [ Ty < ' tcx > ; 4 ] > {
226226 // 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) ) ;
235230 debug ! ( ?ty, "components" ) ;
236231 let mut out_tys = smallvec ! [ ] ;
237232 for ty in tys {
238233 if let Some ( tys) = true_significant_drop_ty ( tcx, ty) {
239234 // Some types can be further opened up because the drop is simply delegated
240235 for ty in tys {
241236 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) ) ;
243238 }
244239 }
245240 } else {
@@ -251,13 +246,13 @@ fn extract_component_raw<'tcx>(
251246 out_tys
252247}
253248
254- #[ instrument( level = "debug" , skip( tcx, param_env ) ) ]
249+ #[ instrument( level = "debug" , skip( tcx, typing_env ) ) ]
255250fn extract_component_with_significant_dtor < ' tcx > (
256251 tcx : TyCtxt < ' tcx > ,
257- param_env : ty:: ParamEnv < ' tcx > ,
252+ typing_env : ty:: TypingEnv < ' tcx > ,
258253 ty : Ty < ' tcx > ,
259254) -> 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 ( ) ) ;
261256 let mut deduplicate = FxHashSet :: default ( ) ;
262257 tys. retain ( |oty| deduplicate. insert ( * oty) ) ;
263258 tys. into_iter ( ) . collect ( )
@@ -359,15 +354,15 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
359354 // We group them per-block because they tend to scheduled in the same drop ladder block.
360355 let mut bid_per_block = IndexMap :: default ( ) ;
361356 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 ) ;
363358 let mut ty_dropped_components = UnordMap :: default ( ) ;
364359 for ( block, data) in body. basic_blocks . iter_enumerated ( ) {
365360 for ( statement_index, stmt) in data. statements . iter ( ) . enumerate ( ) {
366361 if let StatementKind :: BackwardIncompatibleDropHint { place, reason : _ } = & stmt. kind {
367362 let ty = place. ty ( body, tcx) . ty ;
368363 if ty_dropped_components
369364 . 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) )
371366 . is_empty ( )
372367 {
373368 continue ;
@@ -479,7 +474,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
479474 if ty_dropped_components
480475 . entry ( observer_ty)
481476 . 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)
483478 } )
484479 . is_empty ( )
485480 {
@@ -575,7 +570,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
575570 let name = name. as_str ( ) ;
576571
577572 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)
579574 . into_iter ( )
580575 . filter_map ( |ty| {
581576 if let Some ( span) = ty_dtor_span ( tcx, ty) {
0 commit comments