Skip to content

Commit 92c54db

Browse files
committed
Revert "Cache whether a body has inline consts"
This reverts commit eae5031.
1 parent b74702f commit 92c54db

File tree

6 files changed

+4
-22
lines changed

6 files changed

+4
-22
lines changed

Diff for: compiler/rustc_ast_lowering/src/expr.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
7474

7575
let kind = match &e.kind {
7676
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
77-
ExprKind::ConstBlock(c) => {
78-
self.has_inline_consts = true;
79-
hir::ExprKind::ConstBlock(self.lower_expr(c))
80-
}
77+
ExprKind::ConstBlock(c) => hir::ExprKind::ConstBlock(self.lower_expr(c)),
8178
ExprKind::Repeat(expr, count) => {
8279
let expr = self.lower_expr(expr);
8380
let count = self.lower_array_length(count);

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ struct LoweringContext<'a, 'hir> {
9696

9797
/// Bodies inside the owner being lowered.
9898
bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
99-
/// Whether there were inline consts that typeck will split out into bodies
100-
has_inline_consts: bool,
10199
/// Attributes inside the owner being lowered.
102100
attrs: SortedMap<hir::ItemLocalId, &'hir [Attribute]>,
103101
/// Collect items that were created by lowering the current owner.
@@ -160,7 +158,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
160158
item_local_id_counter: hir::ItemLocalId::ZERO,
161159
node_id_to_local_id: Default::default(),
162160
trait_map: Default::default(),
163-
has_inline_consts: false,
164161

165162
// Lowering state.
166163
catch_scope: None,
@@ -570,7 +567,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
570567

571568
let current_attrs = std::mem::take(&mut self.attrs);
572569
let current_bodies = std::mem::take(&mut self.bodies);
573-
let current_has_inline_consts = std::mem::take(&mut self.has_inline_consts);
574570
let current_node_ids = std::mem::take(&mut self.node_id_to_local_id);
575571
let current_trait_map = std::mem::take(&mut self.trait_map);
576572
let current_owner =
@@ -597,7 +593,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
597593

598594
self.attrs = current_attrs;
599595
self.bodies = current_bodies;
600-
self.has_inline_consts = current_has_inline_consts;
601596
self.node_id_to_local_id = current_node_ids;
602597
self.trait_map = current_trait_map;
603598
self.current_hir_id_owner = current_owner;
@@ -634,7 +629,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
634629
let attrs = std::mem::take(&mut self.attrs);
635630
let mut bodies = std::mem::take(&mut self.bodies);
636631
let trait_map = std::mem::take(&mut self.trait_map);
637-
let has_inline_consts = std::mem::take(&mut self.has_inline_consts);
638632

639633
#[cfg(debug_assertions)]
640634
for (id, attrs) in attrs.iter() {
@@ -652,7 +646,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
652646
self.tcx.hash_owner_nodes(node, &bodies, &attrs);
653647
let num_nodes = self.item_local_id_counter.as_usize();
654648
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
655-
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies, has_inline_consts };
649+
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies };
656650
let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash };
657651

658652
self.arena.alloc(hir::OwnerInfo { nodes, parenting, attrs, trait_map })

Diff for: compiler/rustc_hir/src/hir.rs

-3
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,6 @@ pub struct OwnerNodes<'tcx> {
907907
pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
908908
/// Content of local bodies.
909909
pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
910-
/// Whether the body contains inline constants that are created for the query system during typeck
911-
/// of the body.
912-
pub has_inline_consts: bool,
913910
}
914911

915912
impl<'tcx> OwnerNodes<'tcx> {

Diff for: compiler/rustc_hir/src/stable_hash_impls.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<'
9393
// `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing
9494
// the body satisfies the condition of two nodes being different have different
9595
// `hash_stable` results.
96-
let OwnerNodes { opt_hash_including_bodies, nodes: _, bodies: _, has_inline_consts: _ } =
97-
*self;
96+
let OwnerNodes { opt_hash_including_bodies, nodes: _, bodies: _ } = *self;
9897
opt_hash_including_bodies.unwrap().hash_stable(hcx, hasher);
9998
}
10099
}

Diff for: compiler/rustc_middle/src/ty/context.rs

-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,6 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
740740
1,
741741
),
742742
bodies,
743-
has_inline_consts: false,
744743
})));
745744
self.feed_owner_id().hir_attrs(attrs);
746745
}

Diff for: compiler/rustc_mir_transform/src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
225225
// Inline consts' bodies are created in
226226
// typeck instead of during ast lowering, like all other bodies so far.
227227
for def_id in tcx.hir().body_owners() {
228-
// Incremental performance optimization: only load typeck results for things that actually have inline consts
229-
if tcx.hir_owner_nodes(tcx.hir().body_owned_by(def_id).id().hir_id.owner).has_inline_consts
230-
{
231-
set.extend(tcx.typeck(def_id).inline_consts.values())
232-
}
228+
set.extend(tcx.typeck(def_id).inline_consts.values())
233229
}
234230

235231
// Additionally, tuple struct/variant constructors have MIR, but

0 commit comments

Comments
 (0)