diff options
author | Aleksey Kladov <[email protected]> | 2020-06-30 21:12:27 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-06-30 21:12:27 +0100 |
commit | cec92407f412b3c8e01d17eab84101a2b858e59e (patch) | |
tree | 5b84228ac444c9ef918ca21ff0ab5e01f9f77028 /crates | |
parent | bad0b9aa23d2e72366922ec00d50043db0bae338 (diff) |
Don't crash on empty out_dirs with older cargos
closes #5125
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 3b124020d..47a1d393d 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -1,6 +1,11 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use std::{ffi::OsStr, ops, path::Path, process::Command}; | 3 | use std::{ |
4 | ffi::OsStr, | ||
5 | ops, | ||
6 | path::{Path, PathBuf}, | ||
7 | process::Command, | ||
8 | }; | ||
4 | 9 | ||
5 | use anyhow::{Context, Result}; | 10 | use anyhow::{Context, Result}; |
6 | use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; | 11 | use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; |
@@ -308,9 +313,13 @@ pub fn load_extern_resources( | |||
308 | if let Ok(message) = message { | 313 | if let Ok(message) = message { |
309 | match message { | 314 | match message { |
310 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { | 315 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { |
311 | let out_dir = AbsPathBuf::assert(out_dir); | 316 | // cargo_metadata crate returns default (empty) path for |
312 | res.out_dirs.insert(package_id.clone(), out_dir); | 317 | // older cargos, which is not absolute, so work around that. |
313 | res.cfgs.insert(package_id, cfgs); | 318 | if out_dir != PathBuf::default() { |
319 | let out_dir = AbsPathBuf::assert(out_dir); | ||
320 | res.out_dirs.insert(package_id.clone(), out_dir); | ||
321 | res.cfgs.insert(package_id, cfgs); | ||
322 | } | ||
314 | } | 323 | } |
315 | Message::CompilerArtifact(message) => { | 324 | Message::CompilerArtifact(message) => { |
316 | if message.target.kind.contains(&"proc-macro".to_string()) { | 325 | if message.target.kind.contains(&"proc-macro".to_string()) { |