@@ -7,6 +7,7 @@ use log::{info, warn};
77use ra_ap_hir:: Semantics ;
88use ra_ap_ide_db:: line_index:: { LineCol , LineIndex } ;
99use ra_ap_ide_db:: RootDatabase ;
10+ use ra_ap_paths:: { AbsPathBuf , Utf8PathBuf } ;
1011use ra_ap_project_model:: { CargoConfig , ProjectManifest } ;
1112use ra_ap_vfs:: Vfs ;
1213use rust_analyzer:: { ParseResult , RustAnalyzer } ;
@@ -161,6 +162,15 @@ impl<'a> Extractor<'a> {
161162 }
162163}
163164
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+
164174fn main ( ) -> anyhow:: Result < ( ) > {
165175 let start = Instant :: now ( ) ;
166176 let mut cfg = config:: Config :: extract ( ) . context ( "failed to load configuration" ) ?;
@@ -204,7 +214,7 @@ fn main() -> anyhow::Result<()> {
204214 }
205215 extractor. extract_without_semantics ( file, "no manifest found" ) ;
206216 }
207- let cargo_config = cfg. to_cargo_config ( ) ;
217+ let cargo_config = cfg. to_cargo_config ( & cwd ( ) ? ) ;
208218 for ( manifest, files) in map. values ( ) . filter ( |( _, files) | !files. is_empty ( ) ) {
209219 if let Some ( ( ref db, ref vfs) ) = extractor. load_manifest ( manifest, & cargo_config) {
210220 let semantics = Semantics :: new ( db) ;
0 commit comments