rust/tests
Guillaume Boisseau e3c0158788
Rollup merge of #120504 - kornelski:try_with_capacity, r=Amanieu
Vec::try_with_capacity

Related to #91913

Implements try_with_capacity for `Vec`, `VecDeque`, and `String`. I can follow it up with more collections if desired.

`Vec::try_with_capacity()` is functionally equivalent to the current stable:

```rust
let mut v = Vec::new();
v.try_reserve_exact(n)?
```

However, `try_reserve` calls non-inlined `finish_grow`, which requires old and new `Layout`, and is designed to reallocate memory. There is benefit to using `try_with_capacity`, besides syntax convenience, because it generates much smaller code at the call site with a direct call to the allocator. There's codegen test included.

It's also a very desirable functionality for users of `no_global_oom_handling` (Rust-for-Linux), since it makes a very commonly used function available in that environment (`with_capacity` is used much more frequently than all `(try_)reserve(_exact)`).
2024-03-09 21:40:06 +01:00
..
assembly Rollup merge of #121832 - heiher:loongarch64-musl, r=wesleywiser 2024-03-08 08:19:18 +01:00
auxiliary
codegen Rollup merge of #120504 - kornelski:try_with_capacity, r=Amanieu 2024-03-09 21:40:06 +01:00
codegen-units [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
coverage-run-rustdoc [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
debuginfo Update debuginfo tests 2024-03-05 00:19:44 +00:00
incremental fix use of platform_intrinsics in tests 2024-02-25 08:15:44 +01:00
mir-opt Update MIR with MirPatch in UninhabitedEnumBranching 2024-03-08 08:15:14 +08:00
pretty Re-bless tests/pretty 2024-02-22 16:04:05 +00:00
run-make Rollup merge of #121683 - fortanix:raoul/lvi_fixes, r=cuviper 2024-03-04 22:16:31 +01:00
run-make-fulldeps Rename all ParseSess variables/fields/lifetimes as psess. 2024-03-05 08:11:45 +11:00
run-pass-valgrind [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
rustdoc Update test names to not have dots 2024-03-05 09:02:33 +00:00
rustdoc-gui [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
rustdoc-js [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
rustdoc-js-std Add display method to OsStr 2024-01-18 20:38:31 +00:00
rustdoc-json [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
rustdoc-ui Auto merge of #122190 - matthiaskrgr:rollup-9ol4y30, r=matthiaskrgr 2024-03-08 17:31:00 +00:00
ui Rollup merge of #120504 - kornelski:try_with_capacity, r=Amanieu 2024-03-09 21:40:06 +01:00
ui-fulldeps Rewrite the untranslatable_diagnostic lint. 2024-03-06 14:19:01 +11:00
COMPILER_TESTS.md