about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2019-05-23Clarify docs for unreachable! macroBrent Kerby-3/+4
2019-05-23bump nightly to 1.37.0Pietro Albini-3/+2
2019-05-23Rollup merge of #61057 - sfackler:revert-next-back, r=alexcrichtonMazdak Farrokhzad-47/+0
Revert "Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators." This changed observable behavior for several iterator types. r? @alexcrichton
2019-05-22Revert "Add implementations of last in terms of next_back on a bunch of ↵Steven Fackler-47/+0
DoubleEndedIterators." This reverts commit 3e86cf36b5114f201868bf459934fe346a76a2d4.
2019-05-22fix merge conflictswizAmit-1/+0
2019-05-22succint implementationwizAmit-0/+42
2019-05-22wip nth_back on chunks@amit.chandra-36/+0
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-22hopefully working nth_back on chunks@amit.chandra-9/+17
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-22wip nth_back on chunks@amit.chandra-0/+29
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-22Rollup merge of #61029 - blkerby:minimum_spanning_tree, r=alexcrichtonMazdak Farrokhzad-24/+22
Simplify RefCell minimum_spanning_tree example This simplifies the implementation of the `minimum_spanning_tree` example of `RefCell` in the `cell` module-level docs, avoiding an unnecessary recursive call. This also eliminates the need for a block to contain the scope of the borrow in this example. But since that use of a block served an important didactic purpose, we make up for this by instead introducing a block in the initial, simpler example of `RefCell`, where the point will hopefully be conveyed to the reader more easily.
2019-05-22Allow null-pointer-optimized enums in FFI if their underlying representation ↵Michael Bradshaw-0/+2
is FFI safe This allows types like Option<NonZeroU8> to be used in FFI without triggering the improper_ctypes lint. This works by changing the is_repr_nullable_ptr function to consider an enum E to be FFI-safe if: - E has no explicit #[repr(...)]. - It only has two variants. - One of those variants is empty (meaning it has no fields). - The other variant has only one field. - That field is one of the following: - &T - &mut T - extern "C" fn - core::num::NonZero* - core::ptr::NonNull<T> - #[repr(transparent)] struct wrapper around one of the types in this list. - The size of E and its field are both known and are both the same size (implying E is participating in the nonnull optimization).
2019-05-21Simplify RefCell minimum_spanning_tree exampleBrent Kerby-24/+22
2019-05-21adjust deprecation date of mem::uninitializedRalf Jung-1/+1
2019-05-20Rollup merge of #60972 - RalfJung:volatile, r=alexcrichtonMazdak Farrokhzad-6/+0
remove confusing remarks about mixed volatile and non-volatile accesses These comments were originally added by @ecstatic-morse in https://github.com/rust-lang/rust/commit/911d35f0bfd207112806eaec2763201dad06d1c7 and then later edited by me. The intention, I think, was to make sure people do both their reads and writes with these methods if the affected memory really is used for communication with external devices. However, [people read this as saying that mixed volatile/non-volatile accesses are UB](https://github.com/rust-lang/rust/issues/58599#issuecomment-493791130), which -- to my knowledge -- they are not. So better remove this. Cc @rkruppe @rust-lang/wg-unsafe-code-guidelines
2019-05-20Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPCMazdak Farrokhzad-0/+23
Fix intra-doc link resolution failure on re-exporting libstd Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366). ```rust pub use std::*; ``` Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates. Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.) r? @QuietMisdreavus
2019-05-20Document layout guarantee of MaybeUninitPeter Todd-0/+22
2019-05-20elliminate mem::uninitialize from docs in libcoreRalf Jung-60/+4
2019-05-20add out-pointer exampleRalf Jung-1/+25
2019-05-20apply feedbackRalf Jung-28/+36
2019-05-20stabilize core parts of MaybeUninit and deprecate mem::uninitialized in the ↵Ralf Jung-166/+136
future Also expand the documentation a bit
2019-05-20remove confusing remarks about mixed volatile and non-volatile accessesRalf Jung-6/+0
2019-05-19Fix data types indicationVeryTastyTomato-2/+2
Fix the data types indication in basic examples of the Trait std::fmt::LowerExp and std::fmt::UpperExp. Since there aren’t any type annotation on the let statement using the number 42.0, they are of type f64 according to The Book: https://doc.rust-lang.org/book/ch03-02-data-types.html#floating-point-types
2019-05-19Rollup merge of #60947 - blkerby:global_alloc_typo, r=jonas-schievinkMazdak Farrokhzad-2/+2
Fix typos in docs of GlobalAlloc
2019-05-19Rollup merge of #60943 - blkerby:master, r=Mark-SimulacrumMazdak Farrokhzad-1/+1
fix copy-paste typo in docs for ptr::read_volatile
2019-05-19Rollup merge of #60931 - cuviper:array-iter, r=KodrAusMazdak Farrokhzad-16/+16
Use iter() for iterating arrays by slice These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-19Rollup merge of #60370 - Richard-W:const-layout-construction, r=sfacklerMazdak Farrokhzad-1/+13
Mark core::alloc::Layout::from_size_align_unchecked const Makes it possible (pending stabilization of #57563 (`const_fn`)) to rewrite code like ```rust const BUFFER_SIZE: usize = 0x2000; const BUFFER_ALIGN: usize = 0x1000; fn foo() { let layout = std::alloc::Layout::from_size_align(BUFFER_SIZE, BUFFER_ALIGN) .unwrap(); let buffer = std::alloc::alloc(layout); } ``` to ```rust const BUFFER_LAYOUT: std::alloc::Layout = unsafe { std::alloc::Layout::from_size_align_unchecked(0x2000, 0x1000) }; fn foo() { let buffer = std::alloc::alloc(BUFFER_LAYOUT); } ``` which (although `unsafe` is used) looks somewhat cleaner and is easier to read.
2019-05-18Fix typos in docs of GlobalAllocBrent Kerby-2/+2
2019-05-18fix copy-paste typo in docs for ptr::read_volatileBrent Kerby-1/+1
2019-05-17Use iter() for iterating arrays by sliceJosh Stone-16/+16
These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-16Rollup merge of #59923 - czipperz:fix-convert-doc-links, r=steveklabnikMazdak Farrokhzad-20/+20
Fix convert module's documentation links r? @steveklabnik
2019-05-15Stabilize RefCell::try_borrow_unguardedSimon Sapin-2/+1
Servo has been using this since https://github.com/servo/servo/pull/23196 to add a runtime check to some unsafe code, as discussed in PR https://github.com/rust-lang/rust/pull/59211. Stabilizing would help do more of the same in libraries that also have users on Stable.
2019-05-14Rollup merge of #60808 - Schultzer:improve-must-use-linit-for-future, r=CentrilMazdak Farrokhzad-1/+1
Improve the "must use" lint for `Future` Fixes #60797
2019-05-14Rollup merge of #60443 - RalfJung:as_ptr, r=SimonSapinMazdak Farrokhzad-0/+10
as_ptr returns a read-only pointer Add comments to `as_ptr` methods to warn that these are read-only pointers, and writing to them is UB. [It was pointed out](https://internals.rust-lang.org/t/as-ptr-vs-as-mut-ptr/9940) that `CStr` does not even have an `as_mut_ptr`. I originally was going to add one, but there is no method at all that would mutate a `CStr`. Was that a deliberate choice or should I add an `as_mut_ptr` (similar to [what I did for `str`](https://github.com/rust-lang/rust/pull/58200))?
2019-05-14Rollup merge of #60130 - khuey:efficient_last, r=sfacklerMazdak Farrokhzad-0/+47
Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators Provided a `DoubleEndedIterator` has finite length, `Iterator::last` is equivalent to `DoubleEndedIterator::next_back`. But searching forwards through the iterator when it's unnecessary is obviously not good for performance. I ran into this on one of the collection iterators. I tried adding appropriate overloads for a bunch of the iterator adapters like filter, map, etc, but I ran into a lot of type inference failures after doing so. The other interesting case is what to do with `Repeat`. Do we consider it part of the contract that `Iterator::last` will loop forever on it? The docs do say that the iterator will be evaluated until it returns None. This is also relevant for the adapters, it's trivially easy to observe whether a `Map` adapter invoked its closure a zillion times or just once for the last element.
2019-05-14new implementation for nth_back for chunkswizAmit-6/+27
2019-05-14Add const_unchecked_layout test to libcore/testsRichard Wiedenhöft-0/+12
2019-05-14Mark core::alloc::Layout::from_size_align_unchecked constRichard Wiedenhöft-1/+1
2019-05-14hopefully working nth_back on chunks@amit.chandra-9/+17
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-14wip nth_back on chunks@amit.chandra-0/+29
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-13Improve the "must use" lint for `Future`Benjamin Schultzer-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-05-13Rollup merge of #60201 - RalfJung:core-tests, r=alexcrichtonMazdak Farrokhzad-1/+1
coretest: Downgrade deny to warn The `deny` causes a build failure in https://github.com/RalfJung/miri-test-libstd. Since we use `-D warnings` for rustc builds, `warn` should be enough to lead to compile errors here, without impeding external builds.
2019-05-12Auto merge of #60244 - SimonSapin:dangling, r=oli-obkbors-2/+0
const-stabilize NonNull::dangling and NonNull::cast
2019-05-11Auto merge of #60318 - jethrogb:jb/try-from-slice-to-infallible, r=sfacklerbors-1/+8
impl From<Infallible> for TryFromSliceError I believe this was missed when TryFrom was stabilized. I think `TryFromSliceError` and `TryFromIntError` are the only two `TryFrom` error types that appear in `std`. I think trait implementations have to be insta-stable, but I'm not sure.
2019-05-10Auto merge of #60588 - cuviper:be-simd-swap, r=alexcrichtonbors-4/+1
Revert "Disable big-endian simd in swap_nonoverlapping_bytes" This reverts commit 77bd4dc65406ba3cedbc779e6f6280868231912e (#43159). Issue #42778 was formerly easy to reproduce on two big-endian targets, `powerpc64` and `s390x`, so we disabled SIMD on this function for all big-endian targets as a workaround. I have re-tested this code on `powerpc64` and `s390x`, each with the bundled LLVM 8 and with external LLVM 7 and LLVM 6, and the problems no longer appear. So it seems safe to remove this workaround, although I'm still a little uncomfortable that we never found a root-cause... Closes #42778. r? @arielb1
2019-05-09Rollup merge of #60657 - JohnTitor:stabilize-array, r=SimonSapinMazdak Farrokhzad-4/+6
Stabilize and re-export core::array in std Fixes #60014
2019-05-09Rollup merge of #60638 - RalfJung:pin, r=sanxiynMazdak Farrokhzad-1/+1
pin: make the to-module link more visible Cc @gnzlbg
2019-05-09Rollup merge of #60601 - SimonSapin:cast, r=KimundiMazdak Farrokhzad-0/+14
Add a `cast` method to raw pointers. This is similar to `NonNull::cast`. Compared to the `as` operator (which has a wide range of meanings depending on the input and output types), a call to this method: * Can only go from a raw pointer to a raw pointer * Cannot change the pointer’s `const`ness … even when the pointed types are inferred based on context.
2019-05-09Stabilize and re-export core::arrayYuki OKUSHI-4/+6
2019-05-09Rollup merge of #59979 - stepancheg:num-size, r=ehussMazdak Farrokhzad-30/+83
to_xe_bytes for isize and usize returns an array of different size ... on different platforms. Official rustdoc of [`usize::to_le_bytes`](https://doc.rust-lang.org/std/primitive.usize.html#method.to_le_bytes) displays signature ``` pub fn to_ne_bytes(self) -> [u8; 8] ``` which might be misleading: this function returns 4 bytes on 32-bit systems. With this commit applied rustdoc for `isize` and `usize` is this: <img width="740" alt="2019-04-15_0020" src="https://user-images.githubusercontent.com/28969/56100765-9f69b380-5f14-11e9-974c-daa25edaa881.png">
2019-05-08pin: make the to-module link more visibleRalf Jung-1/+1