Skip to content

Commit cc70d60

Browse files
committed
Import anyhow::bail
1 parent c9ce0ec commit cc70d60

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/cargo/core/workspace.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::path::{Path, PathBuf};
55
use std::rc::Rc;
66
use std::slice;
77

8+
use anyhow::bail;
89
use glob::glob;
910
use log::debug;
1011
use url::Url;
@@ -152,7 +153,7 @@ impl<'cfg> Workspace<'cfg> {
152153
ws.target_dir = config.target_dir()?;
153154

154155
if manifest_path.is_relative() {
155-
anyhow::bail!(
156+
bail!(
156157
"manifest_path:{:?} is not an absolute path. Please provide an absolute path.",
157158
manifest_path
158159
)
@@ -523,7 +524,7 @@ impl<'cfg> Workspace<'cfg> {
523524
return Ok(Some(root_config.clone()));
524525
}
525526

526-
_ => anyhow::bail!(
527+
_ => bail!(
527528
"root of a workspace inferred but wasn't a root: {}",
528529
root_path.display()
529530
),
@@ -663,7 +664,7 @@ impl<'cfg> Workspace<'cfg> {
663664
if exclude {
664665
continue;
665666
}
666-
anyhow::bail!(
667+
bail!(
667668
"package `{}` is listed in workspace’s default-members \
668669
but is not a member.",
669670
path.display()
@@ -785,7 +786,7 @@ impl<'cfg> Workspace<'cfg> {
785786
MaybePackage::Virtual(_) => continue,
786787
};
787788
if let Some(prev) = names.insert(name, member) {
788-
anyhow::bail!(
789+
bail!(
789790
"two packages named `{}` in this workspace:\n\
790791
- {}\n\
791792
- {}",
@@ -810,7 +811,7 @@ impl<'cfg> Workspace<'cfg> {
810811
.collect();
811812
match roots.len() {
812813
1 => Ok(()),
813-
0 => anyhow::bail!(
814+
0 => bail!(
814815
"`package.workspace` configuration points to a crate \
815816
which is not configured with [workspace]: \n\
816817
configuration at: {}\n\
@@ -819,7 +820,7 @@ impl<'cfg> Workspace<'cfg> {
819820
self.root_manifest.as_ref().unwrap().display()
820821
),
821822
_ => {
822-
anyhow::bail!(
823+
bail!(
823824
"multiple workspace roots found in the same workspace:\n{}",
824825
roots
825826
.iter()
@@ -840,7 +841,7 @@ impl<'cfg> Workspace<'cfg> {
840841

841842
match root {
842843
Some(root) => {
843-
anyhow::bail!(
844+
bail!(
844845
"package `{}` is a member of the wrong workspace\n\
845846
expected: {}\n\
846847
actual: {}",
@@ -850,7 +851,7 @@ impl<'cfg> Workspace<'cfg> {
850851
);
851852
}
852853
None => {
853-
anyhow::bail!(
854+
bail!(
854855
"workspace member `{}` is not hierarchically below \
855856
the workspace root `{}`",
856857
member.display(),
@@ -907,7 +908,7 @@ impl<'cfg> Workspace<'cfg> {
907908
}
908909
}
909910
};
910-
anyhow::bail!(
911+
bail!(
911912
"current package believes it's in a workspace when it's not:\n\
912913
current: {}\n\
913914
workspace: {}\n\n{}\n\
@@ -963,7 +964,7 @@ impl<'cfg> Workspace<'cfg> {
963964
pub fn load(&self, manifest_path: &Path) -> CargoResult<Package> {
964965
match self.packages.maybe_get(manifest_path) {
965966
Some(&MaybePackage::Package(ref p)) => return Ok(p.clone()),
966-
Some(&MaybePackage::Virtual(_)) => anyhow::bail!("cannot load workspace root"),
967+
Some(&MaybePackage::Virtual(_)) => bail!("cannot load workspace root"),
967968
None => {}
968969
}
969970

@@ -1143,7 +1144,7 @@ impl<'cfg> Workspace<'cfg> {
11431144
&& !requested_features.all_features
11441145
&& requested_features.uses_default_features)
11451146
{
1146-
anyhow::bail!("cannot specify features for packages outside of workspace");
1147+
bail!("cannot specify features for packages outside of workspace");
11471148
}
11481149
// Add all members from the workspace so we can ensure `-p nonmember`
11491150
// is in the resolve graph.
@@ -1159,7 +1160,7 @@ impl<'cfg> Workspace<'cfg> {
11591160
.copied()
11601161
.collect();
11611162
// TODO: typo suggestions would be good here.
1162-
anyhow::bail!(
1163+
bail!(
11631164
"none of the selected packages contains these features: {}",
11641165
missing.join(", ")
11651166
);

0 commit comments

Comments
 (0)