about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-05-21Wrap Context.ext in AssertUnwindSafeJubilee Young-4/+7
2024-05-21improve comment wordingRalf Jung-14/+14
2024-05-21core: actually use TAIT instead of emulating itjoboet-117/+44
2024-05-21Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgrbors-0/+7
Rollup of 7 pull requests Successful merges: - #124570 (Miscellaneous cleanups) - #124772 (Refactor documentation for Apple targets) - #125011 (Add opt-for-size core lib feature flag) - #125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`) - #125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS) - #125266 (compiler: add simd_ctpop intrinsic) - #125348 (Small fixes to `std::path::absolute` docs) Failed merges: - #125296 (Fix `unexpected_cfgs` lint on std) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-21Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikicMatthias Krüger-0/+7
compiler: add simd_ctpop intrinsic Fairly straightforward addition. cc `@rust-lang/opsem` new (extremely boring) intrinsic
2024-05-20Implement BOXED_SLICE_INTO_ITERMichael Goulet-2/+3
2024-05-20Add the impls for Box<[T]>: IntoIteratorMichael Goulet-0/+3
Co-authored-by: ltdk <usr@ltdk.xyz>
2024-05-20Fix c_char on AIXTaiki Endo-1/+2
Refs: https://github.com/rust-lang/rust/issues/122985
2024-05-20Switch to primarily using `&str`Arpad Borsos-7/+6
Surprisingly, benchmarks have shown that using `&str` instead of `&[u8]` with some `unsafe` code is actually faster.
2024-05-20Introduce printable-ASCII fast-path for `impl Debug for str`Arpad Borsos-17/+42
Instead of having a single loop that works on utf-8 `char`s, this splits the implementation into a loop that quickly skips over printable ASCII, falling back to per-char iteration for other chunks.
2024-05-20Add a fast-path to `Debug` ASCII `&str`Arpad Borsos-0/+5
Instead of going through the `EscapeDebug` machinery, we can just skip over ASCII chars that don’t need any escaping.
2024-05-20Write `char::DebugEscape` sequences using `write_str`Arpad Borsos-7/+4
Instead of writing each `char` of an escape sequence one by one, this delegates to `Display`, which uses `write_str` internally in order to write the whole escape sequence at once.
2024-05-19Auto merge of #123786 - a1phyr:cursor_unsafe, r=joboetbors-6/+18
Remove bound checks from `BorrowedBuf` and `BorrowedCursor` methods
2024-05-18compiler: add simd_ctpop intrinsicJubilee Young-0/+7
2024-05-18Add `#[inline]` to float `Debug` fallback used by `cfg(no_fp_fmt_parse)`beetrees-0/+1
2024-05-17Inline Duration construction into Duration::from_{millis,micros,nanos}Noa-3/+21
2024-05-17Don't call Duration::new unnecessarily in Duration::from_secsNoa-3/+7
2024-05-17Auto merge of #125188 - tgross35:f16-f128-powi, r=Nilstriebbors-1/+52
Add `powi` fo `f16` and `f128` This will unblock adding support to compiler_builtins (<https://github.com/rust-lang/compiler-builtins/pull/614>), which will then unblock adding tests for these new functions.
2024-05-17Rollup merge of #125186 - Colepng:master, r=lqdMatthias Krüger-1/+1
Remove duplicate word from addr docs This PR simply removes a duplicate word from the addr docs for *mut T.
2024-05-17Rollup merge of #125171 - scottmcm:rename-flatten, r=jhprattMatthias Krüger-8/+8
Rename `flatten(_mut)` → `as_flattened(_mut)` As requested by libs-api in https://github.com/rust-lang/rust/issues/95629#issuecomment-2113081194 (This is just the rename, not the stabilization, so can land without waiting on the FCP in that other issue.)
2024-05-16Add `powi` to `f16` and `f128`Trevor Gross-0/+12
This will unblock adding support to compiler_builtins (<https://github.com/rust-lang/compiler-builtins/pull/614>), which will then unblock adding tests for these new functions.
2024-05-16Add doctests for f16 and f128 library functions where possibleTrevor Gross-1/+40
2024-05-16Remove duplicate word from addr docsCole Kauder-McMurrich-1/+1
2024-05-16Auto merge of #124728 - beetrees:from-f16-for-f64, r=BurntSushibors-2/+3
Re-add `From<f16> for f64` This impl was originally added in #122470 before being removed in #123830 due to #123831. However, the issue only affects `f32` (which currently only has one `From<{float}>` impl, `From<f32>`) as `f64` already has two `From<{float}>` impls (`From<f32>` and `From<f64>`) and is also the float literal fallback type anyway. Therefore it is safe to re-add `From<f16> for f64`. This PR also updates the FIXME link to point to the open issue #123831 rather than the closed issue #123824. Tracking issue: #116909 `@rustbot` label +F-f16_and_f128 +T-libs-api
2024-05-16Fix linkchecker doc errorsLukas Bergdoll-9/+9
Also includes small doc fixes.
2024-05-16Turn bare links into automatic linksLukas Bergdoll-4/+4
2024-05-16Fix tidy errorsLukas Bergdoll-20/+13
2024-05-16Replace sort implementationsLukas Bergdoll-1543/+2502
- `slice::sort` -> driftsort https://github.com/Voultapher/sort-research-rs/blob/main/writeup/driftsort_introduction/text.md - `slice::sort_unstable` -> ipnsort https://github.com/Voultapher/sort-research-rs/blob/main/writeup/ipnsort_introduction/text.md Replaces the sort implementations with tailor made ones that strike a balance of run-time, compile-time and binary-size, yielding run-time and compile-time improvements. Regressing binary-size for `slice::sort` while improving it for `slice::sort_unstable`. All while upholding the existing soft and hard safety guarantees, and even extending the soft guarantees, detecting strict weak ordering violations with a high chance and reporting it to users via a panic. In addition the implementation of `select_nth_unstable` is also adapted as it uses `slice::sort_unstable` internals.
2024-05-16Auto merge of #124959 - prorealize:update-result-documentation, r=joboetbors-4/+8
Refactor examples and enhance documentation in result.rs - Replaced `map` with `map_err` in the error handling example for correctness - Reordered example code to improve readability and logical flow - Added assertions to examples to demonstrate expected outcomes
2024-05-15Rename `flatten(_mut)` → `as_flattened(_mut)`Scott McMurray-8/+8
2024-05-15Rollup merge of #125038 - ivan-shrimp:checked_sub, r=joboetLeón Orell Valerian Liehr-3/+3
Invert comparison in `uN::checked_sub` After #124114, LLVM no longer combines the comparison and subtraction in `uN::checked_sub` when either operand is a constant (demo: https://rust.godbolt.org/z/MaeoYbsP1). The difference is more pronounced when the expression is slightly more complex (https://rust.godbolt.org/z/4rPavsYdc). This is due to the use of `>=` here: https://github.com/rust-lang/rust/blob/ee97564e3a9f9ac8c65103abb37c6aa48d95bfa2/library/core/src/num/uint_macros.rs#L581-L593 For constant `C`, LLVM eagerly converts `a >= C` into `a > C - 1`, but the backend can only combine `a < C` with `a - C`, not `C - 1 < a` and `a - C`: https://github.com/llvm/llvm-project/blob/e586556e375fc5c4f7e76b5c299cb981f2016108/llvm/lib/CodeGen/CodeGenPrepare.cpp#L1697-L1742 This PR[^1] simply inverts the `>=` into `<` to restore the LLVM magic, and somewhat align this with the implementation of `uN::overflowing_sub` from #103299. When the result is stored as an `Option` (rather than being branched/cmoved on), the discriminant is `self >= rhs`. This PR doesn't affect the codegen (and relevant tests) of that since LLVM will negate `self < rhs` to `self >= rhs` when necessary. [^1]: Note to `self`: My very first contribution to publicly-used code. Hopefully like what I should learn to always be, tiny and humble.
2024-05-15Rollup merge of #124307 - reitermarkus:escape-debug-size-hint-inline, r=joboetLeón Orell Valerian Liehr-79/+126
Optimize character escaping. Allow optimization of panicking branch in `EscapeDebug`, see https://github.com/rust-lang/rust/pull/121805. r? `@joboet`
2024-05-15Update library/core/src/result.rsRenato A-1/+1
Co-authored-by: joboet <jonasboettiger@icloud.com>
2024-05-15Divide float nanoseconds instead of secondsArtyom Pavlov-2/+6
2024-05-13Rollup merge of #116675 - joshlf:patch-10, r=scottmcmJacob Pratt-5/+33
[ptr] Document maximum allocation size Partially addresses https://github.com/rust-lang/unsafe-code-guidelines/issues/465
2024-05-13[ptr] Document maximum allocation sizeJoshua Liebow-Feeser-5/+33
2024-05-13Don't use `T` with both Result and Option, improve explanation.Lokathor-67/+70
2024-05-13Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the preludeJosh Triplett-7/+5
Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it. Add `size_of_val`, `align_of`, and `align_of_val` as well, with similar justification: widely useful, self-explanatory, unmistakeable for anything else, won't produce conflicts.
2024-05-13offset, offset_from: allow zero-byte offset on arbitrary pointersRalf Jung-32/+33
2024-05-12reference type safety invariant docs: clarificationRalf Jung-5/+8
2024-05-12reverse condition in `uN::checked_sub`ivan-shrimp-3/+3
2024-05-11References must also be non-nullJoshua Liebow-Feeser-0/+1
2024-05-11Relax slice safety requirementsJoshua Liebow-Feeser-1/+1
Per https://github.com/rust-lang/rust/pull/116677#issuecomment-1945495786, the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when #117945 is implemented, we can revert to the old language.
2024-05-11Rollup merge of #124954 - kpreid:fmterr, r=NilstriebMatthias Krüger-15/+35
Document proper usage of `fmt::Error` and `fmt()`'s `Result`. I've seen several newcomers wonder why `fmt::Error` doesn't have any error detail information, or propose to return it in response to an error condition found inside a `impl fmt::Display for MyType`. That is incorrect, per [a lone paragraph of the `fmt` module's documentation](https://doc.rust-lang.org/1.78.0/std/fmt/index.html#formatting-traits). However, users looking to implement a formatting trait won't necessarily look there. Therefore, let's add the critical information (that formatting per se is infallible) to all the involved items: every `fmt()` method, and `fmt::Error`. This PR is not intended to make any novel claims about `fmt`; only to repeat an existing one in places where it will be more visible.
2024-05-11Rollup merge of #124928 - okaneco:trim_ascii, r=workingjubileeMatthias Krüger-21/+15
Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str` Remove feature from documentation examples Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions Closes #94035 FCP has successfully completed https://github.com/rust-lang/rust/issues/94035#issuecomment-2102690397
2024-05-10Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`okaneco-21/+15
Remove feature from documentation examples Add rustc_const_stable attribute to stabilized functions Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions
2024-05-10Fix typo in ManuallyDrop's documentationInfinixius-1/+1
2024-05-10Auto merge of #124863 - DaniPopes:from-str-radix-panic, r=Amanieubors-6/+6
from_str_radix: outline only the panic function In the `{integer}::from_str_radix` function, the radix check is labeled as `cold` and `inline(never)`, along with its corresponding panic. It probably was intended to apply these attributes only to the panic function.
2024-05-10Fix assertRenato Alves-1/+1
2024-05-10Refactor examples and enhance documentation in result.rsRenato Alves-4/+8