about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-03-25alloc::Layout: explicitly document size invariant on the type levelRalf Jung-1/+3
2024-03-25Rollup merge of #122990 - SkiFire13:transmute-may-copy, r=jhprattMatthias Krüger-1/+1
Clarify transmute example The example claims using an iterator will copy the entire vector, but this is not true in practice thanks to internal specializations in the stdlib (see https://godbolt.org/z/cnxo3MYs5 for confirmation that this doesn't reallocate nor iterate over the vec's elements). Since neither the copy nor the optimization is guaranteed I opted for saying that they _may_ happen.
2024-03-24Address PR feedbackScott McMurray-12/+23
2024-03-24Slightly simplify the `iN::partial_cmp` MIRScott McMurray-7/+14
This saves some debug and scope metadata in every single function that calls it. Normally wouldn't be worth it, but with the derives there's *so* many of these.
2024-03-24Rollup merge of #122977 - cuviper:as_statically_known_str, r=RalfJungMatthias Krüger-5/+9
Rename `Arguments::as_const_str` to `as_statically_known_str` While `const` has a particular meaning about language guarantees, here we need a fuzzier notion like whether constant propagation was effective, and `statically_known` is the best term we have for now. r? ``@RalfJung``
2024-03-24Clarify transmute exampleGiacomo Stevanato-1/+1
2024-03-23Add+Use `mir::BinOp::Cmp`Scott McMurray-0/+40
2024-03-23Rollup merge of #122762 - RoboSchmied:RoboSchmied-typo, r=workingjubileeJubilee-1/+1
fix typo of endianness fix typo endianess -> endianness
2024-03-23Rename `Arguments::as_const_str` to `as_statically_known_str`Josh Stone-5/+9
While `const` has a particular meaning about language guarantees, here we need a fuzzier notion like whether constant propagation was effective, and `statically_known` is the best term we have for now.
2024-03-24clarify equivalency of binary_search and partition_pointAndy Kurnia-1/+3
2024-03-24Rollup merge of #122963 - RalfJung:core-panicking, r=m-ou-seMatthias Krüger-2/+2
core/panicking: fix outdated comment Looks like this function got renamed/changed at some point and the comment did not get updated. r? `@m-ou-se`
2024-03-24Rollup merge of #122379 - RalfJung:int2ptr-transmute, r=m-ou-seMatthias Krüger-8/+33
transmute: caution against int2ptr transmutation This came up in https://github.com/rust-lang/rust/pull/121282. Cc ```@saethlin``` ```@scottmcm``` Eventually we'll add a proper description of provenance that we can reference, but that's a bunch of work and it's unclear who will have the time to do that when. Meanwhile, let's at least do what we can without mentioning provenance explicitly.
2024-03-23also rename the SIMD intrinsicRalf Jung-0/+7
2024-03-23Auto merge of #122629 - RalfJung:assert-unsafe-precondition, r=saethlinbors-205/+224
refactor check_{lang,library}_ub: use a single intrinsic This enacts the plan I laid out [here](https://github.com/rust-lang/rust/pull/122282#issuecomment-1996917998): use a single intrinsic, called `ub_checks` (in aniticpation of https://github.com/rust-lang/compiler-team/issues/725), that just exposes the value of `debug_assertions` (consistently implemented in both codegen and the interpreter). Put the language vs library UB logic into the library. This makes it easier to do something like https://github.com/rust-lang/rust/pull/122282 in the future: that just slightly alters the semantics of `ub_checks` (making it more approximating when crates built with different flags are mixed), but it no longer affects whether these checks can happen in Miri or compile-time. The first commit just moves things around; I don't think these macros and functions belong into `intrinsics.rs` as they are not intrinsics. r? `@saethlin`
2024-03-23core/panicking: fix outdated commentRalf Jung-2/+2
2024-03-23try adding a test that LowerHex and friends don't panic, but it doesn't workiximeow-0/+14
2024-03-23refactor check_{lang,library}_ub: use a single intrinsic, put policy into ↵Ralf Jung-34/+46
library
2024-03-23move assert_unsafe_preconditions to its own fileRalf Jung-175/+182
These macros and functions are not intrinsics, after all.
2024-03-23Auto merge of #122947 - matthiaskrgr:rollup-10j7orh, r=matthiaskrgrbors-16/+12
Rollup of 11 pull requests Successful merges: - #120577 (Stabilize slice_split_at_unchecked) - #122698 (Cancel `cargo update` job if there's no updates) - #122780 (Rename `hir::Local` into `hir::LetStmt`) - #122915 (Delay a bug if no RPITITs were found) - #122916 (docs(sync): normalize dot in fn summaries) - #122921 (Enable more mir-opt tests in debug builds) - #122922 (-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.) - #122927 (Change an ICE regression test to use the original reproducer) - #122930 (add panic location to 'panicked while processing panic') - #122931 (Fix some typos in the pin.rs) - #122933 (tag_for_variant follow-ups) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-23Rollup merge of #122931 - herobs:patch-1, r=joboetMatthias Krüger-7/+7
Fix some typos in the pin.rs
2024-03-23Rollup merge of #122930 - RalfJung:panic-in-panic-fmt, r=AmanieuMatthias Krüger-2/+3
add panic location to 'panicked while processing panic' Fixes https://github.com/rust-lang/rust/issues/97181 r? `@Amanieu`
2024-03-23Rollup merge of #120577 - wutchzone:slice_split_at_unchecked, r=m-ou-seMatthias Krüger-7/+2
Stabilize slice_split_at_unchecked Greetings! I took the opportunity, and I tried to stabilize the `slice_split_at_unchecked` feature. I followed the guidelines, and I hope everything was done correctly :crossed_fingers: . Closes #76014
2024-03-23Auto merge of #122582 - scottmcm:swap-intrinsic-v2, r=oli-obkbors-60/+44
Let codegen decide when to `mem::swap` with immediates Making `libcore` decide this is silly; the backend has so much better information about when it's a good idea. Thus this PR introduces a new `typed_swap` intrinsic with a fallback body, and replaces that fallback implementation when swapping immediates or scalar pairs. r? oli-obk Replaces #111744, and means we'll never need more libs PRs like #111803 or #107140
2024-03-23improve example on inserting to a sorted vector to avoid shifting equal elementsAndy Kurnia-2/+2
2024-03-23rename ptr::from_exposed_addr -> ptr::with_exposed_provenanceRalf Jung-26/+26
2024-03-23Fix some typos in the pin.rsHerobs-7/+7
2024-03-23add panic location to 'panicked while processing panic'Ralf Jung-2/+3
2024-03-22Remove RustcEncodable/Decodable from 2024 preludeJacob Pratt-17/+31
2024-03-22Soft-destabilize `RustcEncodable`/`RustcDecodable`Jacob Pratt-7/+20
2024-03-22Update stdarch submoduleDaniel Paoliello-0/+1
2024-03-22`swap_simple` no longer needs to be a separate functionScott McMurray-35/+18
2024-03-22Codegen const panic messages as function callsMark Rousskov-3/+66
This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary.
2024-03-22Rollup merge of #122800 - zachs18:nonnull-slice-is_empty, r=AmanieuMatthias Krüger-0/+19
Add `NonNull::<[T]>::is_empty`. As per https://github.com/rust-lang/rust/issues/71146#issuecomment-2008373983 I figured this should be fine to be insta-stable (with an FCP), but I can edit if that is not desired. r? ```@Amanieu```
2024-03-22Auto merge of #122024 - clubby789:remove-spec-option-pe, r=jhprattbors-62/+30
Remove SpecOptionPartialEq With the recent LLVM bump, the specialization for Option::partial_eq on types with niches is no longer necessary. I kept the manual implementation as it still gives us better codegen than the derive (will look at this seperately). Also implemented PartialOrd/Ord by hand as it _somewhat_ improves codegen for #49892: https://godbolt.org/z/vx5Y6oW4Y
2024-03-22Rollup merge of #122829 - ShoyuVanilla:gen-block-impl-fused-iter, ↵Matthias Krüger-0/+1
r=compiler-errors Implement `FusedIterator` for `gen` block cc #117078
2024-03-21Not insta-stableZachary S-5/+3
2024-03-22Implement `FusedIterator` for `gen` blockShoyu Vanilla-0/+1
2024-03-21Implement macro-based deref!() syntax for deref patternsMichael Goulet-0/+20
Stop using `box PAT` syntax for deref patterns, as it's misleading and also causes their semantics being tangled up.
2024-03-21Stabilize `const_caller_location` and `const_location_fields`lilasta-8/+5
2024-03-21Rollup merge of #122806 - compiler-errors:type-ascribe, r=fmeaseMatthias Krüger-2/+2
Make `type_ascribe!` not a built-in The only weird thing is the macro expansion note. I wonder if we should suppress these :thinking: r? ````@fmease```` since you told me about builtin# lol
2024-03-20Make type_ascribe! not a built-inMichael Goulet-2/+2
2024-03-20Rollup merge of #122729 - m-ou-se:relax, r=AmanieuJacob Pratt-6/+3
Relax SeqCst ordering in standard library. Every single SeqCst in the standard library is unnecessary. In all cases, Relaxed or Release+Acquire was sufficient. As I [wrote](https://marabos.nl/atomics/memory-ordering.html#common-misconceptions) in my book on atomics: > [..] when reading code, SeqCst basically tells the reader: "this operation depends on the total order of every single SeqCst operation in the program," which is an incredibly far-reaching claim. The same code would likely be easier to review and verify if it used weaker memory ordering instead, if possible. For example, Release effectively tells the reader: "this relates to an acquire operation on the same variable," which involves far fewer considerations when forming an understanding of the code. > > It is advisable to see SeqCst as a warning sign. Seeing it in the wild often means that either something complicated is going on, or simply that the author did not take the time to analyze their memory ordering related assumptions, both of which are reasons for extra scrutiny. r? ````@Amanieu```` ````@joboet````
2024-03-20Add `NonNull::<[T]>::is_empty` as insta-stable.Zachary S-0/+21
2024-03-20Update target.rs alloc.rs event.rs simd.rsRoboSchmied-1/+1
fix typos
2024-03-20Auto merge of #122754 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68bors-171/+43
Bump to 1.78 bootstrap compiler https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-03-20step cfgsMark Rousskov-171/+43
2024-03-20improve codegen of fmt_num to delete unreachable paniciximeow-4/+4
it seems LLVM doesn't realize that `curr` is always decremented at least once in either loop formatting characters of the input string by their appropriate radix, and so the later `&buf[curr..]` generates a check for out-of-bounds access and panic. this is unreachable in reality as even for `x == T::zero()` we'll produce at least the character `Self::digit(T::zero())` for at least one character output, and `curr` will always be at least one below `buf.len()`. adjust `fmt_int` to make this fact more obvious to the compiler, which fortunately (or unfortunately) results in a measurable performance improvement for workloads heavy on formatting integers.
2024-03-19Only split by-ref/by-move futures for async closuresMichael Goulet-19/+11
2024-03-19Rollup merge of #122720 - heisen-li:offset_of, r=workingjubileeMatthias Krüger-3/+3
[doc]:fix error code example fixs #122716
2024-03-19Manually implement `PartialOrd`/`Ord` for `Option`clubby789-2/+31