From 91510db6d8d89e8907a0cbf33e6068259b3bc88b Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Sun, 16 Jun 2019 00:48:50 +0600 Subject: Fall down of failures --- crates/ra_tools/Cargo.toml | 3 +-- crates/ra_tools/src/bin/pre-commit.rs | 7 ++++--- crates/ra_tools/src/lib.rs | 14 +++++++------- crates/ra_tools/src/main.rs | 11 ++++------- 4 files changed, 16 insertions(+), 19 deletions(-) (limited to 'crates') diff --git a/crates/ra_tools/Cargo.toml b/crates/ra_tools/Cargo.toml index 35ea3231b..a34c8d482 100644 --- a/crates/ra_tools/Cargo.toml +++ b/crates/ra_tools/Cargo.toml @@ -6,8 +6,7 @@ authors = ["rust-analyzer developers"] publish = false [dependencies] -teraron = "0.0.1" +teraron = { git = "https://github.com/mominul/teraron.git", branch = "failure" } walkdir = "2.1.3" itertools = "0.8.0" clap = "2.32.0" -failure = "0.1.4" diff --git a/crates/ra_tools/src/bin/pre-commit.rs b/crates/ra_tools/src/bin/pre-commit.rs index c514e992b..95bb55cae 100644 --- a/crates/ra_tools/src/bin/pre-commit.rs +++ b/crates/ra_tools/src/bin/pre-commit.rs @@ -1,7 +1,5 @@ use std::process::Command; -use failure::bail; - use ra_tools::{Result, run_rustfmt, run, project_root, Overwrite}; fn main() -> Result<()> { @@ -19,7 +17,10 @@ fn update_staged() -> Result<()> { .current_dir(&root) .output()?; if !output.status.success() { - bail!("`git diff --diff-filter=MAR --name-only --cached` exited with {}", output.status); + Err(format!( + "`git diff --diff-filter=MAR --name-only --cached` exited with {}", + output.status + ))?; } for line in String::from_utf8(output.stdout)?.lines() { run(&format!("git update-index --add {}", root.join(line).to_string_lossy()), ".")?; diff --git a/crates/ra_tools/src/lib.rs b/crates/ra_tools/src/lib.rs index 61f6b08cd..821209567 100644 --- a/crates/ra_tools/src/lib.rs +++ b/crates/ra_tools/src/lib.rs @@ -3,15 +3,15 @@ use std::{ collections::HashMap, path::{Path, PathBuf}, process::{Command, Output, Stdio}, - io::{Error, ErrorKind} + io::{Error as IoError, ErrorKind}, + error::Error }; -use failure::bail; use itertools::Itertools; pub use teraron::{Mode, Overwrite, Verify}; -pub type Result = std::result::Result; +pub type Result = std::result::Result>; pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron"; const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; @@ -128,7 +128,7 @@ pub fn install_format_hook() -> Result<()> { fs::copy("./target/debug/pre-commit", result_path)?; } } else { - return Err(Error::new(ErrorKind::AlreadyExists, "Git hook already created").into()); + Err(IoError::new(ErrorKind::AlreadyExists, "Git hook already created"))?; } Ok(()) } @@ -224,7 +224,7 @@ where f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit())); let output = cmd.output()?; if !output.status.success() { - bail!("`{}` exited with {}", cmdline, output.status); + Err(format!("`{}` exited with {}", cmdline, output.status))?; } Ok(output) } @@ -256,11 +256,11 @@ fn tests_from_dir(dir: &Path) -> Result { for (_, test) in collect_tests(&text) { if test.ok { if let Some(old_test) = res.ok.insert(test.name.clone(), test) { - bail!("Duplicate test: {}", old_test.name) + Err(format!("Duplicate test: {}", old_test.name))? } } else { if let Some(old_test) = res.err.insert(test.name.clone(), test) { - bail!("Duplicate test: {}", old_test.name) + Err(format!("Duplicate test: {}", old_test.name))? } } } diff --git a/crates/ra_tools/src/main.rs b/crates/ra_tools/src/main.rs index 285071ea5..846e0223e 100644 --- a/crates/ra_tools/src/main.rs +++ b/crates/ra_tools/src/main.rs @@ -1,6 +1,5 @@ use clap::{App, SubCommand}; use core::str; -use failure::bail; use ra_tools::{ generate, gen_tests, install_format_hook, run, run_with_output, run_rustfmt, Overwrite, Result, run_fuzzer, run_clippy, @@ -64,10 +63,8 @@ fn verify_installed_extensions() -> Result<()> { run_with_output(r"code --list-extensions", ".")? }; if !str::from_utf8(&exts.stdout)?.contains("ra-lsp") { - bail!( - "Could not install the Visual Studio Code extension. Please make sure you \ - have at least NodeJS 10.x installed and try again." - ); + Err("Could not install the Visual Studio Code extension. Please make sure you \ + have at least NodeJS 10.x installed and try again.")?; } Ok(()) } @@ -79,7 +76,7 @@ fn fix_path_for_mac() -> Result<()> { const ROOT_DIR: &str = ""; let home_dir = match env::var("HOME") { Ok(home) => home, - Err(e) => bail!("Failed getting HOME from environment with error: {}.", e), + Err(e) => Err(format!("Failed getting HOME from environment with error: {}.", e))?, }; [ROOT_DIR, &home_dir] @@ -93,7 +90,7 @@ fn fix_path_for_mac() -> Result<()> { if !vscode_path.is_empty() { let vars = match env::var_os("PATH") { Some(path) => path, - None => bail!("Could not get PATH variable from env."), + None => Err("Could not get PATH variable from env.")?, }; let mut paths = env::split_paths(&vars).collect::>(); -- cgit v1.2.3 From d3e74bfd2c1f7dca2054e1cfdc7aa312c9d12c98 Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Mon, 17 Jun 2019 00:07:31 +0600 Subject: Update teraron version --- crates/ra_tools/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_tools/Cargo.toml b/crates/ra_tools/Cargo.toml index a34c8d482..9c5430992 100644 --- a/crates/ra_tools/Cargo.toml +++ b/crates/ra_tools/Cargo.toml @@ -6,7 +6,7 @@ authors = ["rust-analyzer developers"] publish = false [dependencies] -teraron = { git = "https://github.com/mominul/teraron.git", branch = "failure" } +teraron = "0.1.0" walkdir = "2.1.3" itertools = "0.8.0" clap = "2.32.0" -- cgit v1.2.3