about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-11 23:26:55 +0000
committerbors <bors@rust-lang.org>2023-05-11 23:26:55 +0000
commit5b24e12785e6a6bacb69953fb389bcd2fc11ae87 (patch)
tree3eb9d69f5ecb64af4ab0a034bbe4323ddfcc7da2 /compiler/rustc_codegen_llvm/src
parent2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd (diff)
parent15aa7fad7ec83db399c8a85c6b6777d0efc7bc53 (diff)
downloadrust-5b24e12785e6a6bacb69953fb389bcd2fc11ae87.tar.gz
rust-5b24e12785e6a6bacb69953fb389bcd2fc11ae87.zip
Auto merge of #111395 - scottmcm:slice-iter-zst-experiment, r=the8472
Simplify the implementation of iterators over slices of ZSTs

Currently, slice iterators over ZSTs store `end = start.wrapping_byte_add(len)`.

That's slightly convenient for `is_empty`, but kinda annoying for pretty much everything else -- see bugs like #42789, for example.

This PR instead changes it to just `end = ptr::invalid(len)` instead.

That's easier to think about (IMHO, at least) as well as easier to represent.

`next` is still to big to get inlined into the mir-opt/pre-codegen/ tests, but if I bump the inline threshold to force it to show the whole thing, this implementation is also less MIR:
```
> git diff --numstat
241     370     tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir
255     329     tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir
184     216     tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir
182     254     tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir
```
(That's ≈70 lines less for `Iter::next`, for example.)

r? `@ghost`

~~Built atop #111282, so draft until that lands.~~
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions