Commit Graph

115 Commits

Author SHA1 Message Date
James Barford-Evans
84aa27d895 Tests for find_auto_trait_generics_next_solver path 2026-07-06 16:11:03 +01:00
Guillaume Gomez
d6f62f661d rustdoc: Fix crash when trying to inline foreign item which cannot have attributes 2026-07-03 23:33:36 +02:00
Jacob Pratt
9fa34499e3 Rollup merge of #158334 - lapla-cogito:rustdoc_typeconst, r=camelid
rustdoc: Show use-site paths for unevaluated const array lengths

After rust-lang/rust#158171, I noticed a few additional issues with the rendering of consts in rustdoc. This PR fixes them. When rendering array lengths, avoid inlining the full definition of unevaluated constants via `print_inlined_const`. Instead, fall back to `Const::to_string()` for use-site rendering, matching the behavior already used for projections without bodies.

r? camelid
2026-07-01 17:42:28 -04:00
Jacob Pratt
e601172b0b Rollup merge of #158449 - ferrocene:rename-qnx-targets, r=workingjubilee
QNX target renaming

This PR renames two QNX targets:

- `aarch64-unknown-nto-qnx800` becomes simply `aarch64-unknown-qnx`
- `x86_64-pc-nto-qnx800` becomes simply `x86_64-pc-qnx`

In addition:

- references to *QNX OS* and *QNX Neutrino RTOS* are replaced with *QNX SDP* for uniformity
- the `spec::base::nto_qnx` module is renamed to `base::spec::qnx_sdp` to match the above
- the `target_os` of the QNX SDP 8.0 targets is changed to `qnx` to match the target name
- a *lot* of code is then touched to handle `any(target_os = "nto", target_os = "qnx")`

I think it's worth noting that *QNX Software Development Platform* is the *build environment* that you download and install, and you can use it to create a custom *run-time environment*. In SDP 7.x the run-time environment was based on *QNX Neutrino 7.x*, but in SDP 8.0 the run-time environment is based on *QNX OS 8.0*. I think it was weird to users to see the two different run-time environments in the docs, and referring to the build environment just seems to make more sense anyway because that's what users install, it's where the headers live, and ultimately it's what the toolchain will care about.

