Commit Graph

10347 Commits

Author SHA1 Message Date
Jonathan Brouwer fad2a35ebf Rollup merge of #154133 - bjorn3:va_list_drop_defer_codegen, r=nnethercote
Defer codegen for the VaList Drop impl to actual uses

This allows compiling libcore with codegen backends that don't actually implement VaList like cg_clif.
2026-03-24 10:54:04 +01:00
bjorn3 366cf883c7 Add comments 2026-03-24 10:01:46 +01:00
Jacob Pratt 04f63328d6 Rollup merge of #154153 - tgross35:funnel-unchecked, r=Mark-Simulacrum
core: Implement `unchecked_funnel_{shl,shr}`

These methods are just wrappers around the intrinsics.

Tracking issue: https://github.com/rust-lang/rust/issues/145686
2026-03-23 23:42:50 -04:00
Jonathan Brouwer 3cad6d130a Rollup merge of #122668 - Jules-Bertholet:titlecase, r=Mark-Simulacrum
Add APIs for dealing with titlecase

ACP: https://github.com/rust-lang/libs-team/issues/354
Tracking issue: https://github.com/rust-lang/rust/issues/153892

r? libs-api

@rustbot label T-libs -T-libs-api A-unicode

~~The last commit has some insta-stable `PartialEq` impls, therefore: @rustbot label -needs-fcp
Alternatively, I could split those out into a follow-up PR.~~ (Edit: will do in follow-up)
2026-03-23 20:18:32 +01:00
bors eb9d3caf05 Auto merge of #154253 - JonathanBrouwer:rollup-LLZUsz2, r=JonathanBrouwer
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#154241 (`rust-analyzer` subtree update)
 - rust-lang/rust#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - rust-lang/rust#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - rust-lang/rust#153069 ([BPF] add target feature allows-misaligned-mem-access)
 - rust-lang/rust#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - rust-lang/rust#154191 (refactor RangeFromIter overflow-checks impl)
 - rust-lang/rust#154207 (Refactor query loading)
 - rust-lang/rust#153540 (drop derive helpers during attribute parsing)
 - rust-lang/rust#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - rust-lang/rust#154161 (On E0277 tweak help when single type impls traits)
 - rust-lang/rust#154218 (interpret/validity: remove unreachable error kind)
 - rust-lang/rust#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - rust-lang/rust#154228 (Improve inline assembly error messages)
2026-03-23 15:46:13 +00:00
Jonathan Brouwer cd3e866c7a Rollup merge of #153880 - asder8215:intersperse_nonfused, r=Mark-Simulacrum
Lifted intersperse and intersperse_with Fused transformation and updated documentation + tests

This PR once again builds on top of rust-lang/rust#152855. From the discussion in rust-lang/rust#152855, libs team came to the conclusion that `intersperse`/`intersperse_with` shouldn't transform the given iterator to a fused iterator always and a separator should be emitted between `Some(_)` items for non fused iterators (particularly just right before the subsequent `Some(_)`).

On top of the change Zakarumych added in the PR, I lifted the `FusedIterator` trait and transformation of the inner `iter` for `Intersperse`/`IntersperseWith`, so that we can display this behavior. I've adjusted the documentation and tests accordingly to reflect this change as well.

r? @jhpratt
2026-03-23 12:14:54 +01:00
Jonathan Brouwer 452af7ed94 Rollup merge of #154140 - theemathas:checks_always_on_in_const, r=RalfJung
Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.
2026-03-23 12:01:01 +01:00
Jonathan Brouwer 61b4c77781 Rollup merge of #154191 - pitaj:fix-154124, r=tgross35
refactor RangeFromIter overflow-checks impl

Crates with different overflow-checks settings accessing the same RangeFromIter resulted in incorrect values being yielded

Fixes rust-lang/rust#154124

