summaryrefslogtreecommitdiffstats
path: root/tests/codegen/issues/issue-75978.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/codegen/issues/issue-75978.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/codegen/issues/issue-75978.rs b/tests/codegen/issues/issue-75978.rs
new file mode 100644
index 000000000..f335e92c3
--- /dev/null
+++ b/tests/codegen/issues/issue-75978.rs
@@ -0,0 +1,19 @@
+// compile-flags: -O
+// min-llvm-version: 16
+
+#![crate_type = "lib"]
+
+#[no_mangle]
+pub fn test() -> u32 {
+ // CHECK-LABEL: @test(
+ // CHECK: ret i32 13
+ let s = [1, 2, 3, 4, 5, 6, 7];
+
+ let mut iter = s.iter();
+ let mut sum = 0;
+ while let Some(_) = iter.next() {
+ sum += iter.next().map_or(1, |&x| x)
+ }
+
+ sum
+}