aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-06-15 10:45:55 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-06-15 10:45:55 +0100
commit257a15b93942a1e38e561576af471a6a1e63bcff (patch)
tree3586eda54dab85be6d24325e597a1d8f060e36b7 /crates/ra_project_model/src
parent9dbf985df5515f4b9b40a7dcf74f916fa8d57ee3 (diff)
parent408e173bb9737f9484ca773ee57cc791f5c57e16 (diff)
Merge #1404
1404: Fight down failures! r=matklad a=mominul issue #1400 Now only `ra_tools` crate depends on `failure`, should I also fight those? :grin: Co-authored-by: Muhammad Mominul Huque <[email protected]>
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs3
-rw-r--r--crates/ra_project_model/src/lib.rs6
-rw-r--r--crates/ra_project_model/src/sysroot.rs6
3 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 5a1657788..d5ebf2c7a 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -3,7 +3,6 @@ use std::path::{Path, PathBuf};
3use cargo_metadata::{MetadataCommand, CargoOpt}; 3use cargo_metadata::{MetadataCommand, CargoOpt};
4use ra_arena::{Arena, RawId, impl_arena_id}; 4use ra_arena::{Arena, RawId, impl_arena_id};
5use rustc_hash::FxHashMap; 5use rustc_hash::FxHashMap;
6use failure::format_err;
7use ra_db::Edition; 6use ra_db::Edition;
8 7
9use crate::Result; 8use crate::Result;
@@ -127,7 +126,7 @@ impl CargoWorkspace {
127 if let Some(parent) = cargo_toml.parent() { 126 if let Some(parent) = cargo_toml.parent() {
128 meta.current_dir(parent); 127 meta.current_dir(parent);
129 } 128 }
130 let meta = meta.exec().map_err(|e| format_err!("cargo metadata failed: {}", e))?; 129 let meta = meta.exec().map_err(|e| format!("cargo metadata failed: {}", e))?;
131 let mut pkg_by_id = FxHashMap::default(); 130 let mut pkg_by_id = FxHashMap::default();
132 let mut packages = Arena::default(); 131 let mut packages = Arena::default();
133 let mut targets = Arena::default(); 132 let mut targets = Arena::default();
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 4ae7f685c..a3af153f1 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -6,9 +6,9 @@ use std::{
6 fs::File, 6 fs::File,
7 io::BufReader, 7 io::BufReader,
8 path::{Path, PathBuf}, 8 path::{Path, PathBuf},
9 error::Error
9}; 10};
10 11
11use failure::bail;
12use rustc_hash::FxHashMap; 12use rustc_hash::FxHashMap;
13 13
14use ra_db::{CrateGraph, FileId, Edition}; 14use ra_db::{CrateGraph, FileId, Edition};
@@ -24,7 +24,7 @@ pub use crate::{
24}; 24};
25 25
26// FIXME use proper error enum 26// FIXME use proper error enum
27pub type Result<T> = ::std::result::Result<T, ::failure::Error>; 27pub type Result<T> = ::std::result::Result<T, Box<dyn Error + Send + Sync>>;
28 28
29#[derive(Debug, Clone)] 29#[derive(Debug, Clone)]
30pub enum ProjectWorkspace { 30pub enum ProjectWorkspace {
@@ -298,5 +298,5 @@ fn find_cargo_toml(path: &Path) -> Result<PathBuf> {
298 } 298 }
299 curr = path.parent(); 299 curr = path.parent();
300 } 300 }
301 bail!("can't find Cargo.toml at {}", path.display()) 301 Err(format!("can't find Cargo.toml at {}", path.display()))?
302} 302}
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index 72ccb61a7..9e0d8aaac 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -38,18 +38,18 @@ impl Sysroot {
38 .args(&["--print", "sysroot"]) 38 .args(&["--print", "sysroot"])
39 .output()?; 39 .output()?;
40 if !rustc_output.status.success() { 40 if !rustc_output.status.success() {
41 failure::bail!("failed to locate sysroot") 41 Err("failed to locate sysroot")?
42 } 42 }
43 let stdout = String::from_utf8(rustc_output.stdout)?; 43 let stdout = String::from_utf8(rustc_output.stdout)?;
44 let sysroot_path = Path::new(stdout.trim()); 44 let sysroot_path = Path::new(stdout.trim());
45 let src = sysroot_path.join("lib/rustlib/src/rust/src"); 45 let src = sysroot_path.join("lib/rustlib/src/rust/src");
46 if !src.exists() { 46 if !src.exists() {
47 failure::bail!( 47 Err(format!(
48 "can't load standard library from sysroot\n\ 48 "can't load standard library from sysroot\n\
49 {:?}\n\ 49 {:?}\n\
50 try running `rustup component add rust-src`", 50 try running `rustup component add rust-src`",
51 src, 51 src,
52 ); 52 ))?;
53 } 53 }
54 54
55 let mut sysroot = Sysroot { crates: Arena::default() }; 55 let mut sysroot = Sysroot { crates: Arena::default() };