306470 Commits

Author SHA1 Message Date
Matthias Krüger
c6d0059fb8
Rollup merge of #146933 - yotamofek:pr/rustdoc/highlight_no_write_str, r=GuillaumeGomez
Make `render_example_with_highlighting` return an `impl fmt::Display`

Removes some more usages of `write_str`. Shouldn't affect runtime, but makes the codebase a bit more consistent.
Each commit can be reviewed separately
2025-09-25 18:15:11 +02: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
Matthias Krüger
83cf8f9860
Rollup merge of #146859 - cammeresi:btree-alloc-20250920, r=joboet
BTreeMap: Don't leak allocators when initializing nodes

Memory was allocated via `Box::leak` and thence intended to be tracked and deallocated manually, but the allocator was also leaked, not tracked, and never dropped.  Now it is dropped immediately.

According to my reading of the `Allocator` trait, if a copy of the allocator remains live, then its allocations must remain live.  Since the B-tree has a copy of the allocator that will only be dropped after the nodes, it's safe to not store the allocator in each node (which would be a much more intrusive change).

Fixes: rust-lang/rust#106203
2025-09-25 18:15:09 +02:00
Matthias Krüger
fea9196e52
Rollup merge of #146293 - BenjaminBrienen:try_remove, r=joboet
feat: non-panicking `Vec::try_remove`

`if index < my_vector.len() { Some(my_vector.remove(index)) } else { None }` is annoying to write and non-panicking functions are broadly useful.

APC: https://github.com/rust-lang/libs-team/issues/649

Tracking issue: https://github.com/rust-lang/rust/issues/146954
2025-09-25 18:15:09 +02:00
Matthias Krüger
958d1438b6
Rollup merge of #142401 - oli-obk:pattern-mango, r=petrochenkov
Add proper name mangling for pattern types

requires adding demangler support first https://github.com/rust-lang/rustc-demangle/pull/81

needed for https://github.com/rust-lang/rust/pull/136006#discussion_r2139792593 as otherwise we will have symbol collisions
2025-09-25 18:15:08 +02:00
Matthias Krüger
e3f7626732
Rollup merge of #141032 - petrosagg:extract-if-ub, r=joboet
avoid violating `slice::from_raw_parts` safety contract in `Vec::extract_if`

The implementation of the `Vec::extract_if` iterator violates the safety contract adverized by `slice::from_raw_parts` by always constructing a mutable slice for the entire length of the vector even though that span of memory can contain holes from items already drained. The safety contract of `slice::from_raw_parts` requires that all elements must be properly
initialized.

As an example we can look at the following code:

```rust
let mut v = vec![Box::new(0u64), Box::new(1u64)];
for item in v.extract_if(.., |x| **x == 0) {
    drop(item);
}
```

In the second iteration a `&mut [Box<u64>]` slice of length 2 will be constructed. The first slot of the slice contains the bitpattern of an already deallocated box, which is invalid.

This fixes the issue by only creating references to valid items and using pointer manipulation for the rest. I have also taken the liberty to remove the big `unsafe` blocks in place of targetted ones with a SAFETY comment. The approach closely mirrors the implementation of `Vec::retain_mut`.

**Note to reviewers:** The diff is easier to follow with whitespace hidden.
2025-09-25 18:15:07 +02:00
Matthias Krüger
a028b7a9e3
Rollup merge of #135771 - GuillaumeGomez:jump-to-def-perf, r=fmease
[rustdoc] Add support for associated items in "jump to def" feature

Fixes https://github.com/rust-lang/rust/issues/135485.

r? ``@fmease``
2025-09-25 18:15:06 +02:00
Matthias Krüger
a39d5134cd
Rollup merge of #116882 - fmease:rustdoc-generalized-priv-repr-heuristic, r=rustdoc
rustdoc: hide `#[repr]` if it isn't part of the public ABI

> [!IMPORTANT]
> Temporarily stacked on top of PR https://github.com/rust-lang/rust/pull/146527; only the last commit is relevant!

Follow-up to rust-lang/rust#115439.
Unblocks rust-lang/rust#116743, CC ``@dtolnay.``

Fixes rust-lang/rust#66401.
Fixes rust-lang/rust#128364.
Fixes rust-lang/rust#137440.

Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise.

