Skip to content

Commit 7e4648e

Browse files
committed
be more specific about what the pattern expects
1 parent 53f5ebe commit 7e4648e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/status_emitter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,13 @@ fn print_error(error: &Error, path: &Path) {
419419
Error::PatternNotFound(pattern) => {
420420
let msg = match &**pattern {
421421
Pattern::SubString(s) => {
422-
format!("substring `{s}` {} in stderr output", "not found")
422+
format!("`{s}` not found in diagnostics for line {}", pattern.line())
423423
}
424424
Pattern::Regex(r) => {
425-
format!("`/{r}/` does {} stderr output", "not match")
425+
format!(
426+
"`/{r}/` does not match diagnostics for line {}",
427+
pattern.line()
428+
)
426429
}
427430
};
428431
create_error(

tests/integrations/basic-fail/Cargo.stdout

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tests/actual_tests/rustc_ice.rs ... FAILED
1717
tests/actual_tests/bad_pattern.rs FAILED:
1818
command: "rustc" "--error-format=json" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "--out-dir" "$TMP "tests/actual_tests/bad_pattern.rs" "--edition" "2021"
1919

20-
error: substring `miesmätsched types` not found in stderr output
20+
error: `miesmätsched types` not found in diagnostics for line 5
2121
--> tests/actual_tests/bad_pattern.rs:5:17
2222
|
2323
5 | //~^ ERROR: miesmätsched types
@@ -234,7 +234,7 @@ command: "rustc" "--error-format=json" "--extern" "basic_fail=$DIR/$DIR/../../..
234234

235235
fail test got exit status: 101, but expected 1
236236

237-
error: substring `mismatched types` not found in stderr output
237+
error: `mismatched types` not found in diagnostics for line 11
238238
--> tests/actual_tests/rustc_ice.rs:11:17
239239
|
240240
11 | //~^ ERROR: mismatched types
@@ -539,7 +539,7 @@ full stdout:
539539
tests/actual_tests_bless/pass_with_annotation.rs FAILED:
540540
command: "rustc" "--error-format=json" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "--out-dir" "$TMP "tests/actual_tests_bless/pass_with_annotation.rs" "--edition" "2021"
541541

542-
error: substring `the cake is a lie` not found in stderr output
542+
error: `the cake is a lie` not found in diagnostics for line 3
543543
--> tests/actual_tests_bless/pass_with_annotation.rs:3:12
544544
|
545545
3 | //~ ERROR: the cake is a lie
@@ -605,7 +605,7 @@ full stdout:
605605
tests/actual_tests_bless/revisions_bad.rs (revision `bar`) FAILED:
606606
command: "rustc" "--error-format=json" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "--out-dir" "$TMP "tests/actual_tests_bless/revisions_bad.rs" "--cfg=bar" "--edition" "2021"
607607

608-
error: substring ``main` function not found in crate `revisions_bad`` not found in stderr output
608+
error: ``main` function not found in crate `revisions_bad`` not found in diagnostics for line 4
609609
--> tests/actual_tests_bless/revisions_bad.rs:4:31
610610
|
611611
4 | //@[bar] error-in-other-file: `main` function not found in crate `revisions_bad`
@@ -787,7 +787,7 @@ tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.rs ... ok
787787
tests/actual_tests_bless_yolo/revisions_bad.rs (revision `bar`) FAILED:
788788
command: "rustc" "--error-format=json" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/$DIR/../../../target/$TMP/$TRIPLE/debug" "--out-dir" "$TMP "tests/actual_tests_bless_yolo/revisions_bad.rs" "--cfg=bar" "--edition" "2021"
789789

790-
error: substring ``main` function not found in crate `revisions_bad`` not found in stderr output
790+
error: ``main` function not found in crate `revisions_bad`` not found in diagnostics for line 4
791791
--> tests/actual_tests_bless_yolo/revisions_bad.rs:4:31
792792
|
793793
4 | //@[bar] error-in-other-file: `main` function not found in crate `revisions_bad`

0 commit comments

Comments
 (0)