Commit Graph

602 Commits

Author SHA1 Message Date
Guillaume Gomez
9119eba24d Add regression test for doc cfg applied on public items inside private items 2025-09-29 18:08:51 +02:00
Guillaume Gomez
6cccea8731 Remove doc_auto_cfg feature as well 2025-09-27 11:30:57 +02:00
Guillaume Gomez
77885fef2c Improve code comments and extend tests for doc_cfg feature 2025-09-27 11:29:50 +02:00
Guillaume Gomez
6fecff45d9 Fix tests/rustdoc/target-feature.rs test by adding missing #![feature(doc_cfg)] 2025-09-27 11:29:49 +02:00
Guillaume Gomez
c06a076634 Put back the doc_cfg code behind a nightly feature 2025-09-27 11:29:49 +02:00
Guillaume Gomez
2d82c99f1e Add "global" rustdoc test for RFC 3631 2025-09-27 11:29:48 +02:00
Guillaume Gomez
6537278e11 Update rustdoc tests 2025-09-27 11:29:48 +02:00
Guillaume Gomez
dba45cde68 Add tests for new tyalias intra-doc link disambiguator 2025-09-26 15:07:12 +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
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
Iris Shi
bd98e73fe0 Update tests/rustdoc/reexport/private-mod-override-reexport.rs 2025-09-22 17:45:51 +02:00
Iris Shi
52e6998a18 Move test file 2025-09-22 11:47:12 +08:00
Iris Shi
8f1a1f8533 Update tests/rustdoc/private-mod-override-re-export.rs
Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com>
2025-09-22 05:45:23 +02:00
Iris Shi
2a75cb9d6c add private module override re-export test 2025-09-20 16:12:29 +08:00
bors
b3cfb8faf8 Auto merge of #138736 - azhogin:azhogin/sanitizers-target-modificators, r=rcvalle
Sanitizers target modificators

Depends on bool flag fix: https://github.com/rust-lang/rust/pull/138483.

Some sanitizers need to be target modifiers, and some do not. For now, we should mark all sanitizers as target modifiers except for these: AddressSanitizer, LeakSanitizer

For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier.

Many test errors was with sanizer flags inconsistent with std deps. Tests are fixed with `-C unsafe-allow-abi-mismatch`.
2025-09-04 22:51:33 +00:00
Guillaume Gomez
75cbd05d19 Add tests for doc(attribute = "...") attribute 2025-08-28 15:56:30 +02:00
bors
809200ec95 Auto merge of #137229 - GuillaumeGomez:expand-macro, r=lolbinarycat
Add support for macro expansion in rustdoc source code pages

This is what it looks like:

