Commit Graph

625 Commits

Author SHA1 Message Date
Guillaume Gomez 348d9d98e0 Correctly iterate doc comments in intra-doc resolution in rustc_resolve 2025-12-10 12:28:07 +01:00
Asuka Minato 171c77e387 add test 2025-11-26 16:33:13 +09:00
Guillaume Gomez 8642d82ff5 Add test for href of reexported enum variant 2025-11-18 12:23:32 +01:00
Guillaume Gomez 2a1bd47a4a Move tests/rustdoc/import_trait_associated_functions.rs into the reexport folder 2025-11-18 12:23:32 +01:00
Guillaume Gomez 044245c6c8 Add regression test for #148008 2025-11-13 15:34:49 +01:00
Guillaume Gomez dacabcd20d Update jump to def macro link generation test 2025-11-11 17:41:17 +01:00
Stuart Cook f342c62537 Rollup merge of #148639 - midsterx:test/rustdoc, r=GuillaumeGomez
test(rustdoc): move tests into jump-to-def

Fixes https://github.com/rust-lang/rust/issues/148548
2025-11-11 21:09:40 +11:00
midsterx ee8c913bdf test(rustdoc): move tests into jump-to-def 2025-11-09 23:10:27 -08:00
Matthias Krüger 5430082e39 Rollup merge of #148655 - GuillaumeGomez:keyword-as-macros, r=yotamofek,fmease
Fix invalid macro tag generation for keywords which can be followed by values

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

The problem didn't come from the `generate-macro-expansion` feature but was actually uncovered thanks to it.

Keywords like `if` or `return`, when followed by a `!` were considered as macros, which was wrong and let to invalid class stack and to the panic.

