Skip to content

Commit 87315a8

Browse files
authored
Rollup merge of #155411 - Zalathar:should-ice, r=jieyouxu
compiletest: Remove the `//@ should-ice` directive The `//@ should-ice` directive was only being used by one test, which can just as easily use the more general `//@ failure-status` directive instead. All of the removed exit-code checks were redundant with other exit-code checks that are still present. --- I have manually verified that `tests/incremental/delayed_span_bug.rs` fails if the failure-status directive is modified or removed.
2 parents fd57bed + 975402e commit 87315a8

9 files changed

Lines changed: 2 additions & 54 deletions

File tree

src/doc/rustc-dev-guide/src/tests/compiletest.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ substring must not appear anywhere in the compiler output.
190190
This can be useful to ensure certain errors do not appear, but this can be fragile as error messages
191191
change over time, and a test may no longer be checking the right thing but will still pass.
192192

193-
`cfail` tests support the `should-ice` directive to specify that a test should
194-
cause an Internal Compiler Error (ICE).
195-
This is a highly specialized directive
196-
to check that the incremental cache continues to work after an ICE.
197-
198193
Incremental tests may use the attribute `#[rustc_clean(...)]` attribute.
199194
This attribute compares the fingerprint from the current compilation session with the previous one.
200195
The first revision should never have an active `rustc_clean` attribute, since it will always be dirty.

