aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_expand/src/builtin_macro.rs2
-rw-r--r--crates/ra_project_model/src/lib.rs12
-rw-r--r--crates/rust-analyzer/src/main_loop.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs4
-rw-r--r--crates/rust-analyzer/src/req.rs3
5 files changed, 14 insertions, 9 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs
index 3da137f2e..493cda2c4 100644
--- a/crates/ra_hir_expand/src/builtin_macro.rs
+++ b/crates/ra_hir_expand/src/builtin_macro.rs
@@ -358,7 +358,7 @@ fn env_expand(
358 // However, we cannot use an empty string here, because for 358 // However, we cannot use an empty string here, because for
359 // `include!(concat!(env!("OUT_DIR"), "/foo.rs"))` will become 359 // `include!(concat!(env!("OUT_DIR"), "/foo.rs"))` will become
360 // `include!("foo.rs"), which might go to infinite loop 360 // `include!("foo.rs"), which might go to infinite loop
361 let s = get_env_inner(db, arg_id, &key).unwrap_or("__RA_UNIMPLEMENTATED__".to_string()); 361 let s = get_env_inner(db, arg_id, &key).unwrap_or_else(|| "__RA_UNIMPLEMENTATED__".to_string());
362 let expanded = quote! { #s }; 362 let expanded = quote! { #s };
363 363
364 Ok((expanded, FragmentKind::Expr)) 364 Ok((expanded, FragmentKind::Expr))
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 03f2629da..731cbd291 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -285,8 +285,10 @@ impl ProjectWorkspace {
285 let mut env = Env::default(); 285 let mut env = Env::default();
286 let mut extern_source = ExternSource::default(); 286 let mut extern_source = ExternSource::default();
287 if let Some(out_dir) = &krate.out_dir { 287 if let Some(out_dir) = &krate.out_dir {
288 // FIXME: We probably mangle non UTF-8 paths here, figure out a better solution 288 // NOTE: cargo and rustc seem to hide non-UTF-8 strings from env! and option_env!()
289 env.set("OUT_DIR", out_dir.to_string_lossy().to_string()); 289 if let Some(out_dir) = out_dir.to_str().map(|s| s.to_owned()) {
290 env.set("OUT_DIR", out_dir);
291 }
290 if let Some(&extern_source_id) = extern_source_roots.get(out_dir) { 292 if let Some(&extern_source_id) = extern_source_roots.get(out_dir) {
291 extern_source.set_extern_path(&out_dir, extern_source_id); 293 extern_source.set_extern_path(&out_dir, extern_source_id);
292 } 294 }
@@ -402,8 +404,10 @@ impl ProjectWorkspace {
402 let mut env = Env::default(); 404 let mut env = Env::default();
403 let mut extern_source = ExternSource::default(); 405 let mut extern_source = ExternSource::default();
404 if let Some(out_dir) = &cargo[pkg].out_dir { 406 if let Some(out_dir) = &cargo[pkg].out_dir {
405 // FIXME: We probably mangle non UTF-8 paths here, figure out a better solution 407 // NOTE: cargo and rustc seem to hide non-UTF-8 strings from env! and option_env!()
406 env.set("OUT_DIR", out_dir.to_string_lossy().to_string()); 408 if let Some(out_dir) = out_dir.to_str().map(|s| s.to_owned()) {
409 env.set("OUT_DIR", out_dir);
410 }
407 if let Some(&extern_source_id) = extern_source_roots.get(out_dir) { 411 if let Some(&extern_source_id) = extern_source_roots.get(out_dir) {
408 extern_source.set_extern_path(&out_dir, extern_source_id); 412 extern_source.set_extern_path(&out_dir, extern_source_id);
409 } 413 }
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index fc4c77f8a..d993c4146 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -696,7 +696,7 @@ fn on_diagnostic_task(task: DiagnosticTask, msg_sender: &Sender<Message>, state:
696 let uri = match url_from_path_with_drive_lowercasing(&path) { 696 let uri = match url_from_path_with_drive_lowercasing(&path) {
697 Ok(uri) => uri, 697 Ok(uri) => uri,
698 Err(err) => { 698 Err(err) => {
699 log::error!("Couldn't convert path to url ({}): {:?}", err, path.to_string_lossy()); 699 log::error!("Couldn't convert path to url ({}): {}", err, path.display());
700 continue; 700 continue;
701 } 701 }
702 }; 702 };
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index 41d9fe344..10dfe1b6b 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -384,7 +384,7 @@ pub fn handle_runnables(
384 args: check_args, 384 args: check_args,
385 extra_args: Vec::new(), 385 extra_args: Vec::new(),
386 env: FxHashMap::default(), 386 env: FxHashMap::default(),
387 cwd: workspace_root.map(|root| root.to_string_lossy().to_string()), 387 cwd: workspace_root.map(|root| root.to_owned()),
388 }); 388 });
389 Ok(res) 389 Ok(res)
390} 390}
@@ -984,7 +984,7 @@ fn to_lsp_runnable(
984 m.insert("RUST_BACKTRACE".to_string(), "short".to_string()); 984 m.insert("RUST_BACKTRACE".to_string(), "short".to_string());
985 m 985 m
986 }, 986 },
987 cwd: world.workspace_root_for(file_id).map(|root| root.to_string_lossy().to_string()), 987 cwd: world.workspace_root_for(file_id).map(|root| root.to_owned()),
988 }) 988 })
989} 989}
990 990
diff --git a/crates/rust-analyzer/src/req.rs b/crates/rust-analyzer/src/req.rs
index b8b627e28..ae3448892 100644
--- a/crates/rust-analyzer/src/req.rs
+++ b/crates/rust-analyzer/src/req.rs
@@ -17,6 +17,7 @@ pub use lsp_types::{
17 SignatureHelp, SymbolKind, TextDocumentEdit, TextDocumentPositionParams, TextEdit, 17 SignatureHelp, SymbolKind, TextDocumentEdit, TextDocumentPositionParams, TextEdit,
18 WorkDoneProgressParams, WorkspaceEdit, WorkspaceSymbolParams, 18 WorkDoneProgressParams, WorkspaceEdit, WorkspaceSymbolParams,
19}; 19};
20use std::path::PathBuf;
20 21
21pub enum AnalyzerStatus {} 22pub enum AnalyzerStatus {}
22 23
@@ -141,7 +142,7 @@ pub struct Runnable {
141 pub args: Vec<String>, 142 pub args: Vec<String>,
142 pub extra_args: Vec<String>, 143 pub extra_args: Vec<String>,
143 pub env: FxHashMap<String, String>, 144 pub env: FxHashMap<String, String>,
144 pub cwd: Option<String>, 145 pub cwd: Option<PathBuf>,
145} 146}
146 147
147#[derive(Deserialize, Serialize, Debug)] 148#[derive(Deserialize, Serialize, Debug)]