~~While working on it, I realized that `_` was considered as a keyword, so I fixed that as well in the second commit.~~ (reverted, see https://github.com/rust-lang/rust/pull/148655#issuecomment-3508220823, https://github.com/rust-lang/rust/pull/148655#issuecomment-3508262637)

r? `@yotamofek`
2025-11-09 20:59:54 +01:00
Guillaume Gomez 2c4a593b5c Add regression tests for keywords wrongly considered as macros 2025-11-09 18:00:52 +01:00
Matthias Krüger e5a69bb215 Rollup merge of #148683 - fmease:rm-const_trait-attr, r=fee1-dead
Remove `#[const_trait]`

Remove `#[const_trait]` since we now have `const trait`. Update all structured diagnostics that still suggested the attribute.

r? ```@rust-lang/project-const-traits```
2025-11-09 17:37:05 +01:00
bors ab67c37c6d Auto merge of #148660 - fmease:cross-crate-cfg, r=GuillaumeGomez
Encode cfg trace, not its early counterpart to fix cross-crate `doc(auto_cfg)`

Fixes rust-lang/rust#141301.

<details><summary>Rambling about <code>target_feature</code> which I didn't touch here</summary>

Regarding https://github.com/rust-lang/rust/issues/141301#issuecomment-3390100259 (`#[target_feature(enable = …)]` on inlined cross-crate re-exports), it has the same underlying cause (namely, we neither encode `target_feature` nor `AttributeKind::TargetFeature` in the crate metadata). However, I didn't make that change because I first want to experiment with querying `TyCtxt::codegen_fn_attrs` in rustdoc instead which already works cross-crate (and also use to it for reconstructing `no_mangle`, `export_name`, `link_section` to avoid encoding these attributes unnecessarily (basically reverting rust-lang/rust#144050) as suggested in https://github.com/rust-lang/rust/issues/144004#issuecomment-3077725837).

</details>

r? GuillaumeGomez
2025-11-09 11:44:27 +00:00
bors acda5e9f9a Auto merge of #148692 - matthiaskrgr:rollup-hryk71f, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#145656 (Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro)
 - rust-lang/rust#147024 (std_detect: Support run-time detection on OpenBSD using elf_aux_info)
 - rust-lang/rust#147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - rust-lang/rust#147540 (Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.)
 - rust-lang/rust#147686 (update isolate_highest_one for NonZero<T>)
 - rust-lang/rust#148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - rust-lang/rust#148555 (Fix rust-by-example spanish translation)
 - rust-lang/rust#148556 (Fix suggestion for returning async closures)
 - rust-lang/rust#148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - rust-lang/rust#148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-09 01:40:19 +00:00
bors 72b21e1a64 Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
mgca: Add ConstArg representation for const items

tracking issue: rust-lang/rust#132980
fixes rust-lang/rust#131046
fixes rust-lang/rust#134641

As part of implementing `min_generic_const_args`, we need to distinguish const items that can be used in the type system, such as in associated const equality projections, from const items containing arbitrary const code, which must be kept out of the type system. Specifically, all "type consts" must be either concrete (no generics) or generic with a trivial expression like `N` or a path to another type const item.

To syntactically distinguish these cases, we require, for now at least, that users annotate all type consts with the `#[type_const]` attribute. Then, we validate that the const's right-hand side is indeed eligible to be a type const and represent it differently in the HIR.

We accomplish this representation using a new `ConstItemRhs` enum in the HIR, and a similar but simpler enum in the AST. When `#[type_const]` is **not** applied to a const (e.g. on stable), we represent const item right-hand sides (rhs's) as HIR bodies, like before. However, when the attribute is applied, we instead lower to a `hir::ConstArg`. This syntactically distinguishes between trivial const args (paths) and arbitrary expressions, which are represented using `AnonConst`s. Then in `generics_of`, we can take advantage of the existing machinery to bar the `AnonConst` rhs's from using parent generics.
2025-11-08 22:31:33 +00:00
Noah Lev 5171e42cec Fix rustdoc tests 2025-11-08 13:50:48 -05:00
Matthias Krüger a029c11188 Rollup merge of #148230 - fmease:rustdoc-highlight-tweaks, r=GuillaumeGomez
rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks

Before | After
---|---
<img width="517" height="532" alt="Screenshot 2025-10-28 at 23-21-02 pre rs - source" src="https://github.com/user-attachments/assets/5026761f-c604-4bcc-a699-9e75eb73dff6" /> | <img width="499" height="531" alt="Screenshot 2025-10-28 at 23-21-51 pre rs - source" src="https://github.com/user-attachments/assets/cc8c65e7-e3ad-4e20-a2c3-2623cf799093" />
2025-11-08 15:42:23 +01:00
León Orell Valerian Liehr c262920059 Remove #[const_trait] 2025-11-08 07:37:15 +01:00
León Orell Valerian Liehr 6419f9a9df Encode cfg trace, not its early counterpart to fix cross-crate doc(auto_cfg) 2025-11-07 18:09:29 +01:00
Matthias Krüger 7b766e026a Rollup merge of #148213 - GuillaumeGomez:fix-exit-of-expansion, r=yotamofek
Fix invalid tag closing when leaving expansion "original code"

Fixes rust-lang/rust#148184.

Problem was that in case an element inside the expansion's "original" element was not closed, this element would get its `pending_exit` field set to `true`, removing it when the next non-mergeable item gets pushed instead of being put inside it, and then next `exit_elem` would try to exit an empty class queue.

r? ```@notriddle```
2025-11-06 12:29:58 +01:00
León Orell Valerian Liehr 1f23b48492 rustdoc: Properly highlight shebang and frontmatter 2025-10-29 02:49:16 +01:00
Guillaume Gomez 8442380278 Add regression test for #148184 2025-10-28 15:44:52 +01:00
Aarav Desai 0715745c1c Move rustdoc tests to appropriate subdirectories
Reorganize rustdoc tests into their correct subdirectories for better
categorization:
- Move lint-related tests to rustdoc-ui/lints/
- Move intra-doc link tests to rustdoc-ui/intra-doc/
- Move deref-related tests to rustdoc-ui/deref/
- Move doc-cfg test to rustdoc/doc-cfg/

This improves test organization and makes it easier to find tests
related to specific rustdoc functionality.
2025-10-26 19:16:41 -07:00
Guillaume Gomez 21db004f58 Fix invalid jump to def link generated on derive attributes 2025-10-22 16:59:57 +02:00
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. <https://github.com/github/cmark-gfm/blob/587a12bb54d95ac37241377e6ddc93ea0e45439b/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