src/doc/rustc-dev-guide/src/tests/directives.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ See [Controlling pass/fail expectations](ui.md#controlling-passfail-expectations
8080
| `run-fail-or-crash` | Program must `run-fail` or `run-crash` | `ui` | N/A |
8181
| `ignore-pass` | Ignore `--pass` flag | `ui`, `crashes`, `codegen`, `incremental` | N/A |
8282
| `dont-check-failure-status` | Don't check exact failure status (i.e. `1`) | `ui`, `incremental` | N/A |
83-
| `failure-status` | Check | `ui`, `crashes` | Any `u16` |
84-
| `should-ice` | Check failure status is `101` | `coverage`, `incremental` | N/A |
83+
| `failure-status` | On failure, the compiler must exit with this status code. To expect an ICE, use `//@ failure-status: 101`. | `ui`, `crashes`, `incremental` | Any `u16` |
8584
| `should-fail` | Compiletest self-test | All | N/A |
8685

8786
### Controlling output snapshots and normalizations
@@ -318,7 +317,6 @@ See [Pretty-printer](compiletest.md#pretty-printer-tests).
318317
- [`revisions`](compiletest.md#revisions) — compile multiple times
319318
-[`forbid-output`](compiletest.md#incremental-tests) — incremental cfail rejects
320319
output pattern
321-
- [`should-ice`](compiletest.md#incremental-tests) — incremental cfail should ICE
322320
- [`reference`] — an annotation linking to a rule in the reference
323321
- `disable-gdb-pretty-printers` — disable gdb pretty printers for debuginfo tests
324322

src/tools/compiletest/src/directives.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ pub(crate) struct TestProps {
185185
// If true, `rustfix` will only apply `MachineApplicable` suggestions.
186186
pub(crate) rustfix_only_machine_applicable: bool,
187187
pub(crate) assembly_output: Option<String>,
188-
// If true, the test is expected to ICE
189-
pub(crate) should_ice: bool,
190188
// If true, the stderr is expected to be different across bit-widths.
191189
pub(crate) stderr_per_bitwidth: bool,
192190
// The MIR opt to unit test, if any
@@ -220,7 +218,6 @@ mod directives {
220218
pub(crate) const COMPILE_FLAGS: &str = "compile-flags";
221219
pub(crate) const RUN_FLAGS: &str = "run-flags";
222220
pub(crate) const DOC_FLAGS: &str = "doc-flags";
223-
pub(crate) const SHOULD_ICE: &str = "should-ice";
224221
pub(crate) const BUILD_AUX_DOCS: &str = "build-aux-docs";
225222
pub(crate) const UNIQUE_DOC_OUT_DIR: &str = "unique-doc-out-dir";
226223
pub(crate) const FORCE_HOST: &str = "force-host";
@@ -307,7 +304,6 @@ impl TestProps {
307304
run_rustfix: false,
308305
rustfix_only_machine_applicable: false,
309306
assembly_output: None,
310-
should_ice: false,
311307
stderr_per_bitwidth: false,
312308
mir_unit_test: None,
313309
remap_src_base: false,
@@ -377,10 +373,6 @@ impl TestProps {
377373
);
378374
}
379375

380-
if self.should_ice {
381-
self.failure_status = Some(101);
382-
}
383-
384376
if config.mode == TestMode::Incremental {
385377
self.incremental = true;
386378
}

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
286286
"rustc-env",
287287
"rustfix-only-machine-applicable",
288288
"should-fail",
289-
"should-ice",
290289
"stderr-per-bitwidth",
291290
"test-mir-pass",
292291
"unique-doc-out-dir",

src/tools/compiletest/src/directives/handlers.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ fn make_directive_handlers_map() -> HashMap<&'static str, Handler> {
115115
props.pp_exact = config.parse_pp_exact(ln);
116116
}
117117
}),
118-
handler(SHOULD_ICE, |config, ln, props| {
119-
config.set_name_directive(ln, SHOULD_ICE, &mut props.should_ice);
120-
}),
121118
handler(BUILD_AUX_DOCS, |config, ln, props| {
122119
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut props.build_aux_docs);
123120
}),

src/tools/compiletest/src/runtest.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,6 @@ impl<'test> TestCx<'test> {
266266
/// Code executed for each revision in turn (or, if there are no
267267
/// revisions, exactly once, with revision == None).
268268
fn run_revision(&self) {
269-
if self.props.should_ice
270-
&& self.config.mode != TestMode::Incremental
271-
&& self.config.mode != TestMode::Crashes
272-
{
273-
self.fatal("cannot use should-ice in a test that is not cfail");
274-
}
275269
// Run the test multiple times if requested.
276270
// This is useful for catching flaky tests under the parallel frontend.
277271
for _ in 0..self.config.iteration_count {
@@ -672,16 +666,6 @@ impl<'test> TestCx<'test> {
672666
}
673667
}
674668

675-
fn check_no_compiler_crash(&self, proc_res: &ProcRes, should_ice: bool) {
676-
match proc_res.status.code() {
677-
Some(101) if !should_ice => {
678-
self.fatal_proc_rec("compiler encountered internal error", proc_res)
679-
}
680-
None => self.fatal_proc_rec("compiler terminated by signal", proc_res),
681-
_ => (),
682-
}
683-
}
684-
685669
fn check_forbid_output(&self, output_to_check: &str, proc_res: &ProcRes) {
686670
for pat in &self.props.forbid_output {
687671
if output_to_check.contains(pat) {

src/tools/compiletest/src/runtest/codegen_units.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ impl TestCx<'_> {
1414
self.fatal_proc_rec("compilation failed!", &proc_res);
1515
}
1616

17-
self.check_no_compiler_crash(&proc_res, self.props.should_ice);
18-
1917
const PREFIX: &str = "MONO_ITEM ";
2018
const CGU_MARKER: &str = "@@";
2119

src/tools/compiletest/src/runtest/incremental.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ impl TestCx<'_> {
3232
}
3333

3434
if revision.starts_with("cpass") {
35-
if self.props.should_ice {
36-
self.fatal("can only use should-ice in cfail tests");
37-
}
3835
self.run_cpass_test();
3936
} else if revision.starts_with("rpass") {
40-
if self.props.should_ice {
41-
self.fatal("can only use should-ice in cfail tests");
42-
}
4337
self.run_rpass_test();
4438
} else if revision.starts_with("cfail") {
4539
self.run_cfail_test();
@@ -84,16 +78,7 @@ impl TestCx<'_> {
8478
let pm = self.pass_mode();
8579
let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm));
8680
self.check_if_test_should_compile(Some(FailMode::Build), pm, &proc_res);
87-
self.check_no_compiler_crash(&proc_res, self.props.should_ice);
88-
8981
self.check_compiler_output_for_incr(&proc_res);
90-
91-
if self.props.should_ice {
92-
match proc_res.status.code() {
93-
Some(101) => (),
94-
_ => self.fatal("expected ICE"),
95-
}
96-
}
9782
}
9883

9984
fn check_compiler_output_for_incr(&self, proc_res: &ProcRes) {

tests/incremental/delayed_span_bug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ revisions: cfail1 cfail2
2-
//@ should-ice
2+
//@ failure-status: 101
33

44
#![feature(rustc_attrs)]
55

0 commit comments

Comments
 (0)