rust/src/test/mir-opt
Matthew Jasper 16ee042100 Fixes for shallow borrows
* Don't promote these borrows if we're going to remove them before
  codegen
* Correctly mark unreachable code
2019-03-31 15:14:50 +01:00
..
nll Remove licenses 2018-12-25 21:08:33 -07:00
array-index-is-temporary.rs array index accesses are stable places 2018-11-07 16:54:31 +01:00
basic_assignment.rs Auto merge of #58902 - matthewjasper:generator-cleanup-blocks, r=davidtwco 2019-03-21 02:18:27 +00:00
box_expr.rs Check which blocks are cleanup in mir-opt tests 2019-03-03 20:34:26 +00:00
combine_array_len.rs Remove licenses 2018-12-25 21:08:33 -07:00
copy_propagation.rs Remove licenses 2018-12-25 21:08:33 -07:00
copy_propagation_arg.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test_enum.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test_enum_2.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test_multiple.rs Remove licenses 2018-12-25 21:08:33 -07:00
generator-drop-cleanup.rs Don't incorrectly mark blocks in generator drop shims as cleanup 2019-03-03 20:34:26 +00:00
graphviz.rs Use a valid name for graphviz graphs 2019-03-17 10:36:10 +00:00
inline-any-operand.rs Always emit an error for a query cycle 2019-02-15 03:51:47 +01:00
inline-closure-borrows-arg.rs HirIdification: replace NodeId method calls 2019-03-07 09:22:43 +01:00
inline-closure.rs HirIdification: replace NodeId method calls 2019-03-07 09:22:43 +01:00
inline-retag.rs Always emit an error for a query cycle 2019-02-15 03:51:47 +01:00
inline-trait-method.rs [mir-inlining] Don't inline virtual calls 2018-10-14 13:45:46 -04:00
inline-trait-method_2.rs Always emit an error for a query cycle 2019-02-15 03:51:47 +01:00
issue-38669.rs Check which blocks are cleanup in mir-opt tests 2019-03-03 20:34:26 +00:00
issue-41110.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-41697.rs rustc: rename item_path to def_path (except the module in ty). 2019-03-15 13:25:10 +02:00
issue-41888.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-49232.rs Check which blocks are cleanup in mir-opt tests 2019-03-03 20:34:26 +00:00
loop_test.rs Check which blocks are cleanup in mir-opt tests 2019-03-03 20:34:26 +00:00
lower_128bit_debug_test.rs Remove licenses 2018-12-25 21:08:33 -07:00
lower_128bit_test.rs Remove licenses 2018-12-25 21:08:33 -07:00
match_false_edges.rs Fixes for shallow borrows 2019-03-31 15:14:50 +01:00
match_test.rs Move the exit block of the match to the end 2019-02-21 19:03:34 +00:00
packed-struct-drop-aligned.rs Check which blocks are cleanup in mir-opt tests 2019-03-03 20:34:26 +00:00
README.md fix more typos found by codespell. 2018-02-17 17:38:49 +01:00
remove_fake_borrows.rs Check which blocks are cleanup in mir-opt tests 2019-03-03 20:34:26 +00:00
retag.rs rustc: provide DisambiguatedDefPathData in ty::print. 2019-03-15 13:25:10 +02:00
return_an_array.rs Remove licenses 2018-12-25 21:08:33 -07:00
simplify_cfg.rs Make SimplifyCfg collapse goto chains from bb0 2018-12-13 12:01:15 +09:00
simplify_if.rs Remove licenses 2018-12-25 21:08:33 -07:00
simplify_match.rs Run branch cleanup after copy prop 2019-03-19 12:38:18 +01:00
storage_live_dead_in_statics.rs Remove licenses 2018-12-25 21:08:33 -07:00
storage_ranges.rs rustc: explicitly pass the namespace to PrintCx::parameterized. 2019-03-15 09:26:13 +02:00
uniform_array_move_out.rs Remove licenses 2018-12-25 21:08:33 -07:00
uninhabited-enum.rs Add a mir-opt test 2018-12-11 12:18:51 +00:00
unusual-item-types.rs Merge DefPathData::VariantCtor and DefPathData::StructCtor 2019-03-24 17:59:18 +03:00

This folder contains tests for MIR optimizations.

The test format is:

(arbitrary rust code)
// END RUST SOURCE
// START $file_name_of_some_mir_dump_0
//  $expected_line_0
// (lines or elision)
// $expected_line_N
// END $file_name_of_some_mir_dump_0
// (lines or elision)
// START $file_name_of_some_mir_dump_N
//  $expected_line_0
// (lines or elision)
// $expected_line_N
// END $file_name_of_some_mir_dump_N

All the test information is in comments so the test is runnable.

For each $file_name, compiletest expects [$expected_line_0, ..., $expected_line_N] to appear in the dumped MIR in order. Currently it allows other non-matched lines before and after, but not between $expected_lines, should you want to skip lines, you must include an elision comment, of the form (as a regex) //\s*...\s*. The lines will be skipped lazily, that is, if there are two identical lines in the output that match the line after the elision comment, the first one will be matched.

Examples:

The following blocks will not match the one after it.

bb0: {
    StorageLive(_1);
    _1 = const true;
    StorageDead(_1);
}
bb0: {
    StorageLive(_1);
    _1 = const true;
    goto -> bb1
}
bb1: {
    StorageDead(_1);
    return;
}

But this will match the one above,

bb0: {
    StorageLive(_1);
    _1 = const true;
    ...
    StorageDead(_1);
    ...
}

Lines match ignoring whitespace, and the prefix "//" is removed.

It also currently strips trailing comments -- partly because the full file path in "scope comments" is unpredictable and partly because tidy complains about the lines being too long.

compiletest handles dumping the MIR before and after every pass for you. The test writer only has to specify the file names of the dumped files (not the full path to the file) and what lines to expect. There is an option to rustc that tells it to dump the mir into some directly (rather then always dumping to the current directory).