diff --git a/src/cargo/core/compiler/compile_kind.rs b/src/cargo/core/compiler/compile_kind.rs index 31bafef64c0..adfa55fce17 100644 --- a/src/cargo/core/compiler/compile_kind.rs +++ b/src/cargo/core/compiler/compile_kind.rs @@ -143,7 +143,7 @@ impl CompileTarget { // with different paths always produce the same result. let path = Path::new(name) .canonicalize() - .with_context(|| anyhow::format_err!("target path {:?} is not a valid file", name))?; + .with_context(|| format!("target path {:?} is not a valid file", name))?; let name = path .into_os_string() diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 94a34064f1b..ec297fca61f 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -498,10 +498,8 @@ impl Manifest { self.unstable_features .require(Feature::test_dummy_unstable()) .with_context(|| { - anyhow::format_err!( - "the `im-a-teapot` manifest key is unstable and may \ - not work properly in England" - ) + "the `im-a-teapot` manifest key is unstable and may \ + not work properly in England" })?; } diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 08b4f14e919..2400c78327f 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -636,7 +636,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> { .ok_or_else(|| internal(format!("couldn't find source for `{}`", id)))?; let pkg = source .download(id) - .with_context(|| anyhow::format_err!("unable to get packages from source"))?; + .with_context(|| "unable to get packages from source")?; let (url, descriptor) = match pkg { MaybePackage::Ready(pkg) => { debug!("{} doesn't need a download", id); diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index aa8ffd962ea..723b624e8bf 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -87,7 +87,7 @@ impl PackageIdSpec { let i: Vec<_> = i.into_iter().collect(); let spec = PackageIdSpec::parse(spec).with_context(|| { let suggestion = lev_distance::closest_msg(spec, i.iter(), |id| id.name().as_str()); - anyhow::format_err!("invalid package ID specification: `{}`{}", spec, suggestion) + format!("invalid package ID specification: `{}`{}", spec, suggestion) })?; spec.query(i) } diff --git a/src/cargo/core/profiles.rs b/src/cargo/core/profiles.rs index 9feb3ab104a..a86f0899e58 100644 --- a/src/cargo/core/profiles.rs +++ b/src/cargo/core/profiles.rs @@ -1142,10 +1142,9 @@ fn get_config_profile(ws: &Workspace<'_>, name: &str) -> CargoResult PackageRegistry<'cfg> { // corresponding to this `dep`. self.ensure_loaded(dep.source_id(), Kind::Normal) .with_context(|| { - anyhow::format_err!( + format!( "failed to load source for dependency `{}`", dep.package_name() ) @@ -322,7 +322,7 @@ impl<'cfg> PackageRegistry<'cfg> { Ok(summary) }) .collect::>>() - .with_context(|| anyhow::format_err!("failed to resolve patches for `{}`", url))?; + .with_context(|| format!("failed to resolve patches for `{}`", url))?; let mut name_and_version = HashSet::new(); for summary in unlocked_summaries.iter() { @@ -390,7 +390,7 @@ impl<'cfg> PackageRegistry<'cfg> { let _p = profile::start(format!("updating: {}", source_id)); self.sources.get_mut(source_id).unwrap().update() })() - .with_context(|| anyhow::format_err!("Unable to update {}", source_id))?; + .with_context(|| format!("Unable to update {}", source_id))?; Ok(()) } @@ -542,7 +542,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> { // Ensure the requested source_id is loaded self.ensure_loaded(dep.source_id(), Kind::Normal) .with_context(|| { - anyhow::format_err!( + format!( "failed to load source for dependency `{}`", dep.package_name() ) diff --git a/src/cargo/core/resolver/dep_cache.rs b/src/cargo/core/resolver/dep_cache.rs index fe39013ae8b..91afa13f709 100644 --- a/src/cargo/core/resolver/dep_cache.rs +++ b/src/cargo/core/resolver/dep_cache.rs @@ -225,7 +225,7 @@ impl<'a> RegistryQueryer<'a> { .into_iter() .map(|(dep, features)| { let candidates = self.query(&dep).with_context(|| { - anyhow::format_err!( + format!( "failed to get `{}` as a dependency of {}", dep.package_name(), describe_path(&cx.parents.path_to_bottom(&candidate.package_id())), diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 7d5b9b73e98..d00c5e47e1c 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -1415,14 +1415,9 @@ impl WorkspaceRootConfig { Some(p) => p, None => return Ok(Vec::new()), }; - let res = glob(path) - .with_context(|| anyhow::format_err!("could not parse pattern `{}`", &path))?; + let res = glob(path).with_context(|| format!("could not parse pattern `{}`", &path))?; let res = res - .map(|p| { - p.with_context(|| { - anyhow::format_err!("unable to match path to pattern `{}`", &path) - }) - }) + .map(|p| p.with_context(|| format!("unable to match path to pattern `{}`", &path))) .collect::, _>>()?; Ok(res) } diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 13e29b062d2..76b6927519a 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -224,14 +224,12 @@ fn rm_rf(path: &Path, config: &Config) -> CargoResult<()> { config .shell() .verbose(|shell| shell.status("Removing", path.display()))?; - paths::remove_dir_all(path) - .with_context(|| anyhow::format_err!("could not remove build directory"))?; + paths::remove_dir_all(path).with_context(|| "could not remove build directory")?; } else if m.is_ok() { config .shell() .verbose(|shell| shell.status("Removing", path.display()))?; - paths::remove_file(path) - .with_context(|| anyhow::format_err!("failed to remove build artifact"))?; + paths::remove_file(path).with_context(|| "failed to remove build artifact")?; } Ok(()) } diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 3ccedcceb7f..1df7e56f532 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -357,7 +357,7 @@ fn install_one( td.into_path(); } - format_err!( + format!( "failed to compile `{}`, intermediate artifacts can be \ found at `{}`", pkg, @@ -422,7 +422,7 @@ fn install_one( let dst = dst.join(bin); config.shell().status("Installing", dst.display())?; fs::rename(&src, &dst).with_context(|| { - format_err!("failed to move `{}` to `{}`", src.display(), dst.display()) + format!("failed to move `{}` to `{}`", src.display(), dst.display()) })?; installed.bins.push(dst); successful_bins.insert(bin.to_string()); @@ -437,7 +437,7 @@ fn install_one( let dst = dst.join(bin); config.shell().status("Replacing", dst.display())?; fs::rename(&src, &dst).with_context(|| { - format_err!("failed to move `{}` to `{}`", src.display(), dst.display()) + format!("failed to move `{}` to `{}`", src.display(), dst.display()) })?; successful_bins.insert(bin.to_string()); } diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 5d60a6ef3bd..64b1d3620af 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -418,7 +418,7 @@ pub fn new(opts: &NewOptions, config: &Config) -> CargoResult<()> { }; mk(config, &mkopts).with_context(|| { - anyhow::format_err!( + format!( "Failed to create package `{}` at `{}`", name, path.display() @@ -502,7 +502,7 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> { }; mk(config, &mkopts).with_context(|| { - anyhow::format_err!( + format!( "Failed to create package `{}` at `{}`", name, path.display() diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index d6afeabf7bf..1056d73fdaa 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -123,7 +123,7 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult