about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2023-10-13Remove Not for IpAddrltdk-23/+0
2023-10-13impl Not, Bit{And,Or,Xor}{,Assign} for IP addressesltdk-0/+154
2023-10-12Update primitive_docs.rsJoshua Liebow-Feeser-1/+0
2023-10-12Update library/core/src/alloc/layout.rsJoshua Liebow-Feeser-1/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2023-10-12References refer to allocated objectsJoshua Liebow-Feeser-0/+12
2023-10-11Auto merge of #112818 - Benjamin-L:add-slice_split_once, r=cuviperbors-0/+56
Implement `slice::split_once` and `slice::rsplit_once` Feature gate is `slice_split_once` and tracking issue is #112811. These are equivalents to the existing `str::split_once` and `str::rsplit_once` methods.
2023-10-10Update mod.rstae-soo-kim-6/+5
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+1
2023-10-08Bump to latest betaMark Rousskov-36/+26
2023-10-07Auto merge of #100806 - timvermeulen:split_inclusive_double_ended_bound, ↵bors-1/+1
r=dtolnay Fix generic bound of `str::SplitInclusive`'s `DoubleEndedIterator` impl `str::SplitInclusive`'s `DoubleEndedIterator` implementation currently uses a `ReverseSearcher` bound for the corresponding searcher. A `DoubleEndedSearcher` bound should have been used instead. `DoubleEndedIterator` requires that repeated `next_back` calls produce the same items as repeated `next` calls, in opposite order. `ReverseSearcher` lets you search starting from the back of a string, but it makes no guarantees about how its matches correspond to the matches found by a forward search. `DoubleEndedSearcher` is a subtrait of `ReverseSearcher` and does require that the same matches are found in both directions. This bug fix is a breaking change. Calling `next_back` on `"a+++b".split_inclusive("++")` is currently accepted with repeated calls producing `"b"` and `"a+++"`, while forward iteration yields `"a++"` and `"+b"`. Also see https://github.com/rust-lang/rust/issues/100756#issuecomment-1221307166 for more details. I believe that this is the only iterator that uses this bound incorrectly — other related iterators such as `str::Split` do have a `DoubleEndedSearcher` bound for their `DoubleEndedIterator` implementation. And `slice::SplitInclusive` doesn't face this problem at all because it doesn't use patterns, only a predicate. cc `@SkiFire13`
2023-10-07Expose tests for {f32,f64}.total_cmp in docs, along with commentEd Swartz-6/+22
Uncomment the assert! line and account and document that the sign of NaN is not positive, necessarily.
2023-10-06Rollup merge of #116481 - scottmcm:tweak-combinators, r=cuviperMatthias Krüger-4/+4
Reuse existing `Some`s in `Option::(x)or` LLVM still has trouble re-using discriminants sometimes when rebuilding a two-variant enum, so when we have the correct variant already built, just use it. That's shorter in the Rust code, as well as simpler in MIR and the optimized LLVM, so might as well: <https://rust.godbolt.org/z/KhdE8eToW> Thanks to `@veber-alex` for pointing out this opportunity in https://github.com/rust-lang/rust/issues/101210#issuecomment-1732470941
2023-10-06Rollup merge of #114564 - scottmcm:when-to-from, r=dtolnayMatthias Krüger-0/+40
Attempt to describe the intent behind the `From` trait further Inspired by the <https://internals.rust-lang.org/t/allow-use-as-and-try-as-for-from-and-tryfrom-traits/19240/26?u=scottmcm> thread. `@rustbot` label +T-libs-api
2023-10-06optimize zipping over array iteratorsThe 8472-1/+116
2023-10-06Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcmGuillaume Gomez-5/+4
update some comments around swap() Based on ``@eddyb's`` comment [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/461#issuecomment-1742156410). And then I noticed the wrong capitalization for Miri and fixed it in some other places as well.
2023-10-06Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkinGuillaume Gomez-0/+36
Add more diagnostic items for clippy
2023-10-06Rollup merge of #115588 - tifv:fix-comment-successors, r=scottmcmGuillaume Gomez-1/+1
Fix a comment in std::iter::successors The `unfold` function have since #58062 been renamed to `from_fn`. (I'm not sure if this whole comment is still useful—it's not like there are many iterators that *can't* be based on `from_fn`. Anyway, in its current form this comment is not correct, and it sent me into a half-hour research of what happened to `unfold` function, so I want to do *something* with it :upside_down_face: deleting these three lines is a perfectly fine alternative, in my opinion.)
2023-10-06Rollup merge of #115522 - joshlf:patch-8, r=scottmcmGuillaume Gomez-6/+6
Clarify ManuallyDrop bit validity Clarify that `ManuallyDrop<T>` has the same bit validity as `T`.
2023-10-06Rollup merge of #115454 - vwkd:patch-1, r=scottmcmGuillaume Gomez-1/+1
Clarify example in docs of str::char_slice Just a one word improvement. “Last” can be misread as meaning the last (third) instead of the previous (first).
2023-10-06Reuse existing `Some`s in `Option::(x)or`Scott McMurray-4/+4
LLVM still has trouble re-using discriminants sometimes when rebuilding a two-variant enum, so when we have the correct variant already built, just use it. That's simpler in LLVM *and* in MIR, so might as well: <https://rust.godbolt.org/z/KhdE8eToW>
2023-10-05Elaborate some caveats to losslessScott McMurray-2/+5
2023-10-06Don't mention "recover the original" in `From` docsscottmcm-2/+5
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2023-10-05Attempt to describe the intent behind the `From` trait furtherScott McMurray-0/+34
2023-10-05Add more diagnostic items for clippyJason Newcomb-0/+36
2023-10-05Auto merge of #116455 - matthiaskrgr:rollup-p226a5u, r=matthiaskrgrbors-12/+2
Rollup of 5 pull requests Successful merges: - #116220 (stabilize `Option::as_`(`mut_`)`slice`) - #116288 (Add Span to various smir types) - #116415 (Move subtyper below reveal_all and change reveal_all) - #116428 (Add a note to duplicate diagnostics) - #116452 (Do not assert that hidden types don't have erased regions.) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-05Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushiMatthias Krüger-12/+2
stabilize `Option::as_`(`mut_`)`slice` This is the stabilization to #108545. Thanks to everyone who helped getting this into Rust proper.
2023-10-05Auto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubileebors-17/+50
docs: Correct terminology in std::cmp This PR is the result of some discussions on URLO: * [Traits in `std::cmp` and mathematical terminology](https://users.rust-lang.org/t/traits-in-std-cmp-and-mathematical-terminology/69887) * [Are poker hands `Ord` or `PartialOrd`?](https://users.rust-lang.org/t/are-poker-hands-ord-or-partialord/82644) Arguably, the documentation currently isn't very precise regarding mathematical terminology. This can lead to misunderstandings of what `PartialEq`, `Eq`, `PartialOrd`, and `Ord` actually do. While I believe this PR doesn't give any new API guarantees, it expliclitly mentions that `PartialEq::eq(a, b)` may return `true` for two distinct values `a` and `b` (i.e. where `a` and `b` are not equal in the mathematical sense). This leads to the consequence that `Ord` may describe a weak ordering instead of a total ordering. In either case, I believe this PR should be thoroughly reviewed, ideally by someone with mathematical background to make sure the terminology is correct now, and also to ensure that no unwanted new API guarantees are made. In particular, the following problems are addressed: * Some clarifications regarding used (mathematical) terminology: * Avoid using the terms "total equality" and "partial equality" in favor of "equivalence relation" and "partial equivalence relation", which are well-defined and unambiguous. * Clarify that `Ordering` is an ordering between two values (and not an order in the mathematical sense). * Avoid saying that `PartialEq` and `Eq` are "equality comparisons" because the terminology "equality comparison" could be misleading: it's possible to implement `PartialEq` and `Eq` for other (partial) equivalence relations, in particular for relations where `a == b` for some `a` and `b` even when `a` and `b` are not the same value. * Added a section "Strict and non-strict partial orders" to document that the `<=` and `>=` operators do not correspond to non-strict partial orders. * Corrected section "Corollaries" in documenation of `Ord` in regard to `<` only describing a strict total order in cases where `==` conforms to mathematical equality. * ~~Added a section "Weak orders" to explain that `Ord` may also describe a weak order or total preorder, depending on how `PartialEq::eq` has been implemented.~~ (Removed, see [comment](https://github.com/rust-lang/rust/pull/103046#issuecomment-1279929676)) * Made documentation easier to understand: * Explicitly state at the beginning of `PartialEq`'s documentation comment that implementing the trait will provide the `==` and `!=` operators. * Added an easier to understand rule when to implement `Eq` in addition to `PartialEq`: "if it’s guaranteed that `PartialEq::eq(a, a)` always returns `true`." * Explicitly mention in documentation of `Eq` that the properties "symmetric" and "transitive" are already required by `PartialEq`.
2023-10-05Auto merge of #114042 - liushuyu:ubuntu/i586-fpmath, r=workingjubileebors-1/+1
core library: Disable fpmath tests for i586 ... This patch disables the floating-point epsilon test for i586 since x87 registers are too imprecise and can't produce the expected results.
2023-10-05docs: Correct terminology in std::cmpJan Behrens-17/+50
Some clarifications regarding used (mathematical) terminology: * Avoid using the terms "total equality" and "partial equality" in favor of "equivalence relation" and "partial equivalence relation", which are well-defined and unambiguous. * Clarify that `Ordering` is an ordering between two values (and not an order in the mathematical sense). * Avoid saying that `PartialEq` and `Eq` are "equality comparisons" because the terminology "equality comparison" could be misleading: it's possible to implement `PartialEq` and `Eq` for other (partial) equivalence relations, in particular for relations where `a == b` for some `a` and `b` even when `a` and `b` are not the same value. * Added a section "Strict and non-strict partial orders" to document that the `<=` and `>=` operators do not correspond to non-strict partial orders. * Corrected section "Corollaries" in documenation of Ord in regard to `<` only describing a strict total order in cases where `==` conforms to mathematical equality. Made documentation easier to understand: * Explicitly state at the beginning of `PartialEq`'s documentation comment that implementing the trait will provide the `==` and `!=` operators. * Added an easier to understand rule when to implement `Eq` in addition to `PartialEq`: "if it’s guaranteed that `PartialEq::eq(a, a)` always returns `true`." * Explicitly mention in documentation of `Eq` that the properties "symmetric" and "transitive" are already required by `PartialEq`.
2023-10-05Auto merge of #104153 - tspiteri:doc-float-constants, r=workingjubileebors-4/+80
doc: expand description for f32 and f64 associated constants This explains the meaning of some of the floating-point associated constants.
2023-10-04Disable CFI for core and std CFI violationsRamon de C Valle-0/+5
Works around #115199 by temporarily disabling CFI for core and std CFI violations to allow the user rebuild and use both core and std with CFI enabled using the Cargo build-std feature.
2023-10-04Auto merge of #116408 - matthiaskrgr:rollup-hmolg4m, r=matthiaskrgrbors-10/+24
Rollup of 7 pull requests Successful merges: - #115961 (Replace 'mutex' with 'lock' in RwLock documentation) - #116146 (Clarify `arg` and `args` documentation) - #116363 (Adapt `todo!` documentation to mention displaying custom values) - #116365 (bootstrap: make copying linker binaries conditional) - #116388 (rustdoc: fix & clean up handling of cross-crate higher-ranked parameters) - #116393 (Emit feature gate *warning* for `auto` traits pre-expansion) - #116395 (Mark myself as vacation or whatever) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-04Rollup merge of #116363 - Colonial-Dev:issue-116130-fix, r=thomccMatthias Krüger-10/+24
Adapt `todo!` documentation to mention displaying custom values Resolves #116130. I copied from the [existing documentation](https://doc.rust-lang.org/std/macro.unimplemented.html) for `unimplemented!` more or less directly, down to the example trait used. I also took the liberty of fixing some formatting and typographical errors that I noticed.
2023-10-03Bump version placeholdersMark Rousskov-90/+90
2023-10-03Add missing inline attributes to Duration trait implsElichai Turkel-0/+9
2023-10-03Rollup merge of #116361 - eduardosm:bump-stdarch, r=AmanieuMatthias Krüger-0/+1
Bump stdarch submodule r? `@Amanieu`
2023-10-03Rollup merge of #116355 - orlp:signed-zero-rounding-mode, r=thomccMatthias Krüger-4/+6
Clarify float rounding direction for signed zero Closes https://github.com/rust-lang/rust/issues/116339.
2023-10-03Rollup merge of #116351 - asquared31415:ptr_eq_must_use, r=workingjubileeMatthias Krüger-0/+2
Add `must_use` on pointer equality functions `ptr == ptr` (like all use of `==`) has a similar warning, and these functions are simple convenience wrappers over that.
2023-10-02Appease tidyJames Haywood-4/+4
2023-10-02Adapt `todo!` documentation to mention displaying custom valuesJames Haywood-10/+24
Correct hidden trait in doc test
2023-10-02Bump stdarch submoduleEduardo Sánchez Muñoz-0/+1
2023-10-02Rollup merge of #116350 - Nilstrieb:in-situ, r=Dylan-DPCTyler Mandry-1/+1
Improve wording of `hint::black_box` docs The wording is a bit confusing. squash of #109634
2023-10-02Clarify float rounding direction for signed zeroOrson Peters-4/+6
2023-10-02Improve wording of `hint::black_box` docs4gboframram-1/+1
The wording is a bit confusing. Co-authored-by: Chris Denton <christophersdenton@gmail.com>
2023-10-02add must_use on pointer equality functionsasquared31415-0/+2
2023-10-02Rollup merge of #116326 - Colonial-Dev:issue-116165-fix, r=joshtriplettMatthias Krüger-2/+4
Correct misleading std::fmt::Binary example (#116165) Nothing too crazy... - Add two to the width specifier (so all 32 bits are correctly displayed) - Pad out the compared string so the assert passes - Add `// Note` comment highlighting the need for the extra width when using the `#` flag. The exact contents (and placement?) of the note are, of course, highly bikesheddable.
2023-10-02update some comments around swap()Ralf Jung-5/+4
2023-10-02Auto merge of #116325 - scottmcm:addr_eq, r=dtolnaybors-0/+22
Add `ptr::addr_eq` Seconded ACP: https://github.com/rust-lang/libs-team/issues/274#issuecomment-1741853598 Tracking issue: https://github.com/rust-lang/rust/issues/116324 cc `@dtolnay` https://github.com/rust-lang/rust/issues/106447
2023-10-01Correct misleading std::fmt::Binary exampleJames Haywood-2/+4
2023-10-01Add `ptr::addr_eq`Scott McMurray-0/+22