@@ -57,7 +57,6 @@ mod tests;
57
57
58
58
use std:: sync:: Arc ;
59
59
60
- use either:: Either ;
61
60
use hir_expand:: {
62
61
ast_id_map:: FileAstId , diagnostics:: DiagnosticSink , name:: Name , InFile , MacroDefId ,
63
62
} ;
@@ -154,20 +153,16 @@ impl ModuleOrigin {
154
153
155
154
/// Returns a node which defines this module.
156
155
/// 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 > {
161
157
match self {
162
158
ModuleOrigin :: File ( _, file_id) | ModuleOrigin :: Root ( Some ( file_id) ) => {
163
159
let file_id = * file_id;
164
160
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) ) ;
166
162
}
167
163
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) ) ) ,
171
166
}
172
167
}
173
168
}
@@ -348,10 +343,7 @@ impl CrateDefMap {
348
343
349
344
impl ModuleData {
350
345
/// 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 > {
355
347
self . origin . definition_source ( db)
356
348
}
357
349
0 commit comments