@@ -13,7 +13,7 @@ pub mod diagnostics;
1313pub mod builtin_macro;
1414pub mod quote;
1515
16- use std:: hash:: { Hash , Hasher } ;
16+ use std:: hash:: Hash ;
1717use std:: sync:: Arc ;
1818
1919use ra_db:: { salsa, CrateId , FileId } ;
@@ -70,7 +70,7 @@ impl HirFileId {
7070 HirFileIdRepr :: FileId ( file_id) => file_id,
7171 HirFileIdRepr :: MacroFile ( macro_file) => {
7272 let loc = db. lookup_intern_macro ( macro_file. macro_call_id ) ;
73- loc. ast_id . file_id ( ) . original_file ( db)
73+ loc. ast_id . file_id . original_file ( db)
7474 }
7575 }
7676 }
@@ -214,43 +214,12 @@ impl ExpansionInfo {
214214///
215215/// It is stable across reparses, and can be used as salsa key/value.
216216// FIXME: isn't this just a `Source<FileAstId<N>>` ?
217- #[ derive( Debug ) ]
218- pub struct AstId < N : AstNode > {
219- file_id : HirFileId ,
220- file_ast_id : FileAstId < N > ,
221- }
222-
223- impl < N : AstNode > Clone for AstId < N > {
224- fn clone ( & self ) -> AstId < N > {
225- * self
226- }
227- }
228- impl < N : AstNode > Copy for AstId < N > { }
229-
230- impl < N : AstNode > PartialEq for AstId < N > {
231- fn eq ( & self , other : & Self ) -> bool {
232- ( self . file_id , self . file_ast_id ) == ( other. file_id , other. file_ast_id )
233- }
234- }
235- impl < N : AstNode > Eq for AstId < N > { }
236- impl < N : AstNode > Hash for AstId < N > {
237- fn hash < H : Hasher > ( & self , hasher : & mut H ) {
238- ( self . file_id , self . file_ast_id ) . hash ( hasher) ;
239- }
240- }
217+ pub type AstId < N > = InFile < FileAstId < N > > ;
241218
242219impl < N : AstNode > AstId < N > {
243- pub fn new ( file_id : HirFileId , file_ast_id : FileAstId < N > ) -> AstId < N > {
244- AstId { file_id, file_ast_id }
245- }
246-
247- pub fn file_id ( & self ) -> HirFileId {
248- self . file_id
249- }
250-
251220 pub fn to_node ( & self , db : & dyn db:: AstDatabase ) -> N {
252221 let root = db. parse_or_expand ( self . file_id ) . unwrap ( ) ;
253- db. ast_id_map ( self . file_id ) . get ( self . file_ast_id ) . to_node ( & root)
222+ db. ast_id_map ( self . file_id ) . get ( self . value ) . to_node ( & root)
254223 }
255224}
256225
0 commit comments