| Age | Commit message (Collapse) | Author | Lines |
|
std: Mark `ptr::Unique` with `#[doc(hidden)]`
`Unique` is now perma-unstable, so let's hide its docs.
|
|
Inline most of the code paths for conversions with boxed slices
This helps with the specific problem described in #49541, obviously without making any large change to how inlining works in the general case.
Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with
`#[inline]`.
For the record, that function was:
```rust
pub fn foo() -> Box<[u8]> {
vec![0].into_boxed_slice()
}
```
To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
|
|
Some modules were still using the deprecated `allocator` module, use the
`alloc` module instead.
Some modules were using `super` while it's not needed.
Some modules were more or less ordering them, and other not, so the
latter have been modified to match the others.
|
|
|
|
|
|
|
|
Closes #22181, #27779
|
|
94d1970bba87f2d2893f6e934e4c3f02ed50604d moved the alloc::allocator
module to core::heap, moving e.g. Alloc and Layout out of the alloc
crate. While alloc::heap reexports them, it's better to use them from
where they really come from.
|
|
This helps with the specific problem described in #49541, obviously without
making any large change to how inlining works in the general case.
Everything involved in the conversions is made `#[inline]`, except for the
`<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]`
after checking that duplicating the function mentioned in the issue prevented
its inlining if I only annotate it with `#[inline]`.
For the record, that function was:
```rust
pub fn foo() -> Box<[u8]> {
vec![0].into_boxed_slice()
}
```
To help the inliner's job, we also hoist a `self.capacity() != self.len` check
in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
|
|
It' only used for hash::Hasher, but Hasher is also imported.
|
|
Make resuming generators unsafe instead of the creation of immovable generators
cc @withoutboats
Fixes #47787
|
|
generators. Fixes #47787
|
|
Pin, Unpin, PinBox
Implementing rust-lang/rfcs#2349 (do not merge until RFC is merged)
@bors r? @cramertj
|
|
|
|
|
|
|
|
|
|
|
|
FusedIterator is a marker trait that promises that the implementing
iterator continues to return `None` from `.next()` once it has returned
`None` once (and/or `.next_back()`, if implemented).
The effects of FusedIterator are already widely available through
`.fuse()`, but with stable `FusedIterator`, stable Rust users can
implement this trait for their iterators when appropriate.
|
|
|
|
|
|
Make core::ops::Place an unsafe trait
Consumers of `Place` would reasonably expect that the `pointer` function returns a valid pointer to memory that can actually be written to.
|
|
https://github.com/rust-lang/rust/issues/47336
|
|
|
|
|
|
Per https://github.com/rust-lang/rust/pull/46952#issuecomment-353956225
|
|
|
|
|
|
Thew `_raw` prefix is included because the fact that `Box`’s ownership
semantics are "dissolved" or recreated seem more important than the exact
parameter type or return type.
|
|
|
|
Also remove a number of `stage0` annotations and such
|
|
Add Box::leak<'a>(Box<T>) -> &'a mut T where T: 'a
Adds:
```rust
impl<T: ?Sized> Box<T> {
pub fn leak<'a>(b: Box<T>) -> &'a mut T where T: 'a {
unsafe { &mut *Box::into_raw(b) }
}
}
```
which is useful for when you just want to put some stuff on the heap and then have a reference to it for the remainder of the program.
r? @sfackler
cc @durka
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Improve raw Box conversions
This PR has two goals:
- Reduce use of `mem::transmute` in `Box` conversions
I understand that `mem::transmute`-ing non `#[repr(C)]` types is implementation-defined behavior. This may not matter within the reference implementation of Rust, but I believe it's important to remain consistent. For example, I noticed that `str::from_utf8_unchecked` went from using `mem::transmute` to using pointer casts.
- Make `Box` pointer conversions more straightforward regarding `Unique`
|
|
|
|
|
|
Provides a reasonable interface for Box::from_raw implementation.
Does not get around the requirement of mem::transmute for converting
back and forth between Unique and Box.
|
|
Same reasons as commit 904133e1e28b690e2bbd101b719509aa897539a0.
|
|
Seems to cause this error: "Cannot handle boxed::Box<[u8]> represented
as TyLayout".
|
|
|
|
Makes use of conversions via Unique.
|
|
|
|
|