Skip to content

Commit 795aab1

Browse files
committed
custom_build.rs: Import anyhow::bail
1 parent b1684e2 commit 795aab1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cargo/core/compiler/custom_build.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::core::{profiles::ProfileRoot, PackageId};
66
use crate::util::errors::CargoResult;
77
use crate::util::machine_message::{self, Message};
88
use crate::util::{internal, profile};
9-
use anyhow::Context as _;
9+
use anyhow::{bail, Context as _};
1010
use cargo_platform::Cfg;
1111
use cargo_util::paths;
1212
use std::collections::hash_map::{Entry, HashMap};
@@ -543,7 +543,7 @@ impl BuildOutput {
543543
let (key, value) = match (key, value) {
544544
(Some(a), Some(b)) => (a, b.trim_end()),
545545
// Line started with `cargo:` but didn't match `key=value`.
546-
_ => anyhow::bail!("Wrong output in {}: `{}`", whence, line),
546+
_ => bail!("Wrong output in {}: `{}`", whence, line),
547547
};
548548

549549
// This will rewrite paths if the target directory has been moved.
@@ -552,7 +552,7 @@ impl BuildOutput {
552552
script_out_dir.to_str().unwrap(),
553553
);
554554

555-
// Keep in sync with TargetConfig::new.
555+
// Keep in sync with TargetConfig::parse_links_overrides.
556556
match key {
557557
"rustc-flags" => {
558558
let (paths, links) = BuildOutput::parse_rustc_flags(&value, &whence)?;
@@ -632,7 +632,7 @@ impl BuildOutput {
632632
} else {
633633
// Setting RUSTC_BOOTSTRAP would change the behavior of the crate.
634634
// Abort with an error.
635-
anyhow::bail!("Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\
635+
bail!("Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\
636636
note: Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.\n\
637637
help: If you're sure you want to do this in your project, set the environment variable `RUSTC_BOOTSTRAP={}` before running cargo instead.",
638638
val,
@@ -683,7 +683,7 @@ impl BuildOutput {
683683
if value.is_empty() {
684684
value = match flags_iter.next() {
685685
Some(v) => v,
686-
None => anyhow::bail! {
686+
None => bail! {
687687
"Flag in rustc-flags has no value in {}: {}",
688688
whence,
689689
value
@@ -699,7 +699,7 @@ impl BuildOutput {
699699
_ => unreachable!(),
700700
};
701701
} else {
702-
anyhow::bail!(
702+
bail!(
703703
"Only `-l` and `-L` flags are allowed in {}: `{}`",
704704
whence,
705705
value
@@ -715,7 +715,7 @@ impl BuildOutput {
715715
let val = iter.next();
716716
match (name, val) {
717717
(Some(n), Some(v)) => Ok((n.to_owned(), v.to_owned())),
718-
_ => anyhow::bail!("Variable rustc-env has no value in {}: {}", whence, value),
718+
_ => bail!("Variable rustc-env has no value in {}: {}", whence, value),
719719
}
720720
}
721721
}

0 commit comments

Comments
 (0)