Directly use AttributeMap inside OwnerInfo.
This commit is contained in:
@@ -672,6 +672,23 @@ pub struct ParentedNode<'tcx> {
|
||||
pub node: Node<'tcx>,
|
||||
}
|
||||
|
||||
/// Attributes owner by a HIR owner.
|
||||
#[derive(Debug)]
|
||||
pub struct AttributeMap<'tcx> {
|
||||
pub map: BTreeMap<ItemLocalId, &'tcx [Attribute]>,
|
||||
pub hash: Fingerprint,
|
||||
}
|
||||
|
||||
impl<'tcx> AttributeMap<'tcx> {
|
||||
pub const EMPTY: &'static AttributeMap<'static> =
|
||||
&AttributeMap { map: BTreeMap::new(), hash: Fingerprint::ZERO };
|
||||
|
||||
#[inline]
|
||||
pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
|
||||
self.map.get(&id).copied().unwrap_or(&[])
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OwnerNodes<'tcx> {
|
||||
/// Pre-computed hash of the full HIR.
|
||||
@@ -691,8 +708,8 @@ pub struct OwnerInfo<'hir> {
|
||||
pub nodes: OwnerNodes<'hir>,
|
||||
/// Map from each nested owner to its parent's local id.
|
||||
pub parenting: FxHashMap<LocalDefId, ItemLocalId>,
|
||||
|
||||
pub attrs: BTreeMap<ItemLocalId, &'hir [Attribute]>,
|
||||
/// Collected attributes of the HIR nodes.
|
||||
pub attrs: AttributeMap<'hir>,
|
||||
/// Map indicating what traits are in scope for places where this
|
||||
/// is relevant; generated by resolve.
|
||||
pub trait_map: FxHashMap<ItemLocalId, Box<[TraitCandidate]>>,
|
||||
|
||||
Reference in New Issue
Block a user