rebase
This commit is contained in:
parent
8c7c83d6ef
commit
776731dc3f
4 changed files with 17 additions and 22 deletions
|
@ -1467,7 +1467,7 @@ rustc_queries! {
|
||||||
/// *IMPORTANT*: *DO NOT* run this query before promoted MIR body is constructed,
|
/// *IMPORTANT*: *DO NOT* run this query before promoted MIR body is constructed,
|
||||||
/// because this query partially depends on that query.
|
/// because this query partially depends on that query.
|
||||||
/// Otherwise, there is a risk of query cycles.
|
/// Otherwise, there is a risk of query cycles.
|
||||||
query list_significant_drop_tys(ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> &'tcx ty::List<Ty<'tcx>> {
|
query list_significant_drop_tys(ty: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> &'tcx ty::List<Ty<'tcx>> {
|
||||||
desc { |tcx| "computing when `{}` has a significant destructor", ty.value }
|
desc { |tcx| "computing when `{}` has a significant destructor", ty.value }
|
||||||
cache_on_disk_if { false }
|
cache_on_disk_if { false }
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,22 +216,17 @@ fn true_significant_drop_ty<'tcx>(
|
||||||
|
|
||||||
/// Returns the list of types with a "potentially sigificant" that may be dropped
|
/// Returns the list of types with a "potentially sigificant" that may be dropped
|
||||||
/// by dropping a value of type `ty`.
|
/// by dropping a value of type `ty`.
|
||||||
#[instrument(level = "debug", skip(tcx, param_env))]
|
#[instrument(level = "debug", skip(tcx, typing_env))]
|
||||||
fn extract_component_raw<'tcx>(
|
fn extract_component_raw<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
typing_env: ty::TypingEnv<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
ty_seen: &mut UnordSet<Ty<'tcx>>,
|
ty_seen: &mut UnordSet<Ty<'tcx>>,
|
||||||
) -> SmallVec<[Ty<'tcx>; 4]> {
|
) -> SmallVec<[Ty<'tcx>; 4]> {
|
||||||
// Droppiness does not depend on regions, so let us erase them.
|
// Droppiness does not depend on regions, so let us erase them.
|
||||||
let ty = tcx
|
let ty = tcx.try_normalize_erasing_regions(typing_env, ty).unwrap_or(ty);
|
||||||
.try_normalize_erasing_regions(
|
|
||||||
ty::TypingEnv { param_env, typing_mode: ty::TypingMode::PostAnalysis },
|
|
||||||
ty,
|
|
||||||
)
|
|
||||||
.unwrap_or(ty);
|
|
||||||
|
|
||||||
let tys = tcx.list_significant_drop_tys(param_env.and(ty));
|
let tys = tcx.list_significant_drop_tys(typing_env.as_query_input(ty));
|
||||||
debug!(?ty, "components");
|
debug!(?ty, "components");
|
||||||
let mut out_tys = smallvec![];
|
let mut out_tys = smallvec![];
|
||||||
for ty in tys {
|
for ty in tys {
|
||||||
|
@ -239,7 +234,7 @@ fn extract_component_raw<'tcx>(
|
||||||
// Some types can be further opened up because the drop is simply delegated
|
// Some types can be further opened up because the drop is simply delegated
|
||||||
for ty in tys {
|
for ty in tys {
|
||||||
if ty_seen.insert(ty) {
|
if ty_seen.insert(ty) {
|
||||||
out_tys.extend(extract_component_raw(tcx, param_env, ty, ty_seen));
|
out_tys.extend(extract_component_raw(tcx, typing_env, ty, ty_seen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -251,13 +246,13 @@ fn extract_component_raw<'tcx>(
|
||||||
out_tys
|
out_tys
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(tcx, param_env))]
|
#[instrument(level = "debug", skip(tcx, typing_env))]
|
||||||
fn extract_component_with_significant_dtor<'tcx>(
|
fn extract_component_with_significant_dtor<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
typing_env: ty::TypingEnv<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) -> SmallVec<[Ty<'tcx>; 4]> {
|
) -> SmallVec<[Ty<'tcx>; 4]> {
|
||||||
let mut tys = extract_component_raw(tcx, param_env, ty, &mut Default::default());
|
let mut tys = extract_component_raw(tcx, typing_env, ty, &mut Default::default());
|
||||||
let mut deduplicate = FxHashSet::default();
|
let mut deduplicate = FxHashSet::default();
|
||||||
tys.retain(|oty| deduplicate.insert(*oty));
|
tys.retain(|oty| deduplicate.insert(*oty));
|
||||||
tys.into_iter().collect()
|
tys.into_iter().collect()
|
||||||
|
@ -359,7 +354,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
|
||||||
// We group them per-block because they tend to scheduled in the same drop ladder block.
|
// We group them per-block because they tend to scheduled in the same drop ladder block.
|
||||||
let mut bid_per_block = IndexMap::default();
|
let mut bid_per_block = IndexMap::default();
|
||||||
let mut bid_places = UnordSet::new();
|
let mut bid_places = UnordSet::new();
|
||||||
let param_env = tcx.param_env(def_id).with_reveal_all_normalized(tcx);
|
let typing_env = ty::TypingEnv::post_analysis(tcx, def_id);
|
||||||
let mut ty_dropped_components = UnordMap::default();
|
let mut ty_dropped_components = UnordMap::default();
|
||||||
for (block, data) in body.basic_blocks.iter_enumerated() {
|
for (block, data) in body.basic_blocks.iter_enumerated() {
|
||||||
for (statement_index, stmt) in data.statements.iter().enumerate() {
|
for (statement_index, stmt) in data.statements.iter().enumerate() {
|
||||||
|
@ -367,7 +362,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
|
||||||
let ty = place.ty(body, tcx).ty;
|
let ty = place.ty(body, tcx).ty;
|
||||||
if ty_dropped_components
|
if ty_dropped_components
|
||||||
.entry(ty)
|
.entry(ty)
|
||||||
.or_insert_with(|| extract_component_with_significant_dtor(tcx, param_env, ty))
|
.or_insert_with(|| extract_component_with_significant_dtor(tcx, typing_env, ty))
|
||||||
.is_empty()
|
.is_empty()
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -479,7 +474,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
|
||||||
if ty_dropped_components
|
if ty_dropped_components
|
||||||
.entry(observer_ty)
|
.entry(observer_ty)
|
||||||
.or_insert_with(|| {
|
.or_insert_with(|| {
|
||||||
extract_component_with_significant_dtor(tcx, param_env, observer_ty)
|
extract_component_with_significant_dtor(tcx, typing_env, observer_ty)
|
||||||
})
|
})
|
||||||
.is_empty()
|
.is_empty()
|
||||||
{
|
{
|
||||||
|
@ -575,7 +570,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
|
||||||
let name = name.as_str();
|
let name = name.as_str();
|
||||||
|
|
||||||
let mut seen_dyn = false;
|
let mut seen_dyn = false;
|
||||||
let destructors = extract_component_with_significant_dtor(tcx, param_env, observer_ty)
|
let destructors = extract_component_with_significant_dtor(tcx, typing_env, observer_ty)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|ty| {
|
.filter_map(|ty| {
|
||||||
if let Some(span) = ty_dtor_span(tcx, ty) {
|
if let Some(span) = ty_dtor_span(tcx, ty) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! Normalizes MIR in `TypingMode::PostAnalysis`` mode, most notably revealing
|
//! Normalizes MIR in `TypingMode::PostAnalysis` mode, most notably revealing
|
||||||
//! its opaques. We also only normalize specializable associated items once in
|
//! its opaques. We also only normalize specializable associated items once in
|
||||||
//! `PostAnalysis` mode.
|
//! `PostAnalysis` mode.
|
||||||
|
|
||||||
|
|
|
@ -431,13 +431,13 @@ fn adt_significant_drop_tys(
|
||||||
#[instrument(level = "debug", skip(tcx), ret)]
|
#[instrument(level = "debug", skip(tcx), ret)]
|
||||||
fn list_significant_drop_tys<'tcx>(
|
fn list_significant_drop_tys<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
key: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
|
||||||
) -> &'tcx ty::List<Ty<'tcx>> {
|
) -> &'tcx ty::List<Ty<'tcx>> {
|
||||||
tcx.mk_type_list(
|
tcx.mk_type_list(
|
||||||
&drop_tys_helper(
|
&drop_tys_helper(
|
||||||
tcx,
|
tcx,
|
||||||
ty.value,
|
key.value,
|
||||||
ty::TypingEnv { typing_mode: ty::TypingMode::PostAnalysis, param_env: ty.param_env },
|
key.typing_env,
|
||||||
adt_consider_insignificant_dtor(tcx),
|
adt_consider_insignificant_dtor(tcx),
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue