summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2020-11-11Rollup merge of #78216 - workingjubilee:duration-zero, r=m-ou-seJonas Schievink-28/+12
Duration::zero() -> Duration::ZERO In review for #72790, whether or not a constant or a function should be favored for `#![feature(duration_zero)]` was seen as an open question. In https://github.com/rust-lang/rust/issues/73544#issuecomment-691701670 an invitation was opened to either stabilize the methods or propose a switch to the constant value, supplemented with reasoning. Followup comments suggested community preference leans towards the const ZERO, which would be reason enough. ZERO also "makes sense" beside existing associated consts for Duration. It is ever so slightly awkward to have a series of constants specifying 1 of various units but leave 0 as a method, especially when they are side-by-side in code. It seems unintuitive for the one non-dynamic value (that isn't from Default) to be not-a-const, which could hurt discoverability of the associated constants overall. Elsewhere in `std`, methods for obtaining a constant value were even deprecated, as seen with [std::u32::min_value](https://doc.rust-lang.org/std/primitive.u32.html#method.min_value). Most importantly, ZERO costs less to use. A match supports a const pattern, but const fn can only be used if evaluated through a const context such as an inline `const { const_fn() }` or a `const NAME: T = const_fn()` declaration elsewhere. Likewise, while https://github.com/rust-lang/rust/issues/73544#issuecomment-691949373 notes `Duration::zero()` can optimize to a constant value, "can" is not "will". Only const contexts have a strong promise of such. Even without that in mind, the comment in question still leans in favor of the constant for simplicity. As it costs less for a developer to use, may cost less to optimize, and seems to have more of a community consensus for it, the associated const seems best. r? ```@LukasKalbertodt```
2020-11-10Rollup merge of #78910 - tmiasko:intrinsics-link, r=jyn514Jonas Schievink-2/+2
Fix links to stabilized versions of some intrinsics
2020-11-09Bad grammarcyqsimon-1/+1
2020-11-09Clarified description of write! macrocyqsimon-1/+1
2020-11-09Rollup merge of #77640 - ethanboxx:int_error_matching_attempt_2, r=KodrAusDylan DPC-16/+24
Refactor IntErrorKind to avoid "underflow" terminology This PR is a continuation of #76455 # Changes - `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in #76455 - Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178 - Carry the problem `char` with the `InvalidDigit` variant. - Necessary changes were made to the compiler as it depends on `int_error_matching`. - Redid tests to match on specific errors. r? ```@KodrAus```
2020-11-09Fix links to stabilized versions of some intrinsicsTomasz Miąsko-2/+2
2020-11-08Rollup merge of #78852 - camelid:intra-doc-bonanza, r=jyn514Mara Bos-49/+41
Convert a bunch of intra-doc links An intra-doc link bonanza! This was accomplished using a bunch of trial-and-error with sed.
2020-11-08Rollup merge of #78788 - jhpratt:isize-impl-fix, r=m-ou-seMara Bos-3/+3
Correct unsigned equivalent of isize to be usize See [#74913 (comment)](https://github.com/rust-lang/rust/issues/74913#issuecomment-722334456) for why this matters. Apparently it hasn't been used anywhere else, though CI will tell for sure.
2020-11-08Rollup merge of #78728 - a1phyr:const_cell_into_inner, r=dtolnayMara Bos-8/+13
Constantify `UnsafeCell::into_inner` and related Tracking issue: #78729 This PR constantifies: - `UnsafeCell::into_inner` - `Cell::into_inner` - `RefCell::into_inner` - `Atomic*::into_inner` r? `````@dtolnay`````
2020-11-08Rollup merge of #76227 - CDirkx:const-poll, r=KodrAusMara Bos-2/+4
Stabilize `Poll::is_ready` and `is_pending` as const Insta-stabilize the methods `is_ready` and `is_pending` of `std::task::Poll` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198). Possible because of the recent stabilization of const control flow. Part of #76225.
2020-11-08Rollup merge of #76097 - pickfire:stabilize-spin-loop, r=KodrAusMara Bos-22/+56
Stabilize hint::spin_loop Partially fix #55002, deprecate in another release r? ``````@KodrAus``````
2020-11-07Convert a bunch of intra-doc linksCamelid-49/+41
2020-11-07Rollup merge of #78730 - kornelski:not-inverse, r=Dylan-DPCYuki Okushi-2/+6
Expand explanation of reverse_bits Original documentation only rephrased the function name
2020-11-06Stabilize hint::spin_loopIvan Tham-22/+56
Partially fix #55002, deprecate in another release Co-authored-by: Ashley Mannix <kodraus@hey.com> Update stable version for stabilize_spin_loop Co-authored-by: Joshua Nelson <joshua@yottadb.com> Use better example for spinlock As suggested by KodrAus Remove renamed_spin_loop already available in master Fix spin loop example
2020-11-06Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27bors-4/+5
Add non_autolinks lint Part of #77501. r? `@jyn514`
2020-11-05Correct unsigned equivalent of isize to be usizeJacob Pratt-3/+3
2020-11-05Fix even more URLsGuillaume Gomez-1/+1
2020-11-05Rollup merge of #78757 - camelid:crate-link-text, r=jyn514Mara Bos-11/+11
Improve and clean up some intra-doc links
2020-11-05Rollup merge of #78735 - danielhenrymantilla:simplify-unsafecell-getmut, ↵Mara Bos-2/+1
r=RalfJung Simplify the implementation of `get_mut` (no unsafe) Quick PR to reduce one use of `unsafe` pointed out in the previous PR r? ````@RalfJung````
2020-11-05Rollup merge of #78716 - est31:array_traits, r=Dylan-DPCMara Bos-2/+3
Array trait impl comment/doc fixes Two small doc/comment fixes regarding trait implementations on arrays.
2020-11-05Rename lint to non_autolinksGuillaume Gomez-1/+1
2020-11-05Rename automatic_links to url_improvementsGuillaume Gomez-1/+1
2020-11-05Fix automatic_links warningsGuillaume Gomez-3/+4
2020-11-04Don't use `crate` in link textCamelid-11/+11
`crate::` -> `core::` It looks weird to have `crate::` in the link text and we use the actual crate name everywhere else. If anyone is curious, I used this Vim command to update all the links: %s/\(\s\)\[`crate::\(.*\)`\]/\1[`core::\2`](crate::\2)/g
2020-11-04Simplify the implementation of `get_mut` (no unsafe)Daniel Henry-Mantilla-2/+1
2020-11-04Fix outdated comment next to array_impl_defaultest31-2/+3
The comment has become outdated as the array_impl macro has been removed.
2020-11-04Expand explanation of reverse_bitsKornel-2/+6
2020-11-04Add tracking issueBenoît du Garreau-6/+6
2020-11-04Constantify `UnsafeCell::into_inner` and relatedBenoît du Garreau-8/+13
Also includes: - Cell::into_inner - RefCell::into_inner - Atomic*::into_inner
2020-11-03Rollup merge of #78664 - pickfire:patch-4, r=jonas-schievinkYuki Okushi-1/+1
Fix intrinsic size_of stable link I noticed that it is pointing to the same link when I was reading https://github.com/rust-lang/rust-clippy/issues/2997
2020-11-03Expand `NtExpr` tokens only in key-value attributesVadim Petrochenkov-57/+49
2020-11-02Fix intrinsic size_of stable linkIvan Tham-1/+1
I noticed that it is pointing to the same link when I was reading https://github.com/rust-lang/rust-clippy/issues/2997
2020-11-02Rollup merge of #78637 - mystor:atomic_ptr_bool, r=m-ou-seYuki Okushi-0/+125
Add fetch_update methods to AtomicBool and AtomicPtr These methods were stabilized for the integer atomics in #71843, but the methods were not added for the non-integer atomics `AtomicBool` and `AtomicPtr`.
2020-11-02Rollup merge of #78627 - est31:total_cmp_no_superset, r=m-ou-seYuki Okushi-0/+8
Point out that total_cmp is no strict superset of partial comparison Partial comparison and total_cmp are not equal. This helps preventing the mistake of creating float wrappers that base their Ord impl on total_cmp and their PartialOrd impl on the PartialOrd impl of the float type. PartialOrd and Ord [are required to agree with each other](https://doc.rust-lang.org/std/cmp/trait.Ord.html#how-can-i-implement-ord).
2020-11-02Rollup merge of #78620 - gabhijit:bitops_doc_fix, r=m-ou-seYuki Okushi-12/+23
Trivial fixes to bitwise operator documentation Added fixes to documentation of `BitAnd`, `BitOr`, `BitXor` and `BitAndAssign`, where the documentation for implementation on `Vector<bool>` was using logical operators in place of the bitwise operators. r? @steveklabnik Closes #78619
2020-11-02Rollup merge of #78606 - autarch:patch-1, r=m-ou-seYuki Okushi-1/+3
Clarify handling of final line ending in str::lines() I found the description as it stands a bit confusing. I've added a bit more explanation to make it clear that a trailing line ending does not produce a final empty line.
2020-11-01Add fetch_update methods to AtomicBool and AtomicPtrNika Layzell-0/+125
These methods were stabilized for the integer atomics in #71843, but the methods were not added for the non-integer atomics `AtomicBool` and `AtomicPtr`.
2020-11-01Point out that total_cmp is no strict superset of partial comparisonest31-0/+8
Partial comparison and total_cmp are not equal. This helps preventing the mistake of creating float wrappers that base their Ord impl on total_cmp and their PartialOrd impl on the PartialOrd impl of the float type. PartialOrd and Ord are required to agree with each other.
2020-11-01Remove incorrect statement about line ending content in lines doc changeDave Rolsky-2/+2
2020-11-01documentation examples fixes in rustfmt conventionAbhijit Gadgil-11/+19
2020-11-01Rollup merge of #78621 - solson:inline, r=m-ou-seMara Bos-0/+2
Inline Default::default() for atomics Functions like `AtomicUsize::default()` are not cross-crate inlineable before this PR ([see assembly output here](https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=e353321766418f759c69fb141d3732f8)), which can lead to unexpected performance issues when initializing a large array using this function, e.g. as seen [here](https://github.com/spacejam/sled/blob/d513996a85875be8c813fd0e30a548b89682289a/src/histogram.rs#L53) which should turn into a simple loop writing zeroes but doesn't. r? @m-ou-se
2020-11-01Rollup merge of #78602 - RalfJung:raw-ptr-aliasing-issues, r=m-ou-seMara Bos-6/+12
fix various aliasing issues in the standard library This fixes various cases where the standard library either used raw pointers after they were already invalidated by using the original reference again, or created raw pointers for one element of a slice and used it to access neighboring elements.
2020-11-01Rollup merge of #78596 - pavlukivan:master, r=m-ou-seMara Bos-1/+1
Fix doc links to std::fmt `std::format` and `core::write` macros' docs linked to `core::fmt` for format string reference, even though only `std::fmt` has format string documentation (and the link titles were `std::fmt`)
2020-11-01Rollup merge of #78073 - fusion-engineering-forks:inline, r=eddybMara Bos-0/+12
Add #[inline] to some functions in core::str. Almost all str functions already had #[inline].
2020-11-01Inline Default::default() for atomicsScott Olson-0/+2
2020-11-01Fixes incorrect paranthesis.Abhijit Gadgil-1/+1
2020-11-01Trivial fixes to bitwise operator documentationAbhijit Gadgil-4/+7
Added fixes to documentation of `BitAnd`, `BitOr`, `BitXor` and `BitAndAssign`, where the documentation for implementation on `Vector<bool>` was using logical operators in place of the bitwise operators. r? @steveklabnik cc #78619
2020-10-31Clarify handling of final line ending in str::lines()Dave Rolsky-1/+3
I found the description as it stands a bit confusing. I've added a bit more explanation to make it clear that a trailing line ending does not produce a final empty line.
2020-10-31fix aliasing issues in SipHasherRalf Jung-1/+1
2020-10-31fix aliasing issues in u128 formatting codeRalf Jung-5/+11