Commit Graph

10681 Commits

Author SHA1 Message Date
Matthias Krüger ac7ba99209 Rollup merge of #156403 - SpriteOvO:type-info-refactor-variant, r=oli-obk
Add `TypeId` methods `variants` `fields` `field` for `type_info`

Tracking issue rust-lang/rust#146922

- Adds `fn TypeId::variants` returns the number of variants, for struct and union and primitive types, it's always 1.
- Adds `fn TypeId::fields` returns the number of fields.
- Adds `fn TypeId::field` returns a field representing type `FieldId`.
- Adds a new type `FieldId`, which is a wrapper of `FieldRepresentingType`'s `TypeId`.

For methods `{fields,field}`, if indexing out of bounds, a compile-time error will be raised.

Regarding the removal of `Type` items, this will be done in a later PR in one go.

r? @oli-obk
2026-05-28 07:53:35 +02:00
Asuna b513e539c3 FieldId wraps FRT TypeId instead of the actual field TypeId 2026-05-27 22:25:09 +00:00
Guillaume Gomez b464e29405 Rollup merge of #156390 - Randl:iter_related_const, r=oli-obk
Constify Iterator-related methods and functions

These functions are required to eventually constify `Iterator`

r? @oli-obk
2026-05-27 20:45:11 +02:00
Ralf Jung 59428e76e8 MIR inlining: allow backends to opt-in to inlining intrinsics 2026-05-27 13:59:25 +02:00
Jonathan Brouwer 903a08c0b0 Rollup merge of #156161 - mejrs:this_formatargs, r=oli-obk
rustc_on_unimplemented: introduce format specifiers

...as printing options for the annotated item.

See also the test and dev guide prose. This only affects rustc_on_unimplemented, not (yet) the other diagnostic attributes. I plan to do that in some later PR.

```rust
#![feature(rustc_attrs)]

#[rustc_on_unimplemented(
    message = "normal: {This}, path: {This:path},  resolved: {This:resolved}"
)]
pub trait Trait<'lifetime, const CONST_GENERIC: usize, A, B> where A: Send {}
```
will do:
```
normal: Trait, path: Trait<'lifetime, CONST_GENERIC, A, B>,  resolved: Trait<'_, 6, u8, _>
```
2026-05-26 13:42:16 +02:00
bors 31a9463c6e Auto merge of #156930 - JonathanBrouwer:rollup-NuilniS, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#156764 (tests: fix pub-priv-dep test expectation)
 - rust-lang/rust#156825 (compiletest: sort unexpected and unimportant errors)
 - rust-lang/rust#156878 (codegen: re-enable FileCheck for scalable-vector tuple intrinsics)
 - rust-lang/rust#156909 (Rewrite documentation that said to implement `Into`)
2026-05-25 20:03:42 +00:00
Jonathan Brouwer 62bb58892b Rollup merge of #156909 - joshtriplett:into-docs, r=SimonSapin
Rewrite documentation that said to implement `Into`
2026-05-25 20:54:08 +02:00
bors c854ac880b Auto merge of #156594 - LimpSquid:stabilize-bool-to-result, r=SimonSapin
Stabilize bool_to_result

Closes https://github.com/rust-lang/rust/issues/142748
2026-05-25 16:51:27 +00:00
Jonathan Brouwer e8d2321b41 Rollup merge of #156830 - okaneco:phi_doc_alias, r=SimonSapin
Add `#[doc(alias = "phi")]` for float `GOLDEN_RATIO` constants

- Adds "phi" doc alias for `f16`, `f32`, `f64`, and `f128`

I knew this constant was stabilized but I couldn't remember what it was called.
Searching "phi" in the docs only surfaces the π constant, `is_ascii_graphic`, and `spin_loop_hint` methods. This alias would make it much easier to find.
https://doc.rust-lang.org/nightly/std/?search=phi
2026-05-24 08:27:21 +02:00
Josh Triplett 8edc0696b9 Rewrite documentation that said to implement Into 2026-05-24 07:34:39 +02:00
Pieter-Louis Schoeman 501ab4e8c5 Clarify Share trait docs 2026-05-22 16:21:32 +02:00
okaneco 3a6cb0519d Add #[doc(alias = "phi")] for float GOLDEN_RATIO constants 2026-05-22 09:15:36 -04:00
Pieter-Louis Schoeman c01e32073c Document unstable Share trait semantics 2026-05-22 07:21:45 +02:00
Pieter-Louis Schoeman 9b3cd578ab Remove provisional Share trait FIXME notes 2026-05-22 07:13:06 +02:00
Asuna 28733aa84b Add TypeId::field method to get a field representing type for type_info 2026-05-21 21:18:33 +00:00
Pieter-Louis Schoeman 02109ee822 Implement Share for shared references 2026-05-21 22:43:27 +02:00
Pieter-Louis Schoeman e5a67968e6 Add unstable Share trait 2026-05-21 22:43:27 +02:00
Jonathan Brouwer 8162cf582b Rollup merge of #156242 - Jamesbarford:feat/remove-alwaysinline+target-feature, r=RalfJung,saethlin
Remove unsound `target_feature_inline_always` feature

