rust/library/alloc/src/vec
bors 20976bae5c Auto merge of #97293 - est31:remove_box, r=oli-obk
Add #[rustc_box] and use it inside alloc

This commit adds an alternative content boxing syntax, and uses it inside alloc.

```Rust
#![feature(box_syntax)]

fn foo() {
    let foo = box bar;
}
```

is equivalent to

```Rust
#![feature(rustc_attrs)]

fn foo() {
    let foo = #[rustc_box] Box::new(bar);
}
```

The usage inside the very performance relevant code in
liballoc is the only remaining relevant usage of box syntax
in the compiler (outside of tests, which are comparatively easy to port).

box syntax was originally designed to be used by all Rust
developers. This introduces a replacement syntax more tailored
to only being used inside the Rust compiler, and with it,
lays the groundwork for eventually removing box syntax.

[Earlier work](https://github.com/rust-lang/rust/pull/87781#issuecomment-894714878) by `@nbdd0121` to lower `Box::new` to `box` during THIR -> MIR building ran into borrow checker problems, requiring the lowering to be adjusted in a way that led to [performance regressions](https://github.com/rust-lang/rust/pull/87781#issuecomment-894872367). The proposed change in this PR lowers `#[rustc_box] Box::new` -> `box` in the AST -> HIR lowering step, which is way earlier in the compiler, and thus should cause less issues both performance wise as well as regarding type inference/borrow checking/etc. Hopefully, future work can move the lowering further back in the compiler, as long as there are no performance regressions.
2022-06-02 13:20:19 +00:00
..
cow.rs Document From impls for cow.rs 2021-05-26 14:21:44 +00:00
drain.rs Rename unsigned_offset_from to sub_ptr 2022-05-11 17:16:25 -07:00
drain_filter.rs style: applying Rust style 2020-12-29 14:03:30 +00:00
in_place_collect.rs Rename unsigned_offset_from to sub_ptr 2022-05-11 17:16:25 -07:00
in_place_drop.rs Rename unsigned_offset_from to sub_ptr 2022-05-11 17:16:25 -07:00
into_iter.rs Rename unsigned_offset_from to sub_ptr 2022-05-11 17:16:25 -07:00
is_zero.rs Tweak the calloc optimization to only apply to shortish-arrays 2022-05-01 22:28:11 -07:00
mod.rs Auto merge of #97293 - est31:remove_box, r=oli-obk 2022-06-02 13:20:19 +00:00
partial_eq.rs Allow comparing Vecs with different allocators using == 2022-02-08 01:50:55 +00:00
set_len_on_drop.rs refactor: moved SetLenOnDrop to set_len_on_drop 2020-12-29 14:03:30 +00:00
spec_extend.rs Add VecDeque::extend from vec::IntoIter and slice::Iter specializations 2022-04-28 06:13:54 +02:00
spec_from_elem.rs style: applying Rust style 2020-12-29 14:03:30 +00:00
spec_from_iter.rs Update documentation of SpecFromIter to reflect the removed impls 2021-05-31 21:07:03 +02:00
spec_from_iter_nested.rs Improve estimation of capacity in Vec::from_iter 2022-01-19 09:47:49 -05:00
splice.rs Update expressions where we can use array's IntoIterator implementation 2021-06-02 16:09:04 +06:00