1
Fork 0

Use an IndexVec for bodies.

This commit is contained in:
Camille GILLOT 2021-09-17 19:41:05 +02:00
parent 48a339ddbb
commit cd1ace488f
7 changed files with 23 additions and 19 deletions

View file

@ -974,7 +974,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
let body = hir::Body { generator_kind: self.generator_kind, params, value };
let id = body.id();
debug_assert_eq!(id.hir_id.owner, self.current_hir_id_owner);
self.bodies.insert(id.hir_id.local_id, body);
self.bodies.ensure_contains_elem(id.hir_id.local_id, || None);
self.bodies[id.hir_id.local_id] = Some(self.arena.alloc(body));
id
}

View file

@ -97,7 +97,7 @@ struct LoweringContext<'a, 'hir: 'a> {
/// The items being lowered are collected here.
owners: IndexVec<LocalDefId, Option<hir::OwnerInfo<'hir>>>,
bodies: BTreeMap<hir::ItemLocalId, hir::Body<'hir>>,
bodies: IndexVec<hir::ItemLocalId, Option<&'hir hir::Body<'hir>>>,
attrs: BTreeMap<hir::ItemLocalId, &'hir [Attribute]>,
generator_kind: Option<hir::GeneratorKind>,
@ -322,7 +322,7 @@ pub fn lower_crate<'a, 'hir>(
nt_to_tokenstream,
arena,
owners,
bodies: BTreeMap::new(),
bodies: IndexVec::new(),
attrs: BTreeMap::default(),
catch_scope: None,
loop_scope: None,