}
};
- let result = match cargo::ops::fix_maybe_exec_rustc(&config) {
- Ok(true) => Ok(()),
- Ok(false) => {
- let _token = cargo::util::job::setup();
- cli::main(&mut config)
- }
- Err(e) => Err(CliError::from(e)),
+ let result = if let Some(lock_addr) = cargo::ops::fix_get_proxy_lock_addr() {
+ cargo::ops::fix_exec_rustc(&config, &lock_addr).map_err(|e| CliError::from(e))
+ } else {
+ let _token = cargo::util::job::setup();
+ cli::main(&mut config)
};
match result {
Ok(())
}
+/// Provide the lock address when running in proxy mode
+///
+/// Returns `None` if `fix` is not being run (not in proxy mode). Returns
+/// `Some(...)` if in `fix` proxy mode
+pub fn fix_get_proxy_lock_addr() -> Option<String> {
+ env::var(FIX_ENV).ok()
+}
+
/// Entry point for `cargo` running as a proxy for `rustc`.
///
/// This is called every time `cargo` is run to check if it is in proxy mode.
///
-/// Returns `false` if `fix` is not being run (not in proxy mode). Returns
-/// `true` if in `fix` proxy mode, and the fix was complete without any
-/// warnings or errors. If there are warnings or errors, this does not return,
+/// If there are warnings or errors, this does not return,
/// and the process exits with the corresponding `rustc` exit code.
-pub fn fix_maybe_exec_rustc(config: &Config) -> CargoResult<bool> {
- let lock_addr = match env::var(FIX_ENV) {
- Ok(s) => s,
- Err(_) => return Ok(false),
- };
-
+///
+/// See [`fix_proxy_lock_addr`]
+pub fn fix_exec_rustc(config: &Config, lock_addr: &str) -> CargoResult<()> {
let args = FixArgs::get()?;
trace!("cargo-fix as rustc got file {:?}", args.file);
// any. If stderr is empty then there's no need for the final exec at
// the end, we just bail out here.
if output.status.success() && output.stderr.is_empty() {
- return Ok(true);
+ return Ok(());
}
// Otherwise, if our rustc just failed, then that means that we broke the
pub use self::cargo_run::run;
pub use self::cargo_test::{run_benches, run_tests, TestOptions};
pub use self::cargo_uninstall::uninstall;
-pub use self::fix::{fix, fix_maybe_exec_rustc, FixOptions};
+pub use self::fix::{fix, fix_exec_rustc, fix_get_proxy_lock_addr, FixOptions};
pub use self::lockfile::{load_pkg_lockfile, resolve_to_string, write_pkg_lockfile};
pub use self::registry::HttpTimeout;
pub use self::registry::{configure_http_handle, http_handle, http_handle_and_timeout};