summary refs log tree commit diff
path: root/library/alloc/src/boxed.rs
AgeCommit message (Collapse)AuthorLines
2024-03-09miri: do not apply aliasing restrictions to Box with custom allocatorRalf Jung-10/+14
2024-03-05only set noalias on Box with the global allocatorRalf Jung-0/+3
2024-02-22Auto merge of #118634 - Jules-Bertholet:box-allocator-static, r=Amanieubors-9/+3
Remove useless `'static` bounds on `Box` allocator #79327 added `'static` bounds to the allocator parameter for various `Box` + `Pin` APIs to ensure soundness. But it was a bit overzealous, some of the bounds aren't actually needed.
2024-02-06Harmonize blanket implementations for AsyncFn* traitsMichael Goulet-0/+29
2024-02-05Rollup merge of #113833 - WiktorPrzetacznik:master, r=dtolnayMatthias Krüger-8/+8
`std::error::Error` -> Trait Implementations: lifetimes consistency improvement This cleans up `std::error::Error` trait implementations lifetime inconsistency (`'static` -> `'a`) **Reasoning:** Trait implementations for `std::error::Error`, like: `impl From<&str> for Box<dyn Error + 'static, Global>` `impl<'a> From<&str> for Box<dyn Error + Sync + Send + 'a, Global>` use different lifetime annotations misleadingly implying using different life annotations here is a conscious, nonaccidental decision. [(Related forum discussion here)](https://users.rust-lang.org/t/confusing-std-error-source-code/97011/5?u=wiktor)
2024-01-26Fix outdated comment on Boxbjorn3-2/+1
2024-01-02Adjust library tests for unused_tuple_struct_fields -> dead_codeJake Goulding-0/+1
2023-12-04Remove useless `'static` bounds on `Box` allocatorJules Bertholet-9/+3
#79327 added `'static` bounds to the allocator parameter for various `Box` + `Pin` APIs to ensure soundness. But it was a bit overzealous, some of the bounds aren't actually needed.
2023-11-04docs: clarify explicitly freeing heap allocated memoryalpharush-3/+11
2023-10-31delegate box error provideBugen Zhao-0/+4
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
2023-10-21Update boxed.rsGimbles-1/+1
2023-10-20s/generator/coroutine/Oli Scherer-2/+2
2023-10-20s/Generator/Coroutine/Oli Scherer-5/+5
2023-08-14avoid transmuting Box when we can just cast raw pointers insteadRalf Jung-2/+2
2023-07-18std::error::Error -> Trait Implementations: lifetimes consistency improvementWiktorPrzetacznik-8/+8
2023-07-13Eliminate ZST allocations in `Box` and `Vec`Amanieu d'Antras-15/+29
2023-06-16remove box_free and replace with drop implDrMeepster-1/+9
2023-04-29`cfg`-gate `BoxFromSlice` traitJules Bertholet-0/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2023-04-26Loosen `From<&[T]> for Box<[T]>` bound to T: CloneJules Bertholet-8/+30
2023-04-16fix allocDeadbeef-12/+6
2023-04-16rm const traits in libcoreDeadbeef-10/+5
2023-04-12remove some unneeded importsKaDiWa-5/+2
2023-03-28Remove ~const from allocJubilee Young-28/+16
2023-03-03Make `unused_allocation` lint warn against `Box::new`Maybe Waffle-0/+1
2023-02-27Remove or justify use of #[rustc_box]Ben Kimock-5/+4
2022-12-28Update bootstrap cfgPietro Albini-30/+0
2022-12-28Rollup merge of #104024 - noeddl:unused-must-use, r=compiler-errorsfee1-dead-1/+1
Fix `unused_must_use` warning for `Box::from_raw`
2022-12-19Update coerce_unsized tracking issue from #27732 to #18598Anders Kaseorg-1/+1
Issue #27732 was closed as a duplicate of #18598. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-11-22Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnayManish Goregaokar-1/+1
Make the Box one-liner more descriptive I would like to avoid a definition that relies on itself. r? `@GuillaumeGomez`
2022-11-21Touch up Box<T> one-linerDavid Tolnay-2/+2
2022-11-06Bump version placeholders to releaseMark Rousskov-1/+1
2022-11-05Fix unused_must_use warning for Box::from_rawAnett Seeker-1/+1
2022-11-05Enforce Tuple trait on Fn traitsMichael Goulet-0/+31
2022-10-17Auto merge of #101837 - scottmcm:box-array-from-vec, r=m-ou-sebors-1/+50
Add `Box<[T; N]>: TryFrom<Vec<T>>` We have `[T; N]: TryFrom<Vec<T>>` (#76310) and `Box<[T; N]>: TryFrom<Box<[T]>>`, but not this combination. `vec.into_boxed_slice().try_into()` isn't quite a replacement for this, as that'll reallocate unnecessarily in the error case. **Insta-stable, so needs an FCP** (I tried to make this work with `, A`, but that's disallowed because of `#[fundamental]` https://github.com/rust-lang/rust/issues/29635#issuecomment-1247598385)
2022-09-26remove cfg(bootstrap)Pietro Albini-14/+0
2022-09-17Add `Box<[T; N]>: TryFrom<Vec<T>>`Scott McMurray-1/+50
We have `[T; N]: TryFrom<Vec<T>>` and `Box<[T; N]>: TryFrom<Box<[T]>>`, but not the combination. `vec.into_boxed_slice().try_into()` isn't quite a replacement for this, as that'll reallocate unnecessarily in the error case. **Insta-stable, so needs an FCP**
2022-09-16Do not implement `Unpin` as constDeadbeef-2/+1
2022-09-10Make the one-liner more descriptiveStefan Schindler-2/+2
2022-08-28Rollup merge of #99570 - XrXr:box-from-slice-docs, r=thomccMatthias Krüger-1/+1
Box::from(slice): Clarify that contents are copied A colleague mentioned that they interpreted the old text as saying that only the pointer and the length are copied. Add a clause so it is more clear that the pointed to contents are also copied.
2022-08-22Move error trait into coreJane Losare-Lusby-0/+306
2022-08-20Improve primitive/std docs separation and headersCameron Steffen-1/+1
2022-07-21Box::from(slice): Clarify that contents are copiedAlan Wu-1/+1
A colleague mentioned that they interpreted the old text as saying that only the pointer and the length are copied. Add a clause so it is more clear that the pointed to contents are also copied.
2022-07-15add `#[must_use]` to `Box::from_raw`rhysd-0/+1
2022-07-01update cfg(bootstrap)sPietro Albini-21/+4
2022-06-02Rollup merge of #97655 - steffahn:better-pin-box-construction-docs, r=thomccMatthias Krüger-4/+28
Improve documentation for constructors of pinned `Box`es Adds a cross-references between `Box::pin` and `Box::into_pin` (and other related methods, i.e. the equivalent `From` implementation, and the unstable `pin_in` method), in particular now that `into_pin` [was stabilized](https://github.com/rust-lang/rust/pull/97397). The main goal is to further improve visibility of the fact that `Box<T> -> Pin<Box<T>>` conversion exits in the first place, and that `Box::pin(x)` is – essentially – just a convenience function for `Box::into_pin(Box::new(x))` The motivating context why I think this is important is even experienced Rust users overlooking the existence this kind of conversion, [e.g. in this thread on IRLO](https://internals.rust-lang.org/t/pre-rfc-function-variants/16732/7?u=steffahn); and also the fact that that discussion brought up that there would be a bunch of Box-construction methods "missing" such as e.g. methods with fallible allocation a la "`Box::try_pin`", and similar; while those are in fact *not* necessary, because you can use `Box::into_pin(Box::try_new(x)?)` instead. I have *not* included explicit mention of methods (e.g. `try_new`) in the docs of stable methods (e.g. `into_pin`). (Referring to unstable API in stable API docs would be bad style IMO.) Stable examples I have in mind with the statement "constructing a (pinned) Box in a different way than with `Box::new`" are things like cloning a `Box`, or `Box::from_raw`. If/when `try_new` would get stabilized, it would become a very good concrete example use-case of `Box::into_pin` IMO.
2022-06-02Improve documentation for constructors of pinned `Box`esFrank Steffahn-4/+28
2022-06-02Auto merge of #97293 - est31:remove_box, r=oli-obkbors-4/+26
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-02Stabilize `box_into_pin`Yuki Okushi-2/+21
2022-06-01Use #[rustc_box] in alloc instead of box syntaxest31-4/+26
2022-05-30Fix typo uniqeness -> uniquenessDavid Tolnay-1/+1