about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2020-05-01Document unsafety for `*const T` and `*mut T`LeSeulArtichaut-4/+8
2020-04-30Rollup merge of #71597 - CohenArthur:refactor-unique-empty, r=shepmasterDylan DPC-2/+1
Rename Unique::empty() -> Unique::dangling() A `FIXME` comment in `src/libcore/ptr/unique.rs` suggested refactoring `Unique::empty()` to `Unique::dangling()` which this PR does.
2020-04-30Rollup merge of #71692 - dfreese:cfgdocs, r=kennytmDylan DPC-0/+4
Add clarification on std::cfg macro docs v. #[cfg] attribute The wording was discussed, to a limited degree in #71679. This tries to address some confusion I as well as someone else had independently when looking at this macro. Fixes #71679
2020-04-30Rollup merge of #71672 - lcnr:instrinsics-wow, r=Dylan-DPCDylan DPC-12/+86
document missing stable counterparts of intrinsics Notes the stable counterpart of each intrinsic in case one exists. Implements #34338 r? @Dylan-DPC
2020-04-30rename-unique: Rename Unique::empty() to Unique::dangling()cohenarthur-2/+1
rename-unique: Change calls and doc in raw_vec.rs rename-unique: Change empty() -> dangling() in const-ptr-unique-rpass.rs
2020-04-29Update src/libcore/macros/mod.rsDavid Freese-1/+1
Co-Authored-By: kennytm <kennytm@gmail.com>
2020-04-29Add clarification on std::cfg macro docs v. #[cfg] attributeDavid Freese-0/+4
The wording was discussed, to a limited degree in #71679. This tries to address some confusion I as well as someone else had independently when looking at this macro. Fixes #71679
2020-04-29Rollup merge of #71680 - nicholasbishop:bishop-fix-eq-link, r=Mark-SimulacrumDylan DPC-0/+1
Fix doc link to Eq trait from PartialEq trait The `Eq` link was incorrectly going to the `eq` method of `PartialEq` instead of to the `Eq` trait.
2020-04-29Rollup merge of #71507 - CohenArthur:document-unsafe-libcore-ptr, ↵Dylan DPC-7/+45
r=Mark-Simulacrum Document unsafety in core::ptr Contributes to #66219 I have yet to document all the `unsafe` blocks in the lib and would like to know if I'm headed in the right direction r? @steveklabnik
2020-04-29Fix doc link to Eq trait from PartialEq traitNicholas Bishop-0/+1
The `Eq` link was incorrectly going to the `eq` method of `PartialEq` instead of to the `Eq` trait.
2020-04-29document stable counterparts of intrinsicsBastian Kauschke-12/+86
2020-04-29safety-ptr: Add SAFETY on some unsafe blocks from libcore/ptrcohenarthur-3/+43
Add documentation example to slice_from_raw_parts_mut() Add SAFETY explanations to some unsafe blocks in libcore/ptr * libcore/ptr/mod.rs * libcore/ptr/unique.rs * libcore/ptr/non_null.rs safety-mod.rs: Add SAFETY to slice_from_raw_parts(), slice_from_raw_parts_mut() slice_from_raw_parts_mut: Add documentation example safety-ptr-unique.rs: Add SAFETY to new() and cast() safety-ptr-non_null.rs: Add SAFETY to new() safety-ptr-non_null.rs: Add SAFETY to cast() safety-ptr-non_null.rs: Add SAFETY to from() impls safety-ptr-unique.rs: Add SAFETY to from() impls safety-ptr-non_null.rs: Add SAFETY to new() safety-ptr-unique.rs: Add SAFETY to new() safety-ptr-mod.rs: Fix safety explanation https://github.com/rust-lang/rust/pull/71507#discussion_r414488884 safety-prt-non_null.rs: Fix SAFETY comment syntax safety-ptr-unique.rs: Fix syntax for empty() safety-ptr-non_null.rs: Fix misuse of non-null for align_of() safety-ptr-non_null.rs: Remove incorrect SAFETY comment safety-ptr-unique.rs: Remove unsound SAFETY comment safety-ptr-mod.rs: Add std comment on slice_from_raw_parts guarantee safety-ptr-unique.rs: Remove incorrect safety comment Creating a Unique from a NonNull has strict guarantees that the current implementation does not guarantee https://github.com/rust-lang/rust/pull/71507#discussion_r415035952 safety-ptr: Re-adding ignore-tidy directive
2020-04-27Update link to unstable book for llvm_asm macroZach Reizner-1/+1
2020-04-27Rollup merge of #71589 - RalfJung:unique-no-shr, r=SimonSapinDylan DPC-17/+0
remove Unique::from for shared pointer types r? @SimonSapin
2020-04-26remove Unique::from for shared pointer typesRalf Jung-17/+0
2020-04-26Fix since attribute for nonzero_bitor impl'sJonas Platte-5/+5
2020-04-25Auto merge of #71556 - Dylan-DPC:rollup-9ll4shr, r=Dylan-DPCbors-0/+87
Rollup of 7 pull requests Successful merges: - #69041 (proc_macro: Stabilize `Span::resolved_at` and `Span::located_at`) - #69813 (Implement BitOr and BitOrAssign for the NonZero integer types) - #70712 (stabilize BTreeMap::remove_entry) - #71168 (Deprecate `{Box,Rc,Arc}::into_raw_non_null`) - #71544 (Replace filter_map().next() calls with find_map()) - #71545 (Fix comment in docstring example for Error::kind) - #71548 (Add missing Send and Sync impls for linked list Cursor and CursorMut.) Failed merges: r? @ghost
2020-04-25Rollup merge of #69813 - thomcc:nonzero-bitor, r=AmanieuDylan DPC-0/+87
Implement BitOr and BitOrAssign for the NonZero integer types This provides overloaded operators for `NonZero$Int | NonZero$Int`, `NonZero$Int | $Int`, and `$Int | NonZero$Int`. It also provides `BitOrAssign` where `self` is `NonZero$Int`, for symmetry. It's a pretty small conceptual addition, but is good becasue but avoids a case where the operation is obviously sound, but you'd otherwise need unsafe to do it. In crates trying to minimize `unsafe` usage, this is unfortunate and makes working with `NonZero` types often not worth it, even if the operations you're doing are clearly sound. I've marked these as stable as I've been told in the past that trait impls are automatically stable. I'm happy to change it to unstable if this wasn't correct information. I'm not entirely confident what version I should have put down, so I followed https://www.whatrustisit.com. Hopefully it's correct for this. Apologies in advance if this has come up before, but I couldn't find it.
2020-04-25Auto merge of #71439 - Mark-Simulacrum:stage0-next, r=jonas-schievinkbors-150/+10
Bump bootstrap compiler This bumps the bootstrap compiler and the rustfmt that x.py fmt uses.
2020-04-25Bump rustfmt to most recently shippedMark Rousskov-2/+2
2020-04-25Bump bootstrap compilerMark Rousskov-150/+10
2020-04-25Rollup merge of #71480 - GuillaumeGomez:panic-info-example, r=Dylan-DPCDylan DPC-3/+9
Improve PanicInfo examples readability cc @Eijebong r? @Dylan-DPC
2020-04-24Rollup merge of #71476 - RalfJung:miri-test-sizes, r=kennytmDylan DPC-30/+16
more compact way to adjust test sizes for Miri Inspired by @dtolnay
2020-04-24Improve PanicInfo examples readabilityGuillaume Gomez-3/+9
2020-04-24Rollup merge of #71492 - LeSeulArtichaut:document-unsafe-2, r=Mark-SimulacrumDylan DPC-16/+28
Document unsafety in core::{panicking, alloc::layout, hint, iter::adapters::zip} Helps with #66219. r? @Mark-Simulacrum do you want to continue reading safety comments? :D
2020-04-24Rollup merge of #71068 - pyfisch:unicode-version-stable, r=SimonSapinDylan DPC-4/+7
Stabilize UNICODE_VERSION (feature unicode_version) Tracking issue: #49726 r? @sfackler #71020 changed the definition of `UNICODE_VERSION` just yesterday from a struct to a tuple. Maybe you want to wait some more before stabilizing this constant, on the other hand this is a very small and simple addition. CC @behnam @SimonSapin @Serentty
2020-04-24Rollup merge of #71063 - LeSeulArtichaut:document-unsafe, r=Mark-SimulacrumDylan DPC-7/+28
Document unsafety in core::{option, hash} Helps with #66219. I think that the part that will need reviewing the most is the `hash/sip.rs` file. r? @LukasKalbertodt (or someone else from the libs team)
2020-04-24Document unsafety in `core::{panicking, alloc::layout, hint, ↵LeSeulArtichaut-16/+28
iter::adapters::zip}`
2020-04-23Add a note about fat pointersLeSeulArtichaut-0/+6
Co-Authored-By: Mark-Simulacrum <mark.simulacrum@gmail.com>
2020-04-23doc-example: Refactor pointer name to avoid confusioncohenarthur-4/+2
Changed raw pointer name from ptr to raw_pointer to avoid confusion with the `use std::ptr` statement a few lines above. This way the crate name and pointer name are well differenciated.
2020-04-23Rollup merge of #71470 - TyPR124:fix-doc-links, r=jonas-schievinkDylan DPC-1/+1
Fix doc links This fixes a few doc links which were causing `cargo doc` to fail when using `--document-private-items --document-hidden-items` on libstd. Most of the fixes are just escaping '[' and ']' characters in doc comments, and one change actually fixes a doc link.
2020-04-23Rollup merge of #71446 - Amanieu:transmute_copy, r=sfacklerDylan DPC-1/+6
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.
2020-04-23Rollup merge of #71442 - TimDiekmann:allocref-mut-ref, r=AmanieuDylan DPC-0/+47
Add a "by reference" adaptor for `AllocRef` Fixes rust-lang/wg-allocators#53 r? @Amanieu
2020-04-23Rollup merge of #71404 - cuviper:chain-unfused, r=scottmcmDylan DPC-35/+62
Don't fuse Chain in its second iterator Only the "first" iterator is actually set `None` when exhausted, depending on whether you iterate forward or backward. This restores behavior similar to the former `ChainState`, where it would transition from `Both` to `Front`/`Back` and only continue from that side. However, if you mix directions, then this may still set both sides to `None`, totally fusing the iterator. Fixes #71375 r? @scottmcm
2020-04-23libcore: more compact way to adjust test sizes for MiriRalf Jung-30/+16
2020-04-23Add note about paddingLeSeulArtichaut-2/+3
Co-authored-by: Mark-Simulacrum <mark.simulacrum@gmail.com>
2020-04-23Make VaList::arg link actually workTyler Ruckinger-1/+1
2020-04-23Merge branch 'master' into fix-doc-linksTyler Ruckinger-1/+3
2020-04-23Fix doc link errorsTyler Ruckinger-1/+1
2020-04-23Rollup merge of #71454 - ecstatic-morse:inline-core-ptr-docs, r=RalfJungDylan DPC-0/+3
Inline some function docs in `core::ptr` Resolves #64539.
2020-04-23Stabilize UNICODE_VERSION (feature unicode_version)Pyfisch-4/+7
The feature will become stable in Rust 1.45. Noted that the value of UNICODE_VERSION is expected to change.
2020-04-22Inline some function docs re-exported in `std::ptr`Dylan MacKenzie-0/+3
2020-04-22Only use read_unaligned in transmute_copy if necessaryAmanieu d'Antras-1/+6
2020-04-22Rollup merge of #71440 - TimDiekmann:copy-allocerr, r=AmanieuDylan DPC-1/+1
Implement `Copy` for `AllocErr` r? @Amanieu
2020-04-22Rollup merge of #71256 - cuviper:must_use_replace, r=estebankDylan DPC-0/+2
Lint must_use on mem::replace 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`.
2020-04-22Add a "by reference" adaptor for `AllocRef`Tim Diekmann-0/+47
2020-04-22Make `AllocErr` copyableTim Diekmann-1/+1
2020-04-22Rollup merge of #71366 - faern:use-assoc-int-consts3, r=dtolnayYuki Okushi-15/+8
Use assoc int consts3 Define module level int consts with associated constants instead of `min_value()` and `max_value()`. So the code become consistent with what the docs recommend etc. Seems natural. Also remove the last usages of the int module constants from this repo (except src/test/ directory which I have still not really done anything in). Some places were missed in the previous PRs because the code uses `crate::<IntTy>` to reach the constants. This is a continuation of #70857 r? @dtolnay
2020-04-21Don't fuse Chain in its second iteratorJosh Stone-35/+62
Only the "first" iterator is actually set `None` when exhausted, depending on whether you iterate forward or backward. This restores behavior similar to the former `ChainState`, where it would transition from `Both` to `Front`/`Back` and only continue from that side. However, if you mix directions, then this may still set both sides to `None`, totally fusing the iterator.
2020-04-21Rollup merge of #69362 - CAD97:alloc_layout_extras, r=AmanieuDylan DPC-13/+43
Stabilize most common subset of alloc_layout_extras Tracking issue: https://github.com/rust-lang/rust/issues/55724 Specifically, this stabilizes: ```rust pub fn Layout::align_to(&self, align: usize) -> Result<Layout, LayoutErr>; pub fn Layout::pad_to_align(&self) -> Layout; pub fn Layout::extend(&self, next: Layout) -> Result<(Layout, usize), LayoutErr>; pub fn Layout::array<T>(n: usize) -> Result<Layout, LayoutErr>; ``` Methods that are tracked by #55724 but are not stabilized here: ```rust pub fn Layout::padding_needed_for(&self, align: usize) -> usize; pub fn Layout::repeat(&self, n: usize) -> Result<(Layout, usize), LayoutErr>; pub fn Layout::repeat_packed(&self, n: usize) -> Result<Layout, LayoutErr>; pub fn Layout::extend_packed(&self, next: Layout) -> Result<Layout, LayoutErr>; ``` Combined, these stabilized functions allow code to construct and manipulate `repr(C)` layouts while letting the standard library handle correctness in the face of edge cases. For example use cases, consider the usage in [hashbrown](https://github.com/Amanieu/hashbrown/blob/2f2af1d/src/raw/mod.rs#L143), [crossbeam-skiplist](https://github.com/crossbeam-rs/crossbeam-skiplist/blob/master/src/base.rs#L99), [pointer-utils/slice-dst](https://github.com/CAD97/pointer-utils/blob/92aeefeed9399f28d1b1654b63f8dcbe1242d8d4/crates/slice-dst/src/layout_polyfill.rs), and of course the standard library itself. Providing a higher-level API such as `Layout::repr_c<const N: usize>(fields: [Layout; N]) -> Result<(Layout, [usize; N]), LayoutErr>` is blocked on const generics, which are a ways off. Providing an API that doesn't provide offsets would be quite suboptimal, as the reason for calculating the layout like this rather than `Layout::new` is to get the field offsets. The primary issue with the current API is having to call `.pad_to_align()` to match the layout of a `repr(C)` struct. However, I think this is not just a (failing? limitation?) of the API, but rather intrinsic complexity. While all Rust-defined types have size==stride, and probably will for the foreseeable future, there is no inherent reason why this is a limitation of all allocations. As such, the `Layout` manipulation APIs shouldn't impose this limitation, and instead the higher level api of `repr_c` (or just plain old using `Layout::new`) can make keeping it simple. cc @matklad r? @rust-lang/libs