33use std:: io:: { self , BufReader , Write } ;
44use std:: path:: { Component , Path } ;
55use std:: process:: { Command , Stdio } ;
6- use std:: { env , str} ;
6+ use std:: str;
77
8+ use anyhow:: { bail, Result } ;
89use cargo_metadata:: { Artifact , CargoOpt , Message , Metadata , MetadataCommand } ;
910use clap:: { App , AppSettings , Arg } ;
10- use failure:: bail;
1111use rustc_cfg:: Cfg ;
1212
1313pub use tool:: Tool ;
@@ -36,7 +36,7 @@ fn search<'p>(path: &'p Path, file: &str) -> Option<&'p Path> {
3636 path. ancestors ( ) . find ( |dir| dir. join ( file) . exists ( ) )
3737}
3838
39- fn parse < T > ( path : & Path ) -> Result < T , failure :: Error >
39+ fn parse < T > ( path : & Path ) -> Result < T >
4040where
4141 T : for < ' de > serde:: Deserialize < ' de > ,
4242{
5252impl Context {
5353 /* Constructors */
5454 /// Get a context structure from a built artifact.
55- fn from_artifact ( metadata : Metadata , artifact : & Artifact ) -> Result < Self , failure :: Error > {
55+ fn from_artifact ( metadata : Metadata , artifact : & Artifact ) -> Result < Self > {
5656 // Currently there is no clean way to get the target triple from cargo so we can only make
5757 // an approximation, we do this by extracting the target triple from the artifacts path.
5858 // For more info on the path structure see: https://doc.rust-lang.org/cargo/guide/build-cache.html
@@ -81,7 +81,7 @@ impl Context {
8181
8282 /// Get a context structure from a provided target flag, used when cargo
8383 /// was not used to build the binary.
84- fn from_flag ( metadata : Metadata , target_flag : Option < & str > ) -> Result < Self , failure :: Error > {
84+ fn from_flag ( metadata : Metadata , target_flag : Option < & str > ) -> Result < Self > {
8585 let meta = rustc_version:: version_meta ( ) ?;
8686 let host = meta. host ;
8787 let host_target_name = host;
@@ -106,8 +106,8 @@ impl Context {
106106 Self :: from_target_name ( target_name)
107107 }
108108
109- fn from_target_name ( target_name : & str ) -> Result < Self , failure :: Error > {
110- let cfg = Cfg :: of ( target_name) ?;
109+ fn from_target_name ( target_name : & str ) -> Result < Self > {
110+ let cfg = Cfg :: of ( target_name) . map_err ( |e| e . compat ( ) ) ?;
111111
112112 Ok ( Context {
113113 cfg,
@@ -167,9 +167,7 @@ impl<'a> BuildType<'a> {
167167 }
168168}
169169
170- fn determine_artifact (
171- matches : & clap:: ArgMatches ,
172- ) -> Result < ( Metadata , Option < Artifact > ) , failure:: Error > {
170+ fn determine_artifact ( matches : & clap:: ArgMatches ) -> Result < ( Metadata , Option < Artifact > ) > {
173171 let verbose = matches. is_present ( "verbose" ) ;
174172 let target_flag = matches. value_of ( "target" ) ;
175173
@@ -281,7 +279,7 @@ fn determine_artifact(
281279 Ok ( ( metadata, wanted_artifact) )
282280}
283281
284- pub fn run ( tool : Tool , examples : Option < & str > ) -> Result < i32 , failure :: Error > {
282+ pub fn run ( tool : Tool , examples : Option < & str > ) -> Result < i32 > {
285283 let name = tool. name ( ) ;
286284 let about = format ! (
287285 "Proxy for the `llvm-{}` tool shipped with the Rust toolchain." ,
0 commit comments