rust/tests
bors 5423745db8 Auto merge of #105871 - llogiq:option-as-slice, r=scottmcm
Add `Option::as_`(`mut_`)`slice`

This adds the following functions:

* `Option<T>::as_slice(&self) -> &[T]`
* `Option<T>::as_mut_slice(&mut self) -> &[T]`

The `as_slice` and `as_mut_slice_mut` functions benefit from an optimization that makes them completely branch-free. ~~Unfortunately, this optimization is not available on by-value Options, therefore the `into_slice` implementations use the plain `match` + `slice::from_ref` approach.~~

Note that the optimization's soundness hinges on the fact that either the niche optimization makes the offset of the `Some(_)` contents zero or the mempory layout of `Option<T>` is equal to that of `Option<MaybeUninit<T>>`.

The idea has been discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Option.3A.3Aas_slice). Notably the idea for the `as_slice_mut` and `into_slice´ methods came from `@cuviper` and `@Sp00ph` hardened the optimization against niche-optimized Options.

The [rust playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=74f8e4239a19f454c183aaf7b4a969e0) shows that the generated assembly of the optimized method is basically only a copy while the naive method generates code containing a `test dx, dx` on x86_64.

---

EDIT from reviewer: ACP is https://github.com/rust-lang/libs-team/issues/150
2023-03-01 12:32:57 +00:00
..
assembly Update the minimum external LLVM to 14 2023-02-10 16:06:25 -08:00
auxiliary
codegen Add Option::as_slice(_mut) 2023-03-01 00:05:31 +01:00
codegen-units
debuginfo Remove the capture_disjoint_fields feature 2023-02-28 01:21:15 +00:00
incremental
mir-opt Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank 2023-02-28 01:14:56 +00:00
pretty Update tests. 2023-01-29 20:19:26 +01:00
run-make errors: fix translation's run-make test 2023-02-22 09:15:54 +00:00
run-make-fulldeps various: translation resources from cg backend 2023-02-22 09:15:54 +00:00
run-pass-valgrind
rustdoc rustdoc: avoid including <li> tags in item table short desc 2023-02-23 13:53:27 -07:00
rustdoc-gui No need for the wait-for anymore to go around browser navigation bug 2023-02-23 22:04:38 +01:00
rustdoc-js
rustdoc-js-std rustdoc: hide reference methods in search index 2023-02-16 17:21:57 -07:00
rustdoc-json Add regression test for #107677 2023-02-18 18:28:17 +01:00
rustdoc-ui Auto merge of #108473 - matthiaskrgr:rollup-qjyae58, r=matthiaskrgr 2023-02-26 02:04:23 +00:00
ui Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgr 2023-03-01 06:23:19 +00:00
ui-fulldeps Auto merge of #108233 - ChrisDenton:move-std-tests, r=thomcc 2023-02-25 10:26:57 +00:00
COMPILER_TESTS.md