@@ -57,7 +57,6 @@ mod tests;
5757
5858use std:: sync:: Arc ;
5959
60- use either:: Either ;
6160use hir_expand:: {
6261 ast_id_map:: FileAstId , diagnostics:: DiagnosticSink , name:: Name , InFile , MacroDefId ,
6362} ;
@@ -154,20 +153,16 @@ impl ModuleOrigin {
154153
155154 /// Returns a node which defines this module.
156155 /// That is, a file or a `mod foo {}` with items.
157- pub fn definition_source (
158- & self ,
159- db : & impl DefDatabase ,
160- ) -> InFile < Either < ast:: SourceFile , ast:: Module > > {
156+ pub fn definition_source ( & self , db : & impl DefDatabase ) -> InFile < ModuleSource > {
161157 match self {
162158 ModuleOrigin :: File ( _, file_id) | ModuleOrigin :: Root ( Some ( file_id) ) => {
163159 let file_id = * file_id;
164160 let sf = db. parse ( file_id) . tree ( ) ;
165- return InFile :: new ( file_id. into ( ) , Either :: Left ( sf) ) ;
161+ return InFile :: new ( file_id. into ( ) , ModuleSource :: SourceFile ( sf) ) ;
166162 }
167163 ModuleOrigin :: Root ( None ) => unreachable ! ( ) ,
168- ModuleOrigin :: Inline ( m) => InFile :: new ( m. file_id , Either :: Right ( m. to_node ( db) ) ) ,
169- // FIXME: right now it's never constructed, so it's fine to omit
170- ModuleOrigin :: Block ( _b) => unimplemented ! ( ) ,
164+ ModuleOrigin :: Inline ( m) => InFile :: new ( m. file_id , ModuleSource :: Module ( m. to_node ( db) ) ) ,
165+ ModuleOrigin :: Block ( b) => InFile :: new ( b. file_id , ModuleSource :: Block ( b. to_node ( db) ) ) ,
171166 }
172167 }
173168}
@@ -348,10 +343,7 @@ impl CrateDefMap {
348343
349344impl ModuleData {
350345 /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
351- pub fn definition_source (
352- & self ,
353- db : & impl DefDatabase ,
354- ) -> InFile < Either < ast:: SourceFile , ast:: Module > > {
346+ pub fn definition_source ( & self , db : & impl DefDatabase ) -> InFile < ModuleSource > {
355347 self . origin . definition_source ( db)
356348 }
357349
0 commit comments