`--document-{private,hidden}-items` works as expected in this context, too.

Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
2025-09-25 18:15:06 +02:00
Tim 'Piepmatz' Hesse
185ae698aa add doc for NonZero* const creation 2025-09-25 17:52:24 +02: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
León Orell Valerian Liehr
85c193a4ed
rustdoc: hide #[repr(...)] if it isn't part of the public ABI 2025-09-25 11:49:27 +02:00
León Orell Valerian Liehr
d7d7725b8c
rustdoc: Fully escape link section and export name
Escape "special characters" (e.g., double quotes `"` and line breaks `\n`).
Escape HTML.

Lastly, add regression tests and clean up existing tests.
2025-09-25 11:30:58 +02:00
León Orell Valerian Liehr
88e797784e
rustdoc: Slightly clean up attr rendering 2025-09-25 10:16:52 +02:00
bors
bbcbc7818b Auto merge of #146981 - weihanglo:update-cargo, r=weihanglo
Update cargo submodule

17 commits in 966f94733bbc94ca51ff9f1e4c49ad250ebbdc50..f2932725b045d361ff5f18ba02b1409dd1f44e71
2025-09-16 17:24:45 +0000 to 2025-09-24 11:31:26 +0000
- fix: use `host-tuple` for host target subsitution (rust-lang/cargo#16003)
- test(build-std): move away from panic_immediate_abort  (rust-lang/cargo#16006)
- fix: Sparse URLs in `TomlLockfileSourceId` (rust-lang/cargo#15990)
- refactor(gctx): extract toml dotted keys validation (rust-lang/cargo#15998)
- feat: Add lint for global use of `hint-mostly-unused` (rust-lang/cargo#15995)
- Make GlobalContext Sync (rust-lang/cargo#15967)
- chore(deps): update cargo-semver-checks to v0.44.0 (rust-lang/cargo#15993)
- fix(frontatter): Only allow horizontal whitespace after fences (rust-lang/cargo#15975)
- docs: Add Lockfile schemas docs (rust-lang/cargo#15989)
- Add parallel frontend to the build performance guide (rust-lang/cargo#15970)
- chore(deps): update msrv (3 versions) to v1.88 (rust-lang/cargo#15988)
- chore(deps): update msrv (1 version) to v1.90 (rust-lang/cargo#15984)
- feat(cargo-util-schemas): Move lockfile schemas (rust-lang/cargo#15980)
- Clarify multiple version requirement behavior (rust-lang/cargo#15979)
- Adds ghostty as supported terminal for term integration (OSC 9;4) (rust-lang/cargo#15977)
- docs(team): Fixed broken office hours link (rust-lang/cargo#15976)
- docs: Clarify git sources vs git registries in source replacement documentation (rust-lang/cargo#15974)

r? ghost
2025-09-25 07:25:03 +00:00
Sidney Cammeresi
137d4eaf12
BTreeMap: Don't leak allocators when initializing nodes
Memory was allocated via `Box::leak` and thence intended to be tracked
and deallocated manually, but the allocator was also leaked, not
tracked, and never dropped.  Now it is dropped immediately.

According to my reading of the `Allocator` trait, if a copy of the
allocator remains live, then its allocations must remain live.  Since
the B-tree has a copy of the allocator that will only be dropped after
the nodes, it's safe to not store the allocator in each node (which
would be a much more intrusive change).
2025-09-24 18:08:32 -07:00
Matthias Krüger
57ee169ff2
Rollup merge of #146971 - lcnr:fix-writeback, r=BoxyUwU
fix ICE in writeback due to bound regions

fixes rust-lang/rust#117808

r? `@BoxyUwU`
2025-09-24 23:33:29 +02:00
Matthias Krüger
d10d6bfb02
Rollup merge of #146958 - el-ev:fix_path_string_eq_recurse, r=joboet
Fix infinite recursion in Path::eq with String

- Closes [after beta backport] rust-lang/rust#146940
2025-09-24 23:33:28 +02: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
Matthias Krüger
6351a63486
Rollup merge of #146894 - tiif:suggest_feature_attr, r=BoxyUwU
Improve derive suggestion of const param

Make the suggestion not to remove the adt and use the name of the adt variant in the diagnostic.

r? `@BoxyUwU`
2025-09-24 23:33:27 +02:00
Matthias Krüger
7a4ac48345
Rollup merge of #146753 - tiif:unsatisfiable-unstable-feature, r=BoxyUwU
Improve the pretty print of UnstableFeature clause

As per https://github.com/rust-lang/rust/pull/145095#discussion_r2349439492, we could make the diagnostic for unsatisfiable ``UnstableFeature`` clause better.

r? `@BoxyUwU`
2025-09-24 23:33:26 +02:00
Matthias Krüger
0ab93860ed
Rollup merge of #146679 - stepancheg:error-display-source, r=dtolnay
Clarify Display for error should not include source

Fixes rust-lang/rust#145561.

r? `@Noratrieb`
2025-09-24 23:33:25 +02:00
Matthias Krüger
8073b6f169
Rollup merge of #146556 - stepancheg:repro-146228, r=tgross35
Fix duration_since panic on unix when std is built with integer overflow checks

Add a test for regression rust-lang/rust#146228, and turns out this test fails detects error when std is compiled with integer overflow checks.

Original regression was reverted in rust-lang/rust#146473.

First attempt to fix was in rust-lang/rust#146247; test and some code is copied from there, thanks `@eval-exec`

r? `@RalfJung`
2025-09-24 23:33:25 +02:00
Stepan Koltsov
92859e98ee Repro duration_since regression from issue 146228 2025-09-24 21:07:26 +01:00
Stepan Koltsov
a9554b4d5f Clarify Display for error should not include source 2025-09-24 20:02:35 +01:00
bors
caccb4d036 Auto merge of #146999 - matthiaskrgr:rollup-0gbkm82, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#146711 (fix 2 borrowck issues)
 - rust-lang/rust#146857 (revert change removing `has_infer` check. Commit conservatively patch…)
 - rust-lang/rust#146897 (fix ICE in rustdoc::invalid_html_tags)
 - rust-lang/rust#146915 (Make missed precondition-free float intrinsics safe)
 - rust-lang/rust#146932 (Switch next-solver related rustc dependencies of r-a to crates.io ones)
 - rust-lang/rust#146959 (temporary-lifetime-extension-tuple-ctor.rs: make usable on all editions)
 - rust-lang/rust#146964 (library: std: sys: pal: uefi: Add some comments)
 - rust-lang/rust#146969 (const-eval: better wording for errors involving maybe-null pointers)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-24 18:35:58 +00:00
Matthias Krüger
ec378dc773
Rollup merge of #146969 - RalfJung:maybe-null-errors, r=oli-obk
const-eval: better wording for errors involving maybe-null pointers

Fixes https://github.com/rust-lang/rust/issues/146748
r? ``@oli-obk``
2025-09-24 20:34:31 +02:00
Matthias Krüger
24e19c9088
Rollup merge of #146964 - Ayush1325:close-protocol, r=joboet
library: std: sys: pal: uefi: Add some comments

I seemed to have forgotten that since I am using GET_PROTOCOL attribute for the std usecases, I did not need to close the protocols explicitly. So adding these comments as a note to future self not to waste time on the same thing again.
2025-09-24 20:34:31 +02:00
Matthias Krüger
af224996c6
Rollup merge of #146959 - tshepang:patch-2, r=nnethercote
temporary-lifetime-extension-tuple-ctor.rs: make usable on all editions

Also
- add Reference id
- fix typo
2025-09-24 20:34:29 +02:00
Matthias Krüger
4300cd64df
Rollup merge of #146932 - ShoyuVanilla:ra-in-tree-hack, r=lcnr
Switch next-solver related rustc dependencies of r-a to crates.io ones

r? ``@ghost``

cc ``@lnicola`` ``@lcnr``
2025-09-24 20:34:25 +02: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
Matthias Krüger
4e225ee72d
Rollup merge of #146897 - lolbinarycat:rustdoc-invalid_html_tags-ice-146890, r=GuillaumeGomez
fix ICE in rustdoc::invalid_html_tags

fixes https://github.com/rust-lang/rust/issues/146890

r? ```@GuillaumeGomez```
2025-09-24 20:34:21 +02:00
Matthias Krüger
79bb3c4879
Rollup merge of #146857 - tnuha:revert_self_has_no_region_infer, r=lcnr
revert change removing `has_infer` check. Commit conservatively patch…

…es for now, but more development proceeding.

Hotfix for rust-lang/rust#146852.
2025-09-24 20:34:20 +02:00
Matthias Krüger
3150538911
Rollup merge of #146711 - lcnr:fix-placeholder-ice, r=lqd
fix 2 borrowck issues

fixes https://github.com/rust-lang/rust/issues/146467 cc ``@amandasystems``

our understanding here is as follows: region constraints from computing implied bounds gets `ConstraintCategory::Internal`. If there's a higher-ranked subtyping errors while computing implied bounds we then ended up with only `ConstraintCategory::Internal` and `ConstraintCategory::OutlivesUnnameablePlaceholder(_)` constraints.

The path was something like
- `'placeholderU2: 'placeholderU1` (`Internal`)
- `'placeholderU1: 'static` (`OutlivesUnnameablePlaceholder('placeholderU2)`)

It's generally somewhat subtle here as ideally relating placeholders doesn't introduce `'static` constraints. Relating the placeholders themselves will always error regardless, cc https://github.com/rust-lang/rust/pull/142623.

---

separately fixes https://github.com/rust-lang/rust/pull/145925#issuecomment-3303733357 by updating the location for deferred closure requirements inside of promoteds. I am not updating their category as doing so is 1) effort and 2) imo actually undesirable 🤔 see the comments in `TypeChecker::check_promoted` cc ``@lqd``

r? lqd
2025-09-24 20:34:19 +02:00
tiif
4e62715541 Improve the pretty print of UnstableFeature clause 2025-09-24 15:22:10 +00:00
Weihang Lo
6dafcaf6c8
Update cargo submodule 2025-09-24 09:33:43 -04:00
Iris Shi
5a4e536036
Fix infinite recursion in Path::eq with String 2025-09-24 21:30:41 +08:00
tiif
30289353e8 Improve derive suggestion of const param
Make the suggestion not to remove the adt and use the name of the adt
variant
2025-09-24 13:29:23 +00:00
BenjaminBrienen
56734495e2 feature: Implement vec_try_remove
Vec::try_remove is a non-panicking version of Vec::remove
2025-09-24 15:29:09 +02:00
bors
15283f6fe9 Auto merge of #146338 - CrooseGit:dev/reucru01/AArch64-enable-GCS, r=Urgau,davidtwco
Extends AArch64 branch protection support to include GCS

Extends existing support for AArch64 branch protection to include support for [Guarded Control Stacks](https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-2022#guarded-control-stack-gcs:~:text=Extraction%20or%20tracking.-,Guarded%20Control%20Stack%20(GCS),-With%20the%202022).
2025-09-24 13:04:19 +00:00
Shoyu Vanilla
0e7cc32633 Switch next-solver related rustc dependencies of r-a to crates.io ones 2025-09-24 21:28:50 +09:00
joboet
a875f7779e
alloc: simplify Default for Box<CStr> and Rc<CStr> 2025-09-24 14:13:34 +02:00
Ralf Jung
8328c3dada const validation: better error for maybe-null references 2025-09-24 13:35:29 +02:00
Ralf Jung
0a41add629 const-eval: improve and actually test the errors when pointers might be outside the range of a scalar 2025-09-24 13:34:33 +02:00
lcnr
2886ca496a imrpove type_op failure ICE 2025-09-24 13:08:25 +02:00
lcnr
32d24f9efa allow bound regions in writeback 2025-09-24 13:08:25 +02:00
lcnr
3378997867
fix wording
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2025-09-24 12:50:50 +02:00
bors
e9385f9eea Auto merge of #146946 - matthiaskrgr:rollup-fsmrqez, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#146818 (constify {float}::total_cmp())
 - rust-lang/rust#146896 (rustc-dev-guide subtree update)
 - rust-lang/rust#146898 (Update books)
 - rust-lang/rust#146899 (Fix a crash/mislex when more than one frontmatter closing possibility is considered)
 - rust-lang/rust#146904 (rust-lang/rust#140368 Mutex/RwLock/ReentrantLock::data_ptr to be const fn)
 - rust-lang/rust#146907 (add regression test for issue 146537)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-24 09:55:21 +00:00
Ayush Singh
03fd823dbf
library: std: sys: pal: uefi: Add some comments
I seemed to have forgotten that since I am using GET_PROTOCOL attribute
for the std usecases, I did not need to close the protocols explicitly.
So adding these comments as a note to future self not to waste time on
the same thing again.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-09-24 13:26:03 +05:30
Tshepang Mbambo
c9dc0e307a
temporary-lifetime-extension-tuple-ctor.rs: make usable on all editions
Also
- add Reference id
- fix typo
2025-09-24 07:01:24 +02:00
bors
3e887f5faa Auto merge of #146953 - dianqk:update-llvm, r=cuviper
Update LLVM to 21.1.2

Fixes rust-lang/rust#146065.
2025-09-24 04:25:26 +00:00