rust/tests/coverage
Matthias Krüger c4d0c08925
Rollup merge of #126956 - joboet:fmt_no_extern_ty, r=RalfJung
core: avoid `extern type`s in formatting infrastructure

```@RalfJung``` [said](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Use.20of.20.60extern.20type.60.20in.20formatting.20machinery/near/446552837):

>How attached are y'all to using `extern type` in the formatting machinery?
Seems like this was introduced a [long time ago](34ef8f5441). However, it's also [not really compatible with Stacked Borrows](https://github.com/rust-lang/unsafe-code-guidelines/issues/256), and only works currently because we effectively treat references-to-extern-type almost like raw pointers in Stacked Borrows -- which of course is unsound, it's not how LLVM works. I was planning to make Miri emit a warning when this happens to avoid cases like [this](https://github.com/rust-lang/rust/issues/126814#issuecomment-2183816373) where people use extern type specifically to silence Miri without realizing what happens. but with the formatting machinery using  extern type, this warning would just show up everywhere...
>
> The "proper" way to do this in Stacked Borrows is to use raw pointers (or `NonNull`).

This PR does just that.

r? ```@RalfJung```
2024-06-28 08:34:08 +02:00
..
attr coverage: Allow #[coverage(..)] on impl and mod 2024-06-26 10:08:05 +10:00
auxiliary Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
branch coverage: Add debugging flag -Zcoverage-options=no-mir-spans 2024-06-17 21:16:15 +10:00
condition coverage: Instrument the RHS value of lazy logical operators 2024-05-30 15:38:46 +10:00
mcdc coverage: Add tests for the MC/DC condition limit 2024-05-29 20:12:20 +10:00
abort.cov-map Remove c_unwind from tests and fix tests 2024-06-19 13:54:55 +01:00
abort.coverage Remove c_unwind from tests and fix tests 2024-06-19 13:54:55 +01:00
abort.rs Remove c_unwind from tests and fix tests 2024-06-19 13:54:55 +01:00
assert_not.cov-map
assert_not.coverage
assert_not.rs
assert-ne.cov-map coverage: Add tests/coverage/assert-ne.rs 2024-06-12 22:38:16 +10:00
assert-ne.coverage coverage: Add tests/coverage/assert-ne.rs 2024-06-12 22:38:16 +10:00
assert-ne.rs coverage: Add tests/coverage/assert-ne.rs 2024-06-12 22:38:16 +10:00
assert.cov-map
assert.coverage
assert.rs
async2.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
async2.coverage
async2.rs
async_block.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
async_block.coverage
async_block.rs
async.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
async.coverage
async.rs
bad_counter_ids.cov-map
bad_counter_ids.coverage
bad_counter_ids.rs
bench.cov-map
bench.coverage
bench.rs
closure_bug.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
closure_bug.coverage
closure_bug.rs
closure_macro_async.cov-map Update coverage maps in tests 2024-06-22 21:37:26 -07:00
closure_macro_async.coverage
closure_macro_async.rs
closure_macro.cov-map Update coverage maps in tests 2024-06-22 21:37:26 -07:00
closure_macro.coverage
closure_macro.rs
closure_unit_return.cov-map
closure_unit_return.coverage
closure_unit_return.rs
closure.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
closure.coverage
closure.rs
color.coverage
color.rs
conditions.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
conditions.coverage
conditions.rs
continue.cov-map
continue.coverage
continue.rs
coroutine.cov-map Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
coroutine.coverage Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
coroutine.rs Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
coverage_attr_closure.cov-map
coverage_attr_closure.coverage
coverage_attr_closure.rs
dead_code.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
dead_code.coverage
dead_code.rs
drop_trait.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
drop_trait.coverage
drop_trait.rs
fn_sig_into_try.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
fn_sig_into_try.coverage
fn_sig_into_try.rs
generics.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
generics.coverage
generics.rs
if_else.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
if_else.coverage
if_else.rs
if_not.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
if_not.coverage
if_not.rs
if.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
if.coverage
if.rs
ignore_map.coverage
ignore_map.rs
ignore_run.cov-map
ignore_run.rs
inline-dead.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
inline-dead.coverage Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
inline-dead.rs Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
inline.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
inline.coverage
inline.rs
inner_items.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
inner_items.coverage Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
inner_items.rs Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
issue-83601.cov-map update coverage test 2024-06-26 00:06:27 +02:00
issue-83601.coverage
issue-83601.rs
issue-84561.cov-map update coverage test 2024-06-26 00:06:27 +02:00
issue-84561.coverage
issue-84561.rs
issue-85461.cov-map
issue-85461.coverage
issue-85461.rs
issue-93054.cov-map
issue-93054.coverage
issue-93054.rs
lazy_boolean.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
lazy_boolean.coverage
lazy_boolean.rs
let_else_loop.cov-map Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
let_else_loop.coverage Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
let_else_loop.rs Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
long_and_wide.cov-map
long_and_wide.coverage
long_and_wide.rs
loop_break_value.cov-map
loop_break_value.coverage
loop_break_value.rs
loop-break.cov-map coverage: Replace the old span refiner with a single function 2024-06-12 22:59:24 +10:00
loop-break.coverage coverage: Replace the old span refiner with a single function 2024-06-12 22:59:24 +10:00
loop-break.rs coverage: Add tests/coverage/loop-break.rs 2024-06-12 22:48:11 +10:00
loops_branches.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
loops_branches.coverage
loops_branches.rs
macro_in_closure.cov-map
macro_in_closure.coverage
macro_in_closure.rs
macro_name_span.cov-map
macro_name_span.coverage
macro_name_span.rs
match_or_pattern.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
match_or_pattern.coverage
match_or_pattern.rs
mcdc_if.cov-map
mcdc_if.coverage
mcdc_if.rs
mcdc_nested_if.cov-map tests(mcdc-coverage): Add tests for nested decision structures in mcdc_nested_if.rs 2024-04-29 09:13:41 +00:00
mcdc_nested_if.coverage tests(mcdc-coverage): Add tests for nested decision structures in mcdc_nested_if.rs 2024-04-29 09:13:41 +00:00
mcdc_nested_if.rs tests(mcdc-coverage): Add tests for nested decision structures in mcdc_nested_if.rs 2024-04-29 09:13:41 +00:00
mcdc_non_control_flow.cov-map tests(coverage): Bless mcdc_non_control_flow tests 2024-06-19 07:41:51 +00:00
mcdc_non_control_flow.coverage tests(coverage): Bless mcdc_non_control_flow tests 2024-06-19 07:41:51 +00:00
mcdc_non_control_flow.rs tests(coverage): Add mcdc_non_control_flow tests 2024-06-05 08:04:05 +00:00
nested_loops.cov-map
nested_loops.coverage
nested_loops.rs
no_cov_crate.cov-map coverage: Apply #[coverage(..)] recursively to nested functions 2024-06-26 10:08:05 +10:00
no_cov_crate.coverage coverage: Apply #[coverage(..)] recursively to nested functions 2024-06-26 10:08:05 +10:00
no_cov_crate.rs
no_spans_if_not.cov-map
no_spans_if_not.coverage
no_spans_if_not.rs
no_spans.cov-map
no_spans.coverage
no_spans.rs
overflow.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
overflow.coverage
overflow.rs
panic_unwind.cov-map
panic_unwind.coverage
panic_unwind.rs
partial_eq.cov-map Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
partial_eq.coverage Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
partial_eq.rs Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
README.md
simple_loop.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
simple_loop.coverage
simple_loop.rs
simple_match.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
simple_match.coverage
simple_match.rs
sort_groups.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
sort_groups.coverage
sort_groups.rs
test_harness.cov-map
test_harness.coverage
test_harness.rs
thin-lto.cov-map
thin-lto.coverage
thin-lto.rs
tight_inf_loop.cov-map
tight_inf_loop.coverage
tight_inf_loop.rs
trivial.cov-map
trivial.coverage
trivial.rs
try_error_result.cov-map Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
try_error_result.coverage Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
try_error_result.rs Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
unicode.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
unicode.coverage
unicode.rs
unreachable.cov-map
unreachable.coverage
unreachable.rs
unused_mod.cov-map
unused_mod.coverage
unused_mod.rs
unused.cov-map
unused.coverage
unused.rs
uses_crate.cov-map
uses_crate.coverage Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
uses_crate.rs
uses_inline_crate.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
uses_inline_crate.coverage Tweak various coverage test files for slightly nicer formatting 2024-05-29 14:34:11 +10:00
uses_inline_crate.rs
while_early_ret.cov-map
while_early_ret.coverage
while_early_ret.rs
while.cov-map coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
while.coverage
while.rs
yield.cov-map Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
yield.coverage Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00
yield.rs Manually run x fmt on all source files in tests/coverage/ 2024-05-29 14:34:17 +10:00

The tests in this directory are shared by two different test modes, and can be run in multiple different ways:

  • ./x.py test coverage-map (compiles to LLVM IR and checks coverage mappings)
  • ./x.py test coverage-run (runs a test binary and checks its coverage report)
  • ./x.py test coverage (runs both coverage-map and coverage-run)

Maintenance note

These tests can be sensitive to small changes in MIR spans or MIR control flow, especially in HIR-to-MIR lowering or MIR optimizations.

If you haven't touched the coverage code directly, and the tests still pass in coverage-run mode, then it should usually be OK to just re-bless the mappings as necessary with ./x.py test coverage-map --bless, without worrying too much about the exact changes.