Skip to content

Commit 476ffa6

Browse files
authored
Merge pull request #310 from GuillaumeGomez/ice-level-parsing
Add `ICE` level parsing
2 parents ef35ab9 + 2f245ec commit 476ffa6

File tree

4 files changed

+154
-5
lines changed

4 files changed

+154
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If your test tests for failure, you need to add a `//~` annotation where the err
3131
to ensure that the test will always keep failing at the annotated line. These comments can take two forms:
3232

3333
* `//~ LEVEL: XXX` matches by error level and message text
34-
* `LEVEL` can be one of the following (descending order): `ERROR`, `HELP`, `WARN` or `NOTE`
34+
* `LEVEL` can be one of the following (descending order): `ERROR`, `HELP`, `WARN`, `NOTE` or `ICE`
3535
* If a level is specified explicitly, *all* diagnostics of that level or higher need an annotation. To avoid this see `//@require-annotations-for-level`
3636
* This checks the output *before* normalization, so you can check things that get normalized away, but need to
3737
be careful not to accidentally have a pattern that differs between platforms.

src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl std::str::FromStr for Level {
3636
"HELP" | "help" => Ok(Self::Help),
3737
"NOTE" | "note" => Ok(Self::Note),
3838
"failure-note" => Ok(Self::FailureNote),
39-
"error: internal compiler error" => Ok(Self::Ice),
39+
"ICE" | "ice" => Ok(Self::Ice),
4040
_ => Err(format!("unknown level `{s}`")),
4141
}
4242
}

tests/integrations/basic-fail/Cargo.stdout

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ tests/actual_tests/exit_code_fail.rs ... FAILED
1212
tests/actual_tests/filters.rs ... FAILED
1313
tests/actual_tests/foomp.rs ... FAILED
1414
tests/actual_tests/foomp2.rs ... FAILED
15+
tests/actual_tests/ice_annotations.rs ... FAILED
1516
tests/actual_tests/inline_chain.rs ... FAILED
1617
tests/actual_tests/joined_wrong_order.rs ... FAILED
1718
tests/actual_tests/lone_joined_pattern.rs ... FAILED
@@ -318,6 +319,83 @@ full stdout:
318319

319320

320321

