Revert "Cache whether a body has inline consts"
This reverts commit eae5031ecb
.
This commit is contained in:
parent
b74702fbb2
commit
92c54db22f
6 changed files with 4 additions and 22 deletions
|
@ -74,10 +74,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
|
|
||||||
let kind = match &e.kind {
|
let kind = match &e.kind {
|
||||||
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
|
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
|
||||||
ExprKind::ConstBlock(c) => {
|
ExprKind::ConstBlock(c) => hir::ExprKind::ConstBlock(self.lower_expr(c)),
|
||||||
self.has_inline_consts = true;
|
|
||||||
hir::ExprKind::ConstBlock(self.lower_expr(c))
|
|
||||||
}
|
|
||||||
ExprKind::Repeat(expr, count) => {
|
ExprKind::Repeat(expr, count) => {
|
||||||
let expr = self.lower_expr(expr);
|
let expr = self.lower_expr(expr);
|
||||||
let count = self.lower_array_length(count);
|
let count = self.lower_array_length(count);
|
||||||
|
|
|
@ -96,8 +96,6 @@ struct LoweringContext<'a, 'hir> {
|
||||||
|
|
||||||
/// Bodies inside the owner being lowered.
|
/// Bodies inside the owner being lowered.
|
||||||
bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
|
bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
|
||||||
/// Whether there were inline consts that typeck will split out into bodies
|
|
||||||
has_inline_consts: bool,
|
|
||||||
/// Attributes inside the owner being lowered.
|
/// Attributes inside the owner being lowered.
|
||||||
attrs: SortedMap<hir::ItemLocalId, &'hir [Attribute]>,
|
attrs: SortedMap<hir::ItemLocalId, &'hir [Attribute]>,
|
||||||
/// Collect items that were created by lowering the current owner.
|
/// Collect items that were created by lowering the current owner.
|
||||||
|
@ -160,7 +158,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
item_local_id_counter: hir::ItemLocalId::ZERO,
|
item_local_id_counter: hir::ItemLocalId::ZERO,
|
||||||
node_id_to_local_id: Default::default(),
|
node_id_to_local_id: Default::default(),
|
||||||
trait_map: Default::default(),
|
trait_map: Default::default(),
|
||||||
has_inline_consts: false,
|
|
||||||
|
|
||||||
// Lowering state.
|
// Lowering state.
|
||||||
catch_scope: None,
|
catch_scope: None,
|
||||||
|
@ -570,7 +567,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
|
||||||
let current_attrs = std::mem::take(&mut self.attrs);
|
let current_attrs = std::mem::take(&mut self.attrs);
|
||||||
let current_bodies = std::mem::take(&mut self.bodies);
|
let current_bodies = std::mem::take(&mut self.bodies);
|
||||||
let current_has_inline_consts = std::mem::take(&mut self.has_inline_consts);
|
|
||||||
let current_node_ids = std::mem::take(&mut self.node_id_to_local_id);
|
let current_node_ids = std::mem::take(&mut self.node_id_to_local_id);
|
||||||
let current_trait_map = std::mem::take(&mut self.trait_map);
|
let current_trait_map = std::mem::take(&mut self.trait_map);
|
||||||
let current_owner =
|
let current_owner =
|
||||||
|
@ -597,7 +593,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
|
||||||
self.attrs = current_attrs;
|
self.attrs = current_attrs;
|
||||||
self.bodies = current_bodies;
|
self.bodies = current_bodies;
|
||||||
self.has_inline_consts = current_has_inline_consts;
|
|
||||||
self.node_id_to_local_id = current_node_ids;
|
self.node_id_to_local_id = current_node_ids;
|
||||||
self.trait_map = current_trait_map;
|
self.trait_map = current_trait_map;
|
||||||
self.current_hir_id_owner = current_owner;
|
self.current_hir_id_owner = current_owner;
|
||||||
|
@ -634,7 +629,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
let attrs = std::mem::take(&mut self.attrs);
|
let attrs = std::mem::take(&mut self.attrs);
|
||||||
let mut bodies = std::mem::take(&mut self.bodies);
|
let mut bodies = std::mem::take(&mut self.bodies);
|
||||||
let trait_map = std::mem::take(&mut self.trait_map);
|
let trait_map = std::mem::take(&mut self.trait_map);
|
||||||
let has_inline_consts = std::mem::take(&mut self.has_inline_consts);
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
for (id, attrs) in attrs.iter() {
|
for (id, attrs) in attrs.iter() {
|
||||||
|
@ -652,7 +646,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
self.tcx.hash_owner_nodes(node, &bodies, &attrs);
|
self.tcx.hash_owner_nodes(node, &bodies, &attrs);
|
||||||
let num_nodes = self.item_local_id_counter.as_usize();
|
let num_nodes = self.item_local_id_counter.as_usize();
|
||||||
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
|
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
|
||||||
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies, has_inline_consts };
|
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies };
|
||||||
let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash };
|
let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash };
|
||||||
|
|
||||||
self.arena.alloc(hir::OwnerInfo { nodes, parenting, attrs, trait_map })
|
self.arena.alloc(hir::OwnerInfo { nodes, parenting, attrs, trait_map })
|
||||||
|
|
|
@ -907,9 +907,6 @@ pub struct OwnerNodes<'tcx> {
|
||||||
pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
|
pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
|
||||||
/// Content of local bodies.
|
/// Content of local bodies.
|
||||||
pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
|
pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
|
||||||
/// Whether the body contains inline constants that are created for the query system during typeck
|
|
||||||
/// of the body.
|
|
||||||
pub has_inline_consts: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> OwnerNodes<'tcx> {
|
impl<'tcx> OwnerNodes<'tcx> {
|
||||||
|
|
|
@ -93,8 +93,7 @@ impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<'
|
||||||
// `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing
|
// `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing
|
||||||
// the body satisfies the condition of two nodes being different have different
|
// the body satisfies the condition of two nodes being different have different
|
||||||
// `hash_stable` results.
|
// `hash_stable` results.
|
||||||
let OwnerNodes { opt_hash_including_bodies, nodes: _, bodies: _, has_inline_consts: _ } =
|
let OwnerNodes { opt_hash_including_bodies, nodes: _, bodies: _ } = *self;
|
||||||
*self;
|
|
||||||
opt_hash_including_bodies.unwrap().hash_stable(hcx, hasher);
|
opt_hash_including_bodies.unwrap().hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,7 +740,6 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
bodies,
|
bodies,
|
||||||
has_inline_consts: false,
|
|
||||||
})));
|
})));
|
||||||
self.feed_owner_id().hir_attrs(attrs);
|
self.feed_owner_id().hir_attrs(attrs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,11 +225,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
||||||
// Inline consts' bodies are created in
|
// Inline consts' bodies are created in
|
||||||
// typeck instead of during ast lowering, like all other bodies so far.
|
// typeck instead of during ast lowering, like all other bodies so far.
|
||||||
for def_id in tcx.hir().body_owners() {
|
for def_id in tcx.hir().body_owners() {
|
||||||
// Incremental performance optimization: only load typeck results for things that actually have inline consts
|
set.extend(tcx.typeck(def_id).inline_consts.values())
|
||||||
if tcx.hir_owner_nodes(tcx.hir().body_owned_by(def_id).id().hir_id.owner).has_inline_consts
|
|
||||||
{
|
|
||||||
set.extend(tcx.typeck(def_id).inline_consts.values())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additionally, tuple struct/variant constructors have MIR, but
|
// Additionally, tuple struct/variant constructors have MIR, but
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue