summaryrefslogtreecommitdiffstats
path: root/tests/run-coverage/uses_crate.coverage
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /tests/run-coverage/uses_crate.coverage
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-coverage/uses_crate.coverage')
-rw-r--r--tests/run-coverage/uses_crate.coverage286
1 files changed, 143 insertions, 143 deletions
diff --git a/tests/run-coverage/uses_crate.coverage b/tests/run-coverage/uses_crate.coverage
index a3b78e214..9da096dbd 100644
--- a/tests/run-coverage/uses_crate.coverage
+++ b/tests/run-coverage/uses_crate.coverage
@@ -1,170 +1,170 @@
$DIR/auxiliary/used_crate.rs:
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |// compile-flags: -C opt-level=3
- 3| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations
- 4| |
- 5| 1|pub fn used_function() {
- 6| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 7| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 8| 1| // dependent conditions.
- 9| 1| let is_true = std::env::args().len() == 1;
- 10| 1| let mut countdown = 0;
- 11| 1| if is_true {
- 12| 1| countdown = 10;
- 13| 1| }
+ LL| |#![allow(unused_assignments, unused_variables)]
+ LL| |// compile-flags: -C opt-level=3
+ LL| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations
+ LL| |
+ LL| 1|pub fn used_function() {
+ LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ LL| 1| // dependent conditions.
+ LL| 1| let is_true = std::env::args().len() == 1;
+ LL| 1| let mut countdown = 0;
+ LL| 1| if is_true {
+ LL| 1| countdown = 10;
+ LL| 1| }
^0
- 14| 1| use_this_lib_crate();
- 15| 1|}
- 16| |
- 17| 2|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- 18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- 19| 2|}
+ LL| 1| use_this_lib_crate();
+ LL| 1|}
+ LL| |
+ LL| 2|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
+ LL| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
+ LL| 2|}
------------------
| Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
------------------
| used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>:
- | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- | 19| 1|}
+ | LL| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
| used_crate::used_only_from_bin_crate_generic_function::<&str>:
- | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- | 19| 1|}
+ | LL| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
- 20| |// Expect for above function: `Unexecuted instantiation` (see below)
- 21| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- 22| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- 23| 2|}
+ LL| |// Expect for above function: `Unexecuted instantiation` (see below)
+ LL| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
+ LL| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
+ LL| 2|}
------------------
| used_crate::used_only_from_this_lib_crate_generic_function::<&str>:
- | 21| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- | 23| 1|}
+ | LL| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
| used_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
- | 21| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- | 23| 1|}
+ | LL| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
- 24| |
- 25| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- 26| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- 27| 2|}
+ LL| |
+ LL| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
+ LL| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
+ LL| 2|}
------------------
| used_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 27| 1|}
+ | LL| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
| used_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
- | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 27| 1|}
+ | LL| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
- 28| |
- 29| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- 30| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- 31| 2|}
+ LL| |
+ LL| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
+ LL| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
+ LL| 2|}
------------------
| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 29| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 30| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 31| 1|}
+ | LL| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 29| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 30| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 31| 1|}
+ | LL| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
+ | LL| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
+ | LL| 1|}
------------------
- 32| |
- 33| 0|pub fn unused_generic_function<T: Debug>(arg: T) {
- 34| 0| println!("unused_generic_function with {:?}", arg);
- 35| 0|}
- 36| |
- 37| 0|pub fn unused_function() {
- 38| 0| let is_true = std::env::args().len() == 1;
- 39| 0| let mut countdown = 2;
- 40| 0| if !is_true {
- 41| 0| countdown = 20;
- 42| 0| }
- 43| 0|}
- 44| |
- 45| 0|fn unused_private_function() {
- 46| 0| let is_true = std::env::args().len() == 1;
- 47| 0| let mut countdown = 2;
- 48| 0| if !is_true {
- 49| 0| countdown = 20;
- 50| 0| }
- 51| 0|}
- 52| |
- 53| 1|fn use_this_lib_crate() {
- 54| 1| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
- 55| 1| used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
- 56| 1| "used from library used_crate.rs",
- 57| 1| );
- 58| 1| let some_vec = vec![5, 6, 7, 8];
- 59| 1| used_only_from_this_lib_crate_generic_function(some_vec);
- 60| 1| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
- 61| 1|}
- 62| |
- 63| |// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results,
- 64| |// for example:
- 65| |//
- 66| |// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
- 67| |//
- 68| |// These notices appear when `llvm-cov` shows instantiations. This may be a
- 69| |// default option, but it can be suppressed with:
- 70| |//
- 71| |// ```shell
- 72| |// $ `llvm-cov show --show-instantiations=0 ...`
- 73| |// ```
- 74| |//
- 75| |// The notice is triggered because the function is unused by the library itself,
- 76| |// and when the library is compiled, a synthetic function is generated, so
- 77| |// unused function coverage can be reported. Coverage can be skipped for unused
- 78| |// generic functions with:
- 79| |//
- 80| |// ```shell
- 81| |// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...`
- 82| |// ```
- 83| |//
- 84| |// Even though this function is used by `uses_crate.rs` (and
- 85| |// counted), with substitutions for `T`, those instantiations are only generated
- 86| |// when the generic function is actually used (from the binary, not from this
- 87| |// library crate). So the test result shows coverage for all instantiated
- 88| |// versions and their generic type substitutions, plus the `Unexecuted
- 89| |// instantiation` message for the non-substituted version. This is valid, but
- 90| |// unfortunately a little confusing.
- 91| |//
- 92| |// The library crate has its own coverage map, and the only way to show unused
- 93| |// coverage of a generic function is to include the generic function in the
- 94| |// coverage map, marked as an "unused function". If the library were used by
- 95| |// another binary that never used this generic function, then it would be valid
- 96| |// to show the unused generic, with unknown substitution (`_`).
- 97| |//
- 98| |// The alternative is to exclude all generics from being included in the "unused
- 99| |// functions" list, which would then omit coverage results for
- 100| |// `unused_generic_function<T>()`, below.
+ LL| |
+ LL| 0|pub fn unused_generic_function<T: Debug>(arg: T) {
+ LL| 0| println!("unused_generic_function with {:?}", arg);
+ LL| 0|}
+ LL| |
+ LL| 0|pub fn unused_function() {
+ LL| 0| let is_true = std::env::args().len() == 1;
+ LL| 0| let mut countdown = 2;
+ LL| 0| if !is_true {
+ LL| 0| countdown = 20;
+ LL| 0| }
+ LL| 0|}
+ LL| |
+ LL| 0|fn unused_private_function() {
+ LL| 0| let is_true = std::env::args().len() == 1;
+ LL| 0| let mut countdown = 2;
+ LL| 0| if !is_true {
+ LL| 0| countdown = 20;
+ LL| 0| }
+ LL| 0|}
+ LL| |
+ LL| 1|fn use_this_lib_crate() {
+ LL| 1| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
+ LL| 1| used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
+ LL| 1| "used from library used_crate.rs",
+ LL| 1| );
+ LL| 1| let some_vec = vec![5, 6, 7, 8];
+ LL| 1| used_only_from_this_lib_crate_generic_function(some_vec);
+ LL| 1| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
+ LL| 1|}
+ LL| |
+ LL| |// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results,
+ LL| |// for example:
+ LL| |//
+ LL| |// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
+ LL| |//
+ LL| |// These notices appear when `llvm-cov` shows instantiations. This may be a
+ LL| |// default option, but it can be suppressed with:
+ LL| |//
+ LL| |// ```shell
+ LL| |// $ `llvm-cov show --show-instantiations=0 ...`
+ LL| |// ```
+ LL| |//
+ LL| |// The notice is triggered because the function is unused by the library itself,
+ LL| |// and when the library is compiled, a synthetic function is generated, so
+ LL| |// unused function coverage can be reported. Coverage can be skipped for unused
+ LL| |// generic functions with:
+ LL| |//
+ LL| |// ```shell
+ LL| |// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...`
+ LL| |// ```
+ LL| |//
+ LL| |// Even though this function is used by `uses_crate.rs` (and
+ LL| |// counted), with substitutions for `T`, those instantiations are only generated
+ LL| |// when the generic function is actually used (from the binary, not from this
+ LL| |// library crate). So the test result shows coverage for all instantiated
+ LL| |// versions and their generic type substitutions, plus the `Unexecuted
+ LL| |// instantiation` message for the non-substituted version. This is valid, but
+ LL| |// unfortunately a little confusing.
+ LL| |//
+ LL| |// The library crate has its own coverage map, and the only way to show unused
+ LL| |// coverage of a generic function is to include the generic function in the
+ LL| |// coverage map, marked as an "unused function". If the library were used by
+ LL| |// another binary that never used this generic function, then it would be valid
+ LL| |// to show the unused generic, with unknown substitution (`_`).
+ LL| |//
+ LL| |// The alternative is to exclude all generics from being included in the "unused
+ LL| |// functions" list, which would then omit coverage results for
+ LL| |// `unused_generic_function<T>()`, below.
$DIR/uses_crate.rs:
- 1| |// FIXME #110395
- 2| |// ignore-linux
- 3| |
- 4| |// Validates coverage now works with optimizations
- 5| |// compile-flags: -C opt-level=3
- 6| |
- 7| |#![allow(unused_assignments, unused_variables)]
- 8| |
- 9| |// aux-build:used_crate.rs
- 10| |extern crate used_crate;
- 11| |
- 12| 1|fn main() {
- 13| 1| used_crate::used_function();
- 14| 1| let some_vec = vec![1, 2, 3, 4];
- 15| 1| used_crate::used_only_from_bin_crate_generic_function(&some_vec);
- 16| 1| used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs");
- 17| 1| used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec);
- 18| 1| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?");
- 19| 1|}
+ LL| |// This test was failing on Linux for a while due to #110393 somehow making
+ LL| |// the unused functions not instrumented, but it seems to be fine now.
+ LL| |
+ LL| |// Validates coverage now works with optimizations
+ LL| |// compile-flags: -C opt-level=3
+ LL| |
+ LL| |#![allow(unused_assignments, unused_variables)]
+ LL| |
+ LL| |// aux-build:used_crate.rs
+ LL| |extern crate used_crate;
+ LL| |
+ LL| 1|fn main() {
+ LL| 1| used_crate::used_function();
+ LL| 1| let some_vec = vec![1, 2, 3, 4];
+ LL| 1| used_crate::used_only_from_bin_crate_generic_function(&some_vec);
+ LL| 1| used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs");
+ LL| 1| used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec);
+ LL| 1| used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?");
+ LL| 1|}