about summary refs log tree commit diff
path: root/tests/coverage/no_spans.rs
blob: 979b407192775fbb9aa8ee06c9be93f940a8584b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#![feature(coverage_attribute)]
//@ edition: 2021

// Test that coverage instrumentation can gracefully handle functions that end
// up having no relevant spans, without crashing the compiler or causing
// `llvm-cov` to fail.
//
// This was originally a regression test for issues such as #118643 and #118662.

fn main() {
    affected_function()();
}

macro_rules! macro_that_defines_a_function {
    (fn $name:ident () $body:tt) => {
        fn $name () -> impl Fn() $body
    }
}

macro_that_defines_a_function! {
    fn affected_function() {
        || ()
    }
}