diff options
Diffstat (limited to '')
-rw-r--r-- | tests/mir-opt/pre-codegen/slice_iter.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/mir-opt/pre-codegen/slice_iter.rs b/tests/mir-opt/pre-codegen/slice_iter.rs index ca423ca55..4e954aa34 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.rs +++ b/tests/mir-opt/pre-codegen/slice_iter.rs @@ -1,6 +1,7 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit // ignore-debug +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] @@ -36,3 +37,18 @@ pub fn reverse_loop<'a, T>(slice: &'a [T], f: impl Fn(&T)) { f(x) } } + +// EMIT_MIR slice_iter.enumerated_loop.PreCodegen.after.mir +pub fn enumerated_loop<'a, T>(slice: &'a [T], f: impl Fn(usize, &T)) { + for (i, x) in slice.iter().enumerate() { + f(i, x) + } +} + +// EMIT_MIR slice_iter.range_loop.PreCodegen.after.mir +pub fn range_loop<'a, T>(slice: &'a [T], f: impl Fn(usize, &T)) { + for i in 0..slice.len() { + let x = &slice[i]; + f(i, x) + } +} |