@@ -38,7 +38,6 @@ mod tests;
3838use std:: {
3939 fmt:: { self , Debug } ,
4040 hash:: { Hash , Hasher } ,
41- marker:: PhantomData ,
4241 ops:: Index ,
4342} ;
4443
@@ -340,34 +339,37 @@ pub trait ItemTreeNode: Clone {
340339 fn id_to_mod_item ( id : FileItemTreeId < Self > ) -> ModItem ;
341340}
342341
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+ }
346348}
347349
348350impl < N : ItemTreeNode > Clone for FileItemTreeId < N > {
349351 fn clone ( & self ) -> Self {
350- Self { index : self . index , _p : PhantomData }
352+ Self ( self . 0 )
351353 }
352354}
353355impl < N : ItemTreeNode > Copy for FileItemTreeId < N > { }
354356
355357impl < N : ItemTreeNode > PartialEq for FileItemTreeId < N > {
356358 fn eq ( & self , other : & FileItemTreeId < N > ) -> bool {
357- self . index == other. index
359+ self . 0 == other. 0
358360 }
359361}
360362impl < N : ItemTreeNode > Eq for FileItemTreeId < N > { }
361363
362364impl < N : ItemTreeNode > Hash for FileItemTreeId < N > {
363365 fn hash < H : Hasher > ( & self , state : & mut H ) {
364- self . index . hash ( state)
366+ self . 0 . hash ( state)
365367 }
366368}
367369
368370impl < N : ItemTreeNode > fmt:: Debug for FileItemTreeId < N > {
369371 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
370- self . index . fmt ( f)
372+ self . 0 . fmt ( f)
371373 }
372374}
373375
@@ -548,7 +550,7 @@ impl Index<RawVisibilityId> for ItemTree {
548550impl < N : ItemTreeNode > Index < FileItemTreeId < N > > for ItemTree {
549551 type Output = N ;
550552 fn index ( & self , id : FileItemTreeId < N > ) -> & N {
551- N :: lookup ( self , id. index )
553+ N :: lookup ( self , id. index ( ) )
552554 }
553555}
554556
@@ -925,23 +927,23 @@ impl ModItem {
925927
926928 pub fn ast_id ( & self , tree : & ItemTree ) -> FileAstId < ast:: Item > {
927929 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 ( ) ,
945947 }
946948 }
947949}
0 commit comments