Skip to content

Commit beaaefd

Browse files
committed
Use CargoResult pervasively
1 parent fc05277 commit beaaefd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cargo/ops/fix.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use std::path::{Path, PathBuf};
4444
use std::process::{self, ExitStatus};
4545
use std::{env, fs, str};
4646

47-
use anyhow::{bail, Context, Error};
47+
use anyhow::{bail, Context as _};
4848
use cargo_util::{exit_status_to_string, is_simple_exit_code, paths, ProcessBuilder};
4949
use log::{debug, trace, warn};
5050
use rustfix::diagnostics::Diagnostic;
@@ -443,7 +443,7 @@ fn rustfix_crate(
443443
filename: &Path,
444444
args: &FixArgs,
445445
config: &Config,
446-
) -> Result<FixedCrate, Error> {
446+
) -> CargoResult<FixedCrate> {
447447
if !args.can_run_rustfix(config)? {
448448
// This fix should not be run. Skipping...
449449
return Ok(FixedCrate::default());
@@ -548,7 +548,7 @@ fn rustfix_and_fix(
548548
rustc: &ProcessBuilder,
549549
filename: &Path,
550550
config: &Config,
551-
) -> Result<(), Error> {
551+
) -> CargoResult<()> {
552552
// If not empty, filter by these lints.
553553
// TODO: implement a way to specify this.
554554
let only = HashSet::new();
@@ -695,7 +695,7 @@ fn exit_with(status: ExitStatus) -> ! {
695695
process::exit(status.code().unwrap_or(3));
696696
}
697697

698-
fn log_failed_fix(stderr: &[u8], status: ExitStatus) -> Result<(), Error> {
698+
fn log_failed_fix(stderr: &[u8], status: ExitStatus) -> CargoResult<()> {
699699
let stderr = str::from_utf8(stderr).context("failed to parse rustc stderr as utf-8")?;
700700

701701
let diagnostics = stderr
@@ -776,12 +776,12 @@ struct FixArgs {
776776
}
777777

778778
impl FixArgs {
779-
fn get() -> Result<FixArgs, Error> {
779+
fn get() -> CargoResult<FixArgs> {
780780
Self::from_args(env::args_os())
781781
}
782782

783783
// This is a separate function so that we can use it in tests.
784-
fn from_args(argv: impl IntoIterator<Item = OsString>) -> Result<Self, Error> {
784+
fn from_args(argv: impl IntoIterator<Item = OsString>) -> CargoResult<Self> {
785785
let mut argv = argv.into_iter();
786786
let mut rustc = argv
787787
.nth(1)
@@ -792,7 +792,7 @@ impl FixArgs {
792792
let mut other = Vec::new();
793793
let mut format_args = Vec::new();
794794

795-
let mut handle_arg = |arg: OsString| -> Result<(), Error> {
795+
let mut handle_arg = |arg: OsString| -> CargoResult<()> {
796796
let path = PathBuf::from(arg);
797797
if path.extension().and_then(|s| s.to_str()) == Some("rs") && path.exists() {
798798
file = Some(path);

0 commit comments

Comments
 (0)