summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2021-05-03Remove some more constsMark Rousskov-14/+1
2021-05-03drop some const unstables, due to revert no longer possibleMark Rousskov-8/+4
2021-05-03Revert "directly expose copy and copy_nonoverlapping intrinsics"Mark Rousskov-154/+205
This reverts commit 18d12ad171384a82736a88b879540bf464161063.
2021-05-03Revert "Add debug_assert_matches macro."Mark Rousskov-36/+0
This reverts commit 0a8e401188062f0c60c989978352663b1e25e70e.
2021-05-03Revert "Add assert_matches!(expr, pat)."Mark Rousskov-100/+23
This reverts commit eb18746bc6c6c5c710ad674873438cbad5894f06.
2021-03-26SplitInclusive is public APIAlan Egerton-1/+1
2021-03-20Auto merge of #82919 - bstrie:stabchar, r=dtolnaybors-7/+7
Stabilize `assoc_char_funcs` and `assoc_char_consts` Stabilizes the following associated items on `char`: * [`char::MAX`](https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.MAX) * [`char::REPLACEMENT_CHARACTER`](https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.REPLACEMENT_CHARACTER) * [`char::UNICODE_VERSION`](https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.UNICODE_VERSION) * [`char::decode_utf16`](https://doc.rust-lang.org/std/primitive.char.html#method.decode_utf16) * [`char::from_u32`](https://doc.rust-lang.org/std/primitive.char.html#method.from_u32) * [`char::from_u32_unchecked`](https://doc.rust-lang.org/std/primitive.char.html#method.from_u32_unchecked) * [`char::from_digit`](https://doc.rust-lang.org/std/primitive.char.html#method.from_digit) Closes #71763.
2021-03-19Stabilize `assoc_char_funcs` and `assoc_char_consts`bstrie-7/+7
2021-03-19Rollup merge of #83254 - jfrimmel:panic_output-stream, r=m-ou-se,joshtriplettDylan DPC-5/+10
Include output stream in `panic!()` documentation Fixes #83252.
2021-03-19Rollup merge of #82570 - WaffleLapkin:split_whitespace_as_str, r=m-ou-seDylan DPC-4/+61
Add `as_str` method for split whitespace str iterators This PR adds `as_str` methods to `SplitWhitespace` and `SplitAsciiWhitespace` str iterators. The methods return the remainder, similar to `as_str` methods on `Chars` and other split iterators. This PR is a continuation of https://github.com/rust-lang/rust/pull/75265, which added `as_str` for all other str split iterators. The feature gate for new methods is `#![feature(str_split_whitespace_as_str)]`. `SplitWhitespace` and `SplitAsciiWhitespace` use iterators under the hood, so to implement `as_str` it's required to either 1. Make fields of some iterators `pub(crate)` 2. Add getter methods (like `into_inner`, `inner`, `inner_mut`...) to some (all) iterators 3. Completely rewrite `SplitWhitespace` and `SplitAsciiWhitespace` This PR uses the 1. approach since it's easier to implement and requires fewer changes (and no changes to the public API). If you think that's not the right way, please, tell me. r? `@m-ou-se`
2021-03-19Rollup merge of #83270 - steffahn:missing_word_in_skip_while_doc, r=joshtriplettDylan DPC-1/+1
Fix typo/inaccuracy in the documentation of Iterator::skip_while One of the examples used to say “this leads to a possibly confusing situation, where the type of the closure is a double reference” while _actually_ referring to the type of the closure _argument_. This PR just changes a single word in documentation. `````@rustbot````` modify labels: A-iterators, T-doc, T-lang
2021-03-18Apply suggestions from code reviewJ. Frimmel-3/+3
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-03-18Fix typo/inaccuracy in the documentation of Iterator::skip_whileFrank Steffahn-1/+1
One of the examples used to say “this leads to a possibly confusing situation, where the type of the closure is a double reference” while _actually_ referring to the type of the closure _argument_.
2021-03-18Incorporate review feedback #2Julian Frimmel-3/+4
2021-03-18Add more information about panickingJulian Frimmel-5/+9
This includes the description of the default `std` behavior and mentions the `panic::set_hook()` function.
2021-03-18Include output stream in `panic!()` documentationJulian Frimmel-2/+2
2021-03-18Auto merge of #82868 - petrochenkov:bto, r=estebankbors-6/+6
Report missing cases of `bare_trait_objects` Fixes https://github.com/rust-lang/rust/issues/65371
2021-03-18Rollup merge of #82434 - jyn514:hash, r=JohnTitorDylan DPC-2/+8
Add more links between hash and btree collections - Link from `core::hash` to `HashMap` and `HashSet` - Link from HashMap and HashSet to the module-level documentation on when to use the collection - Link from several collections to Wikipedia articles on the general concept See also https://github.com/rust-lang/rust/pull/81989#issuecomment-783920840.
2021-03-18Fix use of bare trait objects everywhereVadim Petrochenkov-6/+6
2021-03-17Auto merge of #82122 - bstrie:dep4real, r=dtolnaybors-2/+6
Deprecate `intrinsics::drop_in_place` and `collections::Bound`, which accidentally weren't deprecated Fixes #82080. I've taken the liberty of updating the `since` values to 1.52, since an unobservable deprecation isn't much of a deprecation (even the detailed release notes never bothered to mention these deprecations). As mentioned in the issue I'm *pretty* sure that using a type alias for `Bound` is semantically equivalent to the re-export; [the reference implies](https://doc.rust-lang.org/reference/items/type-aliases.html) that type aliases only observably differ from types when used on unit structs or tuple structs, whereas `Bound` is an enum.
2021-03-17fix whitespaceJoshua Nelson-1/+1
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2021-03-17Auto merge of #81358 - mcastorina:to-upper-lower-speed, r=joshtriplettbors-6/+14
Add a check for ASCII characters in to_upper and to_lower This extra check has better performance. See discussion here: https://internals.rust-lang.org/t/to-upper-speed/13896 Thanks to `@gilescope` for helping discover and test this.
2021-03-16Rollup merge of #83160 - m-ou-se:deprecate-rustc-serialize-derives, ↵Yuki Okushi-1/+9
r=petrochenkov Deprecate RustcEncodable and RustcDecodable. We can't remove the `RustcEncodable` and `RustcDecodable` derive macros from the prelude, but we can deprecate them.
2021-03-15Constify mem::transmute_copyAlbin Hedman-1/+2
2021-03-15Constify mem::replace and ptr::replaceAlbin Hedman-2/+4
2021-03-15Constify mem::swap and ptr::swap[_nonoverlapping]Albin Hedman-27/+12
2021-03-15Constify copy_to and copy_fromAlbin Hedman-6/+12
2021-03-15Deprecate RustcEncodable and RustcDecodable.Mara Bos-1/+9
2021-03-14Fix a typo in `swap_nonoverlapping_bytes`Motoki Ikeda-1/+1
2021-03-14Rollup merge of #83081 - hyd-dev:assert-message, r=m-ou-seYuki Okushi-1/+1
Fix panic message of `assert_failed_inner` cc https://github.com/rust-lang/rust/pull/79100#discussion_r593731020 r? ``@m-ou-se``
2021-03-14Rollup merge of #83066 - Seppel3210:master, r=joshtriplettYuki Okushi-0/+1
Add `reverse` search alias for Iterator::rev() When searching for "reverse" in rustdoc you can't find the rev method on Iterator so here is a search alias for that.
2021-03-14Rollup merge of #81465 - joshtriplett:duration-formatting-documentation, ↵Yuki Okushi-0/+11
r=m-ou-se Add documentation about formatting `Duration` values Explain why Duration has a Debug impl but not a Display impl, and mention the use of Unicode.
2021-03-13Add documentation about formatting `Duration` valuesJosh Triplett-0/+11
Explain why Duration has a Debug impl but not a Display impl, and mention the use of Unicode.
2021-03-13Auto merge of #83064 - cjgillot:fhash, r=jackh726bors-0/+13
Tweaks to stable hashing
2021-03-13Fix panic message of `assert_failed_inner`hyd-dev-1/+1
2021-03-13Add `reverse` search alias for Iterator::rev()Sebastian Widua-0/+1
2021-03-12Auto merge of #83022 - m-ou-se:mem-replace-no-swap, r=nagisabors-3/+9
Don't implement mem::replace with mem::swap. `swap` is a complicated operation, so this changes the implementation of `replace` to use `read` and `write` instead. See https://github.com/rust-lang/rust/pull/83019. I wrote there: > Implementing the simpler operation (replace) with the much more complicated operation (swap) doesn't make a whole lot of sense. `replace` is just read+write, and the primitive for moving out of a `&mut`. `swap` is for doing that to *two* `&mut` at the same time, which is both more niche and more complicated (as shown by `swap_nonoverlapping_bytes`). This could be especially interesting for `Option<VeryLargeStruct>::take()`, since swapping such a large structure with `swap_nonoverlapping_bytes` is going to be much less efficient than `ptr::write()`'ing a `None`. But also for small values where `swap` just reads/writes using temporary variable, this makes a `replace` or `take` operation simpler: ![image](https://user-images.githubusercontent.com/783247/110839393-c7e6bd80-82a3-11eb-97b7-28acb14deffd.png)
2021-03-12Rollup merge of #82950 - mockersf:slice-intra-doc-link, r=jyn514Yuki Okushi-53/+59
convert slice doc link to intra-doc links Continuing where #80189 stopped, with `core::slice`. I had an issue with two dead links in my doc when implementing `Deref<Target = [T]>` for one of my type. This means that [`binary_search_by_key`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.binary_search_by_key) was available, but not [`sort_by_key`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.sort_by_key) even though it was linked in it's doc (same issue with [`as_ptr`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.as_ptr) and [`as_mut_pbr`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.as_mut_ptr)). It becomes available if I implement `DerefMut`, as it needs an `&mut self`. <details> <summary>Code that will have dead links in its doc</summary> ```rust pub struct A; pub struct B; impl std::ops::Deref for B{ type Target = [A]; fn deref(&self) -> &Self::Target { &A } } ``` </details> I removed the link to `sort_by_key` from `binary_search_by_key` doc as I didn't find a nice way to have a live link: - `binary_search_by_key` is in `core` - `sort_by_key` is in `alloc` - intra-doc link `slice::sort_by_key` doesn't work, as `alloc` is not available when `core` is being build (the warning can't be ignored: ```error[E0710]: an unknown tool name found in scoped lint: `rustdoc::broken_intra_doc_links` ```) - keeping the link as an anchor `#method.sort_by_key` meant a dead link - an absolute link would work but doesn't feel right...
2021-03-12Rollup merge of #80385 - camelid:clarify-cell-replace-docs, r=Mark-SimulacrumYuki Okushi-1/+1
Clarify what `Cell::replace` returns
2021-03-11Don't implement mem::replace with mem::swap.Mara Bos-3/+9
2021-03-11Add inlining.Camille GILLOT-0/+13
2021-03-10apply reviewFrançois Mockers-2/+4
2021-03-10add back sort_by_key link, allow linter and add commentFrançois Mockers-1/+6
2021-03-10Rollup merge of #82977 - camsteffen:opt-get-insert-def, r=m-ou-seDylan DPC-17/+17
Rename `Option::get_or_default` to `get_or_insert_default` ...as [suggested](https://github.com/rust-lang/rust/issues/82901#issuecomment-793548515) by `@m-ou-se.` In hindsight this seems rather obvious, at least to me. r? `@joshtriplett`
2021-03-10Rollup merge of #82217 - m-ou-se:edition-prelude, r=nikomatsakisDylan DPC-4/+38
Edition-specific preludes This changes `{std,core}::prelude` to export edition-specific preludes under `rust_2015`, `rust_2018` and `rust_2021`. (As suggested in https://github.com/rust-lang/rust/issues/51418#issuecomment-395630382.) For now they all just re-export `v1::*`, but this allows us to add things to the 2021edition prelude soon. This also changes the compiler to make the automatically injected prelude import dependent on the selected edition. cc `@rust-lang/libs` `@djc`
2021-03-10Rename Option::get_or_insert_defaultCameron Steffen-17/+17
2021-03-09Deprecate items that accidentally weren't deprecatedbstrie-2/+6
Fixes #82080
2021-03-10Rollup merge of #82849 - camsteffen:option-get-or-default, r=joshtriplettYuki Okushi-0/+28
Add Option::get_or_default Tracking issue: #82901 The original issue is #55042, which was closed, but for an invalid reason (see discussion there). Opening this to reconsider (I hope that's okay). It seems like the only gap for `Option` being "entry-like". I ran into a need for this method where I had a `Vec<Option<MyData>>` and wanted to do `vec[n].get_or_default().my_data_method()`. Using an `Option` as an inner component of a data structure is probably where the need for this will normally arise.
2021-03-10Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, ↵Yuki Okushi-1/+1
r=nikomatsakis Stabilize `unsafe_op_in_unsafe_fn` lint This makes it possible to override the level of the `unsafe_op_in_unsafe_fn`, as proposed in https://github.com/rust-lang/rust/issues/71668#issuecomment-729770896. Tracking issue: #71668 r? ```@nikomatsakis``` cc ```@SimonSapin``` ```@RalfJung``` # Stabilization report This is a stabilization report for `#![feature(unsafe_block_in_unsafe_fn)]`. ## Summary Currently, the body of unsafe functions is an unsafe block, i.e. you can perform unsafe operations inside. The `unsafe_op_in_unsafe_fn` lint, stabilized here, can be used to change this behavior, so performing unsafe operations in unsafe functions requires an unsafe block. For now, the lint is allow-by-default, which means that this PR does not change anything without overriding the lint level. For more information, see [RFC 2585](https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md) ### Example ```rust // An `unsafe fn` for demonstration purposes. // Calling this is an unsafe operation. unsafe fn unsf() {} // #[allow(unsafe_op_in_unsafe_fn)] by default, // the behavior of `unsafe fn` is unchanged unsafe fn allowed() { // Here, no `unsafe` block is needed to // perform unsafe operations... unsf(); // ...and any `unsafe` block is considered // unused and is warned on by the compiler. unsafe { unsf(); } } #[warn(unsafe_op_in_unsafe_fn)] unsafe fn warned() { // Removing this `unsafe` block will // cause the compiler to emit a warning. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } #[deny(unsafe_op_in_unsafe_fn)] unsafe fn denied() { // Removing this `unsafe` block will // cause a compilation error. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } ```
2021-03-09convert slice doc link to intra-doc linksFrançois Mockers-54/+53