r? @tgross35
2026-03-23 12:00:59 +01:00
Tim (Theemathas) Chirananthavat 338deef451 Remove outdated consteval docs for is_val_statically_known.
We've already stabilized float operations in const,
which means we've already accepted that a `const fn`
might behave differently in consteval vs at run time.
2026-03-23 10:56:33 +07:00
Tim (Theemathas) Chirananthavat 8dcb2578e2 Document consteval behavior of ub_checks & overflow_checks. 2026-03-23 10:55:10 +07:00
Peter Jaszkowiak 8befc9d082 refactor RangeFromIter overflow-checks impl
Crates with different overflow-checks settings accessing the same RangeFromIter resulted in incorrect values being yielded
2026-03-22 13:31:50 -06:00
Jules Bertholet 8d072616a5 Add APIs for dealing with titlecase
- `char::is_cased`
- `char::is_titlecase`
- `char::case`
- `char::to_titlecase`
2026-03-21 14:30:38 -04:00
Jonathan Brouwer 70d1c586ce Rollup merge of #154118 - malezjaa:dont-suggest-some-traits-for-unions, r=JonathanBrouwer
don't suggest non-deriveable traits for unions

Fixes rust-lang/rust#137587

Before, the compiler suggested adding `#[derive(Debug)]` (other traits too) for unions,
which is misleading because some traits can't be automatically derived.

Only traits that are still suggested are Copy and Clone.

I noticed the error label changed after removing the suggestion. I hope this isn't a big deal, but let me know if that's an issue.

original example:
```rs
union Union {
    member: usize,
}

impl PartialEq<u8> for Union {
    fn eq(&self, rhs: &u8) -> bool {
        unsafe { self.member == (*rhs).into() }
    }
}

fn main() {
    assert_eq!(Union { member: 0 }, 0);
}
```

