]>
git.proxmox.com Git - rustc.git/blob - tests/mir-opt/pre-codegen/slice_iter.rs
1 // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
4 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
8 // When this test was added, the MIR for `next` was 174 lines just for the basic
9 // blocks -- far more if you counted the scopes. The goal of having this here
10 // is to hopefully keep it a reasonable size, ideally eventually small enough
11 // that the mir inliner would actually be willing to inline it, since it's an
12 // important building block and usually very few *backend* instructions.
14 // As such, feel free to `--bless` whatever changes you get here, so long as
15 // doing so doesn't add substantially more MIR.
17 // EMIT_MIR slice_iter.slice_iter_next.PreCodegen.after.mir
18 pub fn slice_iter_next
<'a
, T
>(it
: &mut std
::slice
::Iter
<'a
, T
>) -> Option
<&'a T
> {
22 // EMIT_MIR slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir
23 pub fn slice_iter_mut_next_back
<'a
, T
>(it
: &mut std
::slice
::IterMut
<'a
, T
>) -> Option
<&'a
mut T
> {
27 // EMIT_MIR slice_iter.forward_loop.PreCodegen.after.mir
28 pub fn forward_loop
<'a
, T
>(slice
: &'a
[T
], f
: impl Fn(&T
)) {
29 for x
in slice
.iter() {
34 // EMIT_MIR slice_iter.reverse_loop.PreCodegen.after.mir
35 pub fn reverse_loop
<'a
, T
>(slice
: &'a
[T
], f
: impl Fn(&T
)) {
36 for x
in slice
.iter().rev() {
41 // EMIT_MIR slice_iter.enumerated_loop.PreCodegen.after.mir
42 pub fn enumerated_loop
<'a
, T
>(slice
: &'a
[T
], f
: impl Fn(usize, &T
)) {
43 for (i
, x
) in slice
.iter().enumerate() {
48 // EMIT_MIR slice_iter.range_loop.PreCodegen.after.mir
49 pub fn range_loop
<'a
, T
>(slice
: &'a
[T
], f
: impl Fn(usize, &T
)) {
50 for i
in 0..slice
.len() {