Commit Graph

9538 Commits

Author SHA1 Message Date
bors
d62f33a7c6 Auto merge of #147449 - matthiaskrgr:rollup-njyi5yr, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#145943 (stdlib docs: document lifetime extension for `format_args!`'s arguments)
 - rust-lang/rust#147243 (cmse: disallow `impl Trait` in `cmse-nonsecure-entry` return types)
 - rust-lang/rust#147402 ([rustdoc] Don't serialize & deserialize data that doesn't go OTW)
 - rust-lang/rust#147418 (Fix target list of `link_section`)
 - rust-lang/rust#147429 (Print tip for human error format in runtest)
 - rust-lang/rust#147441 (Fix comments error for Provenance impls)
 - rust-lang/rust#147442 (c-variadic: fix thir-print for `...` without a pattern)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-07 17:37:56 +00:00
Matthias Krüger
bce59abf1e Rollup merge of #145943 - dianne:format-args-assign-docs, r=joboet
stdlib docs: document lifetime extension for `format_args!`'s arguments

Since rust-lang/rust#140748 is stable and rust-lang/rust#92698 is closed, the section about `format_args!`'s argument lifetime limitation is outdated. I've updated it to point to the Reference docs, which will specify lifetime extension rules for builtin macros once rust-lang/reference#1980 or equivalent is merged.

I've also taken the liberty of updating one of the doctests to assign the result of `format_args!` to a variable, both to provide an example and because I think it reads a little better.

r? `@m-ou-se`
2025-10-07 17:42:10 +02:00
Alice Ryhl
76dcb39c24 Adjust error messages 2025-10-05 17:45:27 +00:00
Alice Ryhl
f65250b3dd Document workaround in docs 2025-10-05 17:45:27 +00:00
Alice Ryhl
cd44cd0f63 Improve docs for module 2025-10-05 17:45:27 +00:00
Alice Ryhl
7e1c00dbce Prevent downstream impl DerefMut for Pin<LocalType> 2025-10-05 17:45:24 +00:00
Stuart Cook
a0a4905723 Rollup merge of #147349 - saethlin:panic-immediate-advice, r=Noratrieb
Improve the advice given by panic_immediate_abort

Now that https://github.com/rust-lang/rust/pull/147338 is merged, users should consider using the Cargo support for immediate-aborting panics.
2025-10-05 15:35:05 +11:00
Stuart Cook
80759350c7 Rollup merge of #147337 - ada4a:write-diag-item, r=fmease
Make `fmt::Write` a diagnostic item

I'm working on an enhancement to [`clippy::format_push_string`](https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string), which would suggest an autofix to replace `push_str`/`+=` with `write!`. But that could require importing `std::fmt::Write`, and so I need this diagnostic item to check if it's already in scope.

The reason I called it `FmtWrite` and not just `Write` is that there's already an `IoWrite` defined.
2025-10-05 15:35:04 +11:00
Ben Kimock
b5fb01d67d Improve the advice given by panic_immediate_abort 2025-10-04 15:53:00 -04:00
Matthias Krüger
18388b8420 Rollup merge of #146479 - Qelxiros:mem_conjure_zst, r=scottmcm,tgross35
add mem::conjure_zst

Tracking issue: rust-lang/rust#95383
2025-10-04 17:11:10 +02:00
Matthias Krüger
dbc1e82f25 Rollup merge of #146330 - Marcondiro:unicode-17, r=Manishearth
Bump unicode_data and printables to version 17.0.0

