Skip to content

Commit 776731d

Browse files
committed
rebase
1 parent 8c7c83d commit 776731d

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ rustc_queries! {
14671467
/// *IMPORTANT*: *DO NOT* run this query before promoted MIR body is constructed,
14681468
/// because this query partially depends on that query.
14691469
/// Otherwise, there is a risk of query cycles.
1470-
query list_significant_drop_tys(ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> &'tcx ty::List<Ty<'tcx>> {
1470+
query list_significant_drop_tys(ty: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> &'tcx ty::List<Ty<'tcx>> {
14711471
desc { |tcx| "computing when `{}` has a significant destructor", ty.value }
14721472
cache_on_disk_if { false }
14731473
}

compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs

+13-18
Original file line numberDiff line numberDiff line change
@@ -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))]
220220
fn 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))]
255250
fn 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) {

compiler/rustc_mir_transform/src/post_analysis_normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Normalizes MIR in `TypingMode::PostAnalysis`` mode, most notably revealing
1+
//! Normalizes MIR in `TypingMode::PostAnalysis` mode, most notably revealing
22
//! its opaques. We also only normalize specializable associated items once in
33
//! `PostAnalysis` mode.
44

compiler/rustc_ty_utils/src/needs_drop.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,13 @@ fn adt_significant_drop_tys(
431431
#[instrument(level = "debug", skip(tcx), ret)]
432432
fn list_significant_drop_tys<'tcx>(
433433
tcx: TyCtxt<'tcx>,
434-
ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
434+
key: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
435435
) -> &'tcx ty::List<Ty<'tcx>> {
436436
tcx.mk_type_list(
437437
&drop_tys_helper(
438438
tcx,
439-
ty.value,
440-
ty::TypingEnv { typing_mode: ty::TypingMode::PostAnalysis, param_env: ty.param_env },
439+
key.value,
440+
key.typing_env,
441441
adt_consider_insignificant_dtor(tcx),
442442
true,
443443
true,

0 commit comments

Comments
 (0)