9803 Commits

Author SHA1 Message Date
Matthias Krüger
847c422cea
Rollup merge of #147171 - Qelxiros:hashmap_diag, r=fee1-dead
recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher

closes rust-lang/rust#147147

~The suggestion span is wrong, but I'm not sure how to find the right one.~ fixed

I'm relatively new to the diagnostics ecosystem, so I'm not sure if `span_help` is the right choice. `span_suggestion_*` might be better, but the output from `x test` looks weird in that case.
2025-11-19 09:48:05 +01:00
Shun Sakai
a25950dec6 feat: Change return type of NonZero::bit_width
Return `NonZero<u32>` instead of `u32`.
2025-11-19 03:17:38 +09:00
Matthias Krüger
e6d08c6521
Rollup merge of #147887 - matthieu-m:task/lib-core-sync-atomic-fence-doc-improvement, r=Mark-Simulacrum
Improve the documentation of atomic::fence

Attempt to "fix" two flaws of the current documentation:

1. The over-emphasis of fence - fence synchronization, relegating atomic - fence and fence - atomic synchronization to second fiddle.
2. The lack of explanation as to how to properly perform atomic - fence and fence - atomic synchronization.

It does so by first making it clear that there are 3 different ways to use an atomic fence, then presenting a full example for each usecase, noting the particular position of the fence with regard to the atomic operation, and rounding up with generic notes.
2025-11-18 16:52:10 +01:00
Camille Gillot
aeb9332b28 Complete doc. 2025-11-18 00:10:04 +00:00
Camille Gillot
12e91cf814 Honor allow_internal_unstable for const intrinsics. 2025-11-18 00:10:03 +00:00
Camille Gillot
72444372ae Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
Tamir Duberstein
1cfd0b7c55
Match <OsString as Debug>::fmt to that of str
819247f1 changed <str as Debug>::fmt such that it does not escape single
quotes, but neglected to apply the same choice to OsString. This commit
does that.
2025-11-17 16:05:00 -05:00
Matthieu M
5431c6fd8e Improve the documentation of atomic::fence
Attempt to "fix" two flaws of the current documentation:

1. The over-emphasis of fence - fence synchronization, relegating
   atomic - fence and fence - atomic synchronization to second fiddle.
2. The lack of explanation as to how to properly perform atomic - fence
   and fence - atomic synchronization.

It does so by first making it clear that there are 3 different ways to
use an atomic fence, then presenting a full example for each usecase,
noting the particular position of the fence with regard to the atomic
operation, and rounding up with generic notes.
2025-11-17 18:12:43 +01:00
Matthias Krüger
4e5c61e932
Rollup merge of #148504 - NeatNit:intlong, r=ibraheemdev
Fix link in c_longlong documentation

