1
Fork 0

Auto merge of #115263 - matthiaskrgr:rollup-taqu2h0, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #114924 (coverage: Tidy up `run-coverage` tests in several small ways)
 - #114927 (CI: add more debug logging to Docker caching)
 - #114957 (tests: Fix tests for LoongArch64)
 - #115007 (Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`.)
 - #115098 (rust-gdbgui: remove excessive quotes)
 - #115111 (compile rust-anaylzer with `x check` if it's enabled)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-08-27 12:19:15 +00:00
commit 9558cdaf2e
51 changed files with 163 additions and 145 deletions

View file

@ -343,18 +343,31 @@ extern "Rust" {
fn __rust_alloc_error_handler(size: usize, align: usize) -> !; fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
} }
/// Abort on memory allocation error or failure. /// Signal a memory allocation error.
/// ///
/// Callers of memory allocation APIs wishing to abort computation /// Callers of memory allocation APIs wishing to cease execution
/// in response to an allocation error are encouraged to call this function, /// in response to an allocation error are encouraged to call this function,
/// rather than directly invoking `panic!` or similar. /// rather than directly invoking [`panic!`] or similar.
/// ///
/// The default behavior of this function is to print a message to standard error /// This function is guaranteed to diverge (not return normally with a value), but depending on
/// and abort the process. /// global configuration, it may either panic (resulting in unwinding or aborting as per
/// It can be replaced with [`set_alloc_error_hook`] and [`take_alloc_error_hook`]. /// configuration for all panics), or abort the process (with no unwinding).
///
/// The default behavior is:
///
/// * If the binary links against `std` (typically the case), then
/// print a message to standard error and abort the process.
/// This behavior can be replaced with [`set_alloc_error_hook`] and [`take_alloc_error_hook`].
/// Future versions of Rust may panic by default instead.
///
/// * If the binary does not link against `std` (all of its crates are marked
/// [`#![no_std]`][no_std]), then call [`panic!`] with a message.
/// [The panic handler] applies as to any panic.
/// ///
/// [`set_alloc_error_hook`]: ../../std/alloc/fn.set_alloc_error_hook.html /// [`set_alloc_error_hook`]: ../../std/alloc/fn.set_alloc_error_hook.html
/// [`take_alloc_error_hook`]: ../../std/alloc/fn.take_alloc_error_hook.html /// [`take_alloc_error_hook`]: ../../std/alloc/fn.take_alloc_error_hook.html
/// [The panic handler]: https://doc.rust-lang.org/reference/runtime.html#the-panic_handler-attribute
/// [no_std]: https://doc.rust-lang.org/reference/names/preludes.html#the-no_std-attribute
#[stable(feature = "global_alloc", since = "1.28.0")] #[stable(feature = "global_alloc", since = "1.28.0")]
#[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")] #[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")]
#[cfg(all(not(no_global_oom_handling), not(test)))] #[cfg(all(not(no_global_oom_handling), not(test)))]

View file

@ -290,15 +290,29 @@ static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut());
/// Registers a custom allocation error hook, replacing any that was previously registered. /// Registers a custom allocation error hook, replacing any that was previously registered.
/// ///
/// The allocation error hook is invoked when an infallible memory allocation fails, before /// The allocation error hook is invoked when an infallible memory allocation fails — that is,
/// the runtime aborts. The default hook prints a message to standard error, /// as a consequence of calling [`handle_alloc_error`] — before the runtime aborts.
/// but this behavior can be customized with the [`set_alloc_error_hook`] and
/// [`take_alloc_error_hook`] functions.
/// ///
/// The hook is provided with a `Layout` struct which contains information /// The allocation error hook is a global resource. [`take_alloc_error_hook`] may be used to
/// retrieve a previously registered hook and wrap or discard it.
///
/// # What the provided `hook` function should expect
///
/// The hook function is provided with a [`Layout`] struct which contains information
/// about the allocation that failed. /// about the allocation that failed.
/// ///
/// The allocation error hook is a global resource. /// The hook function may choose to panic or abort; in the event that it returns normally, this
/// will cause an immediate abort.
///
/// Since [`take_alloc_error_hook`] is a safe function that allows retrieving the hook, the hook
/// function must be _sound_ to call even if no memory allocations were attempted.
///
/// # The default hook
///
/// The default hook, used if [`set_alloc_error_hook`] is never called, prints a message to
/// standard error (and then returns, causing the runtime to abort the process).
/// Compiler options may cause it to panic instead, and the default behavior may be changed
/// to panicking in future versions of Rust.
/// ///
/// # Examples /// # Examples
/// ///

