diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/mir-opt/pre-codegen/slice_iter.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/pre-codegen/slice_iter.rs')
-rw-r--r-- | tests/mir-opt/pre-codegen/slice_iter.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/mir-opt/pre-codegen/slice_iter.rs b/tests/mir-opt/pre-codegen/slice_iter.rs new file mode 100644 index 000000000..ca423ca55 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.rs @@ -0,0 +1,38 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + +#![crate_type = "lib"] + +// When this test was added, the MIR for `next` was 174 lines just for the basic +// blocks -- far more if you counted the scopes. The goal of having this here +// is to hopefully keep it a reasonable size, ideally eventually small enough +// that the mir inliner would actually be willing to inline it, since it's an +// important building block and usually very few *backend* instructions. + +// As such, feel free to `--bless` whatever changes you get here, so long as +// doing so doesn't add substantially more MIR. + +// EMIT_MIR slice_iter.slice_iter_next.PreCodegen.after.mir +pub fn slice_iter_next<'a, T>(it: &mut std::slice::Iter<'a, T>) -> Option<&'a T> { + it.next() +} + +// EMIT_MIR slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir +pub fn slice_iter_mut_next_back<'a, T>(it: &mut std::slice::IterMut<'a, T>) -> Option<&'a mut T> { + it.next_back() +} + +// EMIT_MIR slice_iter.forward_loop.PreCodegen.after.mir +pub fn forward_loop<'a, T>(slice: &'a [T], f: impl Fn(&T)) { + for x in slice.iter() { + f(x) + } +} + +// EMIT_MIR slice_iter.reverse_loop.PreCodegen.after.mir +pub fn reverse_loop<'a, T>(slice: &'a [T], f: impl Fn(&T)) { + for x in slice.iter().rev() { + f(x) + } +} |