322+
FAILED TEST: tests/actual_tests/ice_annotations.rs
323+
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/ice_annotations.rs" "-Ztreat-err-as-bug" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021"
324+
325+
error: test got exit status: 101, but expected 1
326+
= note: the compiler panicked
327+
328+
error: no output was expected
329+
Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/ice_annotations.stderr` to the actual output
330+
+++ <stderr output>
331+
error: internal compiler error[E0308]: mismatched types
332+
--> tests/actual_tests/ice_annotations.rs:8:9
333+
|
334+
8 | add("42", 3);
335+
| --- ^^^^ expected `usize`, found `&str`
336+
| |
337+
| arguments to this function are incorrect
338+
|
339+
note: function defined here
340+
--> $DIR/tests/integrations/basic-fail/src/lib.rs:LL:CC
341+
|
342+
1 | pub fn add(left: usize, right: usize) -> usize {
343+
| ^^^
344+
345+
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:
346+
aborting due to `-Z treat-err-as-bug=1`
347+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
348+
349+
error: the compiler unexpectedly panicked. this is a bug.
350+
351+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
352+
353+
354+
355+
note: compiler flags: -Z treat-err-as-bug
356+
357+
query stack during panic:
358+
#0 [typeck] type-checking `main`
359+
#1 [analysis] running analysis passes on this crate
360+
end of query stack
361+
362+
363+
full stderr:
364+
error: internal compiler error[E0308]: mismatched types
365+
--> tests/actual_tests/ice_annotations.rs:8:9
366+
|
367+
8 | add("42", 3);
368+
| --- ^^^^ expected `usize`, found `&str`
369+
| |
370+
| arguments to this function are incorrect
371+
|
372+
note: function defined here
373+
--> $DIR/tests/integrations/basic-fail/src/lib.rs:LL:CC
374+
|
375+
1 | pub fn add(left: usize, right: usize) -> usize {
376+
| ^^^
377+
378+
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:
379+
aborting due to `-Z treat-err-as-bug=1`
380+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
381+
382+
error: the compiler unexpectedly panicked. this is a bug.
383+
384+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
385+
386+
387+
388+
note: compiler flags: -Z treat-err-as-bug
389+
390+
query stack during panic:
391+
#0 [typeck] type-checking `main`
392+
#1 [analysis] running analysis passes on this crate
393+
end of query stack
394+
395+
full stdout:
396+
397+
398+
321399
FAILED TEST: tests/actual_tests/inline_chain.rs
322400
command: parse comments
323401

@@ -500,6 +578,7 @@ FAILURES:
500578
tests/actual_tests/filters.rs
501579
tests/actual_tests/foomp.rs
502580
tests/actual_tests/foomp2.rs
581+
tests/actual_tests/ice_annotations.rs
503582
tests/actual_tests/inline_chain.rs
504583
tests/actual_tests/joined_wrong_order.rs
505584
tests/actual_tests/lone_joined_pattern.rs
@@ -509,7 +588,7 @@ FAILURES:
509588
tests/actual_tests/touching_above_below.rs
510589
tests/actual_tests/touching_above_below_chain.rs
511590

512-
test result: FAIL. 15 failed; 1 passed
591+
test result: FAIL. 16 failed; 1 passed
513592

514593
Building dependencies ... ok
515594
tests/actual_tests_bless/abort.rs ... ok
@@ -1207,6 +1286,7 @@ tests/actual_tests/exit_code_fail.rs ... FAILED
12071286
tests/actual_tests/filters.rs ... FAILED
12081287
tests/actual_tests/foomp.rs ... FAILED
12091288
tests/actual_tests/foomp2.rs ... FAILED
1289+
tests/actual_tests/ice_annotations.rs ... FAILED
12101290
tests/actual_tests/inline_chain.rs ... FAILED
12111291
tests/actual_tests/joined_wrong_order.rs ... FAILED
12121292
tests/actual_tests/lone_joined_pattern.rs ... FAILED
@@ -1459,6 +1539,53 @@ error: there were 1 unmatched diagnostics
14591539
|
14601540

14611541

1542+
FAILED TEST: tests/actual_tests/ice_annotations.rs
1543+
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/ice_annotations.rs" "-Ztreat-err-as-bug" "--edition" "2021"
1544+
1545+
error: test got exit status: 101, but expected 1
1546+
= note: the compiler panicked
1547+
1548+
error: no output was expected
1549+
Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/ice_annotations.stderr` to the actual output
1550+
+++ <stderr output>
1551+
error: internal compiler error[E0432]: unresolved import `basic_fail`
1552+
--> tests/actual_tests/ice_annotations.rs:5:5
1553+
|
1554+
5 | use basic_fail::add;
1555+
| ^^^^^^^^^^ use of undeclared crate or module `basic_fail`
1556+
1557+
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:
1558+
aborting due to `-Z treat-err-as-bug=1`
1559+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1560+
1561+
error: the compiler unexpectedly panicked. this is a bug.
1562+
1563+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
1564+
1565+
1566+
1567+
note: compiler flags: -Z treat-err-as-bug
1568+
1569+
query stack during panic:
1570+
#0 [resolver_for_lowering_raw] getting the resolver for lowering
1571+
end of query stack
1572+
1573+
1574+
error: `mismatched types` not found in diagnostics on line 8
1575+
--> tests/actual_tests/ice_annotations.rs:9:15
1576+
|
1577+
9 | //~^ ICE: mismatched types
1578+
| ^^^^^^^^^^^^^^^^ expected because of this pattern
1579+
|
1580+
1581+
error: there were 1 unmatched diagnostics
1582+
--> tests/actual_tests/ice_annotations.rs:5:5
1583+
|
1584+
5 | use basic_fail::add;
1585+
| ^^^^^^^^^^ Ice: unresolved import `basic_fail`
1586+
|
1587+
1588+
14621589
FAILED TEST: tests/actual_tests/inline_chain.rs
14631590
command: parse comments
14641591