View file

@ -353,10 +353,17 @@ pub struct RustAnalyzer {
impl Step for RustAnalyzer { impl Step for RustAnalyzer {
type Output = (); type Output = ();
const ONLY_HOSTS: bool = true; const ONLY_HOSTS: bool = true;
const DEFAULT: bool = false; const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/rust-analyzer") let builder = run.builder;
run.path("src/tools/rust-analyzer").default_condition(
builder
.config
.tools
.as_ref()
.map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
)
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {

View file

@ -64,9 +64,8 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
docker --version >> $hash_key docker --version >> $hash_key
# Include cache version. Currently it is needed to bust Docker # Include cache version. Can be used to manually bust the Docker cache.
# cache key after opting in into the old Docker build backend. echo "2" >> $hash_key
echo "1" >> $hash_key
cksum=$(sha512sum $hash_key | \ cksum=$(sha512sum $hash_key | \
awk '{print $1}') awk '{print $1}')
@ -78,6 +77,10 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
set +e set +e
retry curl --max-time 600 -y 30 -Y 10 --connect-timeout 30 -f -L -C - \ retry curl --max-time 600 -y 30 -Y 10 --connect-timeout 30 -f -L -C - \
-o /tmp/rustci_docker_cache "$url" -o /tmp/rustci_docker_cache "$url"
docker_archive_hash=$(sha512sum /tmp/rustci_docker_cache | awk '{print $1}')
echo "Downloaded archive hash: ${docker_archive_hash}"
echo "Loading images into docker" echo "Loading images into docker"
# docker load sometimes hangs in the CI, so time out after 10 minutes with TERM, # docker load sometimes hangs in the CI, so time out after 10 minutes with TERM,
# KILL after 12 minutes # KILL after 12 minutes
@ -115,8 +118,10 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
digest=$(docker inspect rust-ci --format '{{.Id}}') digest=$(docker inspect rust-ci --format '{{.Id}}')
echo "Built container $digest" echo "Built container $digest"
if ! grep -q "$digest" <(echo "$loaded_images"); then if ! grep -q "$digest" <(echo "$loaded_images"); then
echo "Uploading finished image to $url" echo "Uploading finished image $digest to $url"
set +e set +e
# Print image history for easier debugging of layer SHAs
docker history rust-ci
docker history -q rust-ci | \ docker history -q rust-ci | \
grep -v missing | \ grep -v missing | \
xargs docker save | \ xargs docker save | \
@ -131,6 +136,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
mkdir -p "$dist" mkdir -p "$dist"
echo "$url" >"$info" echo "$url" >"$info"
echo "$digest" >>"$info" echo "$digest" >>"$info"
cat "$info"
fi fi
elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
if isCI; then if isCI; then

View file

@ -55,9 +55,9 @@ RUST_GDBGUI="${RUST_GDBGUI:-gdbgui}"
# These arguments get passed through to GDB and make it load the # These arguments get passed through to GDB and make it load the
# Rust pretty printers. # Rust pretty printers.
GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\"" \ GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" \
"-iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\"" \ -iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\" \
"-iex \"set substitute-path /rustc/$RUSTC_COMMIT_HASH $RUSTC_SYSROOT/lib/rustlib/src/rust\"" -iex \"set substitute-path /rustc/$RUSTC_COMMIT_HASH $RUSTC_SYSROOT/lib/rustlib/src/rust\""
# Finally we execute gdbgui. # Finally we execute gdbgui.
PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \ PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \

View file

@ -250,11 +250,11 @@ pub struct IntDoubleInt {
c: i32, c: i32,
} }
// CHECK: define void @f_int_double_int_s_arg(ptr noalias nocapture noundef dereferenceable(24) %a) // CHECK: define void @f_int_double_int_s_arg(ptr noalias nocapture noundef align 8 dereferenceable(24) %a)
#[no_mangle] #[no_mangle]
pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {} pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {}
// CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret(%IntDoubleInt) dereferenceable(24) %0) // CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret(%IntDoubleInt) align 8 dereferenceable(24) %_0)
#[no_mangle] #[no_mangle]
pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt { pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt {
IntDoubleInt { a: 1, b: 2., c: 3 } IntDoubleInt { a: 1, b: 2., c: 3 }

View file

@ -10,6 +10,8 @@ $DIR/auxiliary/doctest_crate.rs:
LL| 3|} LL| 3|}
$DIR/doctest.rs: $DIR/doctest.rs:
LL| |// aux-build:doctest_crate.rs
LL| |
LL| |//! This test ensures that code from doctests is properly re-mapped. LL| |//! This test ensures that code from doctests is properly re-mapped.
LL| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info. LL| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
LL| |//! LL| |//!
@ -78,7 +80,7 @@ $DIR/doctest.rs:
LL| |//! doctest_main() LL| |//! doctest_main()
LL| |//! } LL| |//! }
LL| |//! ``` LL| |//! ```
LL| |// aux-build:doctest_crate.rs LL| |
LL| |/// doctest attached to fn testing external code: LL| |/// doctest attached to fn testing external code:
LL| |/// ``` LL| |/// ```
LL| 1|/// extern crate doctest_crate; LL| 1|/// extern crate doctest_crate;

View file

@ -1,3 +1,5 @@
// aux-build:doctest_crate.rs
//! This test ensures that code from doctests is properly re-mapped. //! This test ensures that code from doctests is properly re-mapped.
//! See <https://github.com/rust-lang/rust/issues/79417> for more info. //! See <https://github.com/rust-lang/rust/issues/79417> for more info.
//! //!
@ -63,7 +65,7 @@
//! doctest_main() //! doctest_main()
//! } //! }
//! ``` //! ```
// aux-build:doctest_crate.rs
/// doctest attached to fn testing external code: /// doctest attached to fn testing external code:
/// ``` /// ```
/// extern crate doctest_crate; /// extern crate doctest_crate;

View file

@ -1,11 +1,5 @@
LL| |// compile-flags: --edition=2018 LL| |// compile-flags: --edition=2018
LL| | LL| |
LL| |use core::{
LL| | future::Future,
LL| | marker::Send,
LL| | pin::Pin,
LL| |};
LL| |
LL| 1|fn non_async_func() { LL| 1|fn non_async_func() {
LL| 1| println!("non_async_func was covered"); LL| 1| println!("non_async_func was covered");
LL| 1| let b = true; LL| 1| let b = true;
@ -15,9 +9,6 @@
^0 ^0
LL| 1|} LL| 1|}
LL| | LL| |
LL| |
LL| |
LL| |
LL| 1|async fn async_func() { LL| 1|async fn async_func() {
LL| 1| println!("async_func was covered"); LL| 1| println!("async_func was covered");
LL| 1| let b = true; LL| 1| let b = true;
@ -27,9 +18,6 @@
^0 ^0
LL| 1|} LL| 1|}
LL| | LL| |
LL| |
LL| |
LL| |
LL| 1|async fn async_func_just_println() { LL| 1|async fn async_func_just_println() {
LL| 1| println!("async_func_just_println was covered"); LL| 1| println!("async_func_just_println was covered");
LL| 1|} LL| 1|}

View file

@ -1,11 +1,5 @@
// compile-flags: --edition=2018 // compile-flags: --edition=2018
use core::{
future::Future,
marker::Send,
pin::Pin,
};
fn non_async_func() { fn non_async_func() {
println!("non_async_func was covered"); println!("non_async_func was covered");
let b = true; let b = true;
@ -14,9 +8,6 @@ fn non_async_func() {
} }
} }
async fn async_func() { async fn async_func() {
println!("async_func was covered"); println!("async_func was covered");
let b = true; let b = true;
@ -25,9 +16,6 @@ async fn async_func() {
} }
} }
async fn async_func_just_println() { async fn async_func_just_println() {
println!("async_func_just_println was covered"); println!("async_func_just_println was covered");
} }

View file

@ -1,3 +1,4 @@
#[allow(dead_code)]
pub fn never_called_function() { pub fn never_called_function() {
println!("I am never called"); println!("I am never called");
} }

View file

@ -1,6 +1,8 @@
#![allow(unused_assignments, unused_variables)] #![allow(unused_assignments, unused_variables)]
// Verify that coverage works with optimizations:
// compile-flags: -C opt-level=3 // compile-flags: -C opt-level=3
use std::fmt::Debug; // ^^ validates coverage now works with optimizations
use std::fmt::Debug;
pub fn used_function() { pub fn used_function() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure // Initialize test constants in a way that cannot be determined at compile time, to ensure
@ -42,6 +44,7 @@ pub fn unused_function() {
} }
} }
#[allow(dead_code)]
fn unused_private_function() { fn unused_private_function() {
let is_true = std::env::args().len() == 1; let is_true = std::env::args().len() == 1;
let mut countdown = 2; let mut countdown = 2;

View file

@ -1,7 +1,7 @@
#![allow(unused_assignments, unused_variables)] #![allow(unused_assignments, unused_variables)]
// Verify that coverage works with optimizations:
// compile-flags: -C opt-level=3 // compile-flags: -C opt-level=3
// ^^ validates coverage now works with optimizations
use std::fmt::Debug; use std::fmt::Debug;
pub fn used_function() { pub fn used_function() {
@ -29,12 +29,6 @@ pub fn used_inline_function() {
use_this_lib_crate(); use_this_lib_crate();
} }
#[inline(always)] #[inline(always)]
pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
println!("used_only_from_bin_crate_generic_function with {:?}", arg); println!("used_only_from_bin_crate_generic_function with {:?}", arg);
@ -71,6 +65,7 @@ pub fn unused_function() {
} }
#[inline(always)] #[inline(always)]
#[allow(dead_code)]
fn unused_private_function() { fn unused_private_function() {
let is_true = std::env::args().len() == 1; let is_true = std::env::args().len() == 1;
let mut countdown = 2; let mut countdown = 2;

View file

@ -1,6 +1,11 @@
LL| |#![allow(unused_assignments, unused_variables)] LL| |#![allow(unused_assignments, unused_variables)]
LL| |// compile-flags: -C opt-level=2 LL| |// compile-flags: -C opt-level=2
LL| 1|fn main() { // ^^ fix described in rustc_middle/mir/mono.rs LL| |
LL| |// This test used to be sensitive to certain coverage-specific hacks in
LL| |// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by
LL| |// <https://github.com/rust-lang/rust/pull/83666>.
LL| |
LL| 1|fn main() {
LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure 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| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
LL| 1| // dependent conditions. LL| 1| // dependent conditions.

View file

@ -1,6 +1,11 @@
#![allow(unused_assignments, unused_variables)] #![allow(unused_assignments, unused_variables)]
// compile-flags: -C opt-level=2 // compile-flags: -C opt-level=2
fn main() { // ^^ fix described in rustc_middle/mir/mono.rs
// This test used to be sensitive to certain coverage-specific hacks in
// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by
// <https://github.com/rust-lang/rust/pull/83666>.
fn main() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure // 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 // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
// dependent conditions. // dependent conditions.

View file

@ -42,7 +42,7 @@
LL| | LL| |
LL| |#[no_coverage] LL| |#[no_coverage]
LL| |fn main() { LL| |fn main() {
LL| | executor::block_on(test()); LL| | executor::block_on(test()).unwrap();
LL| |} LL| |}
LL| | LL| |
LL| |mod executor { LL| |mod executor {
@ -57,16 +57,12 @@
LL| | let mut future = unsafe { Pin::new_unchecked(&mut future) }; LL| | let mut future = unsafe { Pin::new_unchecked(&mut future) };
LL| | use std::hint::unreachable_unchecked; LL| | use std::hint::unreachable_unchecked;
LL| | static VTABLE: RawWakerVTable = RawWakerVTable::new( LL| | static VTABLE: RawWakerVTable = RawWakerVTable::new(
LL| |
LL| | #[no_coverage] LL| | #[no_coverage]
LL| | |_| unsafe { unreachable_unchecked() }, // clone LL| | |_| unsafe { unreachable_unchecked() }, // clone
LL| |
LL| | #[no_coverage] LL| | #[no_coverage]
LL| | |_| unsafe { unreachable_unchecked() }, // wake LL| | |_| unsafe { unreachable_unchecked() }, // wake
LL| |
LL| | #[no_coverage] LL| | #[no_coverage]
LL| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref LL| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref
LL| |
LL| | #[no_coverage] LL| | #[no_coverage]
LL| | |_| (), LL| | |_| (),
LL| | ); LL| | );

View file

@ -41,7 +41,7 @@ pub async fn test() -> Result<(), String> {
#[no_coverage] #[no_coverage]
fn main() { fn main() {
executor::block_on(test()); executor::block_on(test()).unwrap();
} }
mod executor { mod executor {
@ -56,16 +56,12 @@ mod executor {
let mut future = unsafe { Pin::new_unchecked(&mut future) }; let mut future = unsafe { Pin::new_unchecked(&mut future) };
use std::hint::unreachable_unchecked; use std::hint::unreachable_unchecked;
static VTABLE: RawWakerVTable = RawWakerVTable::new( static VTABLE: RawWakerVTable = RawWakerVTable::new(
#[no_coverage] #[no_coverage]
|_| unsafe { unreachable_unchecked() }, // clone |_| unsafe { unreachable_unchecked() }, // clone
#[no_coverage] #[no_coverage]
|_| unsafe { unreachable_unchecked() }, // wake |_| unsafe { unreachable_unchecked() }, // wake
#[no_coverage] #[no_coverage]
|_| unsafe { unreachable_unchecked() }, // wake_by_ref |_| unsafe { unreachable_unchecked() }, // wake_by_ref
#[no_coverage] #[no_coverage]
|_| (), |_| (),
); );

View file

@ -59,7 +59,6 @@
LL| | } LL| | }
LL| 0| } LL| 0| }
LL| | LL| |
LL| |
LL| 1| let mut countdown = 0; LL| 1| let mut countdown = 0;
LL| 1| if true { LL| 1| if true {
LL| 1| countdown = 1; LL| 1| countdown = 1;

View file

@ -55,7 +55,6 @@ fn main() {
} }
} }
let mut countdown = 0; let mut countdown = 0;
if true { if true {
countdown = 1; countdown = 1;

View file

@ -1,4 +1,4 @@
LL| |#![allow(unused_assignments, unused_variables)] LL| |#![allow(dead_code, unused_assignments, unused_variables)]
LL| | LL| |
LL| 0|pub fn unused_pub_fn_not_in_library() { LL| 0|pub fn unused_pub_fn_not_in_library() {
LL| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure LL| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure

View file

@ -1,4 +1,4 @@
#![allow(unused_assignments, unused_variables)] #![allow(dead_code, unused_assignments, unused_variables)]
pub fn unused_pub_fn_not_in_library() { pub fn unused_pub_fn_not_in_library() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure // Initialize test constants in a way that cannot be determined at compile time, to ensure

View file

@ -54,10 +54,6 @@
LL| 1| return Err(1); LL| 1| return Err(1);
LL| 0| } LL| 0| }
LL| 0| LL| 0|
LL| 0|
LL| 0|
LL| 0|
LL| 0|
LL| 0| let _ = Firework { strength: 1000 }; LL| 0| let _ = Firework { strength: 1000 };
LL| 0| LL| 0|
LL| 0| Ok(()) LL| 0| Ok(())

View file

@ -32,10 +32,6 @@ fn main() -> Result<(),u8> {
return Err(1); return Err(1);
} }
let _ = Firework { strength: 1000 }; let _ = Firework { strength: 1000 };
Ok(()) Ok(())

View file

@ -24,6 +24,7 @@ $DIR/auxiliary/inline_always_with_dead_code.rs:
$DIR/issue-85461.rs: $DIR/issue-85461.rs:
LL| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] LL| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]
LL| |
LL| |// aux-build:inline_always_with_dead_code.rs LL| |// aux-build:inline_always_with_dead_code.rs
LL| |extern crate inline_always_with_dead_code; LL| |extern crate inline_always_with_dead_code;
LL| | LL| |

View file

@ -1,4 +1,5 @@
// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] // Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]
// aux-build:inline_always_with_dead_code.rs // aux-build:inline_always_with_dead_code.rs
extern crate inline_always_with_dead_code; extern crate inline_always_with_dead_code;

View file

@ -1,3 +1,5 @@
LL| |#![allow(dead_code, unreachable_code)]
LL| |
LL| |// Regression test for #93054: Functions using uninhabited types often only have a single, LL| |// Regression test for #93054: Functions using uninhabited types often only have a single,
LL| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. LL| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
LL| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. LL| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.

View file

@ -1,3 +1,5 @@
#![allow(dead_code, unreachable_code)]
// Regression test for #93054: Functions using uninhabited types often only have a single, // Regression test for #93054: Functions using uninhabited types often only have a single,
// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. // unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. // Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.

View file

@ -9,8 +9,7 @@
LL| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { LL| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
LL| 1| if true { LL| 1| if true {
LL| 1| if false { LL| 1| if false {
LL| 0| while true { LL| 0| while true {}
LL| 0| }
LL| 1| } LL| 1| }
LL| 1| write!(f, "cool")?; LL| 1| write!(f, "cool")?;
^0 ^0

View file

@ -9,8 +9,7 @@ impl std::fmt::Debug for DebugTest {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
if true { if true {
if false { if false {
while true { while true {}
}
} }
write!(f, "cool")?; write!(f, "cool")?;
} else { } else {

View file

@ -1,5 +1,3 @@
LL| |#![feature(or_patterns)]
LL| |
LL| 1|fn main() { LL| 1|fn main() {
LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure 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| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from

View file

@ -1,5 +1,3 @@
#![feature(or_patterns)]
fn main() { fn main() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure // 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 // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from

View file

@ -12,6 +12,7 @@
LL| |} LL| |}
LL| | LL| |
LL| |#[no_coverage] LL| |#[no_coverage]
LL| |#[allow(dead_code)]
LL| |fn do_not_add_coverage_not_called() { LL| |fn do_not_add_coverage_not_called() {
LL| | println!("not called and not covered"); LL| | println!("not called and not covered");
LL| |} LL| |}
@ -24,6 +25,7 @@
LL| 1| println!("called and covered"); LL| 1| println!("called and covered");
LL| 1|} LL| 1|}
LL| | LL| |
LL| |#[allow(dead_code)]
LL| 0|fn add_coverage_not_called() { LL| 0|fn add_coverage_not_called() {
LL| 0| println!("not called but covered"); LL| 0| println!("not called but covered");
LL| 0|} LL| 0|}

View file

@ -12,6 +12,7 @@ fn do_not_add_coverage_2() {
} }
#[no_coverage] #[no_coverage]
#[allow(dead_code)]
fn do_not_add_coverage_not_called() { fn do_not_add_coverage_not_called() {
println!("not called and not covered"); println!("not called and not covered");
} }
@ -24,6 +25,7 @@ fn add_coverage_2() {
println!("called and covered"); println!("called and covered");
} }
#[allow(dead_code)]
fn add_coverage_not_called() { fn add_coverage_not_called() {
println!("not called but covered"); println!("not called but covered");
} }

View file

@ -1,3 +1,5 @@
LL| |#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)]
LL| |
LL| 2|fn foo<T>(x: T) { LL| 2|fn foo<T>(x: T) {
LL| 2| let mut i = 0; LL| 2| let mut i = 0;
LL| 22| while i < 10 { LL| 22| while i < 10 {

View file

@ -1,3 +1,5 @@
#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)]
fn foo<T>(x: T) { fn foo<T>(x: T) {
let mut i = 0; let mut i = 0;
while i < 10 { while i < 10 {

View file

@ -1,4 +1,5 @@
$DIR/auxiliary/unused_mod_helper.rs: $DIR/auxiliary/unused_mod_helper.rs:
LL| |#[allow(dead_code)]
LL| 0|pub fn never_called_function() { LL| 0|pub fn never_called_function() {
LL| 0| println!("I am never called"); LL| 0| println!("I am never called");
LL| 0|} LL| 0|}

View file

@ -1,7 +1,9 @@
$DIR/auxiliary/used_crate.rs: $DIR/auxiliary/used_crate.rs:
LL| |#![allow(unused_assignments, unused_variables)] LL| |#![allow(unused_assignments, unused_variables)]
LL| |// Verify that coverage works with optimizations:
LL| |// compile-flags: -C opt-level=3 LL| |// compile-flags: -C opt-level=3
LL| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations LL| |
LL| |use std::fmt::Debug;
LL| | LL| |
LL| 1|pub fn used_function() { 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| // Initialize test constants in a way that cannot be determined at compile time, to ensure
@ -90,6 +92,7 @@ $DIR/auxiliary/used_crate.rs:
LL| 0| } LL| 0| }
LL| 0|} LL| 0|}
LL| | LL| |
LL| |#[allow(dead_code)]
LL| 0|fn unused_private_function() { LL| 0|fn unused_private_function() {
LL| 0| let is_true = std::env::args().len() == 1; LL| 0| let is_true = std::env::args().len() == 1;
LL| 0| let mut countdown = 2; LL| 0| let mut countdown = 2;

View file

@ -1,8 +1,8 @@
$DIR/auxiliary/used_inline_crate.rs: $DIR/auxiliary/used_inline_crate.rs:
LL| |#![allow(unused_assignments, unused_variables)] LL| |#![allow(unused_assignments, unused_variables)]
LL| | LL| |// Verify that coverage works with optimizations:
LL| |// compile-flags: -C opt-level=3 LL| |// compile-flags: -C opt-level=3
LL| |// ^^ validates coverage now works with optimizations LL| |
LL| |use std::fmt::Debug; LL| |use std::fmt::Debug;
LL| | LL| |
LL| 1|pub fn used_function() { LL| 1|pub fn used_function() {
@ -32,12 +32,6 @@ $DIR/auxiliary/used_inline_crate.rs:
LL| 1| use_this_lib_crate(); LL| 1| use_this_lib_crate();
LL| 1|} LL| 1|}
LL| | LL| |
LL| |
LL| |
LL| |
LL| |
LL| |
LL| |
LL| |#[inline(always)] LL| |#[inline(always)]
LL| 2|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { 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| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
@ -120,6 +114,7 @@ $DIR/auxiliary/used_inline_crate.rs:
LL| 0|} LL| 0|}
LL| | LL| |
LL| |#[inline(always)] LL| |#[inline(always)]
LL| |#[allow(dead_code)]
LL| 0|fn unused_private_function() { LL| 0|fn unused_private_function() {
LL| 0| let is_true = std::env::args().len() == 1; LL| 0| let is_true = std::env::args().len() == 1;
LL| 0| let mut countdown = 2; LL| 0| let mut countdown = 2;

View file

@ -7,7 +7,7 @@
LL| 1|fn main() { LL| 1|fn main() {
LL| 1| let mut generator = || { LL| 1| let mut generator = || {
LL| 1| yield 1; LL| 1| yield 1;
LL| 1| return "foo" LL| 1| return "foo";
LL| 1| }; LL| 1| };
LL| | LL| |
LL| 1| match Pin::new(&mut generator).resume(()) { LL| 1| match Pin::new(&mut generator).resume(()) {
@ -23,7 +23,7 @@
LL| 1| yield 1; LL| 1| yield 1;
LL| 1| yield 2; LL| 1| yield 2;
LL| 0| yield 3; LL| 0| yield 3;
LL| 0| return "foo" LL| 0| return "foo";
LL| 0| }; LL| 0| };
LL| | LL| |
LL| 1| match Pin::new(&mut generator).resume(()) { LL| 1| match Pin::new(&mut generator).resume(()) {

View file

@ -7,7 +7,7 @@ use std::pin::Pin;
fn main() { fn main() {
let mut generator = || { let mut generator = || {
yield 1; yield 1;
return "foo" return "foo";
}; };
match Pin::new(&mut generator).resume(()) { match Pin::new(&mut generator).resume(()) {
@ -23,7 +23,7 @@ fn main() {
yield 1; yield 1;
yield 2; yield 2;
yield 3; yield 3;
return "foo" return "foo";
}; };
match Pin::new(&mut generator).resume(()) { match Pin::new(&mut generator).resume(()) {