Skip to content

Commit

Permalink
coverage: Regression test for inlining into an uninstrumented crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalathar committed Nov 1, 2024
1 parent a0d98ff commit f3f1593
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/coverage/auxiliary/inline_mixed_helper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ edition: 2021
//@ compile-flags: -Cinstrument-coverage=on

#[inline]
pub fn inline_me() {}

#[inline(never)]
pub fn no_inlining_please() {}

pub fn generic<T>() {}

// FIXME(#132436): Even though this doesn't ICE, it still produces coverage
// reports that undercount the affected code.
14 changes: 14 additions & 0 deletions tests/coverage/inline_mixed.coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
LL| |//@ edition: 2021
LL| |//@ compile-flags: -Cinstrument-coverage=on
LL| |
LL| |#[inline]
LL| 0|pub fn inline_me() {}
LL| |
LL| |#[inline(never)]
LL| 1|pub fn no_inlining_please() {}
LL| |
LL| 0|pub fn generic<T>() {}
LL| |
LL| |// FIXME(#132436): Even though this doesn't ICE, it still produces coverage
LL| |// reports that undercount the affected code.

14 changes: 14 additions & 0 deletions tests/coverage/inline_mixed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ edition: 2021
//@ compile-flags: -Cinstrument-coverage=off
//@ aux-crate: inline_mixed_helper=inline_mixed_helper.rs

// Regression test for <https://github.com/rust-lang/rust/pull/132395>.
// Various forms of cross-crate inlining can cause coverage statements to be
// inlined into crates that are being built without coverage instrumentation.
// At the very least, we need to not ICE when that happens.

fn main() {
inline_mixed_helper::inline_me();
inline_mixed_helper::no_inlining_please();
inline_mixed_helper::generic::<u32>();
}

0 comments on commit f3f1593

Please sign in to comment.