Commit Graph

186 Commits

Author SHA1 Message Date
Jonathan Brouwer
924c479f7c Rollup merge of #163078 - GuillaumeGomez:rustdoc-html-readme, r=Urgau
Add a README in tests/rustdoc-html to explain what each folder content is for

Follow-up of https://github.com/rust-lang/rust/pull/162906.

r? @Urgau
2026-09-21 15:19:28 +02:00
Guillaume Gomez
5abfe0f550 Add a README in tests/rustdoc-html to explain what each folder content is for 2026-09-21 12:22:40 +02:00
Guillaume Gomez
13c1957e9c Move some rustdoc-html tests into the right folder 2026-09-20 20:08:44 +02:00
Jonathan Brouwer
74cd936f47 Rollup merge of #163036 - GuillaumeGomez:dyn-jump-to-def, r=Urgau
[rustdoc] Correctly handle `dyn` trait methods linking for jump to def feature

Part of the missing pieces for https://github.com/rust-lang/rust/pull/162808 to work.

The issue was that in case we had the method of a dyn trait, we tried to use the dyn trait as is and couldn't generate a correct href to its `DefId`. If we get the trait in the `dyn`, it works just as expected.

r? @Urgau
2026-09-20 17:04:31 +02:00
Guillaume Gomez
6c6586a77d Correctly handle dyn trait methods linking for jump to def feature 2026-09-19 22:15:15 +02:00
Jonathan Brouwer
4c79c88679 Rollup merge of #162669 - GuillaumeGomez:inline-same-item-with-different-names, r=lolbinarycat
[rustdoc] Correctly handle intra-doc links on inlined same item with different names

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

It works as follow: we keep the `DefId` indexing, but we add a new `alternatives` entry (same inlined items, but under a different path) which allows to pick the right entry.

So now, why this approach instead of changing the indexing (like `(DefId, Symbol)`)? Because it's much less common to import a same item with different names, so increasing the size of the index seems unnecessary. That does make the code more noisy, which I'm not a big fan of, so if someone has ideas for improvements, definitely interested!

r? @lolbinarycat
2026-09-19 08:45:33 +02:00
Guillaume Gomez
8730acb9e9 Move more rustdoc-html tests in the right location 2026-09-17 16:42:50 +02:00
Guillaume Gomez
cd6287f229 Add regression test for inlined same item with different names 2026-09-16 21:15:48 +02:00
Jonathan Brouwer
ef0d430354 Rollup merge of #162543 - GuillaumeGomez:reexport-from-transient-crates, r=petrochenkov
[rustc_resolve]  Correctly keep all reexports in `ModChild::reexport_chain`

Fixes rust-lang/rust#81893.

First commit comes from https://github.com/rust-lang/rust/pull/161872 and it's the base I used for the fix in the second commit (which also reverts basically everything from the first commit, not sure if I should keep it...). In short, `NameResolution` only seems to have access to local reexports and to the final reexported item. So instead, we keep the information in `DeclKind` (which cannot implement `Drop` because it's part of `DeclData` which is stored in `ResolverArenas::dropless` so I kept a slice instead of a `SmallVec`. Guess how I found out? Lots of `panic`s :') ) and we use this information in `reexport_chain`.

r? @petrochenkov
2026-09-16 20:09:51 +02:00
Guillaume Gomez
cb55fc760e Add regression test for reexport chain in transient crates 2026-09-15 23:31:21 +02:00
Jonathan Brouwer
0152cbf3f6 Rollup merge of #162372 - GuillaumeGomez:cleanup-rustdoc-test, r=Urgau
Clean up `test/rustdoc-html` folder by moving tests where appropriate

<del>Gonna likely continue a bit more before assigning a reviewer.</del>

CI is happy and I think it's already big enough for a first batch.

r? ghost
2026-09-15 09:32:35 +02:00
Guillaume Gomez
4e77563795 Rename tests/rustdoc-html/type-alias folder into tests/rustdoc-html/typedef 2026-09-14 22:17:54 +02:00
Guillaume Gomez
6c291770a4 Clean up test/rustdoc-html folder by moving tests where appropriate 2026-09-14 22:17:28 +02:00
khyperia
0c35264566 migrate tests 2026-09-11 17:08:12 +02:00
Jacob Pratt
d6c2a035c4 Rollup merge of #162030 - GuillaumeGomez:forbid-test-rustdoc-html, r=fmease
Prevent `--test` to be used in `rustdoc-html` testsuite