@@ -1619,6 +1746,7 @@ FAILURES:
16191746
tests/actual_tests/filters.rs
16201747
tests/actual_tests/foomp.rs
16211748
tests/actual_tests/foomp2.rs
1749+
tests/actual_tests/ice_annotations.rs
16221750
tests/actual_tests/inline_chain.rs
16231751
tests/actual_tests/joined_wrong_order.rs
16241752
tests/actual_tests/lone_joined_pattern.rs
@@ -1628,7 +1756,7 @@ FAILURES:
16281756
tests/actual_tests/touching_above_below.rs
16291757
tests/actual_tests/touching_above_below_chain.rs
16301758

1631-
test result: FAIL. 15 failed
1759+
test result: FAIL. 16 failed
16321760

16331761
tests/actual_tests/bad_pattern.rs ... FAILED
16341762
tests/actual_tests/executable.rs ... FAILED
@@ -1637,6 +1765,7 @@ tests/actual_tests/exit_code_fail.rs ... FAILED
16371765
tests/actual_tests/filters.rs ... FAILED
16381766
tests/actual_tests/foomp.rs ... FAILED
16391767
tests/actual_tests/foomp2.rs ... FAILED
1768+
tests/actual_tests/ice_annotations.rs ... FAILED
16401769
tests/actual_tests/inline_chain.rs ... FAILED
16411770
tests/actual_tests/joined_wrong_order.rs ... FAILED
16421771
tests/actual_tests/lone_joined_pattern.rs ... FAILED
@@ -1716,6 +1845,15 @@ full stdout:
17161845
could not spawn `"invalid_foobarlaksdfalsdfj"` as a process
17171846

17181847

1848+
FAILED TEST: tests/actual_tests/ice_annotations.rs
1849+
command: "$CMD" "tests/actual_tests/ice_annotations.rs" "-Ztreat-err-as-bug" "--edition" "2021"
1850+
1851+
full stderr:
1852+
No such file or directory
1853+
full stdout:
1854+
could not spawn `"invalid_foobarlaksdfalsdfj"` as a process
1855+
1856+
17191857
FAILED TEST: tests/actual_tests/inline_chain.rs
17201858
command: parse comments
17211859

@@ -1851,6 +1989,7 @@ FAILURES:
18511989
tests/actual_tests/filters.rs
18521990
tests/actual_tests/foomp.rs
18531991
tests/actual_tests/foomp2.rs
1992+
tests/actual_tests/ice_annotations.rs
18541993
tests/actual_tests/inline_chain.rs
18551994
tests/actual_tests/joined_wrong_order.rs
18561995
tests/actual_tests/lone_joined_pattern.rs
@@ -1860,7 +1999,7 @@ FAILURES:
18601999
tests/actual_tests/touching_above_below.rs
18612000
tests/actual_tests/touching_above_below_chain.rs
18622001

1863-
test result: FAIL. 15 failed
2002+
test result: FAIL. 16 failed
18642003

18652004

18662005
running 0 tests
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@compile-flags: -Ztreat-err-as-bug
2+
//@rustc-env: RUSTC_BOOTSTRAP=1
3+
//@rustc-env: RUSTC_ICE=0
4+
//@normalize-stderr-test: "(?s)(thread 'rustc' panicked).*end of query stack" -> "$1"
5+
use basic_fail::add;
6+
7+
fn main() {
8+
add("42", 3);
9+
//~^ ICE: mismatched types
10+
}

0 commit comments

Comments
 (0)