@@ -84,7 +84,7 @@ struct DefCollector<DB> {
84
84
global_macro_scope : FxHashMap < Name , MacroDefId > ,
85
85
86
86
/// Some macro use `$tt:tt which mean we have to handle the macro perfectly
87
- /// To prevent stackoverflow , we add a deep counter here for prevent that.
87
+ /// To prevent stack overflow , we add a deep counter here for prevent that.
88
88
macro_stack_monitor : MacroStackMonitor ,
89
89
}
90
90
@@ -497,7 +497,7 @@ where
497
497
498
498
fn collect_module ( & mut self , module : & raw:: ModuleData ) {
499
499
match module {
500
- // inline module, just recurse
500
+ // inline module, just recursive
501
501
raw:: ModuleData :: Definition { name, items, ast_id } => {
502
502
let module_id =
503
503
self . push_child_module ( name. clone ( ) , ast_id. with_file_id ( self . file_id ) , None ) ;
@@ -509,7 +509,7 @@ where
509
509
}
510
510
. collect ( & * items) ;
511
511
}
512
- // out of line module, resolve, parse and recurse
512
+ // out of line module, resolve, parse and recursive
513
513
raw:: ModuleData :: Declaration { name, ast_id, attr_path } => {
514
514
let ast_id = ast_id. with_file_id ( self . file_id ) ;
515
515
let is_root = self . def_collector . def_map . modules [ self . module_id ] . parent . is_none ( ) ;
@@ -649,7 +649,8 @@ fn resolve_submodule(
649
649
let file_dir_mod = dir_path. join ( format ! ( "{}/{}.rs" , mod_name, name) ) ;
650
650
let mut candidates = ArrayVec :: < [ _ ; 3 ] > :: new ( ) ;
651
651
let file_attr_mod = attr_path. map ( |file_path| {
652
- let file_attr_mod = dir_path. join ( file_path. to_string ( ) ) ;
652
+ let file_path = normalize_attribute_path ( file_path) ;
653
+ let file_attr_mod = dir_path. join ( file_path) . normalize ( ) ;
653
654
candidates. push ( file_attr_mod. clone ( ) ) ;
654
655
655
656
file_attr_mod
@@ -675,6 +676,17 @@ fn resolve_submodule(
675
676
}
676
677
}
677
678
679
+ fn normalize_attribute_path ( file_path : & SmolStr ) -> String {
680
+ let current_dir = "./" ;
681
+
682
+ let separator = |path : & str | path. replace ( "\\ " , "/" ) ;
683
+ if file_path. starts_with ( current_dir) {
684
+ separator ( & file_path[ current_dir. len ( ) ..] )
685
+ } else {
686
+ separator ( file_path. as_str ( ) )
687
+ }
688
+ }
689
+
678
690
#[ cfg( test) ]
679
691
mod tests {
680
692
use ra_db:: SourceDatabase ;
0 commit comments