about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
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-05Implement nth_back for RChunks(Exact)(Mut)Tim Vermeulen-0/+124
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-0/+23
2019-05-03Add custom nth_back for ChainAndrea Corradi-0/+39
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
2019-04-29const-stabilize std::mem::needs_dropYuki OKUSHI-1/+0
2019-04-29Stabilize str::as_mut_ptrYuki OKUSHI-1/+1
2019-04-27Rename .cap() methods to .capacity()Matthias Geier-2/+2
... but leave the old names in there for backwards compatibility.
2019-04-27Stabilize Iterator::copied in 1.36.0.Mazdak Farrokhzad-11/+9
2019-04-26Add flatten option for `Option<Option<T>>`Ethan Brierley-1/+31
squashed commit
2019-04-26Remove feature gates from std and testsChristopher Serr-1/+0
2019-04-26Stabilize pointer::align_offsetChristopher Serr-4/+2
Closes #44488
2019-04-26Auto merge of #60167 - varkor:tidy-filelength, r=matthewjasperbors-0/+8
Add a tidy check for files with over 3,000 lines Files with a large number of lines can cause issues in GitHub (e.g. https://github.com/rust-lang/rust/issues/60015) and also tend to be indicative of opportunities to refactor into less monolithic structures. This adds a new check to tidy to warn against files that have more than 3,000 lines, as suggested in https://github.com/rust-lang/rust/issues/60015#issuecomment-483868594. (This number was chosen fairly arbitrarily as a reasonable indicator of size.) This check can be ignored with `// ignore-tidy-filelength`. Existing files with greater than 3,000 lines currently ignore the check, but this helps us spot when files are getting too large. (We might try to split up all files larger than this in the future, as in https://github.com/rust-lang/rust/issues/60015).
2019-04-26Rollup merge of #60165 - Nemo157:pin-into-inner, r=cramertjMazdak Farrokhzad-0/+34
Add Pin::{into_inner,into_inner_unchecked} These functions are useful for unsafe code that needs to temporarily pull smart pointers out of the `Pin`, e.g. [the change that inspired them](https://github.com/Nemo157/futures-rs/commit/b4361780faf764c7cb046ed75f863a6fcfd44800#diff-1a4e0ba4d1b539412ca576411ec6c7c2R258) is taking a `Pin<Box<dyn Future>>`, turning it into a `*mut dyn Future` via `Box::into_raw(unsafe { Pin::into_inner_unchecked(pin) })` then later dropping this via `drop(Pin::from(Box::from_raw(ptr)))`. This can be accomplished today via `{ let ptr = unsafe { Pin::get_unchecked_mut(pin.as_mut()) } as *mut dyn Future; mem::forget(pin); ptr }`, but this is far more complicated and loses out on the symmetry of using `Box::into_raw` and `Box::from_raw`. I'll extend the documentation on what guarantees `into_inner_unchecked` needs to uphold once I get some feedback on whether this API is wanted or not. r? @withoutboats
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+8
2019-04-25Auto merge of #60192 - t-rapp:tr-saturating-funcs, r=alexcrichtonbors-0/+83
Implement saturating_abs() and saturating_neg() functions for signed integer types Similar to wrapping_abs() / wrapping_neg() functions but saturating at the numeric bounds instead of wrapping around. Complements the existing set of functions with saturation mechanics. cc #59983
2019-04-25Add tests for saturating_abs() and saturating_neg functionsTobias Rapp-0/+27
2019-04-25Add saturating_abs() and saturating_neg() functions to signed integer typesTobias Rapp-0/+56
Similar to wrapping_abs() / wrapping_neg() functions but saturating at the numeric bounds instead of wrapping around. Complements the existing set of functions with saturation mechanics.
2019-04-25const-stabilize NonNull::dangling and NonNull::castSimon Sapin-2/+0
2019-04-24Add Pin::{into_inner,into_inner_unchecked}Wim Looman-0/+34
2019-04-23Stabilize futures_apiTaylor Cramer-22/+54
2019-04-23Rollup merge of #59839 - KodrAus:must-use-num, r=sfacklerMazdak Farrokhzad-0/+156
Warn on unused results for operation methods on nums From a suggestion by @llogiq Adds a `#[must_use]` attribute to operation methods on integers that take self by value as the first operand and another value as the second. It makes it clear that these methods return the result of the operation instead of mutating `self`, which is the source of a rather embarrassing bug I had in a codebase of mine recently... As an example: ```rust struct Int { value: i64, } impl Int { fn add(&mut self, other: i64) { self.value.wrapping_add(other); } } ``` Will produce a warning like: ``` warning: unused return value of `core::num::<impl i64>::wrapping_add` that must be used --> src/main.rs:7:7 | 7 | self.value.wrapping_add(other); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(unused_must_use)] on by default = note: this returns the result of the operation, without modifying the original ``` If this is something we're on board with, we could do something similar for `f32` and `f64` too. There are probably other methods on integers that make sense.
2019-04-23deny -> warnRalf Jung-1/+1
2019-04-22Remove double trailing newlinesvarkor-10/+0
2019-04-22Auto merge of #60133 - phansch:deny_rust_2018_idioms, r=Centrilbors-38/+38
Deny rust_2018_idioms globally cc https://github.com/rust-lang/rust/issues/58099#issuecomment-484921194
2019-04-20Deny rust_2018_idioms in libcore testsPhilipp Hansch-38/+38
2019-04-19Add implementations of last in terms of next_back on a bunch of ↵Kyle Huey-0/+47
DoubleEndedIterators. r?Manishearth
2019-04-19core::future::Future: Fix markup typo in docs.Jim Blandy-1/+1
2019-04-19Doc fixes for core::future::Future.Jim Blandy-13/+13
Fixed outdated reference to `waker` argument; now futures are passed a `Context`, from which one can obtain a `waker`. Cleaned up explanation of what happens when you call `poll` on a completed future. It doesn't make sense to say that `poll` implementations can't cause memory unsafety; no safe function is ever allowed to cause memory unsafety, so why mention it here? It seems like the intent is to say that the `Future` trait doesn't say what the consequences of excess polls will be, and they might be bad; but that the usual constraints that Rust imposes on any non-`unsafe` function still apply. It's also oddly specific to say 'memory corruption' instead of just 'undefined behavior'; UB is a bit jargony, so the text should provide examples.
2019-04-19Refactor and document unicode.py scriptPaweł Romanowski-302/+518
2019-04-19Rollup merge of #60098 - Centril:libcore-deny-more, r=varkorMazdak Farrokhzad-236/+233
libcore: deny `elided_lifetimes_in_paths` r? @varkor
2019-04-19Rollup merge of #60080 - nathankleyn:fix-issue-60068, r=CentrilMazdak Farrokhzad-3/+3
Fix small errors in docs for `rchunks_exact` and `rchunks_exact_mut`. The documentation for `rchunks_exact` said it started at the beginning of the slice, bit it actually starts at the end of the slice. In addition, there were a couple of "of the slice of the slice" duplicate phrases going on for `rchunks_exact` and `rchunks_exact_mut`. This fixes #60068.
2019-04-19Rollup merge of #60023 - koalatux:nth-back, r=scottmcmMazdak Farrokhzad-0/+49
implement specialized nth_back() for Bytes, Fuse and Enumerate Hi, After my first PR has been successfully merged, here is my second pull request :-) Also this PR contains some specializations for the problem discussed in #54054.
2019-04-19libcore: deny more...Mazdak Farrokhzad-236/+233
2019-04-18Fix tidy errorsPaweł Romanowski-2/+3
2019-04-18More cleanups for unicode.pyPaweł Romanowski-25/+23
2019-04-18Fix small errors in docs for `rchunks_exact` and `rchunks_exact_mut`.Nathan Kleyn-3/+3
The documentation for `rchunks_exact` said it started at the beginning of the slice, bit it actually starts at the end of the slice. In addition, there were a couple of "of the slice of the slice" duplicate phrases going on for `rchunks_exact` and `rchunks_exact_mut`. This fixes #60068.
2019-04-18Clean up unicode.py scriptPaweł Romanowski-103/+269
2019-04-18libcore => 2018Taiki Endo-332/+342
2019-04-17Auto merge of #60013 - NieDzejkob:fix-16bit-usize, r=sanxiynbors-1/+1
Fix the max value of usize on 16-bit platforms