aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/lib.rs
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-11-14 22:20:27 +0000
committerSeivan Heidari <[email protected]>2019-11-14 22:20:27 +0000
commitc622413bc72ea56d5f62a16788d897cb61eca948 (patch)
tree9de3dbe8b5c935ed168efac4e70770e54fbe0714 /xtask/src/lib.rs
parent0525778a3ad590492b51cc11085d815f9bb8f92b (diff)
parentbbb022d3999b3038549ec6c309efb065231c896a (diff)
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r--xtask/src/lib.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index bae4c4650..bfee2f9c8 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -2,10 +2,10 @@
2 2
3pub mod codegen; 3pub mod codegen;
4 4
5use anyhow::Context;
6pub use anyhow::Result;
5use std::{ 7use std::{
6 env, 8 env, fs,
7 error::Error,
8 fs,
9 io::{Error as IoError, ErrorKind}, 9 io::{Error as IoError, ErrorKind},
10 path::{Path, PathBuf}, 10 path::{Path, PathBuf},
11 process::{Command, Output, Stdio}, 11 process::{Command, Output, Stdio},
@@ -13,8 +13,6 @@ use std::{
13 13
14use crate::codegen::Mode; 14use crate::codegen::Mode;
15 15
16pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
17
18const TOOLCHAIN: &str = "stable"; 16const TOOLCHAIN: &str = "stable";
19 17
20pub fn project_root() -> PathBuf { 18pub fn project_root() -> PathBuf {
@@ -69,7 +67,7 @@ pub fn run_rustfmt(mode: Mode) -> Result<()> {
69 .status() 67 .status()
70 { 68 {
71 Ok(status) if status.success() => (), 69 Ok(status) if status.success() => (),
72 _ => install_rustfmt()?, 70 _ => install_rustfmt().context("install rustfmt")?,
73 }; 71 };
74 72
75 if mode == Mode::Verify { 73 if mode == Mode::Verify {
@@ -112,7 +110,7 @@ pub fn run_clippy() -> Result<()> {
112 .status() 110 .status()
113 { 111 {
114 Ok(status) if status.success() => (), 112 Ok(status) if status.success() => (),
115 _ => install_clippy()?, 113 _ => install_clippy().context("install clippy")?,
116 }; 114 };
117 115
118 let allowed_lints = [ 116 let allowed_lints = [
@@ -162,9 +160,9 @@ where
162 let exec = args.next().unwrap(); 160 let exec = args.next().unwrap();
163 let mut cmd = Command::new(exec); 161 let mut cmd = Command::new(exec);
164 f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit())); 162 f(cmd.args(args).current_dir(proj_dir).stderr(Stdio::inherit()));
165 let output = cmd.output()?; 163 let output = cmd.output().with_context(|| format!("running `{}`", cmdline))?;
166 if !output.status.success() { 164 if !output.status.success() {
167 Err(format!("`{}` exited with {}", cmdline, output.status))?; 165 anyhow::bail!("`{}` exited with {}", cmdline, output.status);
168 } 166 }
169 Ok(output) 167 Ok(output)
170} 168}