The new target names match those reported by `clang` running *on* the [self-hosted *QNX Developer Desktop*](https://www.qnx.com/developers/docs/qnxeverywhere/com.qnx.doc.qdd/topic/about.html).

```console
$ clang --version
QNX clang version 21.1.3
Target: x86_64-pc-qnx
Thread model: posix
InstalledDir: /usr/bin
```

Once the compiler knows about the new target names, `libc`, `backtrace` and `cc-rs` can be updated to match, and then building `libstd` for the new targets can be fixed. This rename will cause a bit of churn, but it seemed important to get it changed before anyone tries to finish libstd support for QNX SDP 8.0 (it's currently noted as "in-progress"). It's also Tier 3 so we have fairly broad latitude to do this I think, and aligning with QNX's build of clang just makes sense.

With these changes I can run:

```console
$ ./x build library/std --stage 2 --target x86_64-pc-nto-qnx710,aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710_iosock,aarch64-unknown-nto-qnx710_iosock,aarch64-unknown-nto-qnx700
$ ./x build library/core --stage 1 --target x86_64-pc-qnx,aarch64-unknown-qnx
```

The QNX SDP 7.x targets retain their old names, and their `target_os = "nto", target_env = "qnx710"` configuration, to avoid breakage.
2026-07-01 01:03:15 -04:00
Guillaume Gomez
9aba0b60dd Add rustdoc HTML test to ensure that the inlining of a #[doc(no_inline)] is working as expected 2026-06-30 12:55:28 +02:00
Jonathan Pallant
4eec7f5d40 Fix rustdoc tests
The name of the OS had changed, so the tests needed updating
2026-06-30 09:01:03 +00:00
Jonathan Pallant
804de70ca0 QNX target renaming
- aarch64-unknown-nto-qnx800 becomes simply aarch64-unknown-qnx
- x86_64-pc-nto-qnx800 becomes simply x86_64-pc-qnx
- references to QNX OS and QNX Neutrino RTOS are replaced with QNX SDP for uniformity
- various nto_qnx modules are named to qnx_sdp to match the above

The new target names are more consistent with those used by the QNX SDP 8.0 toolchain, and reflect a level on ongoing API stability similar to that for macOS and Linux (which simply have minimum supported versions record for their targets).

Once the compiler knows about the new target names, libc and backtrace can be updated to match, and then building libstd for the new targets can be fixed.

With these changes I can run:

```console
$ ./x build library/std --stage 2 --target x86_64-pc-nto-qnx710,aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710_iosock,aarch64-unknown-nto-qnx710_iosock,aarch64-unknown-nto-qnx700
$ ./x build library/core --stage 1 --target x86_64-pc-qnx,aarch64-unknown-qnx
```
2026-06-30 09:01:03 +00:00
Guillaume Gomez
a5cb0e7780 Fix handling of inlining of no_inline of foreign items 2026-06-29 23:14:02 +02:00
lapla
1f4b09e15a Show use-site paths for unevaluated const array lengths 2026-06-30 00:06:28 +09:00
Jacob Pratt
a1fbf7b8ea Rollup merge of #158466 - sunshowers:nested-fundamental, r=notriddle
rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs

This is a generalization of rust-lang/rust#92940: that PR handled cases like `impl Foreign for Box<Local>`, but was missing handling for a few other closely related cases.

My particular interest was with showing `impl From<Box<Utf8Path>> for Box<Path>` in camino's documentation. But I ended up handling a bunch of related cases along the way.

I'm new to rustdoc so please let me know if I got anything wrong :) took a bit to fully understand how this worked.

<img width="1733" height="483" alt="image" src="https://github.com/user-attachments/assets/4b987c61-bdac-4de3-a491-c0577e06fa7c" />
2026-06-27 22:13:46 -04:00
Rain
c3864bee80 rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs
This is a generalization of PR 92940: that PR handled cases like `impl Foreign for Box<Local>`, but was missing handling for a few other closely related cases.

My particular interest was with showing `impl From<Box<Utf8Path>> for Box<Path>` in camino's documentation. But I ended up handling a bunch of related cases along the way.

I'm new to rustdoc so please let me know if I got anything wrong :) took a bit to fully understand how this worked.
2026-06-27 03:27:43 -07:00
Guillaume Gomez
702445c767 Remove doc_cfg show/hide conflict error and correctly handle values(any()) 2026-06-26 12:27:26 +02:00
Guillaume Gomez
c383e5c2db Add more regression tests for doc(auto_cfg()) 2026-06-26 12:27:26 +02:00
Guillaume Gomez
3c92a3ce48 Move doc-cfg tests into the right location 2026-06-26 12:27:26 +02:00
Guillaume Gomez
f22107c1c7 Update rustdoc to use new doc_cfg syntax 2026-06-26 12:27:24 +02:00
Jonathan Brouwer
5d9537acfc Rollup merge of #158171 - lapla-cogito:issue_158155, r=camelid
rustdoc: Avoid ICE on unevaluated `type const` projections in array lengths

`clean_middle_ty` used `normalize_erasing_regions` when rendering array lengths, which panics on unevaluatable associated const projections such as `<T as Trait>::ASSOC` under mGCA.

Fixes rust-lang/rust#158155
2026-06-22 21:01:56 +02:00
lapla
a616db318e rustdoc: Avoid ICE on unevaluated type const projections in array lengths 2026-06-23 00:40:54 +09:00
Guillaume Gomez
e219d6134b Rollup merge of #158089 - GuillaumeGomez:jump-to-def-derive, r=Urgau
Fix invalid "jump-to-def" doc link generation when an item has a `derive` proc-macro

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

The problem is that the proc-macros might generate an impl block `impl $(trait)? for Item` where `Item` then has its span pointing to the current item, overwriting its intra-doc link (hopefully this explanation makes sense ^^').

In short, the proc-macro generates an impl block, the `for Item` makes the code enter `visit_qpath` which in turn calls `handle_path` which will take the span of the last segment of the path (so `Item` here) and use it in the link def "span map".

r? @urgau
2026-06-18 20:30:32 +02:00
Guillaume Gomez
813dbb9d19 Fix invalid "jump-to-def" doc link generation when an item has a derive proc-macro 2026-06-18 18:38:24 +02:00
Oli Scherer
a88521a6f6 Reject impl const Trait since the right syntax is const impl Trait now 2026-06-17 17:42:48 +02:00
qaijuang
edad2648fa test without --document-hidden-items 2026-06-13 07:26:22 -04:00
qaijuang
b507c75d03 add regression test 2026-06-12 19:11:22 -04:00
Jacob Pratt
69111374e3 Rollup merge of #157633 - CoCo-Japan-pan:impl-restriction-render-fix, r=GuillaumeGomez
Reorder `impl` restriction rendering and add bottom margin

This PR moves the `impl` restriction rendering above the trait description.
It also adds an ⓘ marker, italicizes the text, and adds a bottom margin.
Tracking issue: rust-lang/rust#105077

before:
<img width="1108" height="651" alt="image" src="https://github.com/user-attachments/assets/520d95cf-a648-44e7-8036-e453cfbdf569" />

after:
<img width="1085" height="671" alt="image" src="https://github.com/user-attachments/assets/84493e56-6227-433b-93d0-4fcbe28ac00c" />

r? @GuillaumeGomez
cc @Urgau @jhpratt
2026-06-09 16:53:03 -04:00
CoCo-Japan-pan
656124ded8 Reorder impl restriction rendering and add bottom margin 2026-06-09 12:28:11 +09:00
Jacob Pratt
67d0937df5 Rollup merge of #157581 - qaijuang:157438-follow-up, r=GuillaumeGomez
Test fixup

Follow up to https://github.com/rust-lang/rust/pull/157438.

r? @GuillaumeGomez
2026-06-07 17:47:56 -04:00
qaijuang
6ba94243f5 Fixup 2026-06-07 13:58:33 -04:00
Yotam Ofek
0053d7602a Cleanup and optimize render_impls
- take ownership of the `Vec<&Impl>` instead of copying into another alloc
- reuse `ImplString` to do natural sort ordering
- lazy formatting
2026-06-07 11:06:19 +03:00
qaijuang
9aeb7c0bed add regression tests 2026-06-04 11:37:15 -04:00
Jacob Pratt
5478269c18 Rollup merge of #157262 - fmease:rustdoc-preserve-sizedness-bounds-on-parent-params, r=notriddle
rustdoc: IXCRE: Preserve sizedness bounds on type params belonging to the parent item

Fixes rust-lang/rust#144015.
2026-06-03 15:15:56 -04:00
CoCo-Japan-pan
5358c2fdbb Add tests for impl restriction rendering 2026-06-03 00:22:16 +09:00
León Orell Valerian Liehr
5a302ffa6c rustdoc: Preserve sizedness bounds on type params belonging to the parent item 2026-06-01 18:05:35 +02:00
Jacob Pratt
229b0d3841 Rollup merge of #157223 - Dnreikronos:rustdoc-async-delegation-157040-b, r=GuillaumeGomez
rustdoc: Fix ICE on delegated async functions

Fixes rust-lang/rust#157040

rustdoc ICEs with "unexpected async fn return type" on an async delegation like `reuse Trait::foo`. The delegation's HIR signature isn't resolved yet, so its return type cleans to `_`, but the header is still `async`, and sugaring an inferred return type panics.

For delegation items we now clean the resolved signature from the ty side, the same way inlined items already do, instead of the HIR one. That sidesteps the panic and also renders the real return type and `self` parameter instead of `-> _` and `self: _`. The `<Self>` generic that shows up on the free-function form is pre-existing (plain sync delegation prints it too) and left alone.
2026-05-31 22:30:33 -04:00
Dnreikronos
3467b6fc20 Clean resolved signature for delegated functions in rustdoc
A delegation item (`reuse path::method`) has an unresolved HIR
signature: its inputs and return type are `InferDelegation` nodes that
clean to `_`. When the delegated function is async, the `async` header
over that inferred return type made `clean_fn_decl_with_params` call
`sugared_async_return_type` on a non-`impl Future` type, panicking with
"unexpected async fn return type".

Clean the resolved ty-side signature for delegation items instead, the
same way inlined items are cleaned. This avoids the ICE and renders the
real return type and `self` parameter rather than `-> _` / `self: _`.
2026-05-31 18:08:27 -03:00
Jacob Pratt
9fc5f902fe Rollup merge of #157171 - fmease:rustdoc-sep-caches-auto-blanket, r=lolbinarycat
rustdoc: Separate the caches for synthetic auto trait & blanket impls

Fixes rust-lang/rust#148980.
2026-05-31 15:30:43 -04:00
Jonathan Brouwer
0ab263462f Rollup merge of #156823 - ajasad25:rustdoc-self-submodule-tests-84827, r=camelid
Add regression test

Fixes rust-lang/rust#84827.
2026-05-30 23:05:33 +02:00
León Orell Valerian Liehr
061088369a rustdoc: Separate the caches for synthetic auto trait & blanket impls 2026-05-30 21:23:30 +02:00
Jonathan Brouwer
377d5bad23 Rollup merge of #157039 - lcian:fix/glob-reexport-feature-combination, r=GuillaumeGomez
rustdoc: correctly propagate cfgs for glob reexports

This fixes some cases of rustdoc not surfacing the correct required feature combination when using `#[cfg(feature = ...)]` in combination with glob reexports.

See the example cases included as tests.

Here's the generated HTML for those test cases before this change:
<img width="150" height="115" alt="Screenshot_20260528_201140" src="https://github.com/user-attachments/assets/8d611f88-7149-49f6-8ee0-530c049ea858" />

and after:
<img width="225" height="125" alt="Screenshot_20260528_201236" src="https://github.com/user-attachments/assets/85cc07c0-9a9a-455f-8ada-69d44d645516" />

My understanding is that this was basically an off-by-one type of oversight.
We need to update `is_inline` before calling `get_all_import_attributes` to immediately reflect that the outermost import we're processing shall indeed be considered as inline, as it's a glob.
Otherwise, we will end up calling `add_without_unwanted_attributes` with `is_inline == false` on the "intermediate" re-export, which will skip propagating its `cfg`s.

I believe this fixes https://github.com/rust-lang/rust/issues/96166, even though the description there is not super clear on the exact test case they used (there's a snippet but the author says their code is actually different).

Refs https://github.com/rust-lang/rust/issues/43781
@rustbot label +F-doc_cfg
@rustbot r? @GuillaumeGomez
2026-05-30 18:01:55 +02:00
Jonathan Brouwer
d1162f6ab8 Rollup merge of #157115 - GuillaumeGomez:fix-foreign-items-macro-expansion, r=Urgau
[rustdoc] Fix foreign items macro expansion

Fixes rust-lang/rust#156486.

The ICE was coming from ast pretty printing not handling `...` (C var args). To handle that, I added a `CVarArgs` variants for all `PatKind` enums.

Second part (and second commits) was to correctly handle foreign items in rustdoc.

r? @Urgau
2026-05-30 18:01:53 +02:00
Guillaume Gomez
872a13faa5 Fix foreign items in rustdoc macro expansion feature 2026-05-29 23:51:40 +02:00
lcian
1f5a5a2b69 rustdoc: correctly propagate cfgs for glob reexports
* rustdoc: correctly propagate cfgs for glob reexports
* address review feedback, add a comment explaining the test
* empty commit to trigger CI
* empty commit to trigger CI
* fix sorting of features in tests
* assert contents of index.html
2026-05-29 15:54:48 +00:00
Jonathan Brouwer
b0d9ae60e1 Rollup merge of #156401 - shivendra02467:doc-cfg-sort-fix, r=GuillaumeGomez
rustdoc: deterministic sorting for `doc_cfg` badges

Fixes rust-lang/rust#156391

Currently, target-exclusive `doc_cfg` badges (eg. "Available on...") reuse the order of predicates as they appear in the source code. This often buries popular targets behind niche ones and leads to inconsistent UI rendering.

This PR introduces a deterministic sorting mechanism to the `Cfg` AST prior to HTML/JSON rendering.

**Note for Reviewers:**
To provide the best UX, I implemented a lightweight tiering heuristic (prioritizing major platforms like Linux/Apple/Windows first, followed by mobile, then BSDs, and alphabetizing the rest). However, I am completely open to tweaking these priority groupings or falling back to a different sorting logic if the team prefers. Let me know what you think!
2026-05-28 14:59:41 +02:00
Shivendra Sharma
f658bf6bb8 rustdoc: deterministic sorting for doc_cfg badges 2026-05-28 16:15:20 +05:30
ajasad25
c24ec53db0 rustdoc: Add regression test for Self in intra-doc links inside submodule impls 2026-05-28 06:55:12 +05:00
bors
e1ff77d898 Auto merge of #156736 - GuillaumeGomez:primitive-assoc-methods, r=fmease
Fix jump to def link generation on primitive type associated methods

Fixes rust-lang/rust#156707.

Interestingly enough, the inference fails on primitive type, so instead I go around a bit by generating a `PrimitiveType` and then tweak a bit the `href` generation.

r? @fmease
2026-05-24 03:17:11 +00:00
Guillaume Gomez
0c7388c750 Fix jump to def link generation on primitive type associated methods 2026-05-23 19:07:36 +02:00
Yotam Ofek
877d57c2c2 Also emit "Dyn Compatibility" section for traits that *are* dyn compatible 2026-05-22 18:08:11 +03:00
bors
4d276d7fdb Auto merge of #155307 - Urgau:rustdoc-stabilize-remap-path-prefix, r=GuillaumeGomez
Stabilize `--remap-path-prefix` in rustdoc



# Stabilization report of  `--remap-path-prefix` in rustdoc

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` in `rustdoc`.

There are no tracking issue.

Stabilization was discussed at the last meeting, [#t-rustdoc/meetings > 2026-04-13 @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/393423-t-rustdoc.2Fmeetings/topic/2026-04-13/near/585264347).

### What is stabilized

The rustdoc `--remap-path-prefix` flag is being stabilized by this PR. (It's equivalent to rustc flag)

It permits remapping (as a best effort) source path prefixes in all output, including diagnostics, debug information, macro expansions, generated documentation, etc.

It takes a value of the form `FROM=TO` where a path prefix equal to `FROM` is rewritten to the value `TO`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo"
```

### What isn't stabilized

Neither `--remap-path-scope` (~~soon to be added as unstable in `rustdoc`~~ https://github.com/rust-lang/rust/issues/155451) or the already unstable in `rustc` `documentation` scope are being stabilized or added here.

## Design

### Implementation history

- rust-lang/rust#107099

### Unresolved questions

There are no unresolved questions.

### Post-implementation changes

The implementation has evolved with `rustc`, but no changes to the flag it-self have been made.

### Nightly extensions

The `documentation` scope, which currently can only be set from `rustc`, as we need to add an equivalent to the `--remap-path-scope` flag, ~~which is planned~~ (EDIT: https://github.com/rust-lang/rust/issues/155451), but not required, the current `--remap-path-prefix` defaults to the `all` scope, like `rustc`.

### Doors closed

We are committing to having to having a flag that permits remapping paths. The compiler team already made the same commitment.

## Feedback

### Call for testing

No call for testing has been done.

### Nightly use

Unable to determine. A [GitHub search](https://github.com/search?q=%20%2F--remap-path-prefix%2F&type=code) only seems to only reveals the `rustc` usage (over 6k though).

Rust-for-Linux is using the [flag](e80d033851/Makefile (L1151-L1153)).

## Implementation

### Major parts

- rust-lang/rust#107099
- rust-lang/rust#149709
- rust-lang/rust#150172
- rust-lang/rust#151589

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs)
- [`tests/rustdoc-ui/remap-path-prefix-invalid-doctest.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-invalid-doctest.rs)
- [`tests/rustdoc-ui/remap-path-prefix-macro.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-macro.rs)
- [`tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.rs)
- [`tests/rustdoc-ui/lints/remap-path-prefix-lint.rs`](12f35ad39e/tests/rustdoc-ui/lints/remap-path-prefix-lint.rs)
- [`tests/rustdoc-html/import-remapped-paths.rs`](12f35ad39e/tests/rustdoc-html/import-remapped-paths.rs)
- [`tests/rustdoc-html/macro/external-macro-src.rs`](12f35ad39e/tests/rustdoc-html/macro/external-macro-src.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-prefix` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. 

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-prefix`.

## Acknowledgments

- @edward-shen
- @Urgau
2026-05-21 22:46:41 +00:00
abdul2801
afedb8727e Update turbofish.rs 2026-05-19 19:29:13 +05:30
Abdul Rafey Ahmed
c454d92f61 fix: improve turbofish jump-to-def handling
Handle turbofish syntax correctly in rustdoc jump-to-def links
and add regression tests covering type aliases.
2026-05-19 16:20:38 +05:30
bors
d3cd04068e Auto merge of #152449 - GuillaumeGomez:rustdoc-bang-attr-macro, r=lolbinarycat,mejrs
rustdoc: properly support macros with multiple kinds



Since it seems like I can't reopen https://github.com/rust-lang/rust/pull/145458, opening this one. Although, it's the same PR minus the last new commit to handle a comment that was left unresolved in the original PR. All relevant details are still in the original PR though.

It's an alternative (and likely a take-over) of https://github.com/rust-lang/rust/pull/148005 since lang-team rejected the idea to add documentation on macro branches, making the multiple files approach less suitable.

This implements rust-lang/rust#145153 in rustdoc. This PR voluntarily doesn't touch anything related to intra-doc links, I'll send a follow-up if needed.

So now about the implementation itself: this is a weird case where a macro can be different things at once but still only gets one file generated. I saw two ways to implement this:
1. Handle `ItemKind::Macro` differently and iter through its `MacroKinds` values.
2. Add new placeholder variants in the `ItemKind` enum, which means that when we encounter them in rendering, we need to ignore them. It also makes the `ItemKind` enum bigger (and also needs more code to be handled). Another downside is that it needs to be handled in the JSON output.

Now there was an interesting improvement that came with this PR in the `html::render::print_item::item_module` function: I simplified its implementation and split the different parts in a `HashMap` where the key is the item type. So then, we can just iterate through the keys and open/close the section at each iteration instead of keeping an `Option<section>` around.

From RFCs:
* https://github.com/rust-lang/rust/pull/144579
* https://github.com/rust-lang/rust/pull/145208

derive:

<img width="442" height="327" alt="Screenshot From 2026-04-18 03-11-40" src="https://github.com/user-attachments/assets/f69587a0-8a2b-4080-bc8a-b63dd18f21c1" />

attr:

<img width="442" height="327" alt="Screenshot From 2026-04-18 03-11-31" src="https://github.com/user-attachments/assets/bf9b235a-9d2f-435c-a91e-167562df6b68" />

both:

<img width="442" height="327" alt="Screenshot From 2026-04-18 03-11-50" src="https://github.com/user-attachments/assets/b7e8b3c6-eb99-495b-bdf9-17ba8fb4da0d" />

r? @notriddle
2026-05-16 18:54:36 +00:00