about summary refs log tree commit diff
path: root/src/test/run-make/coverage/lib
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /src/test/run-make/coverage/lib
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'src/test/run-make/coverage/lib')
-rw-r--r--src/test/run-make/coverage/lib/doctest_crate.rs9
-rw-r--r--src/test/run-make/coverage/lib/inline_always_with_dead_code.rs22
-rw-r--r--src/test/run-make/coverage/lib/unused_mod_helper.rs3
-rw-r--r--src/test/run-make/coverage/lib/used_crate.rs100
-rw-r--r--src/test/run-make/coverage/lib/used_inline_crate.rs90
5 files changed, 0 insertions, 224 deletions
diff --git a/src/test/run-make/coverage/lib/doctest_crate.rs b/src/test/run-make/coverage/lib/doctest_crate.rs
deleted file mode 100644
index c3210146d69..00000000000
--- a/src/test/run-make/coverage/lib/doctest_crate.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-/// A function run only from within doctests
-pub fn fn_run_in_doctests(conditional: usize) {
-    match conditional {
-        1 => assert_eq!(1, 1), // this is run,
-        2 => assert_eq!(1, 1), // this,
-        3 => assert_eq!(1, 1), // and this too
-        _ => assert_eq!(1, 2), // however this is not
-    }
-}
diff --git a/src/test/run-make/coverage/lib/inline_always_with_dead_code.rs b/src/test/run-make/coverage/lib/inline_always_with_dead_code.rs
deleted file mode 100644
index 2b21dee6ccf..00000000000
--- a/src/test/run-make/coverage/lib/inline_always_with_dead_code.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0
-
-#![allow(dead_code)]
-
-mod foo {
-    #[inline(always)]
-    pub fn called() { }
-
-    fn uncalled() { }
-}
-
-pub mod bar {
-    pub fn call_me() {
-        super::foo::called();
-    }
-}
-
-pub mod baz {
-    pub fn call_me() {
-        super::foo::called();
-    }
-}
diff --git a/src/test/run-make/coverage/lib/unused_mod_helper.rs b/src/test/run-make/coverage/lib/unused_mod_helper.rs
deleted file mode 100644
index ae1cc1531ed..00000000000
--- a/src/test/run-make/coverage/lib/unused_mod_helper.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub fn never_called_function() {
-    println!("I am never called");
-}
diff --git a/src/test/run-make/coverage/lib/used_crate.rs b/src/test/run-make/coverage/lib/used_crate.rs
deleted file mode 100644
index 8b8b1f7f351..00000000000
--- a/src/test/run-make/coverage/lib/used_crate.rs
+++ /dev/null
@@ -1,100 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
-use std::fmt::Debug;
-
-pub fn used_function() {
-    // Initialize test constants in a way that cannot be determined at compile time, to ensure
-    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
-    // dependent conditions.
-    let is_true = std::env::args().len() == 1;
-    let mut countdown = 0;
-    if is_true {
-        countdown = 10;
-    }
-    use_this_lib_crate();
-}
-
-pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_only_from_bin_crate_generic_function with {:?}", arg);
-}
-// Expect for above function: `Unexecuted instantiation` (see below)
-pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
-}
-
-pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-pub fn unused_generic_function<T: Debug>(arg: T) {
-    println!("unused_generic_function with {:?}", arg);
-}
-
-pub fn unused_function() {
-    let is_true = std::env::args().len() == 1;
-    let mut countdown = 2;
-    if !is_true {
-        countdown = 20;
-    }
-}
-
-fn unused_private_function() {
-    let is_true = std::env::args().len() == 1;
-    let mut countdown = 2;
-    if !is_true {
-        countdown = 20;
-    }
-}
-
-fn use_this_lib_crate() {
-    used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
-    used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
-        "used from library used_crate.rs",
-    );
-    let some_vec = vec![5, 6, 7, 8];
-    used_only_from_this_lib_crate_generic_function(some_vec);
-    used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
-}
-
-// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results,
-// for example:
-//
-// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
-//
-// These notices appear when `llvm-cov` shows instantiations. This may be a
-// default option, but it can be suppressed with:
-//
-// ```shell
-// $ `llvm-cov show --show-instantiations=0 ...`
-// ```
-//
-// The notice is triggered because the function is unused by the library itself,
-// and when the library is compiled, a synthetic function is generated, so
-// unused function coverage can be reported. Coverage can be skipped for unused
-// generic functions with:
-//
-// ```shell
-// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...`
-// ```
-//
-// Even though this function is used by `uses_crate.rs` (and
-// counted), with substitutions for `T`, those instantiations are only generated
-// when the generic function is actually used (from the binary, not from this
-// library crate). So the test result shows coverage for all instantiated
-// versions and their generic type substitutions, plus the `Unexecuted
-// instantiation` message for the non-substituted version. This is valid, but
-// unfortunately a little confusing.
-//
-// The library crate has its own coverage map, and the only way to show unused
-// coverage of a generic function is to include the generic function in the
-// coverage map, marked as an "unused function". If the library were used by
-// another binary that never used this generic function, then it would be valid
-// to show the unused generic, with unknown substitution (`_`).
-//
-// The alternative is to exclude all generics from being included in the "unused
-// functions" list, which would then omit coverage results for
-// `unused_generic_function<T>()`, below.
diff --git a/src/test/run-make/coverage/lib/used_inline_crate.rs b/src/test/run-make/coverage/lib/used_inline_crate.rs
deleted file mode 100644
index 4a052756d4e..00000000000
--- a/src/test/run-make/coverage/lib/used_inline_crate.rs
+++ /dev/null
@@ -1,90 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
-
-use std::fmt::Debug;
-
-pub fn used_function() {
-    // Initialize test constants in a way that cannot be determined at compile time, to ensure
-    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
-    // dependent conditions.
-    let is_true = std::env::args().len() == 1;
-    let mut countdown = 0;
-    if is_true {
-        countdown = 10;
-    }
-    use_this_lib_crate();
-}
-
-#[inline(always)]
-pub fn used_inline_function() {
-    // Initialize test constants in a way that cannot be determined at compile time, to ensure
-    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
-    // dependent conditions.
-    let is_true = std::env::args().len() == 1;
-    let mut countdown = 0;
-    if is_true {
-        countdown = 10;
-    }
-    use_this_lib_crate();
-}
-
-
-
-
-
-
-
-#[inline(always)]
-pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_only_from_bin_crate_generic_function with {:?}", arg);
-}
-// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`)
-
-#[inline(always)]
-pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
-    println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn unused_generic_function<T: Debug>(arg: T) {
-    println!("unused_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn unused_function() {
-    let is_true = std::env::args().len() == 1;
-    let mut countdown = 2;
-    if !is_true {
-        countdown = 20;
-    }
-}
-
-#[inline(always)]
-fn unused_private_function() {
-    let is_true = std::env::args().len() == 1;
-    let mut countdown = 2;
-    if !is_true {
-        countdown = 20;
-    }
-}
-
-fn use_this_lib_crate() {
-    used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
-    used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
-        "used from library used_crate.rs",
-    );
-    let some_vec = vec![5, 6, 7, 8];
-    used_only_from_this_lib_crate_generic_function(some_vec);
-    used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
-}