about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-02-21make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all ↵Ralf Jung-12/+4
fast-math flags
2024-02-21intrinsics::simd: add missing functionsRalf Jung-0/+103
2024-02-21Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPCbors-0/+12
Rollup of 7 pull requests Successful merges: - #121208 (Convert `delayed_bug`s to `bug`s.) - #121288 (make rustc_expand translatable) - #121304 (Add docs for extension proc-macro) - #121328 (Make --verbose imply -Z write-long-types-to-disk=no) - #121338 (Downgrade ambiguous_wide_pointer_comparisons suggestions to MaybeIncorrect) - #121361 (diagnostic items for legacy numeric modules) - #121375 (Print proper relative path for descriptive name check) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-21Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercotebors-0/+40
Add "algebraic" fast-math intrinsics, based on fast-math ops that cannot return poison Setting all of LLVM's fast-math flags makes our fast-math intrinsics very dangerous, because some inputs are UB. This set of flags permits common algebraic transformations, but according to the [LangRef](https://llvm.org/docs/LangRef.html#fastmath), only the flags `nnan` (no nans) and `ninf` (no infs) can produce poison. And this uses the algebraic float ops to fix https://github.com/rust-lang/rust/issues/120720 cc `@orlp`
2024-02-21Rollup merge of #121361 - pitaj:diag_items-legacy_numeric_constants, r=NilstriebDylan DPC-0/+12
diagnostic items for legacy numeric modules For https://github.com/rust-lang/rust-clippy/pull/12312 Missed these in #121272 r? `@Nilstrieb`
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-15/+8
2024-02-20diagnostic items for legacy numeric modulesPeter Jaszkowiak-0/+12
2024-02-20Add extra detail to field commentGnome!-1/+2
Co-authored-by: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com>
2024-02-20Reduce alignment of TypeId to u64 alignmentGnomedDev-3/+7
2024-02-20Rollup merge of #121352 - malobre:patch-1, r=NilstriebMatthias Krüger-2/+2
docs: add missing "the" to `str::strip_prefix` doc Fix #121348
2024-02-20Rollup merge of #121277 - reitermarkus:generic-nonzero-convert-num, r=dtolnayMatthias Krüger-367/+325
Refactor trait implementations in `core::convert::num`. Tracking issue: https://github.com/rust-lang/rust/issues/120257 Implement conversion traits using generic `NonZero` type, and refactor all macros to use a consistent format/order of parameters. r? `@dtolnay`
2024-02-20Rollup merge of #119203 - farnoy:simd-masked-intrinsic-docfix, r=RalfJungMatthias Krüger-4/+6
Correct the simd_masked_{load,store} intrinsic docs Explains the uniform pointer being used for these two operations and how elements are offset from it.
2024-02-20Add "algebraic" versions of the fast-math intrinsicsBen Kimock-0/+40
2024-02-20docs: add missing "the" to `str::strip_prefix` docMalobre-2/+2
2024-02-20Auto merge of #121345 - Nilstrieb:rollup-reb0xge, r=Nilstriebbors-180/+219
Rollup of 8 pull requests Successful merges: - #121167 (resolve: Scale back unloading of speculatively loaded crates) - #121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions)) - #121241 (Implement `NonZero` traits generically.) - #121278 (Remove the "codegen" profile from bootstrap) - #121286 (Rename `ConstPropLint` to `KnownPanicsLint`) - #121291 (target: Revert default to the medium code model on LoongArch targets) - #121302 (Remove `RefMutL` hack in `proc_macro::bridge`) - #121318 (Trigger `unsafe_code` lint on invocations of `global_asm`) Failed merges: - #121206 (Top level error handling) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-20Correct the simd_masked_{load,store} intrinsic docsJakub Okoński-4/+6
2024-02-20Add examples for some methods on slicesTakashiidobe-1/+10
2024-02-20Rollup merge of #121241 - reitermarkus:generic-nonzero-traits, r=dtolnayNilstrieb-179/+211
Implement `NonZero` traits generically. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? ````@dtolnay````
2024-02-20Rollup merge of #121196 - Nilstrieb:the-clever-solution, r=saethlinNilstrieb-1/+8
Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions) The current complexities in `assert_unsafe_precondition` are delicately balancing several concerns, among them compile times for the cases where there are no debug assertions. This comes at a large runtime cost when the assertions are enabled, making the debug assertion compiler a lot slower, which is very annoying. To avoid this, we always inline the check when building with debug assertions. Numbers (compiling stage1 library after touching core): - master: 80s - just adding `#[inline(always)]` to the `cfg(bootstrap)` `debug_assertions` (equivalent to a bootstrap bump (uhh, i just realized that i was on a slightly outdated master so this bump might have happened already), (#121112)): 67s - this: 54s So this seems like a good solution. I think we can still get the same run-time perf improvements for other users too by massaging this code further (see my other PR about adding `#[rustc_no_mir_inline]` #121114) but this is a simpler step that solves the imminent problem of "holy shit my rustc is sooo slow". Funny consequence: This now means compiling the standard library with dbeug assertions makes it faster (than without, when using debug assertions downstream)! r? ```@saethlin``` (or anyone else if someone wants to review this) fixes #121110, supposedly
2024-02-20Auto merge of #120863 - saethlin:slice-get-checked, r=the8472bors-26/+42
Use intrinsics::debug_assertions in debug_assert_nounwind This is the first item in https://github.com/rust-lang/rust/issues/120848. Based on the benchmarking in this PR, it looks like, for the programs in our benchmark suite, enabling all these additional checks does not introduce significant compile-time overhead, with the single exception of `Alignment::new_unchecked`. Therefore, I've added `#[cfg(debug_assertions)]` to that one call site, so that it remains compiled out in the distributed standard library. The trailing commas in the previous calls to `debug_assert_nounwind!` were causing the macro to expand to `panic_nouwnind_fmt`, which requires more work to set up its arguments, and that overhead alone is measured between this perf run and the next: https://github.com/rust-lang/rust/pull/120863#issuecomment-1937423502
2024-02-20fix doc linkYuri Astrakhan-1/+1
2024-02-20A much simpler version of writeYuri Astrakhan-28/+10
2024-02-20remove constYuri Astrakhan-1/+1
2024-02-20add safety textYuri Astrakhan-0/+1
2024-02-20Fix inlining issue for non-const caseYuri Astrakhan-12/+20
2024-02-20Use intrinsicYuri Astrakhan-0/+13
2024-02-20perf: improve write_fmt to handle simple stringsYuri Astrakhan-4/+6
Per @dtolnay suggestion in https://github.com/serde-rs/serde/pull/2697#issuecomment-1940376414 - attempt to speed up performance in the cases of a simple string format without arguments: ```rust write!(f, "text") -> f.write_str("text") ```
2024-02-19Add more inline(always) to fix opt-level=z test on wasm32Ben Kimock-2/+2
2024-02-19Convert debug_assert_nounwind to intrinsics::debug_assertionsBen Kimock-24/+40
2024-02-19Make `is_nonoverlapping` `#[inline]`Nilstrieb-0/+1
It showed up with 3% execution time in a compiler profile.
2024-02-19Make intrinsic fallback bodies cross-crate inlineableNilstrieb-0/+6
This change was prompted by the stage1 compiler spending 4% of its time when compiling the polymorphic-recursion MIR opt test in `unlikely`. Intrinsic fallback bodies like `unlikely` should always be inlined, it's very silly if they are not. To do this, we enable the fallback bodies to be cross-crate inlineable. Not that this matters for our workloads since the compiler never actually _uses_ the "fallback bodies", it just uses whatever was cfg(bootstrap)ped, so I've also added `#[inline]` to those.
2024-02-19Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions)Nilstrieb-1/+8
The current complexities in `assert_unsafe_precondition` are delicately balancing several concerns, among them compile times for the cases where there are no debug assertions. This comes at a large runtime cost when the assertions are enabled, making the debug assertion compiler a lot slower, which is very annoying. To avoid this, we always inline the check when building with debug assertions. Numbers (compiling stage1 library after touching core): - master: 80s - just adding `#[inline(always)]` to the `cfg(bootstrap)` `debug_assertions`: 67s - this: 54s So this seems like a good solution. I think we can still get the same run-time perf improvements for other users too by massaging this code further (see my other PR about adding `#[rustc_no_mir_inline]`) but this is a simpler step that solves the imminent problem of "holy shit my rustc is sooo slow". Funny consequence: This now means compiling the standard library with dbeug assertions makes it faster (than without, when using debug assertions downstream)!
2024-02-19Rollup merge of #121272 - pitaj:diag_items-legacy_numeric_constants, r=NilstriebMatthias Krüger-0/+32
Add diagnostic items for legacy numeric constants For rust-lang/rust-clippy#12312
2024-02-19Rollup merge of #121041 - Nilstrieb:into-the-future-of-2024, r=Mark-SimulacrumMatthias Krüger-2/+6
Add `Future` and `IntoFuture` to the 2024 prelude Implements rust-lang/rfcs#3509.
2024-02-19Rollup merge of #119808 - GnomedDev:encode-charsearcher-size-in-type, ↵Matthias Krüger-11/+23
r=Mark-Simulacrum Store core::str::CharSearcher::utf8_size as u8 This is already relied on being smaller than u8 due to the `safety invariant: utf8_size must be less than 5`, so this helps LLVM optimize and maybe improve copies due to padding instead of unused bytes.
2024-02-19Refactor trait implementations in `core::convert::num`.Markus Reiter-367/+325
2024-02-18Add `Future` and `IntoFuture` to the 2024 preludeNilstrieb-2/+6
Implements RFC 3509.
2024-02-18diagnostic items for legacy numeric constantsPeter Jaszkowiak-0/+32
2024-02-17Implement `NonZero` traits generically.Markus Reiter-179/+211
2024-02-17Auto merge of #121204 - cuviper:flatten-one-shot, r=the8472bors-12/+275
Specialize flattening iterators with only one inner item For iterators like `Once` and `option::IntoIter` that only ever have a single item at most, the front and back iterator states in `FlatMap` and `Flatten` are a waste, as they're always consumed already. We can use specialization for these types to simplify the iterator methods. It's a somewhat common pattern to use `flatten()` for options and results, even recommended by [multiple][1] [clippy][2] [lints][3]. The implementation is more efficient with `filter_map`, as mentioned in [clippy#9377], but this new specialization should close some of that gap for existing code that flattens. [1]: https://rust-lang.github.io/rust-clippy/master/#filter_map_identity [2]: https://rust-lang.github.io/rust-clippy/master/#option_filter_map [3]: https://rust-lang.github.io/rust-clippy/master/#result_filter_map [clippy#9377]: https://github.com/rust-lang/rust-clippy/issues/9377
2024-02-17Allow newly added non_local_definitions in stdUrgau-0/+5
2024-02-17Rollup merge of #121192 - oli-obk:intrinsics2.0, r=WaffleLapkinGuillaume Boisseau-43/+59
Give some intrinsics fallback bodies cc #93145
2024-02-17Rollup merge of #121187 - Takashiidobe:takashi/examples-for-quickselect, ↵Guillaume Boisseau-6/+21
r=Nilstrieb Add examples to document the return type of quickselect functions Currently, `select_nth_unstable`, `select_nth_unstable_by`, and `select_nth_unstable_by_key`'s examples do not show how to use the return values of the functions in an example, so this PR adds that in. Note: I didn't know what to call the parameters, so I settled on lesser, median, greater because the example is used for median finding so I retained that naming for the pivot, but lesser and greater are poor names for the example that sorts in descending order, because lesser and greater are then flipped. I think it's common to say "lo" and "hi" for low and high respectively, but that's also not great when the comparator flips the elements. Otherwise, "left" and "right" are also commonly used but I think that's poor naming because some languages read right to left so those names are also unintuitive. Lesser and greater are also not that great but I found a test that used `less`, `equal`, `greater` so I took that: https://github.com/rust-lang/rust/blob/dfa88b328f969871d12dba3b2c0257ab3ea6703a/library/core/tests/slice.rs#L1962
2024-02-17Auto merge of #120563 - reitermarkus:generic-nonzero-get, r=dtolnaybors-20/+21
Make `NonZero::get` generic. Tracking issue: https://github.com/rust-lang/rust/issues/120257 Depends on https://github.com/rust-lang/rust/pull/120521. r? `@dtolnay`
2024-02-17Auto merge of #120741 - a1phyr:safe_buffer_advance, r=m-ou-sebors-13/+25
Make `io::BorrowedCursor::advance` safe This also keeps the old `advance` method under `advance_unchecked` name. This makes pattern like `std::io::default_read_buf` safe to write.
2024-02-16Clarify the flatten specialization commentJosh Stone-2/+2
2024-02-16Give the (`un`)`likely` intrinsics fallback bodiesOli Scherer-31/+37
2024-02-16Give the `assume` intrinsic a fallback bodyOli Scherer-13/+23
2024-02-16Specialize flattening iterators with only one inner itemJosh Stone-12/+275
For iterators like `Once` and `option::IntoIter` that only ever have a single item at most, the front and back iterator states in `FlatMap` and `Flatten` are a waste, as they're always consumed already. We can use specialization for these types to simplify the iterator methods. It's a somewhat common pattern to use `flatten()` for options and results, even recommended by [multiple][1] [clippy][2] [lints][3]. The implementation is more efficient with `filter_map`, as mentioned in [clippy#9377], but this new specialization should close some of that gap for existing code that flattens. [1]: https://rust-lang.github.io/rust-clippy/master/#filter_map_identity [2]: https://rust-lang.github.io/rust-clippy/master/#option_filter_map [3]: https://rust-lang.github.io/rust-clippy/master/#result_filter_map [clippy#9377]: https://github.com/rust-lang/rust-clippy/issues/9377
2024-02-16Add examples to document the return type of `select_nth_unstable`, ↵Takashiidobe-6/+21
`select_nth_unstable_by`, and `select_nth_unstable_by_key`.