Ran across this mistake when reading [the documentation](https://doc.rust-lang.org/std/ffi/type.c_longlong.html). I went through the other `.md` files in this directory and didn't spot any other errors.

**I did not check the output of this change** - I couldn't figure out how to get `cargo doc` to work and I figured it's not worth the distraction. It can't really go wrong, can it?
2025-11-17 18:07:32 +01:00
Matthias Krüger
5dd82e8ed9
Rollup merge of #145610 - GrigorenkoPV:char_max_len, r=Amanieu
Stabilize `char_max_len`

Tracking issue: rust-lang/rust#121714

r? t-libs-api

`@rustbot` label +needs-fcp -T-libs +T-libs-api

Closes rust-lang/rust#121714
2025-11-17 18:07:31 +01:00
Jeremy Smart
754a82d87c
recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher 2025-11-17 11:56:21 -05:00
bors
cc328c1238 Auto merge of #149013 - Zalathar:rollup-io1ddhc, r=Zalathar
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#148505 (add larger test for `proc_macro` `FromStr` implementations)
 - rust-lang/rust#148752 (Constify `ManuallyDrop::take`)
 - rust-lang/rust#148757 (Constify `mem::take`)
 - rust-lang/rust#148855 (Error if an autodiff user does not set lto=fat)
 - rust-lang/rust#148912 (add note to `lines` docs about empty str behavior)
 - rust-lang/rust#148958 (Run codegen tests on a 32-bit target in PR CI)
 - rust-lang/rust#148994 (Abi compatibility test cleanup)
 - rust-lang/rust#148999 (Tweak Motor OS linker preset, fix `remote-test-server` for Motor OS)
 - rust-lang/rust#149004 (compiletest: Avoid race condition in file deletion)
 - rust-lang/rust#149008 (triagebot: remove jsha from notifications for rustdoc HTML)
 - rust-lang/rust#149010 (compiletest: Remove the "wasm32-bare" alias for `wasm32-unknown-unknown`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-17 07:49:48 +00:00
Stuart Cook
47585c9f48
Rollup merge of #148912 - msmoiz:main, r=scottmcm
add note to `lines` docs about empty str behavior

This pull request adds a short note to the documentation for `str::lines` that describes the behavior of the resulting iterator when called on an empty string. I tripped over this a few days ago because I thought (incorrectly) that the iterator would return a single line with an empty string. I don't doubt that the actual behavior (return no lines) is the correct behavior, but in the absence of explicit documentation describing it, I came to the wrong conclusion about it and maybe others will too. If this is so obvious as to be not worth including, I'm happy to withdraw the pull request! Thanks for taking a look.
2025-11-17 16:41:03 +11:00
Stuart Cook
6fe5c1d544
Rollup merge of #148757 - nxsaken:const_mem_take, r=scottmcm
Constify `mem::take`

Feature: `const_default` (rust-lang/rust#143894)
2025-11-17 16:41:02 +11:00
Stuart Cook
dd9b8e65a4
Rollup merge of #148752 - nxsaken:const_manually_drop_take, r=scottmcm
Constify `ManuallyDrop::take`

Feature: `const_manually_drop_take`
Tracking issue: rust-lang/rust#148773

This PR constifies `ManuallyDrop::take`.
2025-11-17 16:41:01 +11:00
bors
89fe96197d Auto merge of #148478 - RalfJung:rotating-funnel, r=Mark-Simulacrum
use funnel shift as fallback impl for rotating shifts

That lets us remove this gnarly implementation from Miri and const-eval.

However, `rotate_left`/`rotate_right` are stable as const fn, so to do this we have to `rustc_allow_const_fn_unstable` a bunch of const trait stuff. Is that a bad idea? Cc `@oli-obk` `@fee1-dead`
2025-11-17 04:36:16 +00:00
Manuel Drehwald
f5892da3f2 add autodiff examples 2025-11-16 23:35:37 -05:00
Matthias Krüger
79d765ed38
Rollup merge of #148703 - pitaj:rangefrom-overflow_checks, r=Mark-Simulacrum
Use `overflow_checks` intrinsic so `IterRangeFrom` yields MAX before panicking in debug

Based on rust-lang/rust#128666. For your convenience, here is the [diff from that PR](https://github.com/pitaj/rust/compare/intrinsic-overflow_checks...pitaj:rust:rangefrom-overflow_checks).

When `overflow_checks` are enabled, the following code will output as shown
```rust
for n in std::range::RangeFrom::from(253_u8..) {
    println!("{n}");
}
// 253
// 254
// 255
// panic
```

Which is a change from the current behavior, where it will panic after printing 254.

This behavior was [requested by the libs team](https://github.com/rust-lang/rust/issues/125687#issuecomment-2151118208)

r? `@Mark-Simulacrum`
2025-11-16 20:40:22 +01:00
bors
e1a2ec6051 Auto merge of #148259 - RalfJung:const-ptr-fragment, r=oli-obk
const-eval: fix and re-enable pointer fragment support

The pointer fragment support from https://github.com/rust-lang/rust/pull/144081 got disabled due to https://github.com/rust-lang/rust/issues/146291. This brings it back. To fix the issue, the per-byte provenance fragment tracking tracks *both* the provenance and raw address of the full pointer, so we can ensure that only fragments that are truly part of the same pointer are being merged.

r? `@oli-obk`
Cc `@theemathas`
Fixes https://github.com/rust-lang/const-eval/issues/72 again.
Also fixes https://github.com/rust-lang/rust/issues/147959.

`@traviscross` I assume this won't need another t-lang FCP since it already got FCP'd in rust-lang/rust#144081?
2025-11-16 07:09:45 +00:00
Peter Jaszkowiak
0e5c96c3ec IterRangeFrom: overflow panic after yielding MAX
check overflow after yielding MAX value
new `0_u8..` will yield `255` and only panic on the subsequent `next()`
2025-11-15 21:29:59 -07:00
Peter Jaszkowiak
6d2eb33391 fix a couple unstable attributes 2025-11-15 21:29:59 -07:00
Stuart Cook
8ea74b1a8f
Rollup merge of #148836 - ericseppanen:primitive_reference_docs, r=Mark-Simulacrum
tweak primitive reference docs

This is a docs-only change for primitive reference.

I noticed a typo ("safe to use at type `T`") and fixed it to read "safe to use *as* type `T`".

While reading over the whole page, I also noticed another sentence that was hard to read. I tried to improve it: feel free to comment on the wisdom of this change...
2025-11-16 14:39:59 +11:00
Stuart Cook
ec2f7397ce
Rollup merge of #148827 - GoldsteinE:stabilize-vec-into-raw-parts, r=Mark-Simulacrum
Stabilize vec_into_raw_parts

This stabilizes `Vec::into_raw_parts()` and `String::into_raw_parts()` per FCP in https://github.com/rust-lang/rust/issues/65816#issuecomment-3517630971. While this _does not_ stabilize `Vec::into_parts()`, I fixed up the examples that said they were waiting for `vec_into_raw_parts`. As `Vec::from_parts()` and `Vec::into_parts()` are covered by the same feature `box_vec_non_null`, any doctest that uses `Vec::from_parts()` can also use `Vec::into_parts()` (and same for allocator-aware versions).

Closes rust-lang/rust#65816

``@rustbot`` modify labels: +T-libs-api
2025-11-16 14:39:58 +11:00
bors
54f417673c Auto merge of #148526 - reddevilmidzy:docs, r=Mark-Simulacrum
Expand pow docs with special-case tests

resolve: rust-lang/rust#148316

Files changed:

* library/std/src/num: f32.rs, f64.rs,
  * powi
  * powf
* library/std/src/num: f16.rs, f128.rs
  * powf
* library/core/src/num: f16.rs, f128.rs
  * powi
* library/core/src/num: int_macros.rs, uint_macros.rs
  * checked_pow
  * strict_pow
  * saturating_pow
  * wrapping_pow
  * overflowing_pow
  * pow
2025-11-15 22:01:14 +00:00
Ralf Jung
907fd85e16 const-eval: fix and re-enable pointer fragment support 2025-11-15 10:09:42 +01:00
bors
b6d7ff3aa7 Auto merge of #148944 - theemathas:rm_inherit_overflow, r=joboet
Remove `rustc_inherit_overflow_checks` from `position()` in slice iterators

This method implementation can never cause an overflow, since `i` can never go over the slice's length.
2025-11-14 18:47:43 +00:00
Pavel Grigorenko
f9dcc6b21c Stabilize char_max_len 2025-11-14 18:23:19 +03:00
Theemathas Chirananthavat
8d075ae0aa Remove rustc_inherit_overflow_checks from position() in slice iterators
This method implementation can never cause an overflow,
since `i` can never go over the slice's length.
2025-11-14 20:12:11 +07:00
bors
c91009892b Auto merge of #148940 - dtolnay:implarguments, r=joboet
Combine `impl<'a> Arguments<'a>` blocks

This makes a difference in the documentation rendered by rustdoc.

**Before:**

<p align="center"><img width="700" src="https://github.com/user-attachments/assets/cd5cc519-a8fa-4409-a347-f5a19638efc1" /></p>

**After:**

<p align="center"><img width="700" src="https://github.com/user-attachments/assets/4c6a9564-7f46-4879-a085-51715453bbae" /></p>
2025-11-14 12:19:17 +00:00
David Tolnay
85332e39d2
Combine impl<'a> Arguments<'a> blocks 2025-11-14 02:12:43 -08:00
Stuart Cook
f61bfb0037
Rollup merge of #148725 - scottmcm:experiment-new-try-block-v3, r=petrochenkov
Implement the alternative `try` block desugaring

As discussed in https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727, update the `try` in nightly to match the RFC as a way to experiment.

This addresses the following unresolved issue from https://github.com/rust-lang/rust/issues/31436

>  Address issues with type inference (`try { expr? }?` currently requires an explicit type annotation somewhere).
2025-11-14 19:57:06 +11:00
Scott McMurray
e5803fceed Move into_try_type to a free function 2025-11-13 19:53:02 -08:00
Stuart Cook
355e4cf8d6
Rollup merge of #148906 - m-ou-se:fmt-args-from-str, r=dtolnay
Expose fmt::Arguments::from_str as unstable.

Now that https://github.com/rust-lang/rust/pull/148789 is merged, we can have a fmt::Arguments::from_str. I don't know if we want to commit to always having an implementation that allows for this, but we can expose it as unstable for now so we can play with it.

Tracking issue: https://github.com/rust-lang/rust/issues/148905
2025-11-14 13:14:08 +11:00
Stuart Cook
7481e91e65
Rollup merge of #148826 - btj:cstr-docs, r=joboet
CStr docs: Fix CStr vs &CStr confusion

The CStr documentation used to say things about CStr that are only true for &CStr.

Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
2025-11-14 13:14:01 +11:00
msmoiz
e628b059bb update language from "no lines" to "empty iterator" 2025-11-13 16:44:07 -08:00
msmoiz
4996edc53d add note to lines docs about empty str behavior 2025-11-13 08:36:22 -08:00
Mara Bos
ad1789a5f0 Expose fmt::Arguments::from_str as unstable. 2025-11-13 15:57:51 +01:00
bors
af5c5b74c8 Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Simulacrum,oli-obk
stabilize duration_from_nanos_u128

libs-api FCP passed in https://github.com/rust-lang/rust/issues/139201.
Closes https://github.com/rust-lang/rust/issues/139201.

`@oli-obk` would you prefer if we did a const-hack to avoid allowing `const_trait_impl` here?
2025-11-13 14:48:17 +00:00
Mara Bos
83a0d71e6d Add comment. 2025-11-12 14:33:41 +01:00
Mara Bos
2a14add94d Clarify comment. 2025-11-12 14:31:11 +01:00
Mara Bos
fda03011ef Fix comment about potential niche in FormattingOptions. 2025-11-12 14:25:37 +01:00
Mara Bos
8b20d0d0a1 Allow larger string pieces in fmt::Arguments repr. 2025-11-12 12:48:44 +01:00
Mara Bos
3f85b01256 Clarify internal fmt::Arguments documentation. 2025-11-12 12:48:43 +01:00
Mara Bos
04c5e7b54a Document fmt::Arguments internal representation. 2025-11-12 12:48:39 +01:00
Mara Bos
564c78fe62 Remove the 'always set' bit from FormattingOptions.
We don't need it anymore.
2025-11-12 12:48:37 +01:00
Mara Bos
d66d15be2b New format_args!()+fmt::Arguments implementation. 2025-11-12 12:45:40 +01:00
Eric Seppanen
cac1f99d6d fix typo in primitive reference docs 2025-11-11 11:47:50 -08:00
Eric Seppanen
7b09e1c82b improve primitive reference PartialEq docs
This sentence was unnecessarily complex; try to simplify it.
2025-11-11 11:47:50 -08:00
Bart Jacobs
a56fc9c213
Some tweaks 2025-11-11 19:56:48 +01:00
Max Siling
ac9bb13267
Stabilize vec_into_raw_parts 2025-11-11 20:24:29 +03:00