diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-15 10:45:55 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-15 10:45:55 +0100 |
commit | 257a15b93942a1e38e561576af471a6a1e63bcff (patch) | |
tree | 3586eda54dab85be6d24325e597a1d8f060e36b7 /crates/ra_project_model/src | |
parent | 9dbf985df5515f4b9b40a7dcf74f916fa8d57ee3 (diff) | |
parent | 408e173bb9737f9484ca773ee57cc791f5c57e16 (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.rs | 3 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_project_model/src/sysroot.rs | 6 |
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}; | |||
3 | use cargo_metadata::{MetadataCommand, CargoOpt}; | 3 | use cargo_metadata::{MetadataCommand, CargoOpt}; |
4 | use ra_arena::{Arena, RawId, impl_arena_id}; | 4 | use ra_arena::{Arena, RawId, impl_arena_id}; |
5 | use rustc_hash::FxHashMap; | 5 | use rustc_hash::FxHashMap; |
6 | use failure::format_err; | ||
7 | use ra_db::Edition; | 6 | use ra_db::Edition; |
8 | 7 | ||
9 | use crate::Result; | 8 | use 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 | ||
11 | use failure::bail; | ||
12 | use rustc_hash::FxHashMap; | 12 | use rustc_hash::FxHashMap; |
13 | 13 | ||
14 | use ra_db::{CrateGraph, FileId, Edition}; | 14 | use 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 |
27 | pub type Result<T> = ::std::result::Result<T, ::failure::Error>; | 27 | pub type Result<T> = ::std::result::Result<T, Box<dyn Error + Send + Sync>>; |
28 | 28 | ||
29 | #[derive(Debug, Clone)] | 29 | #[derive(Debug, Clone)] |
30 | pub enum ProjectWorkspace { | 30 | pub 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() }; |