Skip to content

Commit b425030

Browse files
committed
Auto merge of #13480 - Cerber-Ursi:workspace-error-shows-path, r=epage
Error messages when collecting workspace members now mention the workspace root location Fixes #13394 ### What does this PR try to resolve? This is a small tweak in error messages for workspaces, with intention to make it easier for users who accidentally created some unwanted workspace and then was surprised by the error coming seemingly out of nowhere. The exact inspiration for the change was [this comment](https://users.rust-lang.org/t/cargo-using-wrong-directory/107126/9?u=cerber-ursi) in discussion on URLO. ### How should we test and review this PR? This is a simple change in error messages, so the existing test suite should probably be enough. Requests for changing the text further are welcome, of course.
2 parents e08a813 + 51c8e0e commit b425030

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/cargo/core/workspace.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,10 @@ impl<'gctx> Workspace<'gctx> {
697697
self.find_path_deps(&path.join("Cargo.toml"), &root_manifest_path, false)
698698
.with_context(|| {
699699
format!(
700-
"failed to load manifest for workspace member `{}`",
701-
path.display()
700+
"failed to load manifest for workspace member `{}`\n\
701+
referenced by workspace at `{}`",
702+
path.display(),
703+
root_manifest_path.display()
702704
)
703705
})?;
704706
}
@@ -722,9 +724,10 @@ impl<'gctx> Workspace<'gctx> {
722724
continue;
723725
}
724726
bail!(
725-
"package `{}` is listed in workspace’s default-members \
726-
but is not a member.",
727-
path.display()
727+
"package `{}` is listed in default-members but is not a member\n\
728+
for workspace at {}.",
729+
path.display(),
730+
root_manifest_path.display()
728731
)
729732
}
730733
self.default_members.push(manifest_path)

tests/testsuite/workspaces.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ fn invalid_members() {
438438
.with_stderr(
439439
"\
440440
[ERROR] failed to load manifest for workspace member `[..]/foo`
441+
referenced by workspace at `[..]/foo/Cargo.toml`
441442
442443
Caused by:
443444
failed to read `[..]foo/foo/Cargo.toml`
@@ -910,8 +911,8 @@ fn virtual_default_member_is_not_a_member() {
910911
.with_status(101)
911912
.with_stderr(
912913
"\
913-
error: package `[..]something-else` is listed in workspace’s default-members \
914-
but is not a member.
914+
error: package `[..]something-else` is listed in default-members but is not a member\n\
915+
for workspace at [..]Cargo.toml.
915916
",
916917
)
917918
.run();
@@ -1672,8 +1673,8 @@ fn excluded_default_members_still_must_be_members() {
16721673
.with_status(101)
16731674
.with_stderr(
16741675
"\
1675-
error: package `[..]bar` is listed in workspace’s default-members \
1676-
but is not a member.
1676+
error: package `[..]bar` is listed in default-members but is not a member\n\
1677+
for workspace at [..]foo/Cargo.toml.
16771678
",
16781679
)
16791680
.run();
@@ -1902,6 +1903,7 @@ fn glob_syntax_invalid_members() {
19021903
.with_stderr(
19031904
"\
19041905
[ERROR] failed to load manifest for workspace member `[..]/crates/bar`
1906+
referenced by workspace at `[..]/Cargo.toml`
19051907
19061908
Caused by:
19071909
failed to read `[..]foo/crates/bar/Cargo.toml`
@@ -2388,6 +2390,7 @@ fn member_dep_missing() {
23882390
.with_stderr(
23892391
"\
23902392
[ERROR] failed to load manifest for workspace member `[..]/bar`
2393+
referenced by workspace at `[..]/Cargo.toml`
23912394
23922395
Caused by:
23932396
failed to load manifest for dependency `baz`

0 commit comments

Comments
 (0)