diff options
Diffstat (limited to 'compiler/rustc_hir/src/hir.rs')
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 14 | 
1 files changed, 13 insertions, 1 deletions
| diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 58dd3109b34..5329444a5e0 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -2541,11 +2541,17 @@ impl VariantData<'hir> { // The bodies for items are stored "out of line", in a separate // hashmap in the `Crate`. Here we just record the hir-id of the item // so it can fetched later. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Debug, Hash)] pub struct ItemId { pub id: HirId, } +impl ItemId { + pub fn hir_id(&self) -> HirId { + self.id + } +} + /// An item /// /// The name might be a dummy name in case of anonymous items @@ -2559,6 +2565,12 @@ pub struct Item<'hir> { pub span: Span, } +impl Item<'_> { + pub fn item_id(&self) -> ItemId { + ItemId { id: self.hir_id } + } +} + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(Encodable, Decodable, HashStable_Generic)] pub enum Unsafety { | 
