aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/item_tree.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/item_tree.rs')
-rw-r--r--crates/ra_hir_def/src/item_tree.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index 8c93e3adf..3e603bd55 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -5,6 +5,7 @@ mod lower;
5mod tests; 5mod tests;
6 6
7use std::{ 7use std::{
8 any::type_name,
8 fmt::{self, Debug}, 9 fmt::{self, Debug},
9 hash::{Hash, Hasher}, 10 hash::{Hash, Hasher},
10 marker::PhantomData, 11 marker::PhantomData,
@@ -540,7 +541,7 @@ pub struct Enum {
540 pub name: Name, 541 pub name: Name,
541 pub visibility: RawVisibilityId, 542 pub visibility: RawVisibilityId,
542 pub generic_params: GenericParamsId, 543 pub generic_params: GenericParamsId,
543 pub variants: Range<Idx<Variant>>, 544 pub variants: IdRange<Variant>,
544 pub ast_id: FileAstId<ast::EnumDef>, 545 pub ast_id: FileAstId<ast::EnumDef>,
545} 546}
546 547
@@ -698,7 +699,6 @@ pub struct Variant {
698 pub fields: Fields, 699 pub fields: Fields,
699} 700}
700 701
701#[derive(Debug, Clone, PartialEq, Eq)]
702pub struct IdRange<T> { 702pub struct IdRange<T> {
703 range: Range<u32>, 703 range: Range<u32>,
704 _p: PhantomData<T>, 704 _p: PhantomData<T>,
@@ -717,6 +717,26 @@ impl<T> Iterator for IdRange<T> {
717 } 717 }
718} 718}
719 719
720impl<T> fmt::Debug for IdRange<T> {
721 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
722 f.debug_tuple(&format!("IdRange::<{}>", type_name::<T>())).field(&self.range).finish()
723 }
724}
725
726impl<T> Clone for IdRange<T> {
727 fn clone(&self) -> Self {
728 Self { range: self.range.clone(), _p: PhantomData }
729 }
730}
731
732impl<T> PartialEq for IdRange<T> {
733 fn eq(&self, other: &Self) -> bool {
734 self.range == other.range
735 }
736}
737
738impl<T> Eq for IdRange<T> {}
739
720#[derive(Debug, Clone, PartialEq, Eq)] 740#[derive(Debug, Clone, PartialEq, Eq)]
721pub enum Fields { 741pub enum Fields {
722 Record(IdRange<Field>), 742 Record(IdRange<Field>),