about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-01-14Move Neg impl into the macro that generates Div and RemDavid Tolnay-20/+20
2024-01-14Split out `option::unwrap_failed` like we have `result::unwrap_failed`Scott McMurray-2/+10
...and like `option::expect_failed`
2024-01-14Move leading_zeros and trailing_zeros methods into nonzero_integer macroDavid Tolnay-71/+75
2024-01-14Unindent nonzero_integer_impl_div_rem macro bodyDavid Tolnay-21/+21
2024-01-14Move impl Div and Rem into nonzero_integer macroDavid Tolnay-14/+9
2024-01-14Move 'impl FromStr for NonZero' into nonzero_integer macroDavid Tolnay-9/+2
2024-01-14Format nonzero_integer macro calls same way we do the primitive int implsDavid Tolnay-20/+59
The `key = $value` style will be beneficial as we introduce some more macro arguments here in later commits.
2024-01-14Unindent nonzero_integer macro bodyDavid Tolnay-139/+139
2024-01-14Define only a single NonZero type per macro callDavid Tolnay-6/+39
Later in this stack, as the nonzero_integers macro is going to be responsible for producing a larger fraction of the API for the NonZero integer types, it will need to receive a number of additional arguments beyond the ones currently seen here. Additional arguments, especially named arguments across multiple lines, will turn out clearer if everything in one macro call is for the same NonZero type. This commit adopts a similar arrangement to what we do for generating the API of the integer primitives (`impl u8` etc), which also generate a single type's API per top-level macro call, rather than generating all 12 impl blocks for the 12 types from one macro call.
2024-01-14Move nonzero_integers macro call to bottom of moduleDavid Tolnay-15/+15
This way all the other macros defined in this module, such as nonzero_leading_trailing_zeros, are available to call within the expansion of nonzero_integers. (Macros defined by macro_rules cannot be called from the same module above the location of the macro_rules.) In this commit the ability to call things like nonzero_leading_trailing_zeros is not immediately used, but later commits in this stack will be consolidating the entire API of NonZeroT to be generated through nonzero_integers, and will need to make use of some of the other macros to do that.
2024-01-14Add note on SpecOptionPartialEq to `newtype_index`clubby789-0/+1
2024-01-13libs: use `assert_unchecked` instead of intrinsicjoboet-9/+12
2024-01-13Rollup merge of #119902 - asquared31415:patch-1, r=the8472Matthias Krüger-3/+3
fix typo in `fn()` docs
2024-01-12update fn pointer trait impl docsasquared31415-8/+2
2024-01-12fix typo in `fn()` docsasquared31415-3/+3
2024-01-12Auto merge of #119452 - ↵bors-4/+18
AngelicosPhosphoros:make_nonzeroint_get_assume_nonzero, r=scottmcm Add assume into `NonZeroIntX::get` LLVM currently don't support range metadata for function arguments so it fails to optimize non zero integers using their invariant if they are provided using by-value function arguments. Related to https://github.com/rust-lang/rust/issues/119422 Related to https://github.com/llvm/llvm-project/issues/76628 Related to https://github.com/rust-lang/rust/issues/49572
2024-01-12Tune the inlinability of `Result::unwrap`Scott McMurray-1/+1
2024-01-11Waker::will_wake: Compare vtable address instead of its contentTomasz Miąsko-1/+3
Optimize will_wake implementation by comparing vtable address instead of its content. The existing best practice to avoid false negatives from will_wake is to define a waker vtable as a static item. That approach continues to works with the new implementation. While this potentially changes the observable behaviour, the function is documented to work on a best-effort basis. The PartialEq impl for RawWaker remains as it was.
2024-01-11rint: further doc tweaksRalf Jung-4/+6
2024-01-11Make is_global/is_unicast_global special address handling completeJakub Stasiak-2/+10
IANA explicitly documents 192.0.0.9/32, 192.0.0.9/32 and 2001:30::/28 as globally reachable[1][2] and the is_global implementations declare following IANA so let's make this happen. In case of 2002::/16 IANA says N/A so I think it's safe to say we shouldn't return true there either. [1] https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml [2] https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
2024-01-10Implement in-place iteratation markers for iter::{Copied, Cloned}The8472-4/+45
2024-01-10implement TrustedRandomAccess and TrustedLen for SkipThe8472-1/+51
2024-01-10implement TrustedLen for StepByThe8472-7/+9
2024-01-10Add `#[track_caller]` to the "From implies Into" implEmil Gardström-0/+1
2024-01-10Stabilize `slice_first_last_chunk`Trevor Gross-34/+20
This stabilizes all methods under `slice_first_last_chunk`. Additionally, it const stabilizes the non-mut functions and moves the `_mut` functions under `const_slice_first_last_chunk`. These are blocked on `const_mut_refs`. As part of this change, `slice_split_at_unchecked` was marked const-stable for internal use (but not fully stable).
2024-01-10Rollup merge of #119782 - RalfJung:rint, r=cuviperMatthias Krüger-0/+4
rint intrinsics: caution against actually trying to check for floating-point exceptions
2024-01-09rint intrinsics: caution against actually trying to check for floating-point ↵Ralf Jung-0/+4
exceptions
2024-01-09Auto merge of #116846 - krtab:slice_compare_no_memcmp_opt, r=the8472bors-1/+11
A more efficient slice comparison implementation for T: !BytewiseEq (This is a follow up PR on #113654) This PR changes the implementation for `[T]` slice comparison when `T: !BytewiseEq`. The previous implementation using zip was not optimized properly by the compiler, which didn't leverage the fact that both length were equal. Performance improvements are for example 20% when testing that `[Some(0_u64); 4096].as_slice() == [Some(0_u64); 4096].as_slice()`.
2024-01-09core: panic: fix broken linkMiguel Ojeda-1/+1
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-01-09Rollup merge of #118979 - ChrisDenton:unwrap-const, r=Nilstrieb,dtolnayMatthias Krüger-1/+8
Use `assert_unsafe_precondition` for `char::from_u32_unchecked` Use `assert_unsafe_precondition` in `char::from_u32_unchecked` so that it can be stabilized as `const`.
2024-01-09Rollup merge of #119598 - Laura7089:fix/deref-typo, r=NilstriebMatthias Krüger-1/+1
Fix a typo in core::ops::Deref's doc
2024-01-08A more efficient slice comparison implementation for T: !BytewiseEqArthur Carcano-1/+11
The previous implementation was not optimized properly by the compiler, which didn't leverage the fact that both length were equal.
2024-01-08Rollup merge of #116129 - fu5ha:better-pin-docs-2, r=AmanieuMatthias Krüger-370/+1099
Rewrite `pin` module documentation to clarify usage and invariants The documentation of `pin` today does not give a complete treatment of pinning from first principles, nor does it adequately help build intuition and understanding for how the different elements of the pinning story fit together. This rewrite attempts to address these in a way that makes the concept more approachable while also making the documentation more normative. This PR picks up where `@mcy` left off in #88500 (thanks to him for the original work and `@Manishearth` for mentioning it such that I originally found it). I've directly incorporated much of the feedback left on the original PR and have rewritten and changed some of the main conceits of the prose to better adhere to the feedback from the reviewers on that PR or just explain something in (hopefully) a better way.
2024-01-07linkManish Goregaokar-1/+1
2024-01-07Update library/core/src/pin.rsManish Goregaokar-1/+1
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-01-07clean up structural pinningManish Goregaokar-8/+10
2024-01-07footnote on dropping futuresManish Goregaokar-2/+5
2024-01-07validManish Goregaokar-1/+1
2024-01-07punctuation in parensManish Goregaokar-2/+2
2024-01-07Apply suggestions from code reviewManish Goregaokar-4/+4
Co-authored-by: Ralf Jung <post@ralfj.de> Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
2024-01-07Clean up guarantees wordingManish Goregaokar-15/+7
We don't need to go into that much depth at this stage
2024-01-07lifetime -> lifespan where relevant. improve docs on as_ref()Manish Goregaokar-6/+6
2024-01-07Rephrase unpin docs in terms of pinning-agnosticnessManish Goregaokar-4/+6
2024-01-07trim section on managed-box modelGray Olson-9/+4
2024-01-07improve `Pin::new_unchecked` docsGray Olson-10/+16
2024-01-07fix broken linkGray Olson-1/+1
2024-01-07justify motivation of `Unpin` betterGray Olson-14/+30
2024-01-07improve `Pin` and `Pin::new` docsGray Olson-23/+67
2024-01-07`Pin<P>` -> `Pin<Ptr>`Gray Olson-75/+81
2024-01-07fix typos and edit proseGray Olson-76/+85