about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-12-08Adds new intrinsic declarationaaishwarymishra@gmail.com-28/+38
changes old intrinsic to new declaration
2024-12-08docs: better examples for `std::ops::ControlFlow`Prajwal S N-8/+8
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2024-12-07Const-stabilize `str::is_char_boundary` and `str::split_at(_mut)(_checked)`.Zachary S-5/+5
2024-12-07Auto merge of #133978 - matthiaskrgr:rollup-6gh1iho, r=matthiaskrgrbors-110/+129
Rollup of 7 pull requests Successful merges: - #130209 (Stabilize `std::io::ErrorKind::CrossesDevices`) - #130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`) - #132187 (Add Extend impls for tuples of arity 1 through 12) - #133875 (handle `--json-output` properly) - #133934 (Do not implement unsafe auto traits for types with unsafe fields) - #133954 (Hide errors whose suggestions would contain error constants or types) - #133960 (rustdoc: remove eq for clean::Attributes) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-06Auto merge of #118159 - EliasHolzmann:formatting_options, r=m-ou-sebors-83/+334
Implementation of `fmt::FormattingOptions` Tracking issue: #118117 Public API: ```rust #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct FormattingOptions { … } #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Sign { Plus, Minus } #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum DebugAsHex { Lower, Upper } impl FormattingOptions { pub fn new() -> Self; pub fn sign(&mut self, sign: Option<Sign>) -> &mut Self; pub fn sign_aware_zero_pad(&mut self, sign_aware_zero_pad: bool) -> &mut Self; pub fn alternate(&mut self, alternate: bool) -> &mut Self; pub fn fill(&mut self, fill: char) -> &mut Self; pub fn align(&mut self, alignment: Option<Alignment>) -> &mut Self; pub fn width(&mut self, width: Option<usize>) -> &mut Self; pub fn precision(&mut self, precision: Option<usize>) -> &mut Self; pub fn debug_as_hex(&mut self, debug_as_hex: Option<DebugAsHex>) -> &mut Self; pub fn get_sign(&self) -> Option<Sign>; pub fn get_sign_aware_zero_pad(&self) -> bool; pub fn get_alternate(&self) -> bool; pub fn get_fill(&self) -> char; pub fn get_align(&self) -> Option<Alignment>; pub fn get_width(&self) -> Option<usize>; pub fn get_precision(&self) -> Option<usize>; pub fn get_debug_as_hex(&self) -> Option<DebugAsHex>; pub fn create_formatter<'a>(self, write: &'a mut (dyn Write + 'a)) -> Formatter<'a>; } impl<'a> Formatter<'a> { pub fn new(write: &'a mut (dyn Write + 'a), options: FormattingOptions) -> Self; pub fn with_options<'b>(&'b mut self, options: FormattingOptions) -> Formatter<'b>; pub fn sign(&self) -> Option<Sign>; pub fn options(&self) -> FormattingOptions; } ``` Relevant changes from the public API in the tracking issue (I'm leaving out some stuff I consider obvious mistakes, like missing `#[derive(..)]`s and `pub` specifiers): - `enum DebugAsHex`/`FormattingOptions::debug_as_hex`/`FormattingOptions::get_debug_as_hex`: To support `{:x?}` as well as `{:X?}`. I had completely missed these options in the ACP. I'm open for any and all bikeshedding, not married to the name. - `fill`/`get_fill` now takes/returns `char` instead of `Option<char>`. This simply mirrors what `Formatter::fill` returns (with default being `' '`). - Changed `zero_pad`/`get_zero_pad` to `sign_aware_zero_pad`/`get_sign_aware_zero_pad`. This also mirrors `Formatter::sign_aware_zero_pad`. While I'm not a fan of this quite verbose name, I do believe that having the interface of `Formatter` and `FormattingOptions` be compatible is more important. - For the same reason, renamed `alignment`/`get_alignment` to `aling`/`get_align`. - Deviating from my initial idea, `Formatter::with_options` returns a `Formatter` which has the lifetime of the `self` reference as its generic lifetime parameter (in the original API spec, the generic lifetime of the returned `Formatter` was the generic lifetime used by `self` instead). Otherwise, one could construct two `Formatter`s that both mutably borrow the same underlying buffer, which would be unsound. This solution still has performance benefits over simply using `Formatter::new`, so I believe it is worthwhile to keep this method.
2024-12-06Rollup merge of #132187 - shahn:extend_more_tuples, r=dtolnayMatthias Krüger-110/+129
Add Extend impls for tuples of arity 1 through 12
2024-12-06Auto merge of #133089 - eholk:stabilize-noop-waker, r=dtolnaybors-8/+5
Stabilize noop_waker Tracking Issue: #98286 This is a handy feature that's been used widely in tests and example async code and it'd be nice to make it available to users. cc `@rust-lang/wg-async`
2024-12-06core: implement `bool::select_unpredictable`joboet-1/+47
2024-12-05Rollup merge of #133821 - Kobzol:replace-black-with-ruff, r=onur-ozkanGuillaume Gomez-19/+34
Replace black with ruff in `tidy` `ruff` can both lint and format Python code (in fact, it should be a mostly drop-in replacement for `black` in terms of formatting), so it's not needed to use `black` anymore. This PR removes `black` and replaces it with `ruff`, to get rid of one Python dependency, and also to make Python formatting faster (although that's a small thing). If we decide to merge this, we'll need to "reformat the world" - `ruff` is not perfectly compatible with `black`, and it also looks like `black` was actually ignoring some files before. I tried it locally (`./x test tidy --extra-checks=py:fmt --bless`) and it also reformatted some code in subtrees (e.g. `clippy` or `rustc_codegen_gcc`) - I'm not sure how to handle that.
2024-12-05Stabilize noop_wakerEric Holk-8/+5
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2024-12-05Access members of `FormattingOptions` directly instead of via getters/settersElias Holzmann-41/+39
2024-12-05Removed constness for methods receiving a `&mut` parameterElias Holzmann-11/+11
See https://github.com/rust-lang/rust/pull/118159#discussion_r1495760867 for context.
2024-12-05Added better reason for exposing `flags` and `get_flags` as unstableElias Holzmann-2/+10
2024-12-05FormattedElias Holzmann-12/+10
2024-12-05Refactored FormattingOptions to use a bitmask for storing flagsElias Holzmann-44/+46
2024-12-05Revert "Turned public+unstable+hidden functions into private functions"Elias Holzmann-2/+6
See https://github.com/rust-lang/rust/pull/118159#discussion_r1491842170 for context. This reverts commit 62078dffcc1aefd4d678df94bca06e7b864065bd.
2024-12-05Turned public+unstable+hidden functions into private functionsElias Holzmann-6/+2
2024-12-05Made all fns constElias Holzmann-22/+22
2024-12-05impl Default for fmt::FormattingOptionsElias Holzmann-1/+1
2024-12-05Fixed copy+paste error in commentElias Holzmann-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2024-12-05fmt::FormattingOptions: Renamed `alignment` to `align`Elias Holzmann-13/+13
Likewise for `get_alignment`. This is how the method is named on `Formatter`, I want to keep it consistent.
2024-12-05Formatter::with_options: Use different lifetimesElias Holzmann-1/+1
Formatter::with_options takes self as a mutable reference (`&'a mut Formatter<'b>`). `'a` and `'b` need to be different lifetimes. Just taking `&'a mut Formatter<'a>` and trusting in Rust being able to implicitely convert from `&'a mut Formatter<'b>` if necessary (after all, `'a` must be smaller than `'b` anyway) fails because `'b` is behind a *mutable* reference. For background on on this behavior, see https://doc.rust-lang.org/nomicon/subtyping.html#variance.
2024-12-05Added struct `fmt::FormattingOptions`Elias Holzmann-68/+313
This allows to build custom `std::Formatter`s at runtime. Also added some related enums and two related methods on `std::Formatter`.
2024-12-05Formatter: Access members via getter methods wherever possibleElias Holzmann-16/+16
The idea behind this is to make implementing `fmt::FormattingOptions` (as well as any future changes to `std::Formatter`) easier. In theory, this might have a negative performance impact because of the additional function calls. However, I strongly believe that those will be inlined anyway, thereby producing assembly code that has comparable performance.
2024-12-05Rollup merge of #133844 - RalfJung:simd_relaxed_fma-nondet, r=workingjubileeJacob Pratt-1/+2
clarify simd_relaxed_fma non-determinism This is the safer spec in the sense that it is more likely to be satisfied by the backend -- and if people are okay with a non-deterministic result, I assume they don't care whether it's the same choice across all lanes or not? Cc ``@calebzulawski`` ``@workingjubilee``
2024-12-05Rollup merge of #127565 - esp-rs:xtensa-vaargs, r=workingjubileeJacob Pratt-0/+19
Teach rustc about the Xtensa VaListImpl Following on from the target Xtensa target PRs (https://github.com/rust-lang/rust/pull/125141, https://github.com/rust-lang/rust/pull/126380), this PR teaches rustc about the structure of the VA list on the Xtensa arch, as well as adding the required lowering to be able to actually use it.
2024-12-04Reformat Python code with `ruff`Jakub Beránek-19/+34
2024-12-04Rename `core_pattern_type` and `core_pattern_types` lib feature gates to ↵Oli Scherer-2/+2
`pattern_type_macro` That's what the gates are actually gating, and the single char difference in naming was not helpful either
2024-12-04clarify simd_relaxed_fma non-determinismRalf Jung-1/+2
2024-12-04Rollup merge of #133651 - scottmcm:nonnull-nonzero-no-field-projection, ↵Matthias Krüger-29/+58
r=oli-obk Update `NonZero` and `NonNull` to not field-project (per MCP#807) https://github.com/rust-lang/compiler-team/issues/807#issuecomment-2506098540 was accepted, so this is the first PR towards moving the library to not using field projections into `[rustc_layout_scalar_valid_range_*]` types. `NonZero` was already using `transmute` nearly everywhere, so there are very few changes to it. `NonNull` needed more changes, but they're mostly simple, changing `.pointer` to `.as_ptr()`. r? libs cc #133324, which will tidy up some of the MIR from this a bit more, but isn't a blocker.
2024-12-04Auto merge of #133818 - matthiaskrgr:rollup-iav1wq7, r=matthiaskrgrbors-0/+39
Rollup of 7 pull requests Successful merges: - #132937 (a release operation synchronizes with an acquire operation) - #133681 (improve TagEncoding::Niche docs, sanity check, and UB checks) - #133726 (Add `core::arch::breakpoint` and test) - #133768 (Remove `generic_associated_types_extended` feature gate) - #133811 ([AIX] change AIX default codemodel=large) - #133812 (Update wasm-component-ld to 0.5.11) - #133813 (compiletest: explain that UI tests are expected not to compile by default) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-03Rollup merge of #133726 - joshtriplett:breakpoint, r=oli-obkMatthias Krüger-0/+39
Add `core::arch::breakpoint` and test Approved in [ACP 491](https://github.com/rust-lang/libs-team/issues/491).
2024-12-03Update `NonZero` and `NonNull` to not field-project (per MCP807)Scott McMurray-29/+58
2024-12-03Rollup merge of #133796 - TDecking:borrowing-sub, r=tgross35Matthias Krüger-1/+1
Update the definition of `borrowing_sub` Complementary PR to https://github.com/rust-lang/rust/pull/133674, which only updated `carrying_add`.
2024-12-03Rollup merge of #133762 - RalfJung:const-size-of-val, r=workingjubileeMatthias Krüger-5/+5
stabilize const_{size,align}_of_val FCP passed [here](https://github.com/rust-lang/rust/issues/46571#issuecomment-2460285288). Fixes https://github.com/rust-lang/rust/issues/46571.
2024-12-03Rollup merge of #133696 - RalfJung:const-hashmap, r=cuviperMatthias Krüger-3/+3
stabilize const_collections_with_hasher and build_hasher_default_const_new After a lot of preparatory work, finally we can stabilize creating `HashMap` in const context. :) FCP for const_collections_with_hasher passed in https://github.com/rust-lang/rust/issues/102575. Fixes https://github.com/rust-lang/rust/issues/102575. FCP for build_hasher_default_const_new passed in https://github.com/rust-lang/rust/issues/123197. Fixes https://github.com/rust-lang/rust/issues/123197. Cc `@Amanieu` Release notes: https://github.com/rust-lang/rust/issues/133347
2024-12-03Update the definition of `borrowing_sub`Tobias Decking-1/+1
This ensures that it matches the one in `carrying_add`.
2024-12-03Teach rust core about Xtensa VaListImpl and add a custom lowering of vaarg ↵Brian J. Tarricone-0/+19
for xtensa. LLVM does not include an implementation of the va_arg instruction for Xtensa. From what I understand, this is a conscious decision and instead language frontends are encouraged to implement it themselves. The rationale seems to be that loading values correctly requires language and ABI-specific knowledge that LLVM lacks. This is true of most architectures, and rustc already provides implementation for a number of them. This commit extends the support to include Xtensa. See https://lists.llvm.org/pipermail/llvm-dev/2017-August/116337.html for some discussion on the topic. Unfortunately there does not seem to be a reference document for the semantics of the va_list and va_arg on Xtensa. The most reliable source is the GCC implementation, which this commit tries to follow. Clang also provides its own compatible implementation. This was tested for all the types that rustc allows in variadics. Co-authored-by: Brian Tarricone <brian@tarricone.org> Co-authored-by: Jonathan Bastien-Filiatrault <joe@x2a.org> Co-authored-by: Paul Lietar <paul@lietar.net>
2024-12-02Add `core::arch::breakpoint` and testJosh Triplett-0/+39
Approved in [ACP 491](https://github.com/rust-lang/libs-team/issues/491). Remove the `unsafe` on `core::intrinsics::breakpoint()`, since it's a safe intrinsic to call and has no prerequisites. (Thanks to @zachs18 for figuring out the `bootstrap`/`not(bootstrap)` logic.)
2024-12-03Add doc alias 'then_with' for `then` method on `bool`Ross MacArthur-0/+1
2024-12-03Rollup merge of #133395 - calebzulawski:simd_relaxed_fma, r=workingjubileeMatthias Krüger-0/+14
Add simd_relaxed_fma intrinsic Adds compiler support for https://github.com/rust-lang/portable-simd/issues/387#issuecomment-2337169786 r? `@workingjubilee` cc `@RalfJung` is this kind of nondeterminism a problem for miri/opsem?
2024-12-02Rollup merge of #133763 - Urgau:f16-midpoint-const-feat, r=AmanieuGuillaume Gomez-1/+1
Fix `f16::midpoint` const feature gate cc https://github.com/rust-lang/rust/pull/131784#discussion_r1866074470
2024-12-02Rollup merge of #131713 - tgross35:stabilize-const_maybe_uninit_write, ↵Guillaume Gomez-2/+2
r=RalfJung,dtolnay Stabilize `const_maybe_uninit_write` Mark the following API const stable: ```rust impl<T> MaybeUninit<T> { pub const fn write(&mut self, val: T) -> &mut T; } ``` This depends on `const_mut_refs` and [`const_maybe_uninit_assume_init`](https://github.com/rust-lang/rust/issues/86722), both of which have recently been stabilized. Closes: <https://github.com/rust-lang/rust/issues/63567>
2024-12-02stabilize const_{size,align}_of_valRalf Jung-5/+5
2024-12-02Stabilize `const_maybe_uninit_write`Trevor Gross-2/+2
Mark the following API const stable: impl<T> MaybeUninit<T> { pub const fn write(&mut self, val: T) -> &mut T; } This depends on `const_mut_refs` and `const_maybe_uninit_assume_init`, both of which have recently been stabilized. Tracking issue: <https://github.com/rust-lang/rust/issues/63567>
2024-12-02Fix `f16::midpoint` const feature gateUrgau-1/+1
2024-12-02Rollup merge of #133743 - bjoernager:slice-as-array, r=joboetGuillaume Gomez-1/+1
Fix docs for `<[T]>::as_array`. Tracking issue: #133508 This PR fixes a small typographical error in the docs entry for `<[T]>::as_array`.
2024-12-02stabilize const_collections_with_hasher and build_hasher_default_const_newRalf Jung-3/+3
2024-12-02Auto merge of #133728 - jhpratt:rollup-k1i60pg, r=jhprattbors-35/+2
Rollup of 4 pull requests Successful merges: - #133589 (Remove `hir::ArrayLen`) - #133672 (Remove a bunch of unnecessary const stability noise) - #133678 (Stabilize `ptr::fn_addr_eq`) - #133727 (Update mailmap) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-02Fix docs for '<[T]>::as_array';Gabriel Bjørnager Jensen-1/+1