## Summary
- Remove `target_feature_inline_always`
- Update stdarch generators to only use `#[inline]` & regenerate stdarch.

## Why?
Succinctly; the feature relies on LLVMs `AlwaysInlinerPass()` running before LLVMs heuristic based inliner pass. Which is not a basis for sound code.

This has been discussed in [the tracking issue](https://github.com/rust-lang/rust/issues/145574).

If the ordering of the passes were to change, of which they have in the past, it is very possible we could inline functions across callsites with mismatching target features leading to unsound code. Checks proposed in; https://github.com/rust-lang/rust/pull/155426 would only take into account caller -> callee which is not enough to guard against possibly of generating unsound code if the pass ordering were to change.

There doesn't seem to be a way, presently, this this mechanism to provide soundness guarantees nor does it seem like `AlwaysInlinerPass()` is a desired feature of LLVM, which this feature relies on.

r? @RalfJung
2026-05-21 12:21:45 +02:00
Asuna b50aae66b8 Add TypeId::fields method to get number of fields for type_info 2026-05-20 20:46:03 +00:00
Asuna d1ad6292d6 Add TypeId::variants method to get number of variants for type_info 2026-05-20 20:46:03 +00:00
Asuna 7a96d86fb7 Fix typos in intrinsics::size_of_type_id panic message and doc comment 2026-05-20 20:46:03 +00:00
Andrew Gallant de28a95577 Add an example to the NumBuffer documentations
We specifically call out that the sign is written for negative
integers. This would also ideally be called out in `<iN>::format_into`,
but the macro infrastructure for the implementation unfortunately
doesn't really make this easy as far as I can tell.
2026-05-19 22:17:40 -04:00
bors ca9203f29c Auto merge of #156728 - JonathanBrouwer:rollup-Qv3EfnO, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#156146 (test new solver on CI until stabilization)
 - rust-lang/rust#155840 (prefer `T::IS_ZST` over manual check)
 - rust-lang/rust#156723 (Update books)
2026-05-18 21:25:18 +00:00
Jonathan Brouwer 27d3139405 Rollup merge of #155840 - Lars-Schumann:prefer-is-zst, r=clarfonthey
prefer `T::IS_ZST` over manual check

makes the intent clearer and possible small perf improvement
2026-05-18 23:17:17 +02:00
bors 9eb3be26b4 Auto merge of #156720 - JonathanBrouwer:rollup-vArjiS4, r=JonathanBrouwer
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#156709 (stdarch subtree update)
 - rust-lang/rust#155006 (stabilize `feature(cfg_target_has_atomic_equal_alignment)`)
 - rust-lang/rust#156444 (Implement `OsStr::split_at`)
 - rust-lang/rust#156582 (Allow `global_asm!` in statement positions)
 - rust-lang/rust#156661 (Remove `UncheckedIterator`)
 - rust-lang/rust#152367 (Derives `Copy` for `ffi::FromBytesUntilNulError`)
 - rust-lang/rust#156443 (Fix invalid suggestion for parenthesized break)
 - rust-lang/rust#156606 (Add pext/pdep as aliases for extract_bits/deposit_bits)
 - rust-lang/rust#156630 (Replace `println!` with `assert!` in HashMap documentation examples)
 - rust-lang/rust#156644 (Widen the result of `widening_mul`.)
 - rust-lang/rust#156653 (Update `sysinfo` version to `0.39.2`)
 - rust-lang/rust#156697 (Add diagnostic items for IoBufReader and StdinLock)
 - rust-lang/rust#156704 (reduce usage of `box_patterns` in tests)
2026-05-18 18:00:20 +00:00
Jonathan Brouwer 3605c1f769 Rollup merge of #156644 - bjoernager:widening-mul, r=clarfonthey
Widen the result of `widening_mul`.

Tracking issue: rust-lang/rust#152016

This PR implements <https://github.com/rust-lang/rust/issues/152016#issuecomment-3843258926>, which mandates that `widening_mul` return a single, scalar value rather than a low/high tuple.

Consequently, this method is removed from `u128` and `i128` as they are the widest integral types. It has also been removed from `usize` and `isize` due to portability concerns.

Existing `widening_mul` usage has been replaced by equivalent calls to `carrying_mul` (which is logically identical to the old behaviour.) Existing &ndash; generic &ndash; non-doc tests have been removed.

# Public API

```rust
impl u8 {
    pub const fn widening_mul(self, rhs: Self) -> u16;
}

impl u16 {
    pub const fn widening_mul(self, rhs: Self) -> u32;
}

impl u32 {
    pub const fn widening_mul(self, rhs: Self) -> u64;
}

impl u64 {
    pub const fn widening_mul(self, rhs: Self) -> u128;
}

impl i8 {
    pub const fn widening_mul(self, rhs: Self) -> i16;
}

impl i16 {
    pub const fn widening_mul(self, rhs: Self) -> i32;
}

impl i32 {
    pub const fn widening_mul(self, rhs: Self) -> i64;
}

impl i64 {
    pub const fn widening_mul(self, rhs: Self) -> i128;
}
```
2026-05-18 17:07:11 +02:00
Jonathan Brouwer 9333565661 Rollup merge of #156606 - niklasf:alias-pext-pdep, r=SimonSapin
Add pext/pdep as aliases for extract_bits/deposit_bits

So that the methods will be found when searching for the corresponding intrinsics.

Tracking issue for `extract_bits`/`deposit_bits`: https://github.com/rust-lang/rust/issues/149069
2026-05-18 17:07:10 +02:00
Jonathan Brouwer 18bedf4bc6 Rollup merge of #152367 - Conaclos:conaclos/FromBytesUntilNulError-impl-Copy, r=clarfonthey
Derives `Copy` for `ffi::FromBytesUntilNulError`

[`ffi::FromBytesWithNulError` derives `Copy` since Rust 1.93](https://github.com/rust-lang/rust/commit/2f5a3d4b06a0a9e8749c2e361758ec517df0c96a) while `ffi::FromBytesUntilNulError` doesn't.
This Pr fixes that by deriving `Copy` for `ffi::FromBytesUntilNulError`.

I encountered this issue while I was working in a const context.

Note: I couldn't find any documentation about what kind of PR is allowed. As this one is very small, I guess it is ok to submit it directly without opening an issue first?
2026-05-18 17:07:08 +02:00
Jonathan Brouwer 43de103116 Rollup merge of #156661 - theemathas:del-unchecked-iter, r=SimonSapin
Remove `UncheckedIterator`

The only remaining usage of `UncheckedIterator` was in `array::{try_,}from_trusted_iterator`. So, replace `array::repeat` and array's `Clone` impl with a manual `from_fn` call rather than going through unnecessary abstractions, and remove the `UncheckedIterator` trait.
2026-05-18 17:07:07 +02:00
Jonathan Brouwer a6138ec142 Rollup merge of #156444 - ChrisDenton:os_str_split_at, r=nia-e
Implement `OsStr::split_at`

See rust-lang/rust#156199

This allows splitting only on valid UTF-8 boundaries, regardless of the platform, which avoids cross-platform landmines.
2026-05-18 17:07:05 +02:00
Jonathan Brouwer 33d6fe7a9a Rollup merge of #155006 - WaffleLapkin:stabilize_cfg_target_has_atomic_equal_alignment, r=Urgau
stabilize `feature(cfg_target_has_atomic_equal_alignment)`

See stabilization report: https://github.com/rust-lang/rust/issues/93822#issuecomment-4192399374
cc @joshtriplett
2026-05-18 17:07:04 +02:00
Gabriel Bjørnager Jensen 0a07235472 Widen 'widening_mul' result; Remove 'widening_mul' from 'u128' and 'i128'; 2026-05-18 11:21:16 +02:00
Josh Triplett 773ead250c Add doc alias memoffset for offset_of! 2026-05-18 08:30:10 +02:00
Josh Triplett 2acdb580b1 Add doc alias cfg-if for cfg_select! 2026-05-18 08:29:48 +02:00
Jonathan Brouwer b295a02a4e Rollup merge of #156668 - joshtriplett:format-into-typo, r=SimonSapin
Fix typo in `format_into` docs: signed -> unsigned

The documentation for the `format_into` methods on unsigned integers
still said "in signed decimal format". Change them to say "unsigned".
2026-05-18 03:19:50 +02:00
Jonathan Brouwer 868afcb29b Rollup merge of #156647 - oscargus:fasterfloatmidpoint, r=SimonSapin
Change division to multiplication in floating-point midpoint

Multiplication is faster than division on most (all?) platforms. While the optimizer will handle this, there is really no point in relying on that. Using multiplication directly will not have any drawbacks and are numerically identical (in this case since 1.0 / 2.0 == 0.5)

Consider the examples at https://godbolt.org/z/oMvb9vobG where it is clear that the non-optimized version uses division, while the optimized version uses multiplication.
2026-05-18 03:19:49 +02:00
Jonathan Brouwer a62fb3bfd7 Rollup merge of #156624 - lygstate:c_ffi_docs_fixes, r=SimonSapin
c ffi document fixes for c_short.md

There is no reference to `char` in c_short.md
2026-05-18 03:19:48 +02:00
Jonathan Brouwer 8ebe7e84bc Rollup merge of #156488 - justinyaodu:patch-2, r=SimonSapin
Fix missing period in Iterator product doc comment

It looks like the other doc comments all end with a period.
2026-05-18 03:19:47 +02:00
Jonathan Brouwer 5908149302 Rollup merge of #155313 - numero-744:patch-1, r=SimonSapin
doc(core::cmp::Eq): fix definition of symmetry

The definition did not match the one from PartialEq
2026-05-18 03:19:45 +02:00
Lars Schumann 6eefc1b28d prefer T::IS_ZST over manual check 2026-05-17 22:52:25 +00:00
Josh Triplett 43436c9a77 Fix typo in format_into docs: signed -> unsigned
The documentation for the `format_into` methods on unsigned integers
still said "in signed decimal format". Change them to say "unsigned".
2026-05-17 15:16:01 +02:00
Tim (Theemathas Chirananthavat) ea703e28fc Remove UncheckedIterator
The last usage of this trait was removed in a previous commit.
2026-05-17 15:06:12 +07:00
Tim (Theemathas Chirananthavat) 62e595213d Remove array::{try_,}from_trusted_iterator
This is the only remaining place that uses `UncheckedIterator`. So,
replace `array::repeat` and array's `Clone` impl with a manual `from_fn`
call rather than going through unnecessary abstractions.

Removal of `UncheckedIterator` will be done in a later commit.
2026-05-17 14:33:59 +07:00
Oscar Gustafsson 267796532f Change division to multiplication in floating-point midpoint 2026-05-16 19:45:23 +02:00
Yonggang Luo 871a2ae050 c ffi document fixes for c_short.md
There is no reference to `char` in c_short.md
2026-05-16 06:00:48 +08:00
Niklas Fiekas 638a775642 Add pext/pdep as aliases for extract_bits/deposit_bits
So that the methods will be found when searching for the corresponding
intrinsics.

Tracking issue: https://github.com/rust-lang/rust/issues/149069
2026-05-15 14:57:24 +02:00
LimpSquid afc399f1d0 Stabilize bool_to_result 2026-05-15 10:15:58 +02:00
Qai Juang 8909e794e7 Require UTF-8 in Utf8Pattern::StringPattern 2026-05-14 21:26:00 -04:00
Chris Denton 921b35bb6d Implement OsStr::split_at 2026-05-14 06:08:58 +00:00
Jonathan Brouwer ac656cbf21 Rollup merge of #156431 - bushrat011899:core_io_util, r=nia-e
Move `std::io::util` to `core::io`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Subset of: https://github.com/rust-lang/rust/pull/154684

## Description

Moves utility types and functions from `std::io::util` and `std::io` to `core::io`, leaving any IO trait implementations behind. They will be moved along with the traits themselves. Certain documentation links had to be amended.

- `Chain`
- `Empty`
- `Repeat`
- `Sink`
- `Take`
- `empty`
- `repeat`
- `sink`

---

## Notes

* This can be reviewed independently of the other PRs tracked in rust-lang/rust#154046.
* `Chain` and `Take` were previously in the main `mod.rs` file for `std::io`, but I've chosen to move them into the `util.rs` file in `core::io` instead. I think they make more sense in that file, but I'm happy to move them into `mod.rs` if that's a controversial decision.
* No AI tooling of any kind was used during the creation of this PR.
2026-05-12 18:53:37 +02:00