File tree 2 files changed +8
-13
lines changed
2 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -153,17 +153,10 @@ impl ModuleTree {
153
153
self . mods . iter ( ) . map ( |( id, _) | id)
154
154
}
155
155
156
- fn modules_for_source ( & self , source : ModuleSource ) -> Vec < ModuleId > {
157
- self . mods
158
- . iter ( )
159
- . filter ( |( _idx, it) | it. source == source)
160
- . map ( |( idx, _) | idx)
161
- . collect ( )
162
- }
163
-
164
- //TODO: move to source binders?
165
- pub ( crate ) fn any_module_for_source ( & self , source : ModuleSource ) -> Option < ModuleId > {
166
- self . modules_for_source ( source) . pop ( )
156
+ pub ( crate ) fn modules_with_sources < ' a > (
157
+ & ' a self ,
158
+ ) -> impl Iterator < Item = ( ModuleId , ModuleSource ) > + ' a {
159
+ self . mods . iter ( ) . map ( |( id, m) | ( id, m. source ) )
167
160
}
168
161
}
169
162
Original file line number Diff line number Diff line change @@ -61,8 +61,10 @@ fn module_from_source(
61
61
) -> Cancelable < Option < Module > > {
62
62
let source_root_id = db. file_source_root ( module_source. file_id ( ) ) ;
63
63
let module_tree = db. module_tree ( source_root_id) ?;
64
-
65
- let module_id = ctry ! ( module_tree. any_module_for_source( module_source) ) ;
64
+ let m = module_tree
65
+ . modules_with_sources ( )
66
+ . find ( |( _id, src) | src == & module_source) ;
67
+ let module_id = ctry ! ( m) . 0 ;
66
68
Ok ( Some ( Module :: new ( db, source_root_id, module_id) ?) )
67
69
}
68
70
You can’t perform that action at this time.
0 commit comments