before:
```
error[E0277]: `Union` doesn't implement `Debug`
  --> src\main.rs:13:5
   |
13 |     assert_eq!(Union { member: 0 }, 0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `Union`
   |
   = note: add `#[derive(Debug)]` to `Union` or manually `impl Debug for Union`
   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `Union` with `#[derive(Debug)]`
   |
 2 + #[derive(Debug)]
 3 | union Union {
   |
```

after (the message doesn't suggest adding #[derive(Debug)] to unions)
```
error[E0277]: `Union` doesn't implement `Debug`
  --> src\main.rs:13:5
   |
13 |     assert_eq!(Union { member: 0 }, 0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `Debug` is not implemented for `Union`
  --> src\main.rs:2:1
   |
 2 | union Union {
   | ^^^^^^^^^^^
   = note: manually `impl Debug for Union`
```
2026-03-21 00:42:48 +01:00
malezjaa 27212bb09d Don't suggest non-deriveable traits for unions.
Don't suggest non-deriveable traits for unions. This also adds enum, struct and union markers to rustc_on_unimplemented
2026-03-20 23:39:28 +01:00
Trevor Gross d54cf8f40a core: Implement unchecked_funnel_{shl,shr}
These methods are just wrappers around the intrinsics.
2026-03-20 14:59:42 -04:00
bjorn3 0b69ff5074 Defer codegen for the VaList Drop impl to actual uses
This allows compiling libcore with codegen backends that don't actually
implement VaList like cg_clif.
2026-03-20 11:48:36 +01:00
Stuart Cook 83d921de92 Rollup merge of #154019 - cyrgani:feature-clean, r=joboet
two smaller feature cleanups

Remove an unneeded feature gate for a private macro and sort the used features correctly by whether they are language or library features.
2026-03-20 15:33:07 +11:00
Jonathan Brouwer 793d1c9a2e Rollup merge of #153804 - DanielEScherzer:derive-eq-docs, r=Mark-Simulacrum
Derive Macro Eq: link to more detailed documentation

Match the other derive macros in the module (Ord, PartialEq, PartialOrd) by linking to the section in the trait documentation about how the derive macro works.
2026-03-19 13:42:36 +01:00
Jonathan Brouwer 7c6fc44b7c Rollup merge of #151905 - tgross35:dec2flt-traits, r=Mark-Simulacrum
Split the `dec2flt::RawFloat` trait for easier reuse

`RawFloat` is an internal trait with quite a few useful float properties. It currently resides in the `dec2flt` module but is also used in parsing, and would be nice to reuse other places. Unfortunately it cannot be implemented on `f128` because of limitations with how the parsing API is implemented (mantissa must fit into a u64).

To make the trait easier to work with, split it into the following:

* `Float`: Anything that is reasonably applicable to all floating point types.
* `FloatExt`: Items that should be part of `Float` but don't work for all float types. This will eventually be merged back into `Float` once it can be implemented on f128.
* `Lemire`: Items that are specific to the Lemire dec2flt algorithm.

These traits are then moved to places that make sense.

Builds on top of https://github.com/rust-lang/rust/pull/151900
2026-03-19 13:42:32 +01:00
Jonathan Brouwer f7ac53b661 Rollup merge of #154077 - jhpratt:optimize-128-bit-formatting, r=dtolnay
Optimize 128-bit integer formatting

The compiler is unaware of the restricted range of the input, so it is unable to optimize out the final division and modulus. By doing this manually, we get a nontrivial performance gain.

r? @dtolnay

(copied from https://github.com/dtolnay/itoa/pull/68)
2026-03-19 13:42:30 +01:00
bors 8b86f48958 Auto merge of #153480 - RaphiMuehlbacher:track-caller, r=Mark-Simulacrum
Add missing `track_caller` to overflowing trait methods

Fixes rust-lang/rust#152599 by adding `#[track_caller]` to arithmetic trait methods (`Neg`, `Shl`, `ShlAssign`, `Shr` and `ShrAssign`) so overflow panics report the correct call site instead of the trait definition.
2026-03-19 05:52:42 +00:00
Jacob Pratt ebb1f470ca Optimize 128-bit integer formatting
The compiler is unaware of the restricted range of the input, so it is
unable to optimize out the final division and modulus. By doing this
manually, we get a nontrivial performance gain.
2026-03-19 01:08:01 -04:00
Stuart Cook 43e48595e4 Rollup merge of #153985 - lms0806:issue-153542, r=scottmcm
doc: clarify allocator invariant

Added base + size <= usize::MAX to the Allocator documentation.

Please refer to issue [153542](https://github.com/rust-lang/rust/issues/153542).

Close rust-lang/rust#153542
2026-03-18 18:37:36 +11:00
Stuart Cook eeb140dafa Rollup merge of #153945 - theemathas:unwind_safe_pointee_sized, r=scottmcm
Change `?Sized` to `PointeeSized` in `UnwindSafe` impls for pointers

Tracking issue: rust-lang/rust#144404.

This PR is similar to rust-lang/rust#152646.
2026-03-18 18:37:35 +11:00
Stuart Cook 04e7f2f72e Rollup merge of #153677 - ConradIrwin:sanitary-string-panics, r=scottmcm
Remove string content from panics

String content can be useful for debugging panics, particularly when you are working on a small codebase where you can infer more about the path taken through your program based on the content of the string.

In production deployments that upload crashes for centralized debugging, string content poses a risk to user privacy. The string can accidentally contain information that the user is not expecting to share with the development team.

On balance it seems like the risks outweigh the benefits. It is easy to add a `dbg!()` statement to gather more information in development; but comparatively tricky to ensure panics are sanitized by every rust app that monitors their production deployments.

Ref https://internals.rust-lang.org/t/stop-including-string-content-in-index-panics/24067

r? @scottmcm
2026-03-18 18:37:35 +11:00
Jonathan Brouwer eb6170697d Rollup merge of #154012 - folkertdev:f128-from-instances, r=tgross35
unstable impl of `From<{i64, u64}> for f128`

r? tgross35
2026-03-17 21:20:04 +01:00
Folkert de Vries 681b48e228 unstable impl of From<{i64, u64}> for f128 2026-03-17 18:50:39 +01:00
Jonathan Brouwer 19f292aabe Rollup merge of #153972 - folkertdev:stdarch-sync-2026-03-16, r=folkertdev,RalfJung
stdarch subtree update

Subtree update of `stdarch` to https://github.com/rust-lang/stdarch/commit/aa3fc334dcb21b2bf5b5b31a52c19435072d7ced.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-03-17 17:51:28 +01:00
cyrgani e350a56cf9 move features into the correct section 2026-03-17 09:31:03 +00:00
cyrgani aa7d812f34 remove internal_impls_macro feature 2026-03-17 09:27:25 +00:00
lms0806 57fe818124 doc: clarify allocator invariant 2026-03-17 14:54:10 +09:00
bors 6bdc342ddb Auto merge of #146013 - Jules-Bertholet:from-wrapper, r=Mark-Simulacrum
Add `From` impls for wrapper types





- ~`From<T: Copy> for ManuallyDrop<T>`~
- `From<T: UnwindSafe> for AssertUnwindSafe<T>`
- `From<T> for LazyCell<T, F>`
- `From<T> for LazyLock<T, F>`
- `From<T> for ThinBox<T>` (unstable)
- `From<T> for UniqueRc<T>` (unstable)
- `From<T> for UniqueArc<T>` (unstable)

@rustbot label T-libs-api needs-fcp

Also needs a crater run, as the insta-stable impls are technically breaking changes.
2026-03-17 04:14:51 +00:00
Folkert de Vries 8155209828 enable the movrs target feature in core and std 2026-03-16 23:30:37 +01:00
Jonathan Brouwer 42c5d9a455 Rollup merge of #153359 - zedddie:const-param-ty-trait-gating, r=BoxyUwU
Gate `ConstParamTy_` trait behind `const_param_ty_trait` feature

Initially even when user wasn't using unsized const params, the only way to implement/name `ConstParamTy_` was to use `#![feature(unsized_const_params]`, now its gated under `const_param_ty_trait` feature, implied by `unsized_const_params`.

I've also changed use of `unsized_const_params` in tests which were using it only to implement `ConstParamTy_` without using unsized

r? BoxyUwU
2026-03-16 13:11:00 +01:00
Tim (Theemathas) Chirananthavat a89211e552 Change ?Sized to PointeeSized in UnwindSafe impls for pointers 2026-03-16 15:15:55 +07:00
Stuart Cook eb101bb2f1 Rollup merge of #153793 - kpreid:std-mem-doc, r=scottmcm
Add overview documentation for `std::mem`.

I heard that `std::mem` sounds scary to some people, and how it’s described — “Basic functions for dealing with memory” — sounds even to me like something that should be avoided, not even because it would be unsafe, but because it is too low-level.

Let’s fix that by telling people about what they can actually find in the module, without having to read all the individual item descriptions.

The exact contents of the list are, of course, highly debatable, and I chose not to include any of the unstable or deprecated items, nor to include `Discriminant` as well as `discriminant`. I’m also not particularly happy with the wording of the introductory paragraph.
2026-03-16 15:01:34 +11:00
Stuart Cook bd671824d5 Rollup merge of #153570 - RalfJung:assume-init-docs, r=tgross35
MaybeUninit: mention common mistakes in assume_init docs; link to validity invariant docs

Fixes https://github.com/rust-lang/rust/issues/150689
r? @tgross35
2026-03-16 15:01:33 +11:00
Ralf Jung c7220f423b rename min/maxnum intrinsics to min/maximum_number and fix their LLVM lowering 2026-03-15 14:53:00 +01:00
Jules Bertholet c5c1d94e6c Add From impls for wrapper types
- `From<T> for ThinBox<T>`
- `From<T> for UniqueRc<T>`
- `From<T> for UniqueArc<T>`
- `From<T: UnwindSafe> for AssertUnwindSafe<T>`
- `From<T> for LazyCell<T, F>`
- `From<T> for LazyLock<T, F>`
2026-03-14 22:09:35 -04:00
Jules Bertholet 4eb9e661ec Extend ASCII fast paths of char methods beyond ASCII 2026-03-14 19:20:20 -04:00
Mahdi Ali-Raihan 800d9ea8e8 Lifted intersperse and intersperse_with Fused restrictions and updated documentation + tests 2026-03-14 13:57:10 -04:00
Zakarum 425df0dedb Do not emit separator as before elements 2026-03-14 12:02:19 -04:00
Trevor Gross bec94a33d5 dec2flt: Move internal traits to better locations
`Float` and `FloatExt` are already used by both parsing and printing, so
move them out of `dec2flt` to a new module in `num::imp`. `Int` `Cast`
have the potential to be used more places in the future, so move them
there as well. `Lemire` is the only remaining trait; since it is small,
move it into the `dec2flt` root.

The `fmt::LowerExp` bound is removed from `Float` here since the trait
is moving into a module without `#[cfg(not(no_fp_fmt_parse))]` and it
isn't implemented with that config (it's not easily possible to add
`cfg` attributes to a single supertrait, unfortunately). This isn't a
problem since it isn't actually being used.
2026-03-14 04:34:52 -05:00
Trevor Gross b07c0439a4 dec2flt: Split up the RawFloat trait
`RawFloat` is currently used specifically for the implementation of the
lemire algorithm, but it is useful for more than that. Split it into
three different traits:

* `Float`: Anything that is reasonably applicable to all floating point
  types.
* `FloatExt`: Items that should be part of `Float` but don't work for
  all float types. This will eventually be merged back into `Float`.
* `Lemire`: Items that are specific to the Lemire algorithm.
2026-03-14 04:34:52 -05:00
Trevor Gross 02ac190909 dec2flt: Rename Integer to Int
This is more consistent with what the trait is called elsewhere in tree
(specifically compiler-builtins and test-float-parse).
2026-03-14 04:34:52 -05:00
Kevin Reid b1b87ffdbc Add overview documentation for std::mem.
I heard that `std::mem` sounds scary to some people, and how it’s
described — “Basic functions for dealing with memory” — sounds even to
me like something that should be avoided, not even because it would be
unsafe, but because it is too low-level.

Let’s fix that by telling people about what they can actually find in
the module, without having to read all the individual item descriptions.
2026-03-13 17:38:38 -07:00
Matthias Krüger 42c7f52939 Rollup merge of #153569 - abh1nav10:fix-pin-docs, r=joboet
Fix grammar in Pin documentation

Changed "has an address-sensitive" to "has address-sensitive states" in the `Drop` implementation section of the documentation of `Pin` thereby making it grammatically complete.
2026-03-13 19:50:13 +01:00
Matthias Krüger 12d320f884 Rollup merge of #153418 - softmoth:patch-1, r=joboet
core: remove FIXME comment in option.rs FromIterator

The referenced issue rust-lang/rust#11084 was closed in 2021, and the related PR rust-lang/rust#59605 was not merged due to inconclusive results. Similar code (in result.rs, for example) doesn't have this FIXME comment; this is the only reference to issue 11084 (or pull request 59605).

This FIXME was not mentioned in issue rust-lang/rust#44366.
2026-03-13 19:50:13 +01:00
Jonathan Brouwer 935805e80a Rollup merge of #153384 - safer-rust:main, r=oli-obk
Add missing safety doc for CString::from_vec_unchecked and async_drop_in_place

Add missing safety documentation for two unsafe APIs:

* `CString::from_vec_unchecked` – # Safety: the caller must ensure `v` contains no NUL bytes in its contents.
* `async_drop_in_place` – # Safety: see [`ptr::drop_in_place`] for safety requirements.
2026-03-13 13:27:49 +01:00
aisr 3771c65b53 add safety doc for CString::from_vec_unchecked and async_drop_in_place 2026-03-13 20:08:37 +08:00