As [promised](https://github.com/rust-lang/rust/pull/162014#issuecomment-5469387848).

CI will fail until https://github.com/rust-lang/rust/pull/162014 is merged though.

r? @fmease
2026-09-05 23:54:24 -04:00
Guillaume Gomez
c7d7c4830e Limit tests/rustdoc-html/doc-cfg/trait-impls.rs to x86_64 linux 2026-09-05 21:40:16 +02:00
Guillaume Gomez
d4f576d07d Fix/move newly failing rustdoc tests 2026-09-05 17:24:32 +02:00
Jonathan Brouwer
2fdc9cdf36 Rollup merge of #162155 - mejrs:rustc_allowed_through_unstable_modules, r=davidtwco
add suggestion for `rustc_allowed_through_unstable_modules` attribute
2026-09-04 22:29:12 +02:00
Jonathan Brouwer
1a6452f354 Rollup merge of #162072 - ZephyrCodesStuff:main, r=davidtwco
Add new Tier-3 target: `powerpc64-sony-ps3`

Implements a compatible target for the Sony PlayStation 3 console's PPU processor.

> A tier 3 target must have a designated developer or developers (the “target maintainers”) on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I ([@ZephyrCodesStuff](https://github.com/ZephyrCodesStuff)) am the maintainer and developer, both for this PR's target, as well as a [Rust PS3 SDK](https://github.com/zephyrcodesstuff/rust-ps3) to help developers get started.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

Addressed. The PPU is a standard `powerpc64` core, with only marginal changes made for the PS3's hardware configuration. `sony` is used among other Sony console targets, and `ps3` is the console's shorthand.

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.
If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

Addressed.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
The target must not introduce license incompatibilities.

Although it does require a separate linker (`mold`) and a post-fix binary patching tool (included in the SDK above), no part of the build process, from the code, to the compiler, linker or SDK are closed-source. This target is compatible with the aformentioned SDK without any reliance on community "homebrew" tools, nor any licensed Sony / SN Systems compiler or linker.

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

All of my code in this PR, including the SDK above, are licensed `MIT OR Apache-2.0`.

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust’s license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

Addressed.

> “onerous” here is an intentionally subjective term. At a minimum, “onerous” legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, “non-commercial”/“research-only”/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.
Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target’s tier status, though they may otherwise participate in discussions.

All of the components are free, open-source software.

> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

Addressed.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

This target currently does not support the `std` library, but can fully support the `core` and `alloc` feature-sets. Tested and verified on official hardware with the aid of the SDK above.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Documentation is included, both in this PR's Markdown files, as well as the SDK's repository.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via @) to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

This target should not cause issues, as its scope is relatively limited to Sony PlayStation 3 development.

> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Noted.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

This patch does not touch any other target.

> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

This target only has one feature, `+altivec`, universally supported on any Sony PlayStation 3 unit.

> Tier 3 targets must be able to produce assembly using at least one of rustc’s supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

Artifacts built by this target are confirmed to be fully functional on official hardware, once linked with the `mold` linker and patched by the SDK toolchain.
2026-09-04 22:28:58 +02:00
ZephyrCodesStuff
2489df9e38 Add new Tier-3 target: powerpc64-sony-ps3 2026-09-04 12:29:53 +02:00
mejrs
8f316d411d refactor rustc_allowed_through_unstable_modules attribute and lint message 2026-09-03 12:42:20 +02:00
Guillaume Gomez
41258df413 Move more rustdoc-html tests using --test into the right folder 2026-08-31 11:47:23 +02:00
Guillaume Gomez
ce7aa01e65 Rollup merge of #161978 - GuillaumeGomez:cleanup-ui-doctest, r=fmease
Move rustdoc ui doctests into the right testsuite

When working on https://github.com/rust-lang/rust/pull/161944#discussion_r3886415477, I realized that a lot of doctests in `rustdoc-html` testsuite were not in the correct testsuite, so moving them in the right location.

Because you're the one who made me realize it, here goes @fmease (thanks!) :p

r? @fmease
2026-08-29 22:46:04 +02:00
Guillaume Gomez
b41b7bbd9a Rollup merge of #161944 - GuillaumeGomez:keyword-highlighting, r=fmease
rustdoc: Take into account edition information for keyword highlighting

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

The only thing that was missing was passing down an `Edition` to the highlighter (and adding tests).

r? @fmease
2026-08-29 22:46:03 +02:00
Guillaume Gomez
0feecd60a5 Move rustdoc ui doctests into the right testsuite 2026-08-29 21:34:38 +02:00
Guillaume Gomez
40dc9019c8 rustdoc: Take into account edition information for keyword highlighting 2026-08-29 17:51:13 +02:00
Jacob Pratt
b334066019 Rollup merge of #161910 - GuillaumeGomez:generated-macro, r=Urgau
Add rustdoc-html regression test for generated macro

Fixes rust-lang/rust#79289.

I like when bugs are already fixed. =D

r? @Urgau
2026-08-29 01:19:00 -04:00
Guillaume Gomez
66bbc147f5 Add rustdoc-html regression test for generated macro 2026-08-28 12:45:31 +02:00
Guillaume Gomez
7ff6be61e1 rustdoc: Correctly handle when a macro generates multiple items in --generate-macro-expansion 2026-08-27 20:37:01 +02:00
Guillaume Gomez
7d749cfad3 Rollup merge of #161553 - lolbinarycat:rustdoc-fix-read-more, r=GuillaumeGomez
rustdoc: fix issue preventing "read more" links from generating.

fixes https://github.com/rust-lang/rust/issues/161300
2026-08-25 00:33:35 +02:00
Waffle Lapkin
046ebb717e remove #![feature(never_type)] from tests 2026-08-24 19:04:00 +02:00
binarycat
eb1aebfb95 rustdoc: fix issue preventing "read more" links from generating. 2026-08-24 12:01:44 -04:00
Jamie Hill-Daniel
185483794e rustdoc: Always document #[repr(transparent)] if #[rustc_pub_transparent] is applied
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2026-08-19 12:55:34 +02:00
Jonathan Brouwer
6f0ad15b55 Rollup merge of #161105 - GuillaumeGomez:improve-cfg-message, r=Urgau
rustdoc: Small `doc_cfg` messages improvements

Fixes rust-lang/rust#145075.

I was writing a regression test for rust-lang/rust#145075 which was already fixed, saw it was looking like this:

<img width="242" height="247" alt="image" src="https://github.com/user-attachments/assets/421e6b4b-698f-4a01-93d9-022eb346d73c" />

So I made some small changes to improve the wording. Now it looks like this:

<img width="242" height="247" alt="image" src="https://github.com/user-attachments/assets/c950dd68-a760-4f18-b974-555e05fcfd78" />

r? @Urgau
2026-08-15 10:48:25 +02:00
Guillaume Gomez
efd7436979 Add regression test for #145075 2026-08-14 22:03:44 +02:00
Jacob Pratt
6a25fdd901 Rollup merge of #161054 - GuillaumeGomez:enum-variant-field-title, r=Urgau
rustdoc: Fix link title attribute value when field of enum variants

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

The issue was that we link to parent page, we generate a "fragment" to the parent item (so here the enum), because we forgot to take into account that there might be two levels: enum variants can have fields. So in case it's an enum and the `DefId` is a field, we add the field's parent name (so the enum variant) to the title.

r? @Urgau
2026-08-13 18:16:29 -04:00
Guillaume Gomez
a89abc8225 Fix link title attribute value when field of enum variants 2026-08-13 16:54:57 +02:00
mejrs
4449de3ac5 ensure anon consts themselves are not documented 2026-08-13 14:49:49 +02:00
mejrs
6ef144dcb3 rustdoc: use anonymous constant for primitives/keywords/attribute docs 2026-08-13 14:49:49 +02:00
Zac Harrold
413fdcabfb Add basic splat support to rustdoc
Simply replace the parameter name and `#[rustc_splat]` attribute with an ellipsis. This preserves the type information of the splat while still documenting the variadic nature of the function.
2026-08-12 08:18:52 +10:00
zakrad
1a049129e6 Add regression test for cross-crate assoc const private field leak 2026-08-08 23:10:17 +03:30
Jonathan Brouwer
408fecd121 Rollup merge of #159473 - notriddle:rename-parts-to-dep-meta, r=camelid
Fix, simplify, and document doc meta finalize mode

Follow up https://github.com/rust-lang/rust/pull/159415#discussion_r3605070232

Get rid of the mode where you can finalize the CCI and generate more docs at the same time. It isn't used in Cargo, and probably won't be used elsewhere?

Fixes a bug where the crate index, settings page, and help page aren’t generated at finalize time.

Update documentation.

Move CCI tests to run-make, so that we can test the finalize step’s CLI.
2026-08-05 21:55:45 +02:00
Jonathan Brouwer
a1eaf4e5a3 Rollup merge of #106643 - WaffleLapkin:read_recursive, r=joshtriplett
Allow only implementing `Read::read_buf`

This PR allows users to only implement `Read::read_buf`, without the need for implementing `Read::read`. `rustc_must_implement_one_of` annotation ensures that **at least** one of the methods is implemented, so that the default impls don't create infinite recursion.

Note that `Read::read_buf` is unstable, so this doesn't change anything on stable, there you still need to implement `Read::read`, since you can't implement `Read::read_buf`. Thus, we don't expose `rustc_must_implement_one_of` to stable.

r? @thomcc
2026-08-02 16:19:29 +02:00
Pavel Lazureykis
54941bef4f rustdoc: fix ICE when a grapheme cluster joins a Prepend character to _
`EscapeBodyTextWithWbr` iterates `text.grapheme_indices(true)`, so `i` is the
start of a grapheme cluster, but the `_`/`:` word-break arm sliced at `i + 1` --
assuming a cluster containing `_` or `:` is exactly one byte long.

UAX#29 GB9b joins a `Prepend`-class character (U+0600-U+0605, U+0D4E, U+111C2,
...) with the character that follows it, so a cluster can start with a
multi-byte character and still contain `_`. `i + 1` then lands inside that
character and `str` indexing panics. U+0D4E is `XID_Continue`, so this is
reachable from an item name rustc accepts, e.g. `pub struct abc<U+0D4E>_defgh;`,
and rustdoc ICEs instead of documenting the crate.

Break after the whole cluster (`i + s.len()`) instead. The adjacent CamelCase
arm already slices at `i`, which is always a cluster boundary, so it is
unaffected.

This also stops the `<wbr>` from being inserted between `_` and a combining
mark that trails it, which split a grapheme cluster without panicking.
2026-07-30 19:23:18 +00:00
Jonathan Brouwer
ee17d0d02f Rollup merge of #157058 - ThierryBerger:rustdoc_label_trait, r=GuillaumeGomez
Rustdoc label badge for notable traits

- Part of rust-lang/rust#156865
- [x] reuse notable trait feature to feed badge data
- [x] render it in html
- [x] add some html tests
- [x] Render a color from a hash from `its full path`
- [x] fixed oklch hue-driven palette checked against wcag/apca

Should the following be out of scope ?

- [ ] Parse color (`#[doc(notable_trait(color="0xff0000")]`)
- [ ] display a small colored indicator (with a hover/first letter?) when a type implementing a notable trait is listed outside of its main page
- [ ] Some Integration with rust analyzer

<img width="315" height="222" alt="Screenshot 2026-05-28 at 14 06 01" src="https://github.com/user-attachments/assets/2b7c19c4-0d6e-4ed7-8901-f82fba7fc122" />

## Color discussion

I went for the higher chroma, even though some values use a fallback, I'm not opposed to go for a less chromatic palette, but that's very bikeshedding so I'll defer to authority.

with chroma 0.21:
<img width="1048" height="274" alt="Screenshot 2026-06-30 at 21 57 27" src="https://github.com/user-attachments/assets/9f374295-4eb3-43ee-bffa-51276ffa39d2" />

with chroma 0.090:
<img width="1037" height="274" alt="Screenshot 2026-06-30 at 21 58 38" src="https://github.com/user-attachments/assets/81d9c5b5-02a8-4f75-969f-0d4fc62bebd0" />

## History

Initially, this PR added a new feature "label_trait", it was then decided in [rustdoc meeting](https://hackmd.io/CxdTcVFTQPmBUrx-PWXTAw?view) to reuse current notable_trait feature.
2026-07-29 14:10:33 +02:00
Josh Triplett
39429fd245 Fix links to std::io::Read::read 2026-07-28 16:12:25 -07:00
bors
701a6513a4 Auto merge of #159854 - camelid:selfty-head, r=notriddle,GuillaumeGomez
rustdoc: Only analyze head of self type when deciding impl inlining



We only care about whether the self type is a generic or an item (inlined) in
the current crate, so we don't actually need to compute the param_env, which is
expensive when done to every external impl.  This PR avoids computing the
param_env until we actually decide to inline the impl.  Moreover, it adds
specialized cleaning logic for types that stops after the "head" (the top-level
structure) is constructed, which is enough for the self type-based impl
inlining analysis.
2026-07-28 22:40:33 +00:00
Guillaume Gomez
493ed4a987 Make notable trait badge tests a bit "stronger" 2026-07-28 23:21:51 +02:00
Noah Lev
27c97d1380 rustdoc: Remove unneeded branches, add test 2026-07-28 16:51:55 +00:00
Thierry Berger
5b47394a50 add more tests about unlinkable private/doc-hidden/undocumented 2026-07-28 16:47:26 +02:00