@@ -7,7 +7,6 @@ use std::env;
77use std:: ffi:: OsStr ;
88use std:: ffi:: OsString ;
99use std:: fs;
10- use std:: io:: ErrorKind ;
1110use std:: iter;
1211use std:: path:: { Path , PathBuf } ;
1312use std:: process:: { Command , Stdio } ;
@@ -1817,26 +1816,25 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18171816 cmd. arg ( "--gdb" ) . arg ( gdb) ;
18181817 }
18191818
1820- let run = |cmd : & mut Command | {
1821- cmd. output ( ) . map ( |output| {
1822- String :: from_utf8_lossy ( & output. stdout )
1823- . lines ( )
1824- . next ( )
1825- . unwrap_or_else ( || panic ! ( "{:?} failed {:?}" , cmd, output) )
1826- . to_string ( )
1827- } )
1828- } ;
1829-
18301819 let lldb_exe = builder. config . lldb . clone ( ) . unwrap_or_else ( || PathBuf :: from ( "lldb" ) ) ;
18311820 let lldb_version = Command :: new ( & lldb_exe)
18321821 . arg ( "--version" )
18331822 . output ( )
1834- . and_then ( |output| {
1835- if output. status . success ( ) { Ok ( output) } else { Err ( ErrorKind :: Other . into ( ) ) }
1823+ . map ( |output| {
1824+ ( String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) , output. status . success ( ) )
18361825 } )
1837- . map ( |output| String :: from_utf8_lossy ( & output . stdout ) . to_string ( ) )
1838- . ok ( ) ;
1826+ . ok ( )
1827+ . and_then ( | ( output , success ) | if success { Some ( output ) } else { None } ) ;
18391828 if let Some ( ref vers) = lldb_version {
1829+ let run = |cmd : & mut Command | {
1830+ cmd. output ( ) . map ( |output| {
1831+ String :: from_utf8_lossy ( & output. stdout )
1832+ . lines ( )
1833+ . next ( )
1834+ . unwrap_or_else ( || panic ! ( "{:?} failed {:?}" , cmd, output) )
1835+ . to_string ( )
1836+ } )
1837+ } ;
18401838 cmd. arg ( "--lldb-version" ) . arg ( vers) ;
18411839 let lldb_python_dir = run ( Command :: new ( & lldb_exe) . arg ( "-P" ) ) . ok ( ) ;
18421840 if let Some ( ref dir) = lldb_python_dir {
0 commit comments