@@ -23,6 +23,7 @@ pub type CargoResult<T> = Result<T, Box<CargoError>>;
23
23
pub trait CargoError : Error + Send + ' static {
24
24
fn is_human ( & self ) -> bool { false }
25
25
fn cargo_cause ( & self ) -> Option < & CargoError > { None }
26
+ fn as_error ( & self ) -> & Error where Self : Sized { self as & Error }
26
27
}
27
28
28
29
impl Error for Box < CargoError > {
@@ -110,13 +111,13 @@ pub struct ProcessError {
110
111
pub desc : String ,
111
112
pub exit : Option < ExitStatus > ,
112
113
pub output : Option < Output > ,
113
- cause : Option < Box < Error + Send > > ,
114
+ cause : Option < Box < CargoError > > ,
114
115
}
115
116
116
117
impl Error for ProcessError {
117
118
fn description ( & self ) -> & str { & self . desc }
118
119
fn cause ( & self ) -> Option < & Error > {
119
- self . cause . as_ref ( ) . map ( |e| & * * e as & Error )
120
+ self . cause . as_ref ( ) . map ( |e| e . as_error ( ) )
120
121
}
121
122
}
122
123
@@ -375,7 +376,7 @@ impl CargoError for str::ParseBoolError {}
375
376
// Construction helpers
376
377
377
378
pub fn process_error ( msg : & str ,
378
- cause : Option < Box < Error + Send > > ,
379
+ cause : Option < Box < CargoError > > ,
379
380
status : Option < & ExitStatus > ,
380
381
output : Option < & Output > ) -> ProcessError
381
382
{
0 commit comments