Unicode 17 ~~is not stable yet (release planned for 2025-09-09).~~ [has been released!](https://www.unicode.org/versions/Unicode17.0.0/)

Update Unicode data and printables to [Unicode 17](https://www.unicode.org/versions/Unicode17.0.0/)
2025-10-04 17:11:09 +02:00
Matthias Krüger
47bd38c2f1 Rollup merge of #145685 - Qelxiros:cell_get_cloned, r=programmerjake,tgross35
add CloneFromCell and Cell::get_cloned

Tracking issue: rust-lang/rust#145329
2025-10-04 17:11:08 +02:00
Ada Alakbarova
2688f601dd Make fmt::Write a diagnostic item 2025-10-04 16:07:06 +02:00
Jeremy Smart
a9ab29cdb4 add mem::conjure_zst 2025-10-03 13:30:47 -04:00
Jeremy Smart
08b4641f50 add CloneFromCell and Cell::get_cloned 2025-10-01 18:47:09 -04:00
Matthias Krüger
4b905f9cb0 Rollup merge of #147204 - camsteffen:array-windows-ref, r=joboet
Refactor ArrayWindows to use a slice

[Tracking issue](https://github.com/rust-lang/rust/issues/75027)
2025-10-01 18:42:36 +02:00
Cameron Steffen
5ade7647b7 Change ArrayWindows to use a slice 2025-10-01 08:03:19 -05:00
Stuart Cook
5373eb1268 Rollup merge of #146979 - npmccallum:nanosecs, r=Mark-Simulacrum
constify Default on Nanoseconds
2025-09-29 11:56:42 +10:00
Matthias Krüger
750e902a75 Rollup merge of #146675 - Jules-Bertholet:sync-nonexclusive, r=Mark-Simulacrum
Allow shared access to `Exclusive<T>` when `T: Sync`

Addresses libs-api request in https://github.com/rust-lang/rust/issues/98407#issuecomment-3299348713.

Adds the following trait impls to `Exclusive<T>`, all bounded on `T: Sync`:

- `AsRef<T>`
- `Clone`
- `Copy`
- `PartialEq`
- `StructuralPartialEq`
- `Eq`
- `Hash`
- `PartialOrd`
- `Ord`
- `Fn`

``@rustbot`` label T-libs-api
2025-09-28 18:13:12 +02:00
Matthias Krüger
641bedabb1 Rollup merge of #147095 - fmease:libprivrepr, r=dtolnay
Library: Remove remaining private `#[repr]` workarounds

With https://github.com/rust-lang/rust/pull/116882 finally merged, gating these `repr`s behind cfg `not(doc)` is no longer necessary to achieve a private repr.

Follow up to https://github.com/rust-lang/rust/pull/128046 (that was enabled via https://github.com/rust-lang/rust/pull/115439). With that, https://github.com/rust-lang/rust/pull/116743 is now fully realized at long last.

cc ``@dtolnay``
2025-09-28 09:15:29 +02:00
Matthias Krüger
ad864de2c3 Rollup merge of #147082 - danielverkamp:fmt-alternate-octal-binary-mixup, r=Noratrieb
formatting_options: fix alternate docs 0b/0o mixup

The descriptions of the alternate forms of Octal and Binary were swapped in the doc comment for FormattingOptions::alternate().
2025-09-28 09:15:27 +02:00
Matthias Krüger
bd2e18671d Rollup merge of #147076 - joshuarayton:more-float-constants-issue, r=tgross35
update issue number for more_float_constants

Update issue number from https://github.com/rust-lang/rust/issues/103883 to https://github.com/rust-lang/rust/issues/146939

r? ``@tgross35``
2025-09-27 21:26:00 +02:00
Matthias Krüger
01c17f83cf Rollup merge of #146037 - aapoalas:reborrow-lang-experiment, r=tmandry
Introduce CoerceShared lang item and trait, and basic Reborrow tests

Part of rust-lang/rust#145612: This introduces the `CoerceShared` trait which is the `Reborrow` equivalent of a `&mut T` -> `&T` coercion. The trait has a `Target` GAT which makes this (currently) unique in the `core/src/marker.rs`; I'm not sure if this can be considered problematic. Maybe this is not the way such things should be done at the marker trait level? Or maybe it is fine.

Improtantly, this PR introduces a battery of basic `Reborrow` and `CoerceShared` tests. These test the very basics of the feature; custom marker types intended to have exclusive semantics (`Custom<'a>(PhantomData<&'a mut ()>)`), custom exclusive reference wrappers, and standard library exclusive reference wrappers (`Pin<&mut T>` and `Option<&mut T>`). None of these of course work since the implementation for `Reborrow` and `CoerceShared` is entirely missing, but this is the first step towards making these work.

Future PRs will introduce more tests, such as "recursive" reborrowing (ie. reborrowing structs that contain multiple reborrowable fields) and checks around the lifetime semantics of reborrowing ie. that a reborrow produces a new type with the same lifetime as the original.
2025-09-27 21:25:56 +02:00
León Orell Valerian Liehr
35e582f982 Library: Remove remaining private #[repr] workarounds
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2025-09-27 17:09:01 +02:00
Guillaume Gomez
254a2139f6 Remove cfg(bootstrap) for doc_cfg feature following #141925 2025-09-27 11:29:49 +02:00
Guillaume Gomez
fccba2c341 Remove doc_cfg_hide feature 2025-09-27 11:29:49 +02:00
Guillaume Gomez
7c00bccd3b Implement RFC 3631 2025-09-27 11:29:48 +02:00
Daniel Verkamp
97f64374a9 formatting_options: fix alternate docs 0b/0o mixup
The descriptions of the alternate forms of Octal and Binary were swapped
in the doc comment for FormattingOptions::alternate().
2025-09-26 16:32:54 -07:00
Mark Rousskov
4e9716fbc5 Update CURRENT_RUSTC_VERSION post-bump 2025-09-26 18:41:32 -04:00
Aapo Alasuutari
e88fa086fb move Reborrow to ops, fix fmt issues 2025-09-27 01:11:01 +03:00
Joshua Rayton
2e904c4d07 update issue number for more_float_constants 2025-09-26 18:35:29 +01:00
bors
7ac0330c6d Auto merge of #147037 - matthiaskrgr:rollup-xtgqzuu, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#116882 (rustdoc: hide `#[repr]` if it isn't part of the public ABI)
 - rust-lang/rust#135771 ([rustdoc] Add support for associated items in "jump to def" feature)
 - rust-lang/rust#141032 (avoid violating `slice::from_raw_parts` safety contract in `Vec::extract_if`)
 - rust-lang/rust#142401 (Add proper name mangling for pattern types)
 - rust-lang/rust#146293 (feat: non-panicking `Vec::try_remove`)
 - rust-lang/rust#146859 (BTreeMap: Don't leak allocators when initializing nodes)
 - rust-lang/rust#146924 (Add doc for `NonZero*` const creation)
 - rust-lang/rust#146933 (Make `render_example_with_highlighting` return an `impl fmt::Display`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-25 20:35:49 +00:00
Matthias Krüger
781f71a6fe Rollup merge of #146924 - cptpiepmatz:doc-nonzero-const-creation, r=joboet
Add doc for `NonZero*` const creation

I ran into trouble using `NonZero*` values because I didn’t see any clear way to create them at compile time. At first I ended up using `NonZero*::new_unchecked` a lot, until I realized that `Option::unwrap` and `Option::expect` are `const` and can be used in a `const` context. With that, you can create non-zero values at compile time safely, without touching `unsafe`. This wasn’t obvious to me and my peers who’ve been using Rust for a while, so I thought adding a note to the docs would make it easier for others to discover.

If this should be worded differently or placed in another location, we can do that. I just want to make this more obvious.
2025-09-25 18:15:10 +02:00
Tim 'Piepmatz' Hesse
185ae698aa add doc for NonZero* const creation 2025-09-25 17:52:24 +02:00
bors
6f34f4ee07 Auto merge of #147019 - Zalathar:rollup-boxzbmo, r=Zalathar
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#145067 (RawVecInner: add missing `unsafe` to unsafe fns)
 - rust-lang/rust#145277 (Do not materialise X in [X; 0] when X is unsizing a const)
 - rust-lang/rust#145973 (Add `std` support for `armv7a-vex-v5`)
 - rust-lang/rust#146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization)
 - rust-lang/rust#146735 (unstably constify float mul_add methods)
 - rust-lang/rust#146737 (f16_f128: enable some more tests in Miri)
 - rust-lang/rust#146766 (Add attributes for #[global_allocator] functions)
 - rust-lang/rust#146905 (llvm: update remarks support on LLVM 22)
 - rust-lang/rust#146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`)
 - rust-lang/rust#147005 (Small string formatting cleanup)
 - rust-lang/rust#147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`)
 - rust-lang/rust#147008 (bootstrap.py: Respect build.jobs while building bootstrap tool)
 - rust-lang/rust#147013 (rustdoc: Fix documentation for `--doctest-build-arg`)
 - rust-lang/rust#147015 (Use `LLVMDisposeTargetMachine`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-25 14:03:21 +00:00
Stuart Cook
8e62f95376 Rollup merge of #146735 - Qelxiros:const_mul_add, r=tgross35,RalfJung
unstably constify float mul_add methods

Tracking issue: rust-lang/rust#146724
r? `@tgross35`
2025-09-25 20:31:54 +10:00
bors
7cfd7d328b Auto merge of #147003 - matthiaskrgr:rollup-b5z9uiz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#146556 (Fix duration_since panic on unix when std is built with integer overflow checks)
 - rust-lang/rust#146679 (Clarify Display for error should not include source)
 - rust-lang/rust#146753 (Improve the pretty print of UnstableFeature clause)
 - rust-lang/rust#146894 (Improve derive suggestion of const param)
 - rust-lang/rust#146950 (core: simplify `CStr::default()`)
 - rust-lang/rust#146958 (Fix infinite recursion in Path::eq with String)
 - rust-lang/rust#146971 (fix ICE in writeback due to bound regions)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-25 10:30:50 +00:00
Matthias Krüger
6618ac7bb1 Rollup merge of #146950 - joboet:cstr_default, r=tgross35
core: simplify `CStr::default()`

Just use a `CStr`-literal...
2025-09-24 23:33:27 +02:00
Jeremy Smart
a00f24116e unstably constify float mul_add methods
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-09-24 15:21:31 -04:00
Stepan Koltsov
a9554b4d5f Clarify Display for error should not include source 2025-09-24 20:02:35 +01:00
Matthias Krüger
2320fc3a38 Rollup merge of #146915 - clarfonthey:safe-intrinsics-2, r=RalfJung
Make missed precondition-free float intrinsics safe

So, in my defence, these were both separated out from the other intrinsics in the file *and* had a different safety comment in the stable versions, so, I didn't notice them before. But, in my offence, the entire reason I did the previous PR was because I was using them for SIMD intrinsic fallbacks, and `fabs` is needed for those too, so, I don't really have an excuse.

Extra follow-up to rust-lang/rust#146683.

r? ```@RalfJung``` who reviewed the previous one

These don't appear to be used anywhere outside of the standard locations, at least.
2025-09-24 20:34:22 +02:00
Nathaniel McCallum
d910253165 constify Default on Nanoseconds 2025-09-24 09:21:44 -04:00
joboet
aa537824c4 core: simplify CStr::default()
Just use a `CStr`-literal...
2025-09-24 00:50:36 +02:00
ltdk
e8a8e061bf Make missed precondition-free float intrinsics safe 2025-09-23 18:15:11 -04:00
Matthias Krüger
c2e11d7e43 Rollup merge of #146818 - npmccallum:total_cmp, r=fee1-dead
constify {float}::total_cmp()
2025-09-23 23:40:27 +02:00
Matthias Krüger
076ada52d3 Rollup merge of #146632 - ctz:jbp-adaptor-spelling, r=petrochenkov
Fix uses of "adaptor"

These docs are in en_US, so "adapter" is the correct spelling (and indeed used in the next line.)

A second commit comes along for the ride to fix other instances in non-rustdoc comments.
2025-09-23 18:13:51 +02:00
bors
4056082360 Auto merge of #146317 - saethlin:panic=immediate-abort, r=nnethercote
Add panic=immediate-abort

MCP: https://github.com/rust-lang/compiler-team/issues/909

This adds a new panic strategy, `-Cpanic=immediate-abort`. This panic strategy essentially just codifies use of `-Zbuild-std-features=panic_immediate_abort`. This PR is intended to just set up infrastructure, and while it will change how the compiler is invoked for users of the feature, there should be no other impacts.

In many parts of the compiler, `PanicStrategy::ImmediateAbort` behaves just like `PanicStrategy::Abort`, because actually most parts of the compiler just mean to ask "can this unwind?" so I've added a helper function so we can say `sess.panic_strategy().unwinds()`.

The panic and unwind strategies have some level of compatibility, which mostly means that we can pre-compile the sysroot with unwinding panics then the sysroot can be linked with aborting panics later. The immediate-abort strategy is all-or-nothing, enforced by `compiler/rustc_metadata/src/dependency_format.rs` and this is tested for in `tests/ui/panic-runtime/`. We could _technically_ be more compatible with the other panic strategies, but immediately-aborting panics primarily exist for users who want to eliminate all the code size responsible for the panic runtime. I'm open to other use cases if people want to present them, but not right now. This PR is already large.

`-Cpanic=immediate-abort` sets both `cfg(panic = "immediate-abort")` _and_ `cfg(panic = "abort")`. bjorn3 pointed out that people may be checking for the abort cfg to ask if panics will unwind, and also the sysroot feature this is replacing used to require `-Cpanic=abort` so this seems like a good back-compat step. At least for the moment. Unclear if this is a good idea indefinitely. I can imagine this being confusing.

The changes to the standard library attributes are purely mechanical. Apart from that, I removed an `unsafe` we haven't needed for a while since the `abort` intrinsic became safe, and I've added a helpful diagnostic for people trying to use the old feature.

To test that `-Cpanic=immediate-abort` conflicts with other panic strategies, I've beefed up the core-stubs infrastructure a bit. There is now a separate attribute to set flags on it.

I've added a test that this produces the desired codegen, called `tests/run-make-cargo/panic-immediate-abort-codegen/` and also a separate run-make-cargo test that checks that we can build a binary.
2025-09-23 06:37:03 +00:00
bors
ce4beebecb Auto merge of #146683 - clarfonthey:safe-intrinsics, r=RalfJung,Amanieu
Mark float intrinsics with no preconditions as safe

Note: for ease of reviewing, the list of safe intrinsics is sorted in the first commit, and then safe intrinsics are added in the second commit.

All *recently added* float intrinsics have been correctly marked as safe to call due to the fact that they have no preconditions. This adds the remaining float intrinsics which are safe to call to the safe intrinsic list, and removes the unsafe blocks around their calls.

---

Side note: this may want a try run before being added to the queue, since I'm not sure if there's any tier-2 code that uses these intrinsics that might not be tested on the usual PR flow. We've already uncovered a few places in subtrees that do this, and it's worth double-checking before clogging up the queue.
2025-09-22 14:35:46 +00:00
Nathaniel McCallum
5dde557fc4 constify {float}::total_cmp() 2025-09-22 10:24:39 -04:00
Ralf Jung
7d0012914e assert_unsafe_precondition: fix some incorrect check_language_ub 2025-09-22 09:28:38 +02:00