rust/src/liballoc
bors 8a2dec6e58 Auto merge of #53804 - RalfJung:ptr-invalid, r=nagisa
fix some uses of pointer intrinsics with invalid pointers

[Found by miri](https://github.com/solson/miri/pull/446):

* `Vec::into_iter` calls `ptr::read` (and the underlying `copy_nonoverlapping`) with an unaligned pointer to a ZST. [According to LLVM devs](https://bugs.llvm.org/show_bug.cgi?id=38583), this is UB because it contradicts the metadata we are attaching to that pointer.
* `HashMap` creation calls `ptr:.write_bytes` on a NULL pointer with a count of 0. This is likely not currently UB *currently*, but it violates the rules we are setting in https://github.com/rust-lang/rust/pull/53783, and we might want to exploit those rules later (e.g. with more `nonnull` attributes for LLVM).

    Probably what `HashMap` really should do is use `NonNull::dangling()` instead of 0 for the empty case, but that would require a more careful analysis of the code.

It seems like ideally, we should do a review of usage of such intrinsics all over libstd to ensure that they use valid pointers even when the size is 0. Is it worth opening an issue for that?
2018-09-16 18:03:39 +00:00
..
benches Auto merge of #52553 - Pazzaz:vecdeque-append, r=SimonSapin 2018-08-18 08:56:12 +00:00
collections Breaking change upgrades 2018-09-04 13:22:08 -06:00
tests Auto merge of #52994 - varkor:trim_direction, r=alexcrichton 2018-09-05 23:45:08 +00:00
alloc.rs Replace usages of ptr::offset with ptr::{add,sub}. 2018-08-20 07:28:34 -04:00
borrow.rs Review fix 2018-08-15 22:06:35 +03:00
boxed.rs Fix typos. 2018-09-06 21:31:06 +02:00
boxed_test.rs Add missing dyn in liballoc 2018-07-10 22:32:19 +02:00
Cargo.toml Breaking change upgrades 2018-09-04 13:22:08 -06:00
fmt.rs Reexport fmt::Alignment into std 2018-06-03 17:04:48 +02:00
lib.rs stabalize infer outlives requirements (RFC 2093). 2018-09-11 11:40:04 -04:00
macros.rs fix some typos 2017-11-21 15:33:45 +01:00
pin.rs remove copyright headers now that they are not madatory 2018-08-25 00:07:00 +03:00
prelude.rs Add the alloc::prelude module 2018-07-07 23:08:43 +02:00
raw_vec.rs Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJung 2018-08-21 22:05:30 +08:00
rc.rs Auto merge of #51885 - GuillaumeGomez:trait-impl-show-docs, r=Mark-Simulacrum,QuietMisdreavus 2018-09-08 04:14:54 +00:00
slice.rs Replace usages of ptr::offset with ptr::{add,sub}. 2018-08-20 07:28:34 -04:00
str.rs docs: std::string::String.repeat(): slightly rephrase to be more in-line with other descriptions. 2018-08-22 08:35:34 +02:00
string.rs Fix invalid urls 2018-09-06 23:32:30 +02:00
sync.rs Auto merge of #51885 - GuillaumeGomez:trait-impl-show-docs, r=Mark-Simulacrum,QuietMisdreavus 2018-09-08 04:14:54 +00:00
task.rs Switch to bootstrapping from 1.29 beta 2018-08-01 11:59:08 -06:00
vec.rs use mem::zeroed to make up ZST values 2018-09-16 14:26:27 +02:00