about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2020-05-29Added tests for the implementationsAlexis Bourget-1/+19
2020-05-29Added implementations for TryFrom<{int}> for NonZero{int}Alexis Bourget-0/+37
2020-05-29Rollup merge of #72466 - lzutao:stabilize_str-strip, r=dtolnayDylan DPC-5/+2
Stabilize str_strip feature This PR stabilizes these APIs: ```rust impl str { /// Returns a string slice with the prefix removed. /// /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly /// once. pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str>; /// Returns a string slice with the suffix removed. /// /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly /// once. pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str> where P: Pattern<'a>, <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>; } ``` Closes #67302
2020-05-28Skip leak test on targets without panic=unwindMikail Bagishov-0/+8
2020-05-28from_u32_unchecked: check validity when debug assertions are enabledRalf Jung-2/+2
2020-05-28FIx off-by-one in char::steps_betweenCAD97-1/+3
2020-05-27Fix is_char_boundary documentationMikko Rantanen-4/+3
2020-05-26Add Peekable::next_ifJoshua Nelson-0/+88
Prior art: `rust_analyzer` uses [`Parser::eat`](https://github.com/rust-analyzer/rust-analyzer/blob/50f4ae798b7c54d417ee88455b87fd0477473150/crates/ra_parser/src/parser.rs#L94), which is `next_if` specialized to `|y| next_if(|x| x == y)`. Basically every other parser I've run into in Rust has an equivalent of Parser::eat; see for example - [cranelift](https://github.com/bytecodealliance/wasmtime/blob/94190d57244b26baf36629c88104b0ba516510cf/cranelift/reader/src/parser.rs#L498) - [rcc](https://github.com/jyn514/rcc/blob/a8159c3904a0c950fbba817bf9109023fad69033/src/parse/mod.rs#L231) - [crunch](https://github.com/Kixiron/crunch-lang/blob/8521874fab8a7d62bfa7dea8bd1da94b63e31be8/crates/crunch-parser/src/parser/mod.rs#L213-L241)
2020-05-27Rollup merge of #72626 - phimuemue:doubleendediter_doc, r=dtolnayDylan DPC-0/+26
Add remark regarding DoubleEndedIterator While reviewing https://github.com/rust-itertools/itertools/pull/442/commits/14293bd18f01b6bd4856816222f808f46603eccd#diff-2c16d2ada06ad2fd1fc754679646d471, I realized that a `DoubleEndedIterator` may yield different elements depending on whether it is traversed forwards or backwards. (Not only the *order*, but possibly also the yielded values.) I found this remarkable, but could not find anything in the current docs, so I thought it may be worth mentioning this explicitly. Unfortunately, I could not test these changes locally (`rustdoc` complains about `unresolved import`). Sorry if this causes headache. If I should change something, please let me know. If it seems too trivial, feel free to just close this PR.
2020-05-27Rollup merge of #72606 - GuillaumeGomez:cell-example-update, r=Dylan-DPCDylan DPC-3/+3
Small cell example update r? @Dylan-DPC
2020-05-27Add tests for 'impl Default for [T; N]'Mikail Bagishov-0/+41
2020-05-26Add remark regarding DoubleEndedIteratorphilipp-0/+26
2020-05-26Small cell example updateGuillaume Gomez-3/+3
2020-05-25Display information about captured variable in `FnMut` errorAaron Hill-0/+1
Fixes #69446 When we encounter a region error involving an `FnMut` closure, we display a specialized error message. However, we currently do not tell the user which upvar was captured. This makes it difficult to determine the cause of the error, especially when the closure is large. This commit records marks constraints involving closure upvars with `ConstraintCategory::ClosureUpvar`. When we decide to 'blame' a `ConstraintCategory::Return`, we additionall store the captured upvar if we found a `ConstraintCategory::ClosureUpvar` in the path. When generating an error message, we point to relevant spans if we have closure upvar information available. We further customize the message if an `async` closure is being returned, to make it clear that the captured variable is being returned indirectly.
2020-05-26Add tracing issue for total_cmpPyry Kontio-2/+2
2020-05-25Rollup merge of #72450 - csmoe:issue-72442, r=oli-obkDylan DPC-0/+1
Fix ice-#72442 Closes #72442 Closes #72426 r? @oli-obk
2020-05-25core: Make pointer offset methods "const fn"Joe Richey-12/+27
Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-26Fix the same typos again orzPyry Kontio-4/+4
2020-05-26Add bit twiddlingPyry Kontio-15/+19
2020-05-26remove unneeded and unidiomatic must_usePyry Kontio-2/+0
2020-05-26Fix typo in src/libcore/num/f32.rsPyry Kontio-1/+1
Co-authored-by: bluss <bluss@users.noreply.github.com>
2020-05-26Fix typo in src/libcore/num/f32.rsPyry Kontio-1/+1
Co-authored-by: bluss <bluss@users.noreply.github.com>
2020-05-25Add total_cmp to f32 and f64, plus testsPyry Kontio-0/+146
2020-05-25Rollup merge of #72551 - alilleybrinker:document-debug-stability, r=KodrAusRalf Jung-0/+7
First draft documenting Debug stability. Debug implementations of std types aren't stable, and neither are derived Debug implementations for any types, including user-defined types. This commit adds a section to the Debug documentation noting this stability status. This issue is tracked by #62794.
2020-05-25Rollup merge of #71940 - SimonSapin:nonnull-slice, r=kennytmRalf Jung-0/+61
Add `len` and `slice_from_raw_parts` to `NonNull<[T]>` This follows the precedent of the recently-added `<*const [T]>::len` (adding to its tracking issue https://github.com/rust-lang/rust/issues/71146) and `ptr::slice_from_raw_parts`.
2020-05-24First draft documenting Debug stability.Andrew Lilley Brinker-0/+7
Debug implementations of std types aren't stable, and neither are derived Debug implementations for any types, including user-defined types. This commit adds a section to the Debug documentatio noting this stability status.
2020-05-24Rollup merge of #72535 - saschanaz:patch-1, r=jonas-schievinkRalf Jung-1/+1
Use sort_unstable_by in its own docs Currently it uses `sort_by` instead of itself.
2020-05-24Use sort_unstable_by in its own docsKagami Sascha Rosylight-1/+1
2020-05-24Use `dyn` trait syntax in more comments and docsratijas-4/+4
Probably missed it out during earlier `dyn` refactoring.
2020-05-23Rollup merge of #72431 - RalfJung:ub-warning, r=shepmasterDylan DPC-13/+13
add warning sign to UB examples Just to make it less likely that people miss the fact that these are examples for how to *not* do it.
2020-05-23add warning sign to UB examplesRalf Jung-13/+13
2020-05-22Rollup merge of #72459 - yoshuawuyts:into-future, r=nikomatsakisDylan DPC-0/+31
Add core::future::IntoFuture This patch reintroduces the `core::future::IntoFuture` trait. However unlike earlier PRs this patch does not integrate it into the `async/.await` lowering since that lead to performance regressions. By introducing the trait separately from the integration, the integration PR can be more narrowly scoped, and people can start trying out the `IntoFuture` trait today. Thanks heaps! cc/ @rust-lang/wg-async-foundations ## References - Original PR adding `IntoFuture` https://github.com/rust-lang/rust/pull/65244 - Open issue to re-land `IntoFuture` (assigned to me) https://github.com/rust-lang/rust/issues/67982 - Tracking issue for `IntoFuture` https://github.com/rust-lang/rust/issues/67644
2020-05-22Stabilize str_strip featureLzu Tao-5/+2
2020-05-22Add core::future::IntoFutureYoshua Wuyts-0/+31
This patch adds `core::future::IntoFuture`. However unlike earlier PRs this patch does not integrate it into the `async/.await` lowering. That integration should be done in a follow-up PR.
2020-05-22Rollup merge of #71607 - RalfJung:pin-drop-panic, r=nikomatsakisRalf Jung-2/+4
clarify interaction of pin drop guarantee and panics Cc https://github.com/rust-lang/unsafe-code-guidelines/issues/232 @Diggsey would this have helped?
2020-05-21Clarified the documentation for Formatter::precisionNathan West-1/+2
2020-05-22only try to suggest for try trait_refcsmoe-0/+1
2020-05-21Add a test for char rangesCAD97-0/+10
2020-05-21Add safety annotations in iter::rangeCAD97-0/+4
2020-05-21TypoRalf Jung-1/+1
2020-05-21Improve documentation of `slice::from_raw_parts`Daniel Henry-Mantilla-1/+30
This is to provide a more explicit statement against a code pattern that many people end up coming with, since the reason of it being unsound comes from the badly known single-allocation validity rule. Providing that very pattern as a counter-example could help mitigate that. Co-authored-by: Ralf Jung <post@ralfj.de>
2020-05-21Rollup merge of #72371 - Elrendio:char_documentation, r=steveklabnikRalf Jung-2/+4
FIX - Char documentation for unexperienced users This is my first PR on rust and even if I've read [CONTRIBUTING.md](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#pull-requests) I'm ensure everything is perfect. Sorry if I didn't follow the exact procedure. **What it does:** - Add an example in the char documentation **Explanation** Unexperienced users might not know that punctuation is `Case_Ignorable` and not `Uppercase` and `Lowercase` which mean that when checking if a string is uppercase one might be tempted to write: ```rust my_string.chars().all(char::is_uppercase) ``` However this will return false for `"HELLO WORLD"` which is not intuitive. Since the function `is_case_ignorable` doesn't exists I believe the correct way to check is: ```rust !my_string.chars().any(char::is_lowercase) ``` The aim of this example is to prevent unexperienced users to make an error which punctuation chars.
2020-05-21Rollup merge of #71854 - eduardosm:assoc-char-funcs-and-consts, r=AmanieuRalf Jung-2/+239
Make `std::char` functions and constants associated to `char`. First step to fix https://github.com/rust-lang/rust/issues/71763.
2020-05-21Use Step::forward_unchecked in RangeInclusive::nextCAD97-1/+5
2020-05-21impl Step for charCAD97-0/+64
Enables Range<char> to be iterable Note: https://rust.godbolt.org/z/fdveKo An iteration over all char ('\0'..=char::MAX) includes unreachable panic code currently. Updating RangeInclusive::next to call Step::forward_unchecked (which is safe to do but not done yet becuase it wasn't necessary) successfully removes the panic from this iteration.
2020-05-21Auto merge of #70705 - lcnr:generic_discriminant, r=nikomatsakisbors-3/+41
Use `T`'s discriminant type in `mem::Discriminant<T>` instead of `u64`. fixes #70509 Adds the lang-item `discriminant_kind`. Updates the function signature of `intrinsics::discriminant_value`. Adds the *probably permanently unstable* trait `DiscriminantKind`. `mem::Discriminant` should now be smaller in some cases. r? @ghost
2020-05-20Rollup merge of #72361 - golddranks:split_inclusive_add_tracking_issue, ↵Dylan DPC-20/+20
r=shepmaster split_inclusive: add tracking issue number (72360) Adds tracking issue number ( https://github.com/rust-lang/rust/issues/72360 ) to the unstable feature attributes.
2020-05-20Rollup merge of #72139 - nnethercote:standalone-fold, r=cuviperDylan DPC-20/+199
Make `fold` standalone. `fold` is currently implemented via `try_fold`, but implementing it directly results in slightly less LLVM IR being generated, speeding up compilation of some benchmarks. r? @cuviper
2020-05-20FIX - Char documentation for unexperienced usersElrendio-2/+4
2020-05-19Resolve overflow behavior for RangeFromCAD97-13/+11