@@ -89,8 +89,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
89
89
pub trait FileLoader {
90
90
/// Text of the file.
91
91
fn file_text ( & self , file_id : FileId ) -> Arc < String > ;
92
- fn resolve_relative_path ( & self , anchor : FileId , relative_path : & RelativePath )
93
- -> Option < FileId > ;
92
+ fn resolve_path ( & self , anchor : FileId , path : & str ) -> Option < FileId > ;
94
93
fn relevant_crates ( & self , file_id : FileId ) -> Arc < Vec < CrateId > > ;
95
94
96
95
fn resolve_extern_path (
@@ -155,20 +154,21 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
155
154
fn file_text ( & self , file_id : FileId ) -> Arc < String > {
156
155
SourceDatabaseExt :: file_text ( self . 0 , file_id)
157
156
}
158
- fn resolve_relative_path (
159
- & self ,
160
- anchor : FileId ,
161
- relative_path : & RelativePath ,
162
- ) -> Option < FileId > {
163
- let path = {
164
- let mut path = self . 0 . file_relative_path ( anchor) ;
165
- assert ! ( path. pop( ) ) ;
166
- path. push ( relative_path) ;
167
- path. normalize ( )
157
+ /// Note that we intentionally accept a `&str` and not a `&Path` here. This
158
+ /// method exists to handle `#[path = "/some/path.rs"] mod foo;` and such,
159
+ /// so the input is guaranteed to be utf-8 string. We might introduce
160
+ /// `struct StrPath(str)` for clarity some day, but it's a bit messy, so we
161
+ /// get by with a `&str` for the time being.
162
+ fn resolve_path ( & self , anchor : FileId , path : & str ) -> Option < FileId > {
163
+ let rel_path = {
164
+ let mut rel_path = self . 0 . file_relative_path ( anchor) ;
165
+ assert ! ( rel_path. pop( ) ) ;
166
+ rel_path. push ( path) ;
167
+ rel_path. normalize ( )
168
168
} ;
169
169
let source_root = self . 0 . file_source_root ( anchor) ;
170
170
let source_root = self . 0 . source_root ( source_root) ;
171
- source_root. file_by_relative_path ( & path )
171
+ source_root. file_by_relative_path ( & rel_path )
172
172
}
173
173
174
174
fn relevant_crates ( & self , file_id : FileId ) -> Arc < Vec < CrateId > > {
0 commit comments