summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2019-06-26Revert "Set test flag when rustdoc is running with --test option"Oliver Middleton-6/+6
This reverts commit 8ed2292dbe75b9b65e9fe1a079428d1e1e3b610f. It caused doctests in this repository to no longer be tested including all of the core crate.
2019-06-26Hygienize macros in the standard libraryVadim Petrochenkov-11/+11
2019-05-28Revert "Add implementations of last in terms of next_back on a bunch of ↵Steven Fackler-47/+0
DoubleEndedIterators." This reverts commit 3e86cf36b5114f201868bf459934fe346a76a2d4.
2019-05-25adjust 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-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-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-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
2019-05-07Rollup merge of #60609 - spastorino:be-explicit-on-mem-replace-doc, r=CentrilMazdak Farrokhzad-2/+2
Be a bit more explicit asserting over the vec rather than the len
2019-05-07Be a bit more explicit asserting over the vec rather than the lenSantiago Pastorino-2/+2
2019-05-07Add a `cast` method to raw pointers.Simon Sapin-0/+14
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-06Revert "Disable big-endian simd in swap_nonoverlapping_bytes"Josh Stone-4/+1
This reverts commit 77bd4dc65406ba3cedbc779e6f6280868231912e. 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...
2019-05-05to_xe_bytes for isize and usize returns an array of different sizeStepan Koltsov-30/+83
... 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.
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-0/+23
2019-05-02clarify wordingRalf Jung-5/+4
2019-05-01as_ptr returns a read-only pointerRalf Jung-0/+11
2019-04-29Rollup merge of #60356 - JohnTitor:stabilize-as-mut-ptr, r=CentrilMazdak Farrokhzad-1/+1
Stabilize str::as_mut_ptr Closes #58215
2019-04-29Rollup merge of #60256 - ethanboxx:master, r=alexcrichtonMazdak Farrokhzad-1/+31
Option::flatten This PR makes this possible. ```rust assert_eq!(Some(6), Some(Some(6)).flatten()); assert_eq!(Some(6), Some(Some(6)).into()); ```
2019-04-29Rollup merge of #59946 - mernen:patch-2, r=ehussMazdak Farrokhzad-1/+1
Fix equivalent string in escape_default docs This newline should be escaped.
2019-04-29impl From<Infallible> for TryFromSliceErrorJethro Beekman-1/+8
2019-04-29Auto merge of #60364 - JohnTitor:stabilize-const-needs-drop, r=oli-obkbors-1/+0
const-stabilize: std::mem::needs_drop Closes #51929 r? @oli-obk