Skip to content

Commit c3aa679

Browse files
author
Yihai Lin
committed
feat: Make no target found hint more clear.
1 parent 8b8398d commit c3aa679

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/cargo/ops/cargo_compile/unit_generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'a> UnitGenerator<'a, '_> {
286286
if !suggestion.is_empty() {
287287
write!(
288288
msg,
289-
"no {} target {} `{}`{}{}",
289+
"no {} target {} `{}` in default-run packages{}{}",
290290
target_desc,
291291
if is_glob { "matches pattern" } else { "named" },
292292
target_name,
@@ -301,7 +301,7 @@ impl<'a> UnitGenerator<'a, '_> {
301301
} else {
302302
writeln!(
303303
msg,
304-
"no {} target {} `{}`.",
304+
"no {} target {} `{}` in default-run packages.",
305305
target_desc,
306306
if is_glob { "matches pattern" } else { "named" },
307307
target_name,

tests/testsuite/build.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ fn cargo_compile_with_filename() {
13371337
p.cargo("build --bin bin.rs")
13381338
.with_status(101)
13391339
.with_stderr_data(str![[r#"
1340-
[ERROR] no bin target named `bin.rs`.
1340+
[ERROR] no bin target named `bin.rs` in default-run packages.
13411341
Available bin targets:
13421342
a
13431343
@@ -1348,7 +1348,7 @@ Available bin targets:
13481348
p.cargo("build --bin a.rs")
13491349
.with_status(101)
13501350
.with_stderr_data(str![[r#"
1351-
[ERROR] no bin target named `a.rs`
1351+
[ERROR] no bin target named `a.rs` in default-run packages
13521352
13531353
[HELP] a target with a similar name exists: `a`
13541354
@@ -1358,7 +1358,7 @@ Available bin targets:
13581358
p.cargo("build --example example.rs")
13591359
.with_status(101)
13601360
.with_stderr_data(str![[r#"
1361-
[ERROR] no example target named `example.rs`.
1361+
[ERROR] no example target named `example.rs` in default-run packages.
13621362
Available example targets:
13631363
a
13641364
@@ -1369,7 +1369,7 @@ Available example targets:
13691369
p.cargo("build --example a.rs")
13701370
.with_status(101)
13711371
.with_stderr_data(str![[r#"
1372-
[ERROR] no example target named `a.rs`
1372+
[ERROR] no example target named `a.rs` in default-run packages
13731373
13741374
[HELP] a target with a similar name exists: `a`
13751375
@@ -5906,7 +5906,7 @@ fn target_filters_workspace() {
59065906
ws.cargo("build -v --example ex")
59075907
.with_status(101)
59085908
.with_stderr_data(str![[r#"
5909-
[ERROR] no example target named `ex`
5909+
[ERROR] no example target named `ex` in default-run packages
59105910
59115911
[HELP] a target with a similar name exists: `ex1`
59125912
@@ -5916,7 +5916,7 @@ fn target_filters_workspace() {
59165916
ws.cargo("build -v --example 'ex??'")
59175917
.with_status(101)
59185918
.with_stderr_data(str![[r#"
5919-
[ERROR] no example target matches pattern `ex??`
5919+
[ERROR] no example target matches pattern `ex??` in default-run packages
59205920
59215921
[HELP] a target with a similar name exists: `ex1`
59225922

tests/testsuite/run.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ automatically infer them to be a target, such as in subfolders.
623623
624624
For more information on this warning you can consult
625625
https://github.com/rust-lang/cargo/issues/5330
626-
[ERROR] no example target named `a`.
626+
[ERROR] no example target named `a` in default-run packages.
627627
Available example targets:
628628
do_magic
629629
@@ -655,7 +655,7 @@ fn run_example_autodiscover_2015_with_autoexamples_disabled() {
655655
p.cargo("run --example a")
656656
.with_status(101)
657657
.with_stderr_data(str![[r#"
658-
[ERROR] no example target named `a`.
658+
[ERROR] no example target named `a` in default-run packages.
659659
Available example targets:
660660
do_magic
661661
@@ -743,7 +743,7 @@ fn run_with_filename() {
743743
p.cargo("run --bin bin.rs")
744744
.with_status(101)
745745
.with_stderr_data(str![[r#"
746-
[ERROR] no bin target named `bin.rs`.
746+
[ERROR] no bin target named `bin.rs` in default-run packages.
747747
Available bin targets:
748748
a
749749
@@ -754,7 +754,7 @@ Available bin targets:
754754
p.cargo("run --bin a.rs")
755755
.with_status(101)
756756
.with_stderr_data(str![[r#"
757-
[ERROR] no bin target named `a.rs`
757+
[ERROR] no bin target named `a.rs` in default-run packages
758758
759759
[HELP] a target with a similar name exists: `a`
760760
@@ -764,7 +764,7 @@ Available bin targets:
764764
p.cargo("run --example example.rs")
765765
.with_status(101)
766766
.with_stderr_data(str![[r#"
767-
[ERROR] no example target named `example.rs`.
767+
[ERROR] no example target named `example.rs` in default-run packages.
768768
Available example targets:
769769
a
770770
@@ -775,7 +775,7 @@ Available example targets:
775775
p.cargo("run --example a.rs")
776776
.with_status(101)
777777
.with_stderr_data(str![[r#"
778-
[ERROR] no example target named `a.rs`
778+
[ERROR] no example target named `a.rs` in default-run packages
779779
780780
[HELP] a target with a similar name exists: `a`
781781

tests/testsuite/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,15 +2447,15 @@ fn bad_example() {
24472447
p.cargo("run --example foo")
24482448
.with_status(101)
24492449
.with_stderr_data(str![[r#"
2450-
[ERROR] no example target named `foo`.
2450+
[ERROR] no example target named `foo` in default-run packages.
24512451
24522452
24532453
"#]])
24542454
.run();
24552455
p.cargo("run --bin foo")
24562456
.with_status(101)
24572457
.with_stderr_data(str![[r#"
2458-
[ERROR] no bin target named `foo`.
2458+
[ERROR] no bin target named `foo` in default-run packages.
24592459
24602460
24612461
"#]])

tests/testsuite/workspaces.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,7 @@ Available binaries in `pattern2` package:
28032803
p.cargo("run --bin crate2")
28042804
.with_status(101)
28052805
.with_stderr_data(str![[r#"
2806-
[ERROR] no bin target named `crate2`
2806+
[ERROR] no bin target named `crate2` in default-run packages
28072807
28082808
[HELP] a target with a similar name exists: `crate1`
28092809
Available bin in `crate2` package:
@@ -2816,7 +2816,7 @@ Available bin in `crate2` package:
28162816
p.cargo("check --bin pattern*")
28172817
.with_status(101)
28182818
.with_stderr_data(str![[r#"
2819-
[ERROR] no bin target matches pattern `pattern*`.
2819+
[ERROR] no bin target matches pattern `pattern*` in default-run packages.
28202820
Available bin in `pattern1` package:
28212821
pattern1
28222822
Available bin in `pattern2` package:
@@ -2842,7 +2842,7 @@ Available bin in `pattern2` package:
28422842
p.cargo("run --bin crate2")
28432843
.with_status(101)
28442844
.with_stderr_data(str![[r#"
2845-
[ERROR] no bin target named `crate2`.
2845+
[ERROR] no bin target named `crate2` in default-run packages.
28462846
Available bin in `crate2` package:
28472847
crate2
28482848

0 commit comments

Comments
 (0)