From 9709bd39ca8a564d517372ee33304d34ac0b09bf Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Sat, 15 Jun 2019 02:42:56 +0600 Subject: Get rid of failure: ra_lsp_server & ra_project_model --- crates/ra_project_model/src/cargo_workspace.rs | 3 +-- crates/ra_project_model/src/lib.rs | 6 +++--- crates/ra_project_model/src/sysroot.rs | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_project_model/src') 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}; use cargo_metadata::{MetadataCommand, CargoOpt}; use ra_arena::{Arena, RawId, impl_arena_id}; use rustc_hash::FxHashMap; -use failure::format_err; use ra_db::Edition; use crate::Result; @@ -127,7 +126,7 @@ impl CargoWorkspace { if let Some(parent) = cargo_toml.parent() { meta.current_dir(parent); } - let meta = meta.exec().map_err(|e| format_err!("cargo metadata failed: {}", e))?; + let meta = meta.exec().map_err(|e| format!("cargo metadata failed: {}", e))?; let mut pkg_by_id = FxHashMap::default(); let mut packages = Arena::default(); 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::{ fs::File, io::BufReader, path::{Path, PathBuf}, + error::Error }; -use failure::bail; use rustc_hash::FxHashMap; use ra_db::{CrateGraph, FileId, Edition}; @@ -24,7 +24,7 @@ pub use crate::{ }; // FIXME use proper error enum -pub type Result = ::std::result::Result; +pub type Result = ::std::result::Result>; #[derive(Debug, Clone)] pub enum ProjectWorkspace { @@ -298,5 +298,5 @@ fn find_cargo_toml(path: &Path) -> Result { } curr = path.parent(); } - bail!("can't find Cargo.toml at {}", path.display()) + Err(format!("can't find Cargo.toml at {}", path.display()))? } 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 { .args(&["--print", "sysroot"]) .output()?; if !rustc_output.status.success() { - failure::bail!("failed to locate sysroot") + Err("failed to locate sysroot")? } let stdout = String::from_utf8(rustc_output.stdout)?; let sysroot_path = Path::new(stdout.trim()); let src = sysroot_path.join("lib/rustlib/src/rust/src"); if !src.exists() { - failure::bail!( + Err(format!( "can't load standard library from sysroot\n\ {:?}\n\ try running `rustup component add rust-src`", src, - ); + ))?; } let mut sysroot = Sysroot { crates: Arena::default() }; -- cgit v1.2.3