rust/tests/coverage/unused-local-file.rs
Zalathar 078144fdfa coverage: Detect unused local file IDs to avoid an LLVM assertion
This case can't actually happen yet (other than via a testing flag), because
currently all of a function's spans must belong to the same file and expansion.
But this will be an important edge case when adding expansion region support.
2025-05-10 00:24:03 +10:00

23 lines
911 B
Rust

//! If we give LLVM a local file table for a function, but some of the entries
//! in that table have no associated mapping regions, then an assertion failure
//! will occur in LLVM. We therefore need to detect and skip any function that
//! would trigger that assertion.
//!
//! To test that this case is handled, even before adding code that could allow
//! it to happen organically (for expansion region support), we use a special
//! testing-only flag to force it to occur.
//@ edition: 2024
//@ compile-flags: -Zcoverage-options=inject-unused-local-file
// The `llvm-cov` tool will complain if the test binary ends up having no
// coverage metadata at all. To prevent that, we also link to instrumented
// code in an auxiliary crate that doesn't have the special flag set.
//@ aux-build: discard_all_helper.rs
extern crate discard_all_helper;
fn main() {
discard_all_helper::external_function();
}