@@ -12,7 +12,7 @@ use intern::sym;
1212use rustc_hash:: FxHashSet ;
1313
1414use crate :: {
15- FindPathConfig , ModuleDefId , ModuleId ,
15+ FindPathConfig , ModuleDefId , ModuleIdLt ,
1616 db:: DefDatabase ,
1717 item_scope:: ItemInNs ,
1818 nameres:: DefMap ,
@@ -24,7 +24,7 @@ use crate::{
2424pub fn find_path (
2525 db : & dyn DefDatabase ,
2626 item : ItemInNs ,
27- from : ModuleId ,
27+ from : ModuleIdLt < ' _ > ,
2828 mut prefix_kind : PrefixKind ,
2929 ignore_local_imports : bool ,
3030 mut cfg : FindPathConfig ,
@@ -102,14 +102,14 @@ struct FindPathCtx<'db> {
102102 cfg : FindPathConfig ,
103103 ignore_local_imports : bool ,
104104 is_std_item : bool ,
105- from : ModuleId ,
105+ from : ModuleIdLt < ' db > ,
106106 from_crate : Crate ,
107- crate_root : ModuleId ,
107+ crate_root : ModuleIdLt < ' db > ,
108108 from_def_map : & ' db DefMap ,
109109 fuel : Cell < usize > ,
110110}
111111
112- /// Attempts to find a path to refer to the given `item` visible from the `from` ModuleId
112+ /// Attempts to find a path to refer to the given `item` visible from the `from` ModuleIdLt<'_>
113113fn find_path_inner ( ctx : & FindPathCtx < ' _ > , item : ItemInNs , max_len : usize ) -> Option < ModPath > {
114114 // - if the item is a module, jump straight to module search
115115 if !ctx. is_std_item
@@ -157,10 +157,10 @@ fn find_path_inner(ctx: &FindPathCtx<'_>, item: ItemInNs, max_len: usize) -> Opt
157157}
158158
159159#[ tracing:: instrument( skip_all) ]
160- fn find_path_for_module (
161- ctx : & FindPathCtx < ' _ > ,
162- visited_modules : & mut FxHashSet < ( ItemInNs , ModuleId ) > ,
163- module_id : ModuleId ,
160+ fn find_path_for_module < ' db > (
161+ ctx : & ' db FindPathCtx < ' db > ,
162+ visited_modules : & mut FxHashSet < ( ItemInNs , ModuleIdLt < ' db > ) > ,
163+ module_id : ModuleIdLt < ' db > ,
164164 maybe_extern : bool ,
165165 max_len : usize ,
166166) -> Option < Choice > {
@@ -217,7 +217,7 @@ fn find_path_for_module(
217217 ctx. db ,
218218 ctx. from_def_map ,
219219 ctx. from ,
220- ItemInNs :: Types ( module_id. into ( ) ) ,
220+ ItemInNs :: Types ( unsafe { module_id. to_static ( ) } . into ( ) ) ,
221221 ctx. ignore_local_imports ,
222222 ) ;
223223 if let Some ( scope_name) = scope_name {
@@ -244,7 +244,7 @@ fn find_path_for_module(
244244 }
245245
246246 // - if the module is in the prelude, return it by that path
247- let item = ItemInNs :: Types ( module_id. into ( ) ) ;
247+ let item = ItemInNs :: Types ( unsafe { module_id. to_static ( ) } . into ( ) ) ;
248248 if let Some ( choice) = find_in_prelude ( ctx. db , ctx. from_def_map , item, ctx. from ) {
249249 return Some ( choice) ;
250250 }
@@ -257,10 +257,10 @@ fn find_path_for_module(
257257 best_choice
258258}
259259
260- fn find_in_scope (
261- db : & dyn DefDatabase ,
260+ fn find_in_scope < ' db > (
261+ db : & ' db dyn DefDatabase ,
262262 def_map : & DefMap ,
263- from : ModuleId ,
263+ from : ModuleIdLt < ' db > ,
264264 item : ItemInNs ,
265265 ignore_local_imports : bool ,
266266) -> Option < Name > {
@@ -278,7 +278,7 @@ fn find_in_prelude(
278278 db : & dyn DefDatabase ,
279279 local_def_map : & DefMap ,
280280 item : ItemInNs ,
281- from : ModuleId ,
281+ from : ModuleIdLt < ' _ > ,
282282) -> Option < Choice > {
283283 let ( prelude_module, _) = local_def_map. prelude ( ) ?;
284284 let prelude_def_map = prelude_module. def_map ( db) ;
@@ -310,8 +310,8 @@ fn find_in_prelude(
310310fn is_kw_kind_relative_to_from (
311311 db : & dyn DefDatabase ,
312312 def_map : & DefMap ,
313- item : ModuleId ,
314- from : ModuleId ,
313+ item : ModuleIdLt < ' _ > ,
314+ from : ModuleIdLt < ' _ > ,
315315) -> Option < PathKind > {
316316 if item. krate ( db) != from. krate ( db) || item. block ( db) . is_some ( ) || from. block ( db) . is_some ( ) {
317317 return None ;
@@ -332,9 +332,9 @@ fn is_kw_kind_relative_to_from(
332332}
333333
334334#[ tracing:: instrument( skip_all) ]
335- fn calculate_best_path (
336- ctx : & FindPathCtx < ' _ > ,
337- visited_modules : & mut FxHashSet < ( ItemInNs , ModuleId ) > ,
335+ fn calculate_best_path < ' db > (
336+ ctx : & ' db FindPathCtx < ' db > ,
337+ visited_modules : & mut FxHashSet < ( ItemInNs , ModuleIdLt < ' db > ) > ,
338338 item : ItemInNs ,
339339 max_len : usize ,
340340 best_choice : & mut Option < Choice > ,
@@ -372,9 +372,9 @@ fn calculate_best_path(
372372 }
373373}
374374
375- fn find_in_sysroot (
376- ctx : & FindPathCtx < ' _ > ,
377- visited_modules : & mut FxHashSet < ( ItemInNs , ModuleId ) > ,
375+ fn find_in_sysroot < ' db > (
376+ ctx : & ' db FindPathCtx < ' db > ,
377+ visited_modules : & mut FxHashSet < ( ItemInNs , ModuleIdLt < ' db > ) > ,
378378 item : ItemInNs ,
379379 max_len : usize ,
380380 best_choice : & mut Option < Choice > ,
@@ -418,9 +418,9 @@ fn find_in_sysroot(
418418 } ) ;
419419}
420420
421- fn find_in_dep (
422- ctx : & FindPathCtx < ' _ > ,
423- visited_modules : & mut FxHashSet < ( ItemInNs , ModuleId ) > ,
421+ fn find_in_dep < ' db > (
422+ ctx : & ' db FindPathCtx < ' db > ,
423+ visited_modules : & mut FxHashSet < ( ItemInNs , ModuleIdLt < ' db > ) > ,
424424 item : ItemInNs ,
425425 max_len : usize ,
426426 best_choice : & mut Option < Choice > ,
@@ -461,9 +461,9 @@ fn find_in_dep(
461461 }
462462}
463463
464- fn calculate_best_path_local (
465- ctx : & FindPathCtx < ' _ > ,
466- visited_modules : & mut FxHashSet < ( ItemInNs , ModuleId ) > ,
464+ fn calculate_best_path_local < ' db > (
465+ ctx : & ' db FindPathCtx < ' db > ,
466+ visited_modules : & mut FxHashSet < ( ItemInNs , ModuleIdLt < ' db > ) > ,
467467 item : ItemInNs ,
468468 max_len : usize ,
469469 best_choice : & mut Option < Choice > ,
@@ -558,11 +558,11 @@ fn path_kind_len(kind: PathKind) -> usize {
558558}
559559
560560/// Finds locations in `from.krate` from which `item` can be imported by `from`.
561- fn find_local_import_locations (
562- ctx : & FindPathCtx < ' _ > ,
561+ fn find_local_import_locations < ' db > (
562+ ctx : & ' db FindPathCtx < ' db > ,
563563 item : ItemInNs ,
564- visited_modules : & mut FxHashSet < ( ItemInNs , ModuleId ) > ,
565- mut cb : impl FnMut ( & mut FxHashSet < ( ItemInNs , ModuleId ) > , & Name , ModuleId ) ,
564+ visited_modules : & mut FxHashSet < ( ItemInNs , ModuleIdLt < ' db > ) > ,
565+ mut cb : impl FnMut ( & mut FxHashSet < ( ItemInNs , ModuleIdLt < ' db > ) > , & Name , ModuleIdLt < ' db > ) ,
566566) {
567567 let _p = tracing:: info_span!( "find_local_import_locations" ) . entered ( ) ;
568568 let db = ctx. db ;
0 commit comments