![Screenshot From 2025-02-18 18-08-51](https://github.com/user-attachments/assets/ce2b3806-6218-47df-94bf-e9e9ed40cd41)

![image](https://github.com/user-attachments/assets/891042db-8632-4dba-9343-e28570c058fe)

You can test it [here](https://rustdoc.crud.net/imperio/macro-expansion/src/lib/lib.rs.html). In this case, I also enabled the `--generate-link-to-definition` to show that both options work well together.

Note: <del>There is a bug currently in firefox where the line numbers are not displayed correctly if they're inside the "macro expansion" span: https://bugzilla.mozilla.org/show_bug.cgi?id=1949948<del> Found a workaround around this bug.

r? `@notriddle`
2025-08-24 19:46:17 +00:00
Karol Zwolak
b8313dfb04 rustdoc: render attributes in Field and Variants sections 2025-08-24 12:01:08 +02:00
Karol Zwolak
90aa25a1c5 rustdoc: update attribute tests 2025-08-23 11:27:03 +02:00
Guillaume Gomez
0e9b126695 Also support statements and patterns for macro expansion 2025-08-23 00:57:29 +02:00
Andrew Zhogin
6d637dfecc -Zsanitize and -Zsanitizer-cfi-normalize-integers flags are now target modifiers with custom consistency check function 2025-08-21 16:08:00 +07:00
Michael Howell
8511e40e72 rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
Tsukasa OI
74aca53f55 rustdoc: Allow multiple references to a single footnote
Multiple references to a single footnote is a part of GitHub Flavored
Markdown syntax (although not explicitly documented as well as regular
footnotes, it is implemented in GitHub's fork of CommonMark) and not
prohibited by rustdoc.

cf. <587a12bb54/test/extensions.txt (L762-L780)>

However, using it makes multiple "sup" elements with the same "id"
attribute, which is invalid per the HTML specification.

Still, not only this is a valid GitHub Flavored Markdown syntax, this is
helpful on certain cases and actually tested (accidentally) in
tests/rustdoc/footnote-reference-in-footnote-def.rs.

This commit keeps track of the number of references per footnote and gives
unique ID to each reference.  It also emits *all* back links from a footnote
to its references as "↩" (return symbol) plus a numeric list in superscript.

As a known limitation, it assumes that all references to a footnote are
rendered (this is not always true if a dangling footnote has one or more
references but considered a reasonable compromise).

Also note that, this commit is designed so that no HTML changes will occur
unless multiple references to a single footnote is actually used.
2025-08-14 04:39:31 +00:00
Eval EXEC
de13718c66 test: Add rustdoc test for enum negative overflow 2025-08-10 23:02:53 +08:00
Guillaume Gomez
25e767b0ee Ignore impl associated types in jump to def feature 2025-08-10 15:49:22 +02:00
Guillaume Gomez
d528a49fd7 Fix panic if an item does not have a body 2025-08-10 12:00:08 +02:00
Guillaume Gomez
f1649a4e43 Better handling of paths in link to def feature 2025-08-10 12:00:08 +02:00
Guillaume Gomez
49044d0d40 Add support for trait associated items 2025-08-10 12:00:08 +02:00
binarycat
34b358d52a rustdoc: fix caching of intra-doc links on reexports 2025-08-05 15:34:51 -05:00
Samuel Tardieu
4eddebd42b Rollup merge of #143662 - obi1kenobi:pg/unsafe-attribute-wrappers, r=t-rustdoc
[rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.

Use Rust 2024 edition representation for unsafe attributes in rustdoc HTML:
- `#[no_mangle]` -> `#[unsafe(no_mangle)]`
- `#[export_name = "foo"]` -> `#[unsafe(export_name = "foo")]`
- `#[link_section = ".text"]` -> `#[unsafe(link_section = ".text")]`

The 2024 edition representation is used regardless of the crate's own edition. This ensures that Rustaceans don't have to learn the rules of an outdated edition (e.g. that `unsafe()` wasn't always necessary) in order to understand a crate's documentation.

After some looking through the `T-rustdoc` issues, I was not able to find an existing issue for this. Apologies if I missed it.

r? ``````@aDotInTheVoid``````
2025-08-02 11:24:21 +02:00
Jacob Pratt
e6b80f3407 Rollup merge of #143849 - lolbinarycat:rustdoc-priv-normalize-143222, r=GuillaumeGomez
rustdoc: never link to unnamable items

fixes rust-lang/rust#143222
2025-08-01 00:38:19 -04:00
Kornel
0813cc9dcf Test renamed crates in rustdoc 2025-07-28 13:34:03 +01:00
Predrag Gruevski
45231fa599 [rustdoc] Display unsafe attrs with edition 2024 unsafe() wrappers. 2025-07-23 00:00:01 +00:00
binarycat
94700f8f3f fix regression test 2025-07-22 17:11:48 -05:00
binarycat
293f95fb0c add regression test for RUST-143222 2025-07-22 17:11:48 -05:00
Jonathan Brouwer
9f16db6611 Regression test 2025-07-17 08:03:17 +02:00
Guillaume Gomez
086b13d170 Add regression test for #143107 2025-07-10 11:41:50 +02:00
Jacob Pratt
01fe1c0b0e Rollup merge of #143381 - fee1-dead-contrib:push-pzxuvlnymxpu, r=GuillaumeGomez
rustdoc: don't treat methods under const impls or traits as const

Fixes rust-lang/rust#143071
2025-07-04 05:47:28 +02:00
Guillaume Gomez
678ec9bbd4 Rollup merge of #141831 - lolbinarycat:rustdoc-extern-reexport-135092, r=GuillaumeGomez
rustdoc: fix attrs of locally reexported foreign items

fixes rust-lang/rust#135092

also tweaks a few outdated/misleading comments.

r? `@GuillaumeGomez`
2025-07-03 19:45:30 +02:00
Deadbeef
510e5d7e66 rustdoc: don't treat methods under const impls or traits as const 2025-07-03 23:16:47 +08:00
Jana Dönszelmann
622722aada Rollup merge of #143083 - JonathanBrouwer:rustdoc-fix, r=jdonszelmann
Fix rustdoc not correctly showing attributes on re-exports

Fixes attributes not being shown correctly in rustdoc on re-exports

Does this need to be backported to beta?

r? ``@jdonszelmann``
2025-07-03 13:29:37 +02:00
Matthias Krüger
e5bd07ac2e Rollup merge of #142367 - GuillaumeGomez:extern-crate-items-intra-doc, r=lolbinarycat
Add regression test for #137857 to ensure that we generate intra doc links for extern crate items.

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

I checked that linking to extern crates was generating valid links (with the `/index.html` part) and since it's already working, just adding a regression test.

r? `@notriddle`
2025-06-29 06:59:28 +02:00
Matthias Krüger
8f30a98591 Rollup merge of #142987 - lolbinarycat:rustdoc-non_exhaustive-enum-v-142599, r=GuillaumeGomez
rustdoc: show attributes on enum variants

mostly for #[non_exhaustive]

unsure if there's any attributes we should take care to *not* include, it could use `render_code_attribute` and `is_non_exhaustive` instead, if that is a concern.

fixes rust-lang/rust#142599
2025-06-28 22:05:30 +02:00
Guillaume Gomez
1052ddda96 Add regression test for #137857 to ensure that we generate intra doc links for extern crate items. 2025-06-28 11:27:12 +02:00
Jonathan Brouwer
58418d881a Fix rustdoc not correctly showing attributes with re-exports
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-27 23:31:25 +02:00
Matthias Krüger
36c2b011cb Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-dead
New const traits syntax

This PR only affects the AST and doesn't actually change anything semantically.

All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser

Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error

r? ``@fee1-dead``

cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27 22:13:00 +02:00
binarycat
f7321becd2 rustdoc: add regression test for issue 135092 2025-06-27 11:49:12 -05:00
binarycat
b2be01c815 rustdoc: show attributes on enum variants
mostly for #[non_exhaustive]
2025-06-26 12:33:30 -05:00