Commit Graph

11069 Commits

Author SHA1 Message Date
Shun Sakai
8463342e91 docs(time): replace "method" with "function" 2026-09-08 17:18:39 +09:00
Jonathan Brouwer
501a26cc6a Rollup merge of #161896 - yara-blue:reflection-refactor-array-slice, r=oli-obk
Remove fields from TypeKind: Array, Slice

Tracking issue rust-lang/rust#146922

Part of the [Refactoring to many methods](https://rust-lang.zulipchat.com/#narrow/channel/572285-goals.2Freflection/topic/Refactoring.20to.20many.20methods/with/592226560) reflection subgoal. See that for the full context. In short for various reasons we are moving from an enum `TypeKind` where the variants hold the types information to one that just tells you the type kind. Separate methods on `TypeId` provide a way to get to the data that used to be in the variant.

r? @oli-obk
2026-09-07 21:27:59 +02:00
Jonathan Brouwer
ea913e9a58 Rollup merge of #162436 - beetrees:rfcs-link-to-book, r=mejrs
Replace links to `github.com/rust-lang/rfcs` with links to the Rust RFC Book

I noticed many error codes link to Rust RFCs via the [source GitHub `.md` files](https://github.com/rust-lang/rfcs/tree/master/text) instead of linking to the [RFC Book](https://rust-lang.github.io/rfcs/). This PR updates those links to point to the RFC book - I also updated any other links to RFCs in the repo (not including subtrees) while I was at it.
2026-09-07 21:27:57 +02:00
Yara
ed8f8b6025 reflection: replace TypeKind::Array field with methods 2026-09-07 21:23:19 +02:00
Yara
2edd31488a reflection: replace TypeKind::Slice's field with TypeId::element_ty 2026-09-07 20:58:18 +02:00
bors
f0bbd8dfa9 Auto merge of #162434 - JonathanBrouwer:rollup-kGs5tvl, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#158153 (avoid spurious lifetime diagnostic in async generic case)
 - rust-lang/rust#160197 (Restrict LLVM inline asm location cookie usage. Fixes rust-lang/rust#150451)
 - rust-lang/rust#162413 (Unconditionally invalidate the library when the compiler changes)
 - rust-lang/rust#162294 (Reflection refactor ptrs)
 - rust-lang/rust#162354 (Make comptime functions ineligible for coverage)
 - rust-lang/rust#162379 (add test ensuring we refuse to const-eval the body of a rustc_do_not_const_check function)
 - rust-lang/rust#162386 (Add a regression test for trailing attributes in doctests)
 - rust-lang/rust#162410 (std: remove exceed whitespace in docs)
 - rust-lang/rust#162420 (mir_build: Don't pass a redundant `scrutinee_span` to some MIR-build methods)
 - rust-lang/rust#162430 (rustc-dev-guide subtree update)
 - rust-lang/rust#162431 (add next-solver FIXMEs)
2026-09-07 15:25:50 +00:00
Jonathan Brouwer
706214d854 Rollup merge of #162294 - yara-blue:reflection-refactor-ptrs, r=oli-obk
Reflection refactor ptrs

Tracking issue rust-lang/rust#146922

Part of the [Refactoring to many methods](https://rust-lang.zulipchat.com/#narrow/channel/572285-goals.2Freflection/topic/Refactoring.20to.20many.20methods/with/592226560) reflection subgoal. See that for the full context. In short for various reasons we are moving from an enum `TypeKind` where the variants hold the types information to one that just tells you the type kind. Separate methods on `TypeId` provide a way to get to the data that used to be in the variant.

Since function pointers have a lot of fields it felt better to keep the `FnPtr` struct we have now then add an intrinsic for each field.

r? @oli-obk
2026-09-07 17:08:09 +02:00
beetrees
ac599d4e90 Replace links to github.com/rust-lang/rfcs with links to the Rust RFC Book 2026-09-07 16:07:24 +01:00
bors
752b9bf879 Auto merge of #162374 - theemathas:VaArgSafe-dyn-incompat, r=clarfonthey
Make `VaArgSafe` dyn-incompatible

This is done just in case we want to later do stuff like adding a `Sized` supertrait.

See discussion at [#t-libs > Should `VaArgSafe` require `Sized`?](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Should.20.60VaArgSafe.60.20require.20.60Sized.60.3F/with/622074620)

r? @clarfonthey
2026-09-07 12:14:19 +00:00
Jacob Pratt
71655777c1 Rollup merge of #162390 - RedDaedalus:fix-raw-get-comment, r=RalfJung
remove outdated comment in `UnsafeCell::raw_get` source

It was decided that UnsafeCell can be accessed mutably without going through `get` (https://github.com/rust-lang/unsafe-code-guidelines/issues/281) and a comment stating that std has special privileges was removed in rust-lang/rust#159730, but that PR missed `raw_get`. This comment actively contradicted `CovariantUnsafeCell`:
5a2be9f5f0/library/core/src/cell/covariant_unsafe_cell.rs (L154-L161)
2026-09-07 04:06:38 -04:00
Jacob Pratt
4e8672fcff Rollup merge of #162319 - bardiharborow:docs/fix-thumbv8m-atomic-cas, r=JohnTitor
docs(core): correct ARMv8-M Baseline atomic CAS support

ARMv8-M Baseline targets support CAS operations, but the atomic module docs incorrectly list them as load and store-only.

The incorrect ARMv8-M Baseline comment was introduced in rust-lang/rust#149241 while updating the atomic portability notes for ARMv4T/ARMv5TE.

Limit that restriction to ARMv6-M and include `thumbv8m.base-*` among the targets with full CAS support.

@rustbot label +A-docs +A-atomic +O-Arm +T-libs
2026-09-07 04:06:35 -04:00
Daedalus
ff721141e7 remove outdated UnsafeCell raw_get comment 2026-09-06 15:43:33 -06:00
Tim (Theemathas Chirananthavat)
16529d723a Make VaArgSafe dyn-incompatible
This is done just in case we want to later do stuff like adding
a `Sized` supertrait.

See discussion at
https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Should.20.60VaArgSafe.60.20require.20.60Sized.60.3F/with/622074620
2026-09-06 21:01:08 +07:00
Jonathan Brouwer
3b6ec47385 Rollup merge of #162158 - kpreid:numbuffer, r=hanna-kruppe
Revise documentation of `NumBuffer` and `format_into()`.

The previous documentation was, in my opinion, overly focused on the implementation of these items, rather than how and when to use them. In particular, this new documentation:

* Begins the `format_into()` documentation with what it does when called.
* Specifies that `format_into()` is a specialized alternative to the more commonly used `Display`.
* Specifies that `NumBuffer` cannot be read or otherwise used by itself.

@rustbot label +A-docs
2026-09-06 11:20:31 +02:00
Jonathan Brouwer
34606c697f Rollup merge of #161607 - kiana1kaslana:track-caller-signed-div, r=Mark-Simulacrum
Add #[track_caller] to signed integer div/rem methods

Fixes rust-lang/rust#139672

The unsigned div/rem methods got #[track_caller] in 724fe8fcfb but
the signed side was missed. This adds it to the 8 signed methods
listed in the issue, including overflowing_div_euclid which the
issue missed but wrapping_div_euclid delegates to.

No test added, matching the unsigned side. cg_gcc doesn't
propagate track_caller through inlined div/rem yet so a runtime
check would fail on the gcc-core-tests CI job.
2026-09-06 11:20:30 +02:00
bors
f207aa3913 Auto merge of #162333 - Zalathar:rollup-DdpfsFl, r=Zalathar
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#162324 (miri subtree update)
 - rust-lang/rust#162170 (bootstrap: use target's LLVM libdir when cross-compiling)
 - rust-lang/rust#158312 (Adds support for AArch64 SVE to inline assembly)
 - rust-lang/rust#159792 (A more readable debug map for IndexMaps)
 - rust-lang/rust#160745 (make closures act like MaybeDangling)
 - rust-lang/rust#161263 (break rustc_expand-rustc_middle dependency)
 - rust-lang/rust#161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment)
 - rust-lang/rust#161940 (Promote `wasm32-wasip3` to a tier 2 target)
 - rust-lang/rust#161397 (coverage: Tidy tests and add some new ones)
 - rust-lang/rust#161616 (Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval)
 - rust-lang/rust#162248 (Add regression test for unsized const parameter default ICE)
 - rust-lang/rust#162250 (Fix hashing of span end columns in incremental compilation)
 - rust-lang/rust#162265 (cargotest: add lockfiles)
 - rust-lang/rust#162318 (bootstrap: Fix broken path for `./x doc compiler/rustc --open`)
2026-09-05 17:04:57 +00:00
Stuart Cook
bdedfdd557 Rollup merge of #161616 - bardiharborow:get-unchecked-index-precondition-const-eval, r=RalfJung
Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval

The precondition check was gated on `check_language_ub`, which is disabled in const-eval and Miri, on the grounds that the `assume` below it is language UB that the interpreter will catch anyway. It does catch it, but only as "`assume` called with `false`", which says nothing about what the caller did wrong.

This PR instead gates the check on `check_library_ub`, matching `get_unchecked_mut`, so that the interpreter reports the violated precondition.

Fixes rust-lang/rust#161611
2026-09-05 23:04:50 +10:00
Bardi Harborow
39745288db Report precondition violation for <usize as SliceIndex>::get_unchecked in const-eval
* Add a test for the diagnostics on `<usize as SliceIndex>::get_unchecked` in const-eval
* Report a precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval

The precondition check was gated on `check_language_ub`, which is disabled in const-eval and Miri, on the grounds that the `assume` below it is language UB that the interpreter will catch anyway. It does catch it, but only as "`assume` called with `false`", which says nothing about what the caller did wrong.

This commit instead gates the check on `check_library_ub`, matching `get_unchecked_mut`, so that the interpreter reports the violated precondition.
* fixup! Report a precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval
* tweak comment

Co-authored-by: Ralf Jung <post@ralfj.de>
2026-09-05 07:33:30 +00:00
Bardi Harborow
a9fd5e0ccb docs(core): correct ARMv8-M Baseline atomic CAS support
ARMv8-M Baseline targets support CAS operations, but the atomic module docs incorrectly list them as load and store-only.

 Limit that restriction to ARMv6-M and include thumbv8m.base-* among the targets with full CAS support.
2026-09-05 15:35:18 +10:00
Kevin Reid
6c2b37483d Revise documentation of NumBuffer and format_into().
The previous documentation was, in my opinion, overly focused on the
implementation of these items, rather than how and when to use them.
This new documentation:

* Begins the `format_into()` documentation with what it does when called.
* Specifies that `format_into()` is a specialized alternative to the more
  commonly used `Display`.
* Specifies that `NumBuffer` cannot be read or otherwise used by itself.
2026-09-04 20:40:17 -07:00
Jonathan Brouwer
2fdc9cdf36 Rollup merge of #162155 - mejrs:rustc_allowed_through_unstable_modules, r=davidtwco
add suggestion for `rustc_allowed_through_unstable_modules` attribute
2026-09-04 22:29:12 +02:00
Yara
06fa642f23 reflection: remove field from TypeKind::FnPtr 2026-09-04 19:28:09 +02:00
Yara
98d68aa8ce reflection: adds TypeId::function_ptr returning FnPtr 2026-09-04 19:27:24 +02:00
Yara
f4cdf28df5 reflection: remove field from TypeKind::Reference 2026-09-04 19:26:30 +02:00
Yara
e46de86eee reflection: make points_to and points_mutably support references 2026-09-04 19:26:30 +02:00
Yara
9c36788af1 reflection: remove field from TypeKind::Pointer variant 2026-09-04 19:26:30 +02:00
Yara
f123df5b07 reflection: adds TypeId::points_to and TypeId::is_mutable_pointer 2026-09-04 19:26:30 +02:00
Ralf Jung
b7e5447e85 simplify ManuallyDrop by making it natively 'like MaybeDangling' 2026-09-04 16:35:10 +02:00
Jonathan Brouwer
6c04f17c6f Rollup merge of #162199 - sorairolake:clarify-hour-minute-seconds, r=jhpratt
docs(time): clarify exact seconds for hour and minute

Documented that `Duration::from_hours` defines one hour as 3,600 seconds (60 minutes), and `Duration::from_mins` defines one minute as 60 seconds.

Doctests for these methods also appear to be based on these definitions.

The purpose of this is to clarify that `Duration` is a fixed length value that ignores factors such as a leap second.

This is inspired by <https://github.com/rust-lang/libs-team/issues/869#issuecomment-5500049965>.

It seems that no library in Rust handle leap seconds, so there isn't much point in documenting this. However, I don't think it would hurt to include it for the sake of consistency with rust-lang/rust#162195.

See also rust-lang/rust#120301

@rustbot label +A-docs
2026-09-03 20:02:58 +02:00
Jonathan Brouwer
98dcf8ca2d Rollup merge of #162195 - sorairolake:clarify-week-day-seconds, r=jhpratt
docs(time): clarify exact seconds for week and day

Documented that `Duration::from_weeks` defines one week as 604,800 seconds (7 days), and `Duration::from_days` defines one day as 86,400 seconds (24 hours).

Doctests for these methods also appear to be based on these definitions.

The purpose of this is to clarify that `Duration` is a fixed length value that ignores factors such as DST or a leap second.

This is inspired by <https://github.com/rust-lang/libs-team/issues/869#issuecomment-5500049965>.

See also rust-lang/rust#120301

@rustbot label +A-docs
2026-09-03 20:02:57 +02:00
Jonathan Brouwer
05d74f6588 Rollup merge of #162191 - ojeda:clamp-inline, r=clarfonthey
core: mark float `ClampBounds` methods as `#[inline]`

Commit bd174e1b20 ("Implement clamp_to") added a few float methods that are not marked `#[inline]`. This causes `core` to require new symbols in soft-float builds, even if the methods are unused, e.g. from the Linux kernel:

    ld.lld: error: undefined symbol: fmaximum_numf
    >>> referenced by core.1f440ee8661e09f9-cgu.0
    >>>               rust/core.o:(<core::ops::range::RangeFrom<f32> as core::cmp:🗜️:ClampBounds<f32>>::clamp) in archive vmlinux.a

(and similar for `f{min,max}imum_num{f,}` and `__gt{s,d}f2`).

It is possible to work around this in the Linux side, but these methods should probably be `#[inline]` to begin with, like many other similar methods are.

Thus mark them as inline.
2026-09-03 20:02:56 +02:00
Jonathan Brouwer
93b5d3fb05 Rollup merge of #161227 - folkertdev:complex-add-sub, r=nia-e
implement `Add` and `Sub` for `Complex`

tracking issue: https://github.com/rust-lang/rust/issues/154023

Adds the `Add` and `Sub` implementations described in the tracking issue. Some notes

- I also added a derive for `Eq`, which is useful for `Complex<{integer}>`
- The versions that add/sub by a scalar need a `Copy` bound. That seems fine for most actual use cases.

Apparently `num_complex` will `Clone` in these operations https://docs.rs/num-complex/latest/num_complex/struct.Complex.html#impl-Add%3CT%3E-for-%26Complex%3CT%3E, but that seems unlike `core` to me. Anyhow, libs can re-litigate that later.
2026-09-03 20:02:50 +02:00
Jonathan Brouwer
c6021880dc Rollup merge of #162076 - sorairolake:clarify-int-try-from-docs, r=JohnTitor
docs(num): clarify conditions under which error occurs in `impl TryFrom<int> for int`

`impl_try_from_unbounded` always returns `Ok(T)`, but the documentation is written as if it may return an error, so I fixed this.

I also clarified that `impl_try_from_lower_bounded` returns an error only when the source value is less than `T::MIN`, and `impl_try_from_upper_bounded` returns an error only when the source value is greater than `T::MAX`.

While the original text

> This returns an error if the source value is outside of the range of the target type.

is fine for both cases, but I think the revised text makes it clearer that the error occurs at either the lower bound or the upper bound.

As for `impl_try_from_both_bounded`, I think the current text is fine, so I have not made any changes to it.
2026-09-03 12:43:09 +02:00
Jonathan Brouwer
e48a722293 Rollup merge of #160564 - RalfJung:volatile-with-trap, r=nikic
volatile: allow accesses to non-AM memory to trap

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/610 by saying that yes, volatile accesses may trap. This also fixes what I believe to be the last case of "time-traveling UB" we have in Rust: with this change, UB always fully sequenced wrt observable events (I/O and volatile accesses). UB can still travel around unobservable events such as non-volatile memory accesses.

For writes, LLVM has already implemented the new semantics for a long time. For reads, LLVM only recently implemented the "may trap" semantics with LLVM 23. We still allow compiling rustc with older versions of LLVM. To (hopefully) prevent old LLVM from screwing this up with optimizations, this PR makes the backend emit an inline asm block *without* `willreturn`, which should prevent optimizations that break programs where a volatile load traps.

Cc @rust-lang/opsem @rust-lang/wg-llvm
2026-09-03 12:42:57 +02:00
Jonathan Brouwer
82b1966132 Rollup merge of #162164 - nnethercote:revert-concat-Debug, r=clarfonthey
Revert "Implement Debug for C-like enums with a concatenated string"

From rust-lang/rust#155452.

Fixes rust-lang/rust#162124.
2026-09-03 12:42:56 +02:00
mejrs
8f316d411d refactor rustc_allowed_through_unstable_modules attribute and lint message 2026-09-03 12:42:20 +02:00
Shun Sakai
cf0c54cda4 docs(time): clarify exact seconds for hour and minute 2026-09-02 23:50:07 +09:00
Shun Sakai
75ff1f50b6 docs(time): clarify exact seconds for week and day 2026-09-02 22:50:47 +09:00
Miguel Ojeda
07c009005b core: mark float ClampBounds methods as #[inline]
Commit bd174e1b20 ("Implement clamp_to") added a few float methods that
are not marked `#[inline]`. This causes `core` to require new symbols
in soft-float builds, even if the methods are unused, e.g. from the
Linux kernel:

    ld.lld: error: undefined symbol: fmaximum_numf
    >>> referenced by core.1f440ee8661e09f9-cgu.0
    >>>               rust/core.o:(<core::ops::range::RangeFrom<f32> as core::cmp:🗜️:ClampBounds<f32>>::clamp) in archive vmlinux.a

(and similar for `f{min,max}imum_num{f,}` and `__gt{s,d}f2`).

It is possible to work around this in the Linux side, but these methods
should probably be `#[inline]` to begin with, like many other similar
methods are.

Thus mark them as inline.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-09-02 14:48:32 +02:00
Ralf Jung
ece2980246 volatile: allow accesses to trap 2026-09-02 14:46:04 +02:00
Nicholas Nethercote
f91c12f29e Revert "Implement Debug for C-like enums with a concatenated string"
From #155452.

Fixes #162124.
2026-09-02 11:05:02 +10:00
Jonathan Brouwer
92f9694ce2 Rollup merge of #162110 - RalfJung:range, r=nia-e
make it clear that Range cannot represent arbitrary ranges

This seems like a useful clarification, though it is already heavily implied by the first sentence in the docs.

What is less clear to me is what type one *should* use to represent arbitrary ranges. Should we recommend `(Bound<T>, Bound<T>)` for that purpose? It seems best-stuied, and is already used for that purpose by the btree collections and in https://github.com/rust-lang/rust/issues/136903. However, I suspect it is also common that one wants to represent an arbitrary range that's bounded on both sides. `RangeInclusive` can represent all those (though representing the empty range is a bit awkward), `Range` cannot.

Nominating for t-libs to get their general vibe on what we want to recommend here, if anything.
2026-09-01 21:26:20 +02:00
Jonathan Brouwer
e2897d777d Rollup merge of #162073 - camsteffen:lib-eat-never, r=clarfonthey
Change some `Infallible` to `!` in std

I believe this desirable since we recommend `!` over `Infallible`, so std follows its own advice. Most changes are to unstable features, but not all. Similar changes in compiler have to wait for a bootstrap update.
2026-09-01 21:26:17 +02:00
Jonathan Brouwer
4679857002 Rollup merge of #161209 - scottmcm:redo-npot, r=clarfonthey
Rework `next_power_of_two` to always be `1 << …`

r? @clarfonthey
Who accidentally nerd-sniped me by mentioning rust-lang/rust#161069

This obviates that PR by reworking the `(checked_)next_power_of_two` logic to calculate the necessary exponent e, then return 2ᵉ, so it's structurally obvious from the IR -- the `shl nuw 1, …` instruction -- that it's always a power of two.

As always, the reason this is tricky is because shifts don't work for `<< Self::BITS`.  The previous code handled that by checking `self <= 1` first, and thus doing a `-1 >> n` where `n < BITS`.  This code instead flips the check: it looks up-front for a value that will wrap (an input above `1 << (BITS - 1)`) and thus by excluding those cases the calculated `1 << n` always has `n < BITS`.  And the codegen tests show that, without needing any `llvm.assume`s, LLVM can take advantage of it to do things like rewriting `%` to masking.  Plus the overflow check optimizes out for constrained inputs like slice lengths.
2026-09-01 21:26:16 +02:00
Ralf Jung
baf382f0f5 make it clear that Range cannot represent arbitrary ranges 2026-09-01 18:14:01 +02:00
Cameron Steffen
dd132214ed Dogfood never type in std 2026-09-01 08:57:20 -05:00
Scott McMurray
f771946e61 Rework next_power_of_two to always be 1 << … 2026-08-31 12:42:39 -07:00
N1ark
edcae4441d Make sin, cos, exp, exp2, log, log2, log10 generic 2026-08-31 18:57:54 +01:00
Shun Sakai
f92efc873b docs(num): clarify conditions under which error occurs 2026-09-01 02:19:18 +09:00
bors
45f215f136 Auto merge of #162046 - jhpratt:rollup-mIDSgO6, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#161301 (libcore: expose volatile atomic operations)
 - rust-lang/rust#161379 (Use better generic type parameter names for `Extend` and `FromIterator`)
 - rust-lang/rust#161926 (borrowck: Restore alias rigidity from HIR typeck)
 - rust-lang/rust#161956 (Remove unused `perform_locally_with_next_solver`)
 - rust-lang/rust#162026 (Emit delayed bug instead of ICEing when `TypeOutlives` goal fails)
 - rust-lang/rust#162034 (Make the LLVM version mismatch ICE a fatal error)
 - rust-lang/rust#162037 (LLVM wrapper cleanups)
 - rust-lang/rust#162043 (_ an unused parameter)
2026-08-31 07:55:09 +00:00