Created
March 1, 2017 18:42
-
-
Save luser/859206ae83767bbea821e832993e8b1c to your computer and use it in GitHub Desktop.
some rust with a compile error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let is_rustc = if filename.to_string_lossy().to_lowercase() == "rustc" { | |
// Sanity check that it's really rustc. | |
let child = creator.clone().new_command_sync(&executable) | |
.stdout(Stdio::piped()) | |
.stderr(Stdio::null()) | |
.args(&["--version"]) | |
.spawn().chain_err(|| { | |
format!("failed to execute {:?}", executable) | |
}); | |
let output = child.into_future().and_then(move |child| { | |
child.wait_with_output() | |
.chain_err(|| "failed to read child output") | |
}); | |
Box::new(output.map(|output| { | |
if output.status.success() { | |
if let Ok(stdout) = String::from_utf8(output.stdout) { | |
if stdout.starts_with("rustc ") { | |
return true; | |
} | |
} | |
} | |
false | |
})) | |
} else { | |
future::ok(false).boxed() | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment