about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
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-6/+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-168/+40
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-168/+40
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
2024-03-19Remove `SpecOptionPartialEq`clubby789-71/+10
2024-03-19SeqCst->Relaxed in doc examples.Mara Bos-6/+3
SeqCst is unnecessary here.
2024-03-19[doc]:fix error code exampleheisen-li-3/+3
2024-03-19Make ptr_guaranteed_cmp a rustc_intrinsic and favor its body over backends ↵Oli Scherer-9/+18
implementing it
2024-03-19Make `vtable_align` a rustc_intrinsicOli Scherer-2/+14
2024-03-19Make `const_eval_select` a rustc_intrinsicOli Scherer-56/+74
2024-03-19add notes on how to store 'ptr or int'Ralf Jung-2/+6
2024-03-18Reimplement `CaseMappingIter` with `core::array::IntoIter`Jules Bertholet-128/+181
Makes the iterator 2*usize larger, but I doubt that matters much. In exchange, we save a lot on instruction count. In the absence of delegation syntax, we must forward all the specialized impls manually…
2024-03-19Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obkbors-1/+1
Stabilize associated type bounds (RFC 2289) This PR stabilizes associated type bounds, which were laid out in [RFC 2289]. This gives us a shorthand to express nested type bounds that would otherwise need to be expressed with nested `impl Trait` or broken into several `where` clauses. ### What are we stabilizing? We're stabilizing the associated item bounds syntax, which allows us to put bounds in associated type position within other bounds, i.e. `T: Trait<Assoc: Bounds...>`. See [RFC 2289] for motivation. In all position, the associated type bound syntax expands into a set of two (or more) bounds, and never anything else (see "How does this differ[...]" section for more info). Associated type bounds are stabilized in four positions: * **`where` clauses (and APIT)** - This is equivalent to breaking up the bound into two (or more) `where` clauses. For example, `where T: Trait<Assoc: Bound>` is equivalent to `where T: Trait, <T as Trait>::Assoc: Bound`. * **Supertraits** - Similar to above, `trait CopyIterator: Iterator<Item: Copy> {}`. This is almost equivalent to breaking up the bound into two (or more) `where` clauses; however, the bound on the associated item is implied whenever the trait is used. See #112573/#112629. * **Associated type item bounds** - This allows constraining the *nested* rigid projections that are associated with a trait's associated types. e.g. `trait Trait { type Assoc: Trait2<Assoc2: Copy>; }`. * **opaque item bounds (RPIT, TAIT)** - This allows constraining associated types that are associated with the opaque without having to *name* the opaque. For example, `impl Iterator<Item: Copy>` defines an iterator whose item is `Copy` without having to actually name that item bound. The latter three are not expressible in surface Rust (though for associated type item bounds, this will change in #120752, which I don't believe should block this PR), so this does represent a slight expansion of what can be expressed in trait bounds. ### How does this differ from the RFC? Compared to the RFC, the current implementation *always* desugars associated type bounds to sets of `ty::Clause`s internally. Specifically, it does *not* introduce a position-dependent desugaring as laid out in [RFC 2289], and in particular: * It does *not* desugar to anonymous associated items in associated type item bounds. * It does *not* desugar to nested RPITs in RPIT bounds, nor nested TAITs in TAIT bounds. This position-dependent desugaring laid out in the RFC existed simply to side-step limitations of the trait solver, which have mostly been fixed in #120584. The desugaring laid out in the RFC also added unnecessary complication to the design of the feature, and introduces its own limitations to, for example: * Conditionally lowering to nested `impl Trait` in certain positions such as RPIT and TAIT means that we inherit the limitations of RPIT/TAIT, namely lack of support for higher-ranked opaque inference. See this code example: https://github.com/rust-lang/rust/pull/120752#issuecomment-1979412531. * Introducing anonymous associated types makes traits no longer object safe, since anonymous associated types are not nameable, and all associated types must be named in `dyn` types. This last point motivates why this PR is *not* stabilizing support for associated type bounds in `dyn` types, e.g, `dyn Assoc<Item: Bound>`. Why? Because `dyn` types need to have *concrete* types for all associated items, this would necessitate a distinct lowering for associated type bounds, which seems both complicated and unnecessary compared to just requiring the user to write `impl Trait` themselves. See #120719. ### Implementation history: Limited to the significant behavioral changes and fixes and relevant PRs, ping me if I left something out-- * #57428 * #108063 * #110512 * #112629 * #120719 * #120584 Closes #52662 [RFC 2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html
2024-03-18Rollup merge of #122675 - tmfink:doc-clarify, r=scottmcmMatthias Krüger-0/+2
core: document default attribute stabilization As of now, the first release which stabilized the `#[default]` macro for the deriving the `Default` trait for enus is not documented. I have had to search the [`RELEASES.md`](https://github.com/rust-lang/rust/blob/master/RELEASES.md) when making sure my code would be accepted by an older Rust compiler. I just added a line in the doc comment since, as far as I know, there's no option to pass to the `#[stable()]` attribute. I am open to improvements in the wording.
2024-03-18remove retag_box_to_raw, it is no longer neededRalf Jung-13/+0
2024-03-17Let codegen decide when to `mem::swap` with immediatesScott McMurray-25/+26
Making `libcore` decide this is silly; the backend has so much better information about when it's a good idea. So introduce a new `typed_swap` intrinsic with a fallback body, but replace that implementation for immediates and scalar pairs.
2024-03-17chore(121952): echo comments on the `*_assign` methodsPetr Portnov-0/+3
2024-03-17chore(121952): remove redundant commentsPetr Portnov-3/+0
These were only relevant for the unsafe-containing implementations Signed-off-by: Petr Portnov <me@progrm-jarvis.ru>
2024-03-17feat: implement `{Div,Rem}Assign<NonZero<X>>` on `X`Petr Portnov-1/+20
Signed-off-by: Petr Portnov <me@progrm-jarvis.ru>
2024-03-17Rollup merge of #119411 - yotamofek:array-ptr-get, r=NilstriebMatthias Krüger-0/+84
Add as_(mut_)ptr and as_(mut_)slice to raw array pointers Hey, first time contributing to the standard libraries so not completely sure about the process. These functions are complementary to the ones being added in #74265 . I found them missing on array pointers. See also: - ACP: https://github.com/rust-lang/libs-team/issues/321 - Tracking issue: #119834