diff options
| author | bors <bors@rust-lang.org> | 2025-06-18 03:18:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-06-18 03:18:10 +0000 |
| commit | 27733d46d79f4eb92e240fbba502c43022665735 (patch) | |
| tree | be5214bb2385eb8d2b35bf47e14924a9a3b712e6 /tests/codegen | |
| parent | 77ec48f5642ee1aa451d270f11f308c297f55f76 (diff) | |
| parent | 8f77681656c47aa09d1b66f87dc249aae1694d07 (diff) | |
| download | rust-27733d46d79f4eb92e240fbba502c43022665735.tar.gz rust-27733d46d79f4eb92e240fbba502c43022665735.zip | |
Auto merge of #130887 - Soveu:repeatn, r=scottmcm
Safer implementation of RepeatN I've seen the "Use MaybeUninit for RepeatN" commit while reading This Week In Rust and immediately thought about something I've written some time ago - https://github.com/Soveu/repeat_finite/blob/master/src/lib.rs. Using the fact, that `Option` will find niche in `(T, NonZeroUsize)`, we can construct something that has the same size as `(T, usize)` while completely getting rid of `MaybeUninit`. This leaves only `unsafe` on `TrustedLen`, which is pretty neat.
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/iter-repeat-n-trivial-drop.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 3bb942d11d5..28173530324 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -1,5 +1,6 @@ //@ compile-flags: -C opt-level=3 //@ only-x86_64 +//@ needs-deterministic-layouts #![crate_type = "lib"] #![feature(iter_repeat_n)] @@ -25,10 +26,10 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN<NotCopy>) -> Option<NotCop // CHECK-NEXT: br i1 %[[COUNT_ZERO]], label %[[EMPTY:.+]], label %[[NOT_EMPTY:.+]] // CHECK: [[NOT_EMPTY]]: - // CHECK-NEXT: %[[DEC:.+]] = add i64 %[[COUNT]], -1 - // CHECK-NEXT: store i64 %[[DEC]] // CHECK-NOT: br - // CHECK: %[[VAL:.+]] = load i16 + // CHECK: %[[DEC:.+]] = add i64 %[[COUNT]], -1 + // CHECK-NEXT: %[[VAL:.+]] = load i16 + // CHECK-NEXT: store i64 %[[DEC]] // CHECK-NEXT: br label %[[EMPTY]] // CHECK: [[EMPTY]]: |
