about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2023-10-06Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcmGuillaume Gomez-7/+6
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-02MIRI -> MiriRalf Jung-2/+2
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
2023-10-01Add track_caller attribute to Result::unwrap_or_elseravenclaw900-0/+1
2023-10-01Rollup merge of #116295 - asquared31415:mem_drop_docs, r=WaffleLapkinMatthias Krüger-1/+1
Fix `core::mem::drop` docs inaccuracy r? `@Nilstrieb`
2023-10-01Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrumbors-1/+56
Partially outline code inside the panic! macro This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-09-30mem::drop docsasquared31415-1/+1
2023-09-29Rollup merge of #116241 - dtolnay:exclusivefwd, r=AmanieuMatthias Krüger-1/+45
Add Exclusive forwarding impls (FnOnce, FnMut, Generator) This is adapted from #104057.
2023-09-29Auto merge of #113797 - RalfJung:offset_from_docs, r=workingjubileebors-6/+40
offset_from: docs improvements This is the part of https://github.com/rust-lang/rust/pull/112837 that doesn't add a new function, just tweaks the existing docs.
2023-09-29Auto merge of #116176 - FedericoStra:isqrt, r=dtolnaybors-0/+165
Add "integer square root" method to integer primitive types For every suffix `N` among `8`, `16`, `32`, `64`, `128` and `size`, this PR adds the methods ```rust const fn uN::isqrt() -> uN; const fn iN::isqrt() -> iN; const fn iN::checked_isqrt() -> Option<iN>; ``` to compute the [integer square root](https://en.wikipedia.org/wiki/Integer_square_root), addressing issue #89273. The implementation is based on the [base 2 digit-by-digit algorithm](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Binary_numeral_system_(base_2)) on Wikipedia, which after some benchmarking has proved to be faster than both binary search and Heron's/Newton's method. I haven't had the time to understand and port [this code](http://atoms.alife.co.uk/sqrt/SquareRoot.java) based on lookup tables instead, but I'm not sure whether it's worth complicating such a function this much for relatively little benefit.
2023-09-28Const stabilize mem::discriminantDavid Tolnay-3/+2
2023-09-28Add Exclusive forwarding impls (FnOnce, FnMut, Generator)David Tolnay-1/+45
2023-09-28isqrt: disable long running tests in MiriFederico Stra-0/+8
2023-09-28Stabilize `const_maybe_uninit_assume_init_read`DaniPopes-2/+4
2023-09-28Rollup merge of #116221 - ArchUsr64:patch-1, r=ChrisDentonMatthias Krüger-1/+1
core/slice: Fix inconsistency between docs for `rotate_left` and `rotate_right` A minor fix for documentation inconsistency as shown below: ## Before: ![2023_09_28_0k3_Kleki](https://github.com/rust-lang/rust/assets/83179501/569a49d3-0d72-49ac-92a2-ef5e1d94130b) ## After: ![image](https://github.com/rust-lang/rust/assets/83179501/afd0c8d7-6fb7-4878-801b-b47c8fe23c7d) Docs url: https://doc.rust-lang.org/stable/core/primitive.slice.html#method.rotate_left
2023-09-28isqrt: `assume` that `isqrt` takes half as many bitsFederico Stra-0/+7
https://github.com/rust-lang/rust/issues/89273#issuecomment-970581089