about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2025-03-07Rollup merge of #138034 - thaliaarchi:use-prelude-size-of, r=tgross35Matthias Krüger-222/+184
library: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80. try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-1
2025-03-07Rollup merge of #138129 - RalfJung:stabilize-const-things, r=tgross35Matthias Krüger-10/+10
Stabilize const_char_classify, const_sockaddr_setters FCP for const_char_classify: #132241 FCP for const_sockaddr_setters: #131714 Fixes #132241 Fixes #131714 Cc ``@rust-lang/wg-const-eval``
2025-03-07Rollup merge of #137904 - scottmcm:ordering-is, r=workingjubileeMatthias Krüger-6/+16
Improve the generic MIR in the default `PartialOrd::le` and friends It looks like I regressed this accidentally in #137197 due to #137901 So this PR does two things: 1. Tweaks the way we're calling `is_some_and` so that it optimizes in the generic MIR (rather than needing to optimize it in every monomorphization) -- the first commit adds a MIR test, so you can see the difference in the second commit. 2. Updates the implementations of `is_le` and friends to be slightly simpler, and parallel how clang does them.
2025-03-07Rollup merge of #136667 - vita-rust:revert-vita-c-char, r=cuviperMatthias Krüger-2/+6
Revert vita's c_char back to i8 # Description Hi! https://github.com/rust-lang/rust/pull/132975 changed the definition of `c_char` from i8 to u8 for most ARM targets. While that would usually be correct, [VITASDK uses signed chars by default](https://github.com/vitasdk/buildscripts/blob/master/patches/gcc/0001-gcc-10.patch#L33-L34). The Clang definitions are incorrect because Clang is not (yet?) supported by the vita commmunity / `VITADSK`, On the Rust side, the pre-compiled libraries the user can link to are all compiled using vita's `gcc` and [we set `TARGET_CC` and `TARGET_CXX`](https://github.com/vita-rust/cargo-vita/blob/d564a132cbd43947118c0d6d0ebfbea7d1dd7fa7/src/commands/build.rs#L230) in `cargo vita` for build scripts using `cc`. I'm creating it as a draft PR so that we can discuss it and possibly get it approved here, but wait to merge the [libc side](https://github.com/rust-lang/libc/pull/4258) and get a libc version first, as having the definitions out of sync breaks std. As a nightly-only target it can be confusing/frustrating for new users when the latest nightly, which is the default, is broken.
2025-03-06Use turbofish for size_of<T> and align_of<T> in docsThalia Archibald-10/+10
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-212/+174
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-07Auto merge of #138127 - compiler-errors:rollup-kcarqrz, r=compiler-errorsbors-3/+2
Rollup of 17 pull requests Successful merges: - #137827 (Add timestamp to unstable feature usage metrics) - #138041 (bootstrap and compiletest: Use `size_of_val` from the prelude instead of imported) - #138046 (trim channel value in `get_closest_merge_commit`) - #138053 (Increase the max. custom try jobs requested to `20`) - #138061 (triagebot: add a `compiler_leads` ad-hoc group) - #138064 (Remove - from xtensa targets cpu names) - #138075 (Use final path segment for diagnostic) - #138078 (Reduce the noise of bootstrap changelog warnings in --dry-run mode) - #138081 (Move `yield` expressions behind their own feature gate) - #138090 (`librustdoc`: flatten nested ifs) - #138092 (Re-add `DynSend` and `DynSync` impls for `TyCtxt`) - #138094 (a small borrowck cleanup) - #138098 (Stabilize feature `const_copy_from_slice`) - #138103 (Git ignore citool's target directory) - #138105 (Fix broken link to Miri intrinsics in documentation) - #138108 (Mention me (WaffleLapkin) when changes to `rustc_codegen_ssa` occur) - #138117 ([llvm/PassWrapper] use `size_t` when building arg strings) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-06Auto merge of #138114 - compiler-errors:rollup-7xr4b69, r=compiler-errorsbors-9/+78
Rollup of 25 pull requests Successful merges: - #135733 (Implement `&pin const self` and `&pin mut self` sugars) - #135895 (Document workings of successors more clearly) - #136922 (Pattern types: Avoid having to handle an Option for range ends in the type system or the HIR) - #137303 (Remove `MaybeForgetReturn` suggestion) - #137327 (Undeprecate env::home_dir) - #137358 (Match Ergonomics 2024: add context and examples to the unstable book) - #137534 ([rustdoc] hide item that is not marked as doc(inline) and whose src is doc(hidden)) - #137565 (Try to point of macro expansion from resolver and method errors if it involves macro var) - #137637 (Check dyn flavor before registering upcast goal on wide pointer cast in MIR typeck) - #137643 (Add DWARF test case for non-C-like `repr128` enums) - #137744 (Re-add `Clone`-derive on `Thir`) - #137758 (fix usage of ty decl macro fragments in attributes) - #137764 (Ensure that negative auto impls are always applicable) - #137772 (Fix char count in `Display` for `ByteStr`) - #137798 (ci: use ubuntu 24 on arm large runner) - #137802 (miri native-call support: all previously exposed provenance is accessible to the callee) - #137805 (adjust Layout debug printing to match the internal field name) - #137808 (Do not require that unsafe fields lack drop glue) - #137820 (Clarify why InhabitedPredicate::instantiate_opt exists) - #137825 (Provide more context on resolve error caused from incorrect RTN) - #137834 (rustc_fluent_macro: use CARGO_CRATE_NAME instead of CARGO_PKG_NAME) - #137868 (Add minimal platform support documentation for powerpc-unknown-linux-gnuspe) - #137910 (Improve error message for `AsyncFn` trait failure for RPIT) - #137920 (interpret/provenance_map: consistently use range_is_empty) - #138038 (Update `compiler-builtins` to 0.1.151) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-06stabilize const_sockaddr_settersRalf Jung-8/+8
2025-03-06stabilize const_char_classifyRalf Jung-2/+2
2025-03-06Remove #[cfg(not(test))] gates in coreThalia Archibald-114/+79
These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
2025-03-06Add examples in stdlib demonstrating the use syntaxSantiago Pastorino-0/+19
2025-03-06Add UseCloned trait related codeSantiago Pastorino-0/+51
2025-03-06Rollup merge of #138105 - reddevilmidzy:fix-broken-link, r=saethlinMichael Goulet-1/+1
Fix broken link to Miri intrinsics in documentation This PR updates an outdated link in the library/core/src/intrinsics/mod.rs file. The previous link, pointing to the Miri repository's src/shims/intrinsics directory, has been replaced with the correct one: https://github.com/rust-lang/miri/tree/master/src/intrinsics. This ensures that users can access the appropriate resources for the relevant intrinsic functions.
2025-03-06Add second precondition for `skip_search`.Markus Reiter-57/+205
2025-03-06Allow optimizing out `panic_bounds_check` in Unicode checks.Markus Reiter-39/+34
2025-03-06Update stdarchEric Huss-0/+3
2025-03-06Rollup merge of #137808 - jswrenn:droppy-unsafe-fields, r=nnethercoteMichael Goulet-2/+2
Do not require that unsafe fields lack drop glue Instead, we adopt the position that introducing an `unsafe` field itself carries a safety invariant: that if you assign an invariant to that field weaker than what the field's destructor requires, you must ensure that field is in a droppable state in your destructor. See: - https://github.com/rust-lang/rfcs/pull/3458#discussion_r1971676100 - https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/unsafe.20fields.20RFC/near/502113897 Tracking Issue: #132922
2025-03-06Rollup merge of #137772 - thaliaarchi:bstr-display, r=joshtriplettMichael Goulet-1/+3
Fix char count in `Display` for `ByteStr` `ByteStr as Display` performs a byte count when a char count is required. r? ```````````@joshtriplett```````````
2025-03-06Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, ↵Michael Goulet-1/+0
r=lcnr Ensure that negative auto impls are always applicable r? lcnr (or reassign if you dont want to review) https://github.com/rust-lang/rust/issues/68318#issuecomment-2689265030
2025-03-06Rollup merge of #136922 - oli-obk:pattern-types-option-ends, r=BoxyUwUMichael Goulet-0/+62
Pattern types: Avoid having to handle an Option for range ends in the type system or the HIR Instead, 1. during hir_ty_lowering, we now generate constants for the min/max when the range doesn't have a start/end specified. 2. in a later commit we generate those constants during ast lowering, simplifying everything further by not having to handle the range end inclusivity anymore in the type system (and thus avoiding any issues of `0..5` being different from `0..=4` I think it makes all the type system code simpler, and the cost of the extra `ConstKind::Value` processing seems negligible. r? `@BoxyUwU` cc `@joshtriplett` `@scottmcm`
2025-03-06Rollup merge of #135895 - hkBst:patch-15, r=joboetMichael Goulet-5/+11
Document workings of successors more clearly This is an attempt to fix #135087 together with https://github.com/rust-lang/rust/pull/135886, but I am not sure if I've succeeded in adding much clarity here, so don't be shy with your comments.
2025-03-07Fix broken link to Miri intrinsics in documentationRedddy-1/+1
Replaced the outdated link to https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics with the correct link https://github.com/rust-lang/miri/tree/master/src/intrinsics in the library/core/src/intrinsics/mod.rs file.
2025-03-06Stabilize `const_copy_from_slice` featureokaneco-2/+1
Stabilizes `copy_from_slice` method on `[T]`
2025-03-06Remove the `Option` part of range ends in the HIROli Scherer-0/+62
2025-03-05Make `is_le` and friends work like clang'sScott McMurray-6/+16
2025-03-05Rollup merge of #136662 - thaliaarchi:formatter-pad-char-count, r=m-ou-se许杰友 Jieyou Xu (Joe)-37/+29
Count char width at most once in `Formatter::pad` When both width and precision flags are specified, then `Formatter::pad` counts the character width twice. Instead, record the character width when truncating it to the precision, so it does not need to be recomputed. Simplify control flow so the cases are more clear. Related: - 6c9e708f4be (`fmt::Formatter::pad`: don't call chars().count() more than one time, 2021-09-01): Reduce counting chars from thrice to twice in worst case - ede39aeb331 (feat: reinterpret `precision` field for strings, 2016-06-29): Change meaning of precision for strings - b820748ff5a (Implement formatting arguments for strings and integers, 2013-08-10): Implement `Formatter::pad`
2025-03-05Rollup merge of #134063 - tgross35:dec2flt-refactoring, r=Noratrieb许杰友 Jieyou Xu (Joe)-583/+713
dec2flt: Clean up float parsing modules This is the first portion of my work adding support for parsing and printing `f16`. Changes in `float.rs` replace the magic constants with expressions and add some use of generics to better support the new float types. Everything else is related to documentation or naming; there are no functional changes in this PR. This can be reviewed by commit.
2025-03-04Rollup merge of #137829 - cramertj:stabilize-split-off, r=jhprattJubilee-27/+7
Stabilize [T]::split_off... methods This was previously known as the slice_take feature. Closes #62280
2025-03-04Ensure that negative auto impls are always applicableMichael Goulet-1/+0
2025-03-04atomic: clarify that failing conditional RMW operations are not 'writes'Ralf Jung-2/+3
2025-03-04Auto merge of #137959 - matthiaskrgr:rollup-62vjvwr, r=matthiaskrgrbors-1/+1
Rollup of 12 pull requests Successful merges: - #135767 (Future incompatibility warning `unsupported_fn_ptr_calling_conventions`: Also warn in dependencies) - #137852 (Remove layouting dead code for non-array SIMD types.) - #137863 (Fix pretty printing of unsafe binders) - #137882 (do not build additional stage on compiler paths) - #137894 (Revert "store ScalarPair via memset when one side is undef and the other side can be memset") - #137902 (Make `ast::TokenKind` more like `lexer::TokenKind`) - #137921 (Subtree update of `rust-analyzer`) - #137922 (A few cleanups after the removal of `cfg(not(parallel))`) - #137939 (fix order on shl impl) - #137946 (Fix docker run-local docs) - #137955 (Always allow rustdoc-json tests to contain long lines) - #137958 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-03stabilize const_cellRalf Jung-5/+5
2025-03-03Rollup merge of #137054 - jhpratt:phantom-variance, r=Mark-SimulacrumMatthias Krüger-0/+12
Make phantom variance markers transparent
2025-03-03fix order on shl implSpeedy_Lex-1/+1
this doesn't fix any bugs, it just looks more consistent with the other impl's
2025-03-02Rollup merge of #137871 - pitaj:rangebounds-is_empty-intersect, r=scottmcmMatthias Krüger-1/+1
fix `RangeBounds::is_empty` documentation One-sided ranges are never empty follow-up for https://github.com/rust-lang/rust/pull/137304#pullrequestreview-2646899461
2025-03-02Document workings of successors more clearlyMarijn Schouten-5/+11
This is an attempt to fix #135087 together with https://github.com/rust-lang/rust/pull/135886, but I am not sure if I've succeeded in adding much clarity here, so don't be shy with your comments.
2025-03-02dec2flt: Refactor the fast pathTrevor Gross-24/+23
This is just a bit of code cleanup to make use of returning early.
2025-03-02dec2flt: Refactor float traitsTrevor Gross-111/+203
A lot of the magic constants can be turned into expressions. This reduces some code duplication. Additionally, add traits to make these operations fully generic. This will make it easier to support `f16` and `f128`.
2025-03-02dec2flt: Rename fields to be consistent with documented notationTrevor Gross-14/+18
2025-03-02dec2flt: Rename `Number` to `Decimal`Trevor Gross-9/+9
The previous commit renamed `Decimal` to `DecimalSeq`. Now, rename the type that represents a decimal floating point number to be `Decimal`. Additionally, add some tests for internal behavior.
2025-03-02dec2flt: Rename `Decimal` to `DecimalSeq`Trevor Gross-22/+39
This module currently contains two decimal types, `Decimal` and `Number`. These names don't provide a whole lot of insight into what exactly they are, and `Number` is actually the one that is more like an expected `Decimal` type. In accordance with this, rename the existing `Decimal` to `DecimalSeq`. This highlights that it contains a sequence of decimal digits, rather than representing a base-10 floating point (decimal) number. Additionally, add some tests to validate internal behavior.
2025-03-02dec2flt: Update documentation of existing methodsTrevor Gross-17/+35
Fix or elaborate existing float parsing documentation. This includes introducing a convention that should make naming more consistent.
2025-03-02float: Update some constants to `pub(crate)`Trevor Gross-6/+6
These constants can be useful outside of their current module. Make them `pub(crate)` to allow for this.
2025-03-01fix `RangeBounds::is_empty` documentationPeter Jaszkowiak-1/+1
One-sided ranges are never empty
2025-03-01Use `BinOp::Cmp` for `iNN::signum`Scott McMurray-8/+7
This way it can use the nice new LLVM intrinsic in LLVM20.
2025-03-01Rollup merge of #137828 - folkertdev:simd-intrinsic-doc-fixes, r=workingjubileeMatthias Krüger-36/+34
Fix inaccurate `std::intrinsics::simd` documentation This addresses two issues: - the docs on comparison operators (`simd_gt` etc.) said they only work for floating-point vectors, but they work for integer vectors too. - the docs on various functions that use a mask did not document that the mask must be a signed integer vector. Unsigned integer vectors would cause invalid behavior when the mask vector is widened (unsigned integers would use zero extension, producing incorrect results). r? ``@workingjubilee``
2025-03-01intrinsics::simd: document that masks must be signed integer vectorsFolkert de Vries-27/+27
this is because they may be widened, and that only works when sign extension is used: zero extension would produce invalid results
2025-03-01correct the docs on `simd_` comparison operatorsFolkert de Vries-15/+13
these all also accept integer vectors as arguments
2025-02-28Stabilize [T]::split_off... methodsTaylor Cramer-27/+7
This was previously known as the slice_take feature.