summaryrefslogtreecommitdiffstats
path: root/tests/run-make/coverage/while_early_ret.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/run-make/coverage/while_early_ret.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/coverage/while_early_ret.rs')
-rw-r--r--tests/run-make/coverage/while_early_ret.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/run-make/coverage/while_early_ret.rs b/tests/run-make/coverage/while_early_ret.rs
new file mode 100644
index 000000000..1fcea9c85
--- /dev/null
+++ b/tests/run-make/coverage/while_early_ret.rs
@@ -0,0 +1,42 @@
+#![allow(unused_assignments)]
+// expect-exit-status-1
+
+fn main() -> Result<(),u8> {
+ let mut countdown = 10;
+ while
+ countdown
+ >
+ 0
+ {
+ if
+ countdown
+ <
+ 5
+ {
+ return
+ if
+ countdown
+ >
+ 8
+ {
+ Ok(())
+ }
+ else
+ {
+ Err(1)
+ }
+ ;
+ }
+ countdown
+ -=
+ 1
+ ;
+ }
+ Ok(())
+}
+
+// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and
+// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux
+// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program
+// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical
+// to the coverage test for early returns, but this is a limitation that should be fixed.