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

@ -19,6 +19,7 @@ macro_rules! arena_types {
[] attribute: rustc_ast::Attribute,
[] block: rustc_hir::Block<$tcx>,
[] bare_fn_ty: rustc_hir::BareFnTy<$tcx>,
[] body: rustc_hir::Body<$tcx>,
[] generic_arg: rustc_hir::GenericArg<$tcx>,
[] generic_args: rustc_hir::GenericArgs<$tcx>,
[] generic_bound: rustc_hir::GenericBound<$tcx>,

View file

@ -666,7 +666,7 @@ pub struct WhereEqPredicate<'hir> {
pub struct OwnerInfo<'hir> {
pub node: OwnerNode<'hir>,
pub attrs: BTreeMap<ItemLocalId, &'hir [Attribute]>,
pub bodies: BTreeMap<ItemLocalId, Body<'hir>>,
pub bodies: IndexVec<ItemLocalId, Option<&'hir Body<'hir>>>,
/// Map indicating what traits are in scope for places where this
/// is relevant; generated by resolve.
pub trait_map: FxHashMap<ItemLocalId, Box<[TraitCandidate]>>,
@ -705,9 +705,9 @@ impl Crate<'hir> {
self.owners[id.def_id].as_ref().unwrap().node.expect_foreign_item()
}
pub fn body(&self, id: BodyId) -> &Body<'hir> {
pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
let HirId { owner, local_id } = id.hir_id;
&self.owners[owner].as_ref().unwrap().bodies[&local_id]
self.owners[owner].as_ref().unwrap().bodies[local_id].unwrap()
}
pub fn attrs(&self, id: HirId) -> &'hir [Attribute] {