Skip to content

Conversation

matthiaskrgr
Copy link
Member

@matthiaskrgr matthiaskrgr commented Sep 25, 2025

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

GuillaumeGomez and others added 25 commits August 10, 2025 12:00
These functions used to be shared with the JSON backend but nowadays they
aren't.
…act_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`.

Signed-off-by: Petros Angelatos <[email protected]>
Vec::try_remove is a non-panicking version of Vec::remove
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).
Escape "special characters" (e.g., double quotes `"` and line breaks `\n`).
Escape HTML.

Lastly, add regression tests and clean up existing tests.
…pr-heuristic, r=rustdoc

rustdoc: hide `#[repr]` if it isn't part of the public ABI

> [!IMPORTANT]
> Temporarily stacked on top of PR rust-lang#146527; only the last commit is relevant!

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

Fixes rust-lang#66401.
Fixes rust-lang#128364.
Fixes rust-lang#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.
…=fmease

[rustdoc] Add support for associated items in "jump to def" feature

Fixes rust-lang#135485.

r? ``@fmease``
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.
Add proper name mangling for pattern types

requires adding demangler support first rust-lang/rustc-demangle#81

needed for rust-lang#136006 (comment) as otherwise we will have symbol collisions
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: rust-lang/libs-team#649

Tracking issue: rust-lang#146954
…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#106203
…tion, 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.
…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
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Sep 25, 2025
@rustbot rustbot added the rollup A PR which is a rollup label Sep 25, 2025
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Sep 25, 2025

📌 Commit c6d0059 has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 25, 2025
@bors
Copy link
Collaborator

bors commented Sep 25, 2025

⌛ Testing commit c6d0059 with merge 7ac0330...

@bors
Copy link
Collaborator

bors commented Sep 25, 2025

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing 7ac0330 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 25, 2025
@bors bors merged commit 7ac0330 into rust-lang:master Sep 25, 2025
11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 25, 2025
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#116882 rustdoc: hide #[repr] if it isn't part of the public ABI 527cc109a4d963acc879f0a69f3a46f6055d7a82 (link)
#135771 [rustdoc] Add support for associated items in "jump to def"… ed502bfee460abc382d858538e1c37932ae2a6e2 (link)
#141032 avoid violating slice::from_raw_parts safety contract in … 753eb310d89cbdc26ab2694c498cc2d24040b478 (link)
#142401 Add proper name mangling for pattern types 38a66603c4e9fb355abcce47fc6c7603b6a2daec (link)
#146293 feat: non-panicking Vec::try_remove f41202abaef0110aba61b6dbc07aad8b2f9a7944 (link)
#146859 BTreeMap: Don't leak allocators when initializing nodes 04136f64c385dc532b96d4cec890427cec71859e (link)
#146924 Add doc for NonZero* const creation 89187f3f66af23b9042cd10b7789cdc859731b09 (link)
#146933 Make render_example_with_highlighting return an `impl fmt… 151d162058348e01689c3386be5bcd9ffbbf0288 (link)

previous master: eabf390b4c

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing eabf390 (parent) -> 7ac0330 (this PR)

Test differences

Show 2112 test diffs

Stage 1

  • [rustdoc] tests/rustdoc/attribute-rendering.rs: pass -> [missing] (J0)
  • [rustdoc] tests/rustdoc/inline_cross/repr.rs: pass -> [missing] (J0)
  • [rustdoc] tests/rustdoc/jump-to-def-assoc-items.rs: [missing] -> pass (J0)
  • [rustdoc] tests/rustdoc/jump-to-def-ice-assoc-types.rs: [missing] -> pass (J0)
  • [rustdoc] tests/rustdoc/jump-to-def-ice.rs: [missing] -> pass (J0)
  • [rustdoc] tests/rustdoc/reexport/reexport-attrs.rs: pass -> [missing] (J0)
  • vec::test_try_remove: [missing] -> pass (J3)

Stage 2

  • vec::test_try_remove: [missing] -> pass (J1)
  • [rustdoc] tests/rustdoc/attribute-rendering.rs: pass -> [missing] (J2)
  • [rustdoc] tests/rustdoc/inline_cross/repr.rs: pass -> [missing] (J2)
  • [rustdoc] tests/rustdoc/jump-to-def-assoc-items.rs: [missing] -> pass (J2)
  • [rustdoc] tests/rustdoc/jump-to-def-ice-assoc-types.rs: [missing] -> pass (J2)
  • [rustdoc] tests/rustdoc/jump-to-def-ice.rs: [missing] -> pass (J2)
  • [rustdoc] tests/rustdoc/reexport/reexport-attrs.rs: pass -> [missing] (J2)

Additionally, 2098 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 7ac0330c6d684d86d6f86fabe601a3defdc3b234 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-apple: 6766.5s -> 8069.9s (19.3%)
  2. x86_64-gnu-nopt: 7726.8s -> 6700.2s (-13.3%)
  3. dist-x86_64-musl: 8581.7s -> 7662.8s (-10.7%)
  4. x86_64-mingw-1: 9709.1s -> 10410.5s (7.2%)
  5. dist-android: 1603.6s -> 1489.0s (-7.1%)
  6. dist-various-1: 4217.0s -> 3931.1s (-6.8%)
  7. i686-gnu-1: 7909.6s -> 7420.0s (-6.2%)
  8. dist-x86_64-netbsd: 4902.0s -> 5200.8s (6.1%)
  9. dist-aarch64-windows-gnullvm: 4591.3s -> 4848.3s (5.6%)
  10. dist-apple-various: 3936.2s -> 4132.9s (5.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7ac0330): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.1%] 2
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 2
Improvements ✅
(primary)
-1.0% [-1.1%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-1.1%, 0.1%] 4

Max RSS (memory usage)

Results (primary 5.4%, secondary 3.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
5.4% [4.1%, 6.4%] 3
Regressions ❌
(secondary)
3.3% [3.3%, 3.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.4% [4.1%, 6.4%] 3

Cycles

Results (primary 2.4%, secondary 2.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [2.2%, 2.6%] 3
Regressions ❌
(secondary)
2.3% [2.3%, 2.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [2.2%, 2.6%] 3

Binary size

Results (primary -0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 9
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-1.4%, -0.0%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-1.4%, 0.1%] 15

Bootstrap: 470.601s -> 471.374s (0.16%)
Artifact size: 388.11 MiB -> 388.15 MiB (0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Sep 26, 2025
@Mark-Simulacrum Mark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Sep 29, 2025
@Mark-Simulacrum
Copy link
Member

Several rustdoc changes, including what looks like net-new features. I don't think it's worth digging deeper into the relatively small, relatively few-benchmark-affecting doc regressions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.