@@ -38,7 +38,6 @@ mod tests;
38
38
use std:: {
39
39
fmt:: { self , Debug } ,
40
40
hash:: { Hash , Hasher } ,
41
- marker:: PhantomData ,
42
41
ops:: Index ,
43
42
} ;
44
43
@@ -340,34 +339,37 @@ pub trait ItemTreeNode: Clone {
340
339
fn id_to_mod_item ( id : FileItemTreeId < Self > ) -> ModItem ;
341
340
}
342
341
343
- pub struct FileItemTreeId < N : ItemTreeNode > {
344
- index : Idx < N > ,
345
- _p : PhantomData < N > ,
342
+ pub struct FileItemTreeId < N : ItemTreeNode > ( Idx < N > ) ;
343
+
344
+ impl < N : ItemTreeNode > FileItemTreeId < N > {
345
+ pub fn index ( & self ) -> Idx < N > {
346
+ self . 0
347
+ }
346
348
}
347
349
348
350
impl < N : ItemTreeNode > Clone for FileItemTreeId < N > {
349
351
fn clone ( & self ) -> Self {
350
- Self { index : self . index , _p : PhantomData }
352
+ Self ( self . 0 )
351
353
}
352
354
}
353
355
impl < N : ItemTreeNode > Copy for FileItemTreeId < N > { }
354
356
355
357
impl < N : ItemTreeNode > PartialEq for FileItemTreeId < N > {
356
358
fn eq ( & self , other : & FileItemTreeId < N > ) -> bool {
357
- self . index == other. index
359
+ self . 0 == other. 0
358
360
}
359
361
}
360
362
impl < N : ItemTreeNode > Eq for FileItemTreeId < N > { }
361
363
362
364
impl < N : ItemTreeNode > Hash for FileItemTreeId < N > {
363
365
fn hash < H : Hasher > ( & self , state : & mut H ) {
364
- self . index . hash ( state)
366
+ self . 0 . hash ( state)
365
367
}
366
368
}
367
369
368
370
impl < N : ItemTreeNode > fmt:: Debug for FileItemTreeId < N > {
369
371
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
370
- self . index . fmt ( f)
372
+ self . 0 . fmt ( f)
371
373
}
372
374
}
373
375
@@ -548,7 +550,7 @@ impl Index<RawVisibilityId> for ItemTree {
548
550
impl < N : ItemTreeNode > Index < FileItemTreeId < N > > for ItemTree {
549
551
type Output = N ;
550
552
fn index ( & self , id : FileItemTreeId < N > ) -> & N {
551
- N :: lookup ( self , id. index )
553
+ N :: lookup ( self , id. index ( ) )
552
554
}
553
555
}
554
556
@@ -925,23 +927,23 @@ impl ModItem {
925
927
926
928
pub fn ast_id ( & self , tree : & ItemTree ) -> FileAstId < ast:: Item > {
927
929
match self {
928
- ModItem :: Use ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
929
- ModItem :: ExternCrate ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
930
- ModItem :: ExternBlock ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
931
- ModItem :: Function ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
932
- ModItem :: Struct ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
933
- ModItem :: Union ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
934
- ModItem :: Enum ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
935
- ModItem :: Const ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
936
- ModItem :: Static ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
937
- ModItem :: Trait ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
938
- ModItem :: TraitAlias ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
939
- ModItem :: Impl ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
940
- ModItem :: TypeAlias ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
941
- ModItem :: Mod ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
942
- ModItem :: MacroCall ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
943
- ModItem :: MacroRules ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
944
- ModItem :: MacroDef ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
930
+ ModItem :: Use ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
931
+ ModItem :: ExternCrate ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
932
+ ModItem :: ExternBlock ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
933
+ ModItem :: Function ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
934
+ ModItem :: Struct ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
935
+ ModItem :: Union ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
936
+ ModItem :: Enum ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
937
+ ModItem :: Const ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
938
+ ModItem :: Static ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
939
+ ModItem :: Trait ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
940
+ ModItem :: TraitAlias ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
941
+ ModItem :: Impl ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
942
+ ModItem :: TypeAlias ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
943
+ ModItem :: Mod ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
944
+ ModItem :: MacroCall ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
945
+ ModItem :: MacroRules ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
946
+ ModItem :: MacroDef ( it) => tree[ it. index ( ) ] . ast_id ( ) . upcast ( ) ,
945
947
}
946
948
}
947
949
}
0 commit comments