diff options
author | Muhammad Mominul Huque <[email protected]> | 2019-06-14 21:42:56 +0100 |
---|---|---|
committer | Muhammad Mominul Huque <[email protected]> | 2019-06-14 21:42:56 +0100 |
commit | 9709bd39ca8a564d517372ee33304d34ac0b09bf (patch) | |
tree | 4d12b93f2aab3a85898099c2308d364501946dbb /crates/ra_project_model | |
parent | a931fb1ef633473e272bb3f9ba86968dd90f44a7 (diff) |
Get rid of failure: ra_lsp_server & ra_project_model
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r-- | crates/ra_project_model/Cargo.toml | 2 | ||||
-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 |
4 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index cf4adf35c..c1a91d950 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml | |||
@@ -9,8 +9,6 @@ log = "0.4.5" | |||
9 | rustc-hash = "1.0" | 9 | rustc-hash = "1.0" |
10 | relative-path = "0.4.0" | 10 | relative-path = "0.4.0" |
11 | 11 | ||
12 | failure = "0.1.4" | ||
13 | |||
14 | walkdir = "2.2.7" | 12 | walkdir = "2.2.7" |
15 | 13 | ||
16 | cargo_metadata = "0.7.0" | 14 | cargo_metadata = "0.7.0" |
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 8b87aa7bd..d6eb824a3 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() }; |