about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2019-04-27Stabilize Iterator::copied in 1.36.0.Mazdak Farrokhzad-11/+9
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-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-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-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-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 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-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
2019-04-17Rollup merge of #60018 - RalfJung:miri-test-libstd, r=oli-obkMazdak Farrokhzad-4/+13
Miri now supports entropy, but is still slow Adjust the `cfg` and their comments in the test suites accordingly.
2019-04-17test sort_unstable in MiriRalf Jung-3/+12
2019-04-16implement nth_back for EnumerateAdrian Friedli-0/+28
2019-04-16implement nth_back for FuseAdrian Friedli-0/+16
2019-04-16implement nth_back for BytesAdrian Friedli-0/+5
2019-04-16Miri now supports entropy, but is still slowRalf Jung-2/+2
2019-04-16Fix the max value of usize on 16-bit platformsJakub Kądziołka-1/+1
2019-04-16Rollup merge of #59717 - Reconcyl:master, r=steveklabnikMazdak Farrokhzad-4/+3
improve docs for std::hint::unreachable_unchecked() Fixes #59549
2019-04-15Rollup merge of #59955 - RalfJung:stdsimd, r=alexcrichtonMazdak Farrokhzad-1/+1
bump stdsimd; make intra_doc_link_resolution_failure an error again; make lints more consistent I made `intra_doc_link_resolution_failure` warn so that it would properly respect `deny-warnings = false` in `config.toml`. `#[warn]` still become errors with `-D warnings` so I thought this was fine. Turns out however that we don't pass `-D warnings` when running rustdoc, so for additional rustdoc-lints we need to set them to `deny`. Also sue the opportunity to make the lint flags more consistent between libcore, liballoc, libstd. Cc @gnzlbg for the *big* stdsimd update.
2019-04-15Rollup merge of #59648 - alex:must-use-result, r=alexcrichtonMazdak Farrokhzad-0/+4
Add must_use annotations to Result::is_ok and is_err Discussed in #59610
2019-04-15Hasher: replace unsafe trasmute with to_ne_bytesStepan Koltsov-14/+10
Spead the knowledge of `to_ne_bytes` functions existence.
2019-04-14Rollup merge of #59900 - czipperz:remove-bracket-mut-syntax-in-pin-docs, ↵Mazdak Farrokhzad-12/+16
r=RalfJung Remove [mut] syntax in pin docs Resolves #59832
2019-04-14bump stdsimd; make intra_doc_link_resolution_failure an error againRalf Jung-1/+1
2019-04-14Rollup merge of #59925 - solson:split_ascii_whitespace-docfix, r=CentrilMazdak Farrokhzad-1/+1
Fix paste error in split_ascii_whitespace docs. It was accidentally still testing the unicode version, `split_whitespace`.
2019-04-14Rollup merge of #59912 - RalfJung:maybe-uninit, r=CentrilMazdak Farrokhzad-34/+0
MaybeUninit: remove deprecated functions
2019-04-13Expand note on mutable referencesChris Gregory-1/+4
2019-04-12Fix paste error in split_ascii_whitespace docs.Scott Olson-1/+1
2019-04-12Auto merge of #59733 - cramertj:wake-by-ref, r=withoutboatsbors-11/+49
Final (one can only hope) futures_api adjustments Based on https://github.com/rust-lang/rust/pull/59119 -- this change is only the latter two commits. cc https://github.com/rust-lang/rust/issues/59725 r? @withoutboats
2019-04-12MaybeUninit: remove deprecated functionsRalf Jung-34/+0
2019-04-12Rollup merge of #59880 - solson:transmute-float, r=alexcrichtonMazdak Farrokhzad-10/+0
Remove note about transmute for float bitpatterns. This particular usecase has been safely abstracted in these `std` functions: [f32::to_bits](https://doc.rust-lang.org/std/primitive.f32.html#method.to_bits), [f32::from_bits](https://doc.rust-lang.org/std/primitive.f32.html#method.from_bits), [f64::to_bits](https://doc.rust-lang.org/std/primitive.f64.html#method.to_bits), [f64::from_bits](https://doc.rust-lang.org/std/primitive.f64.html#method.from_bits). So, I think we shouldn't recommend an unnecessary use of `unsafe` here anymore.
2019-04-12Rollup merge of #59836 - andersk:nominator, r=CentrilMazdak Farrokhzad-14/+14
std::ops::Div examples: correct nominator to numerator
2019-04-12Rollup merge of #59831 - ehuss:ordering-docs, r=kennytmMazdak Farrokhzad-3/+3
Remove strange formatting in `Ordering` docs. I can't really fathom what the intent of the brackets is. The [original PR](#12956) doesn't give any hints. I think it seems fine without them.
2019-04-12Add comment that field projectin also works with mutable fieldsChris Gregory-5/+6
2019-04-11Remove [mut] syntax in pin docsChris Gregory-9/+9
2019-04-11Remove note about transmute for float bitpatterns.Scott Olson-10/+0
2019-04-11Auto merge of #59211 - nox:refcell-borrow-state, r=KodrAusbors-0/+38
Introduce RefCell::try_borrow_unguarded *Come sit next to the fireplace with me, this is going to be a long story.* So, you may already be aware that Servo has weird design constraints that forces us developers working on it to do weird things. The thing that interests us today is that we do layout on a separate thread with its own thread pool to do some things in parallel, whereas the data it uses comes from the script thread, which implements the entire DOM and related pieces, with `!Sync` data types such as `RefCell<T>`. The invariant we maintain is that script does not do anything ever with the DOM data as long as layout is doing its job. That's all nice and all, but one thing we don't ensure is that we don't actually know if script was currently mutably borrowing some `RefCell<T>` prior to starting layout, which may lead to aliasing mutable memory and obviously undefined behaviour. This PR reinstates `RefCell::borrow_state` so that [this method](https://github.com/servo/servo/blob/master/components/script/dom/bindings/cell.rs#L23-L30) can make use of it and return `None` if the cell was mutably borrowed. Cc @SimonSapin