diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-19 14:43:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-19 14:43:19 +0200 |
| commit | 35188440b5e3d02acdb02f616aad800c9c377dca (patch) | |
| tree | ebe1a0bec997b025778ab512717a439f8a1dc429 /compiler/rustc_codegen_gcc | |
| parent | 5f10d1312dc53758824bd1da5fdbc4175e8d1c61 (diff) | |
| parent | 8cec88ba76e1d6edc98f30101c40f9247c754898 (diff) | |
| download | rust-35188440b5e3d02acdb02f616aad800c9c377dca.tar.gz rust-35188440b5e3d02acdb02f616aad800c9c377dca.zip | |
Rollup merge of #96089 - ojeda:no-vec-no_global_oom_handling, r=Mark-Simulacrum
`alloc`: make `vec!` unavailable under `no_global_oom_handling` `alloc`: make `vec!` unavailable under `no_global_oom_handling` The `vec!` macro has 3 rules, but two are not usable under `no_global_oom_handling` builds of the standard library (even with a zero size): ```rust let _ = vec![42]; // Error: requires `exchange_malloc` lang_item. let _ = vec![42; 0]; // Error: cannot find function `from_elem`. ``` Thus those two rules should not be available to begin with. The remaining one, with an empty matcher, is just a shorthand for `new()` and may not make as much sense to have alone, since the idea behind `vec!` is to enable `Vec`s to be defined with the same syntax as array expressions. Furthermore, the documentation can be confusing since it shows the other rules. Thus perhaps it is better and simpler to disable `vec!` entirely under `no_global_oom_handling` environments, and let users call `new()` instead: ```rust let _: Vec<i32> = vec![]; let _: Vec<i32> = Vec::new(); ``` Notwithstanding this, a `try_vec!` macro would be useful, such as the one introduced in https://github.com/rust-lang/rust/pull/95051. If the shorthand for `new()` is deemed worth keeping on its own, then it may be interesting to have a separate `vec!` macro with a single rule and different, simpler documentation. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions
