| Age | Commit message (Collapse) | Author | Lines |
|
|
|
libstd/libcore: fix various typos
|
|
|
|
stabilize const mem::forget
Stabilizes const `mem::forget` as implemented in https://github.com/rust-lang/rust/pull/69617 and tracked in https://github.com/rust-lang/rust/issues/69616.
Closes https://github.com/rust-lang/rust/issues/69616
|
|
|
|
|
|
And final part!!!
|
|
|
|
|
|
add missing doc links
The doc comments contain ``[`size_of_val`]`` but the link target was missing.
|
|
|
|
|
|
|
|
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
|
|
|
|
|
|
|
|
Co-authored-by: David Tolnay <dtolnay@gmail.com>
|
|
|
|
|
|
|
|
It already has a Debug implementation.
|
|
|
|
|
|
|
|
terminology.
|
|
|
|
Only use read_unaligned in transmute_copy if necessary
I've noticed that this causes LLVM to generate poor code on targets that don't support unaligned memory accesses.
|
|
|
|
This adds a hint on `mem::replace`, "if you don't need the old value,
you can just assign the new value directly". This is in similar spirit
to the `must_use` on `ManuallyDrop::take`.
|
|
Allow calculating the layout behind a pointer
There was some discussion around allowing this previously.
This does make the requirement for raw pointers to have valid metadata exposed as part of the std API (as a safety invariant, not validity invariant), though I think this is not strictly necessarily required as of current. cc @rust-lang/wg-unsafe-code-guidelines
Naming is hard; I picked the best "obvious" name I could come up with.
If it's agreed that this is actually a desired API surface, I'll file a tracking issue and update the attributes.
|
|
Let align/size_of_of_val intrinsics work on ptrs
|
|
Co-Authored-By: lzutao <taolzu@gmail.com>
|
|
Co-Authored-By: Ralf Jung <post@ralfj.de>
|
|
As pointed out by Ralf Jung, dangling references and boxes are
undefined behavior as per
https://doc.rust-lang.org/reference/behavior-considered-undefined.html
and the Miri checker.
|
|
As discussed on reddit, this commit addresses two issues with the
documentation of `mem::forget()`:
* The documentation of `mem::forget()` can confuse the reader because of the
discrepancy between usage examples that show correct usage and the
accompanying text which speaks of the possibility of double-free. The
text that says "if the panic occurs before `mem::forget` was called"
refers to a variant of the second example that was never shown, modified
to use `mem::forget` instead of `ManuallyDrop`. Ideally the documentation
should show both variants, so it's clear what it's talking about.
Also, the double free could be fixed just by placing `mem::forget(v)`
before the construction of `s`. Since the lifetimes of `s` and `v`
wouldn't overlap, there would be no point where panic could cause a double
free. This could be mentioned, and contrasted against the more robust fix
of using `ManuallyDrop`.
* This sentence seems unjustified: "For some types, operations such as
passing ownership (to a funcion like `mem::forget`) requires them to
actually be fully owned right now [...]". Unlike C++, Rust has no move
constructors, its moves are (possibly elided) bitwise copies. Even if you
pass an invalid object to `mem::forget`, no harm should come to pass
because `mem::forget` consumes the object and exists solely to prevent
drop, so there no one left to observe the invalid state state.
|
|
implement zeroed and uninitialized with MaybeUninit
This is the second attempt of doing such a change (first PR: https://github.com/rust-lang/rust/pull/62150). The last change [got reverted](https://github.com/rust-lang/rust/pull/63343) because it [caused](https://github.com/rust-lang/rust/issues/62825) some [issues](https://github.com/rust-lang/rust/issues/52898#issuecomment-512182438) in [code that incorrectly used these functions](https://github.com/erlepereira/x11-rs/issues/99).
Since then, the [problematic code has been fixed](https://github.com/erlepereira/x11-rs/pull/101), and rustc [gained a lint](https://github.com/rust-lang/rust/pull/63346) that is able to detect many misuses of these functions statically and a [dynamic check that panics](https://github.com/rust-lang/rust/pull/66059) instead of causing UB for some incorrect uses.
Fixes https://github.com/rust-lang/rust/issues/62825
|
|
|
|
|
|
|
|
make `mem::discriminant` const
implements #69821, which could be used as a tracking issue for `const_discriminant`.
Should this be added to the meta tracking issue #57563?
@Lokathor
|
|
mem::zeroed/uninit: panic on types that do not permit zero-initialization
r? @eddyb @oli-obk
Cc https://github.com/rust-lang/rust/issues/62825
Also see [this summary comment](https://github.com/rust-lang/rust/pull/66059#issuecomment-586734747)
|
|
|
|
|
|
|
|
|
|
|
|
Suggested by @ametisf in https://github.com/rust-lang/rust/pull/65948#issuecomment-589988183
Co-Authored-By: Frantisek Fladung <fladufra@fel.cvut.cz>
|
|
|
|
Eg. mem::replace()
|