about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-12-11Add a note saying that `{u8,i8}::from_{be,le,ne}_bytes` is meaninglessTobias Bucher-4/+29
2024-12-10Rollup merge of #134116 - RalfJung:const_nonnull_new, r=jhprattLeón Orell Valerian Liehr-4/+1
stabilize const_nonnull_new FCP passed in https://github.com/rust-lang/rust/issues/93235 Closes #93235
2024-12-10Rollup merge of #134100 - eholk:noop-rustc-const-stable, r=dtolnayLeón Orell Valerian Liehr-1/+0
Remove rustc_const_stable attribute on const NOOP This was accidentally reintroduced while editing #133089. r? dtolnay
2024-12-10Add references to the specific ABI documentsAlex Richardson-7/+63
Expcept for L4RE and Xtensa these were obtained from #131319 I could not find an open link to the Xtensa documentation, but the signedness was confirmed by on of the Xtensa developers in https://github.com/llvm/llvm-project/pull/115967#issuecomment-2506292323 Co-authored-by: Taiki Endo <te316e89@gmail.com>
2024-12-10Remove l4re from the unsigned char operating system listAlex Richardson-2/+2
As noted in https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240, the default for userland apps is to follow the architecture defaults, the -funsigned-char flag only applies to kernel builds.
2024-12-10De-duplicate and improve definition of core::ffi::c_charAlex Richardson-53/+24
Instead of having a list of unsigned char targets for each OS, follow the logic Clang uses and instead set the value based on architecture with a special case for Darwin and Windows operating systems. This makes it easier to support new operating systems targeting Arm/AArch64 without having to modify this config statement for each new OS. The new list does not quite match Clang since I noticed a few bugs in the Clang implementation (https://github.com/llvm/llvm-project/issues/115957). Fixes: https://github.com/rust-lang/rust/issues/129945
2024-12-10stabilize const_nonnull_newRalf Jung-4/+1
2024-12-09Remove rustc_const_stable attribute on const NOOPEric Holk-1/+0
This was accidentally reintroduced while editing #133089.
2024-12-09Rollup merge of #134032 - snprajwal:fix-docs, r=joboetLeón Orell Valerian Liehr-8/+8
docs: better examples for `std::ops::ControlFlow` Fixes #133963. Lesson learnt, never force-push from a bare clone of a repo :skull:
2024-12-09core: use public method instead of instrinsicjoboet-2/+2
2024-12-09core: improve commentsJonas Böttiger-3/+5
Co-authored-by: Yotam Ofek <yotam.ofek@gmail.com> Co-authored-by: Hanna Kruppe <hanna.kruppe@gmail.com>
2024-12-09Auto merge of #134052 - matthiaskrgr:rollup-puxwqrk, r=matthiaskrgrbors-0/+1
Rollup of 7 pull requests Successful merges: - #133567 (A bunch of cleanups) - #133789 (Add doc alias 'then_with' for `then` method on `bool`) - #133880 (Expand home_dir docs) - #134036 (crash tests: use individual mir opts instead of mir-opt-level where easily possible) - #134045 (Fix some triagebot mentions paths) - #134046 (Remove ignored tests for hangs w/ new solver) - #134050 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-09Rollup merge of #133789 - rossmacarthur:then-with-doc-alias, r=Mark-SimulacrumMatthias Krüger-0/+1
Add doc alias 'then_with' for `then` method on `bool` I think its logical to search for this name since `Ordering::then_with` exists as well.
2024-12-08Switch inline(always) in core/src/fmt/rt.rs to plain inlineBen Kimock-17/+17
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/+142
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/+359
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/+142
Add Extend impls for tuples of arity 1 through 12
2024-12-06Auto merge of #133089 - eholk:stabilize-noop-waker, r=dtolnaybors-9/+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-9/+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-54/+52
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/+342
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/+20
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-05Rollup merge of #133863 - oli-obk:push-pystoxvtvssx, r=lqdLeón Orell Valerian Liehr-2/+2
Rename `core_pattern_type` and `core_pattern_types` lib feature gates to `pattern_type_macro` That's what the gates are actually gating, and the single char difference in naming was not helpful either fixes #128987
2024-12-05Rollup merge of #118833 - Urgau:lint_function_pointer_comparisons, r=cjgillotLeón Orell Valerian Liehr-0/+1
Add lint against function pointer comparisons This is kind of a follow-up to https://github.com/rust-lang/rust/pull/117758 where we added a lint against wide pointer comparisons for being ambiguous and unreliable; well function pointer comparisons are also unreliable. We should IMO follow a similar logic and warn people about it. ----- ## `unpredictable_function_pointer_comparisons` *warn-by-default* The `unpredictable_function_pointer_comparisons` lint checks comparison of function pointer as the operands. ### Example ```rust fn foo() {} let a = foo as fn(); let _ = a == foo; ``` ### Explanation Function pointers comparisons do not produce meaningful result since they are never guaranteed to be unique and could vary between different code generation units. Furthermore different function could have the same address after being merged together. ---- This PR also uplift the very similar `clippy::fn_address_comparisons` lint, which only linted on if one of the operand was an `ty::FnDef` while this PR lints proposes to lint on all `ty::FnPtr` and `ty::FnDef`. ```@rustbot``` labels +I-lang-nominated ~~Edit: Blocked on https://github.com/rust-lang/libs-team/issues/323 being accepted and it's follow-up pr~~
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`.