@@ -7,6 +7,7 @@ use log::{info, warn};
7
7
use ra_ap_hir:: Semantics ;
8
8
use ra_ap_ide_db:: line_index:: { LineCol , LineIndex } ;
9
9
use ra_ap_ide_db:: RootDatabase ;
10
+ use ra_ap_paths:: { AbsPathBuf , Utf8PathBuf } ;
10
11
use ra_ap_project_model:: { CargoConfig , ProjectManifest } ;
11
12
use ra_ap_vfs:: Vfs ;
12
13
use rust_analyzer:: { ParseResult , RustAnalyzer } ;
@@ -161,6 +162,15 @@ impl<'a> Extractor<'a> {
161
162
}
162
163
}
163
164
165
+ fn cwd ( ) -> anyhow:: Result < AbsPathBuf > {
166
+ let path = std:: env:: current_dir ( ) . context ( "current directory" ) ?;
167
+ let utf8_path = Utf8PathBuf :: from_path_buf ( path)
168
+ . map_err ( |p| anyhow:: anyhow!( "{} is not a valid UTF-8 path" , p. display( ) ) ) ?;
169
+ let abs_path = AbsPathBuf :: try_from ( utf8_path)
170
+ . map_err ( |p| anyhow:: anyhow!( "{} is not absolute" , p. as_str( ) ) ) ?;
171
+ Ok ( abs_path)
172
+ }
173
+
164
174
fn main ( ) -> anyhow:: Result < ( ) > {
165
175
let start = Instant :: now ( ) ;
166
176
let mut cfg = config:: Config :: extract ( ) . context ( "failed to load configuration" ) ?;
@@ -204,7 +214,7 @@ fn main() -> anyhow::Result<()> {
204
214
}
205
215
extractor. extract_without_semantics ( file, "no manifest found" ) ;
206
216
}
207
- let cargo_config = cfg. to_cargo_config ( ) ;
217
+ let cargo_config = cfg. to_cargo_config ( & cwd ( ) ? ) ;
208
218
for ( manifest, files) in map. values ( ) . filter ( |( _, files) | !files. is_empty ( ) ) {
209
219
if let Some ( ( ref db, ref vfs) ) = extractor. load_manifest ( manifest, & cargo_config) {
210
220
let semantics = Semantics :: new ( db) ;
0 commit comments