about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2025-06-16rustdoc: add ways of collapsing all impl blocksbinarycat-6/+22
either shift+click the Summary button, or use the `_` key. this collapses everything, including (inherent) impl blocks. no need for a special "expand all impl blocks" method, as impl blocks are expanded during regular "expand all". doing "expand all" -> "collapse all" will always result in only impl blocks being expaned. some of the html is split up a bit awkwardly to try to avoid introducing new whitespaces nodes, which could affect display. Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-06-16Add comment to prevent having code other than `initSearch` at the end of ↵Guillaume Gomez-0/+4
`search.js`
2025-06-14Auto merge of #142335 - nnethercote:rustdoc-json-allocations, r=aDotInTheVoidbors-141/+159
rustdoc_json: reduce allocations These commits reduce the number of allocations done for rustdoc_json, mostly by avoiding unnecessary clones. Best reviewed one commit at a time. r? `@aDotInTheVoid`
2025-06-14Fix random failure when JS code is executed when the whole file was not read yetGuillaume Gomez-37/+37
2025-06-14Rollup merge of #141399 - GuillaumeGomez:extracted-doctest, r=aDotInTheVoidMatthias Krüger-50/+219
[rustdoc] Give more information into extracted doctest information Follow-up of https://github.com/rust-lang/rust/pull/134531. This update fragment the doctest code into its sub-parts to give more control to the end users on how they want to use it. The new JSON looks like this: ```json { "format_version":2, "doctests":[ { "file":"$DIR/extract-doctests-result.rs", "line":8, "doctest_attributes":{ "original":"", "should_panic":false, "no_run":false, "ignore":"None", "rust":true, "test_harness":false, "compile_fail":false, "standalone_crate":false, "error_codes":[], "edition":null, "added_css_classes":[], "unknown":[] }, "original_code":"let x = 12;\nOk(())", "doctest_code":{ "crate_level":"#![allow(unused)]\n", "code":"let x = 12;\nOk(())", "wrapper":{ "before":"fn main() { fn _inner() -> core::result::Result<(), impl core::fmt::Debug> {\n", "after":"\n} _inner().unwrap() }", "returns_result":true } }, "name":"$DIR/extract-doctests-result.rs - (line 8)" } ] } ``` for this doctest: ```rust let x = 12; Ok(()) ``` With this, I think it matches what you need ``@ojeda?`` If so, once merged I'll update the patch I sent to RfL. r? ``@aDotInTheVoid``
2025-06-13Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgrbors-2/+3
Rollup of 9 pull requests Successful merges: - rust-lang/rust#128425 (Make `missing_fragment_specifier` an unconditional error) - rust-lang/rust#135927 (retpoline and retpoline-external-thunk flags (target modifiers) to enable retpoline-related target features) - rust-lang/rust#140770 (add `extern "custom"` functions) - rust-lang/rust#142176 (tests: Split dont-shuffle-bswaps along opt-levels and arches) - rust-lang/rust#142248 (Add supported asm types for LoongArch32) - rust-lang/rust#142267 (assert more in release in `rustc_ast_lowering`) - rust-lang/rust#142274 (Update the stdarch submodule) - rust-lang/rust#142276 (Update dependencies in `library/Cargo.lock`) - rust-lang/rust#142308 (Upgrade `object`, `addr2line`, and `unwinding` in the standard library) Failed merges: - rust-lang/rust#140920 (Extract some shared code from codegen backend target feature handling) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-apple try-job: x86_64-msvc-1 try-job: x86_64-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: test-various
2025-06-13Rollup merge of #135927 - azhogin:azhogin/retpoline, r=davidtwcoMatthias Krüger-2/+3
retpoline and retpoline-external-thunk flags (target modifiers) to enable retpoline-related target features `-Zretpoline` and `-Zretpoline-external-thunk` flags are target modifiers (tracked to be equal in linked crates). * Enables target features for `-Zretpoline-external-thunk`: `+retpoline-external-thunk`, `+retpoline-indirect-branches`, `+retpoline-indirect-calls`. * Enables target features for `-Zretpoline`: `+retpoline-indirect-branches`, `+retpoline-indirect-calls`. It corresponds to clang -mretpoline & -mretpoline-external-thunk flags. Also this PR forbids to specify those target features manually (warning). Issue: rust-lang/rust#116852
2025-06-13Rollup merge of #142158 - xizheyin:141617, r=jdonszelmannMatthias Krüger-1/+1
Tracking the old name of renamed unstable library features This PR resolves the first problem of rust-lang/rust#141617 : tracking renamed unstable features. The first commit is to add a ui test, and the second one tracks the changes. I will comment on the code for clarification. r? `@jdonszelmann` There have been a lot of PR's reviewed by you lately, thanks for your time! cc `@jyn514`
2025-06-13Rollup merge of #141770 - GuillaumeGomez:cfg-false-mod-rendering, r=camelidMatthias Krüger-13/+16
Merge `Cfg::render_long_html` and `Cfg::render_long_plain` methods common code Follow-up of https://github.com/rust-lang/rust/pull/141747. Thanks `@camelid` for spotting it! r? `@camelid`
2025-06-12Tracking the old name of renamed unstable library attributexizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-11Update extracted-doctest feature documentationGuillaume Gomez-0/+1
2025-06-11Don't clone `new_item` in `after_krate`.Nicholas Nethercote-7/+16
We can avoid it by using the `entry` API, which lets us do the `assert_eq` comparison before `new_item` is consumed.
2025-06-11Avoid more clones in rustdoc JSON output.Nicholas Nethercote-125/+133
By making `JsonRenderer::item` take `&clean::Item` instead of a `clean::Item`. This required also changing `FromClean` and `IntoJson` methods to take references, which required a lot of follow-on sigil wrangling that is mostly tedious.
2025-06-10rustdoc search: prefer stable items in search resultsbinarycat-3/+39
fixes https://github.com/rust-lang/rust/issues/138067
2025-06-10Add more tests to check extracted doctests featureGuillaume Gomez-3/+55
2025-06-10Improve naming of variables in `DocTestBuilder::generate_unique_doctest`Guillaume Gomez-9/+40
Improve code
2025-06-10Give more information into extracted doctest informationGuillaume Gomez-49/+134
2025-06-10Avoid cloning `self.index` in `after_krate`.Nicholas Nethercote-2/+4
It can be very big. This reduces peak memory usage for some `--output-format=json` runs by up to 8%.
2025-06-10Simplify `JsonRenderer`.Nicholas Nethercote-10/+9
- It doesn't need to be cloneable. - Some of the `Rc`s and `RefCell`s aren't doing anything. - `after_krate` can consume `self`.
2025-06-10rustdoc: Refractor `clean_ty_generics`Alona Enraght-Moony-74/+19
2025-06-09-Zretpoline and -Zretpoline-external-thunk flags (target modifiers) to ↵Andrew Zhogin-2/+3
enable retpoline-related target features
2025-06-08Rollup merge of #142053 - heiher:loong32-none, r=wesleywiserJubilee-0/+1
Add new Tier-3 targets: `loongarch32-unknown-none*` MCP: https://github.com/rust-lang/compiler-team/issues/865 NOTE: LoongArch32 ELF object support is available starting with object v0.37.0.
2025-06-07Rollup merge of #140560 - Urgau:test_attr-module-level, r=GuillaumeGomezGuillaume Gomez-59/+127
Allow `#![doc(test(attr(..)))]` everywhere This PR adds the ability to specify [`#![doc(test(attr(..)))]`](https://doc.rust-lang.org/nightly/rustdoc/write-documentation/the-doc-attribute.html#testattr) ~~at module level~~ everywhere in addition to allowing it at crate-root. This is motivated by a recent PR #140323 (by ````@tgross35)```` where we have to duplicate 2 attributes to every single `f16` and `f128` doctests, by allowing `#![doc(test(attr(..)))]` at module level (and everywhere else) we can omit them entirely and just have (in both module): ```rust #![doc(test(attr(feature(cfg_target_has_reliable_f16_f128))))] #![doc(test(attr(expect(internal_features))))] ``` Those new attributes are appended to the one found at crate-root or at a previous module. Those "global" attributes are compatible with merged doctests (they already were before). Given the small addition that this is, I'm proposing to insta-stabilize it, but I can feature-gate it if preferred. Best reviewed commit by commit. r? ````@GuillaumeGomez````
2025-06-06Add new Tier-3 targets: `loongarch32-unknown-none*`WANG Rui-0/+1
MCP: https://github.com/rust-lang/compiler-team/issues/865
2025-06-06Rollup merge of #142092 - fmease:rustdoc-alias-terms, r=GuillaumeGomezMatthias Krüger-131/+106
rustdoc: Support middle::ty associated const equality predicates again Fix intentional regression from PR rust-lang/rust#125076. Fixes rust-lang/rust#125092. Fixes rust-lang/rust#134775. CC rust-lang/rust#141368 (`EqPredicates` and rustdoc).
2025-06-05Support middle::ty assoc const eq predicates againLeón Orell Valerian Liehr-118/+92
2025-06-05Rename `should_show_cast` to `should_fully_qualify`León Orell Valerian Liehr-15/+16
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-1/+1
2025-06-04Rollup merge of #141968 - oli-obk:wfck-everything-at-once, r=wesleywiserMatthias Krüger-3/+1
Run wfcheck in one big loop instead of per module Maybe we can merge this big loop in the future with the `par_hir_body_owners` call below and run typeck only on items that didn't fail wfcheck. For now let's just see if perf likes it, as it by itself should be beneficial to parallel rustc
2025-06-03Run wfcheck in one big loop instead of per moduleOli Scherer-3/+1
2025-06-03Overhaul `UsePath`.Nicholas Nethercote-3/+3
`UsePath` contains a `SmallVec<[Res; 3]>`. This holds up to three `Res` results, one per namespace (type, value, or macro). `lower_import_res` takes a `PerNS<Option<Res<NodeId>>>` result and lowers it into the `SmallVec`. This is pretty weird. The input `PerNS` makes it clear which `Res` belongs to which namespace, but the `SmallVec` throws that information away. And code that operates on the `SmallVec` tends to use iteration (or even just grabbing the first entry!) without knowing which namespace the `Res` belongs to. Even weirder! Also, `SmallVec` is an overly flexible type to use here, because it can contain any number of elements (even though it's optimized for 3 in this case). This commit changes `UsePath` so it also contains a `PerNS<Option<Res<HirId>>>`. This type preserves more information and is more self-documenting. The commit also changes a lot of the use sites to access the result for a particular namespace. E.g. if you're looking up a trait, it will be in the `Res` for the type namespace if it's present; it's silly to look in the `Res` for the value namespace or macro namespace. Overall I find the new code much easier to understand. However, some use sites still iterate. These now use `present_items` because that filters out the `None` results. Also, `redundant_pub_crate.rs` gets a bigger change. A `UseKind:ListStem` item gets no `Res` results, which means the old `all` call in `is_not_macro_export` would succeed (because `all` succeeds on an empty iterator) and the `ListStem` would be ignored. This is what we want, but was more by luck than design. The new code detects `ListStem` explicitly. The commit generalizes the name of that function accordingly. Finally, the commit also removes the `use_path` arena, because `PerNS<Option<Res>>` impls `Copy` (unlike `SmallVec`) and it can be allocated in the arena shared by all `Copy` types.
2025-05-31Rollup merge of #141740 - nnethercote:hir-ItemKind-field-order, r=fee1-deadMatthias Krüger-10/+10
Hir item kind field order A follow-up to rust-lang/rust#141675. r? `@fee1-dead`
2025-05-30* Merge `Cfg::render_long_html` and `Cfg::render_long_plain` methods common codeGuillaume Gomez-13/+16
* Fix invalid whitespace handling
2025-05-30Auto merge of #141765 - matthiaskrgr:rollup-4hug83b, r=matthiaskrgrbors-50/+88
Rollup of 5 pull requests Successful merges: - rust-lang/rust#141703 (Structurally normalize types as needed in `projection_ty_core`) - rust-lang/rust#141719 (Add tls_model for cygwin and enable has_thread_local) - rust-lang/rust#141736 (resolve stage0 sysroot from rustc) - rust-lang/rust#141746 (Rework `#[doc(cfg(..))]` checks as distinct pass in rustdoc) - rust-lang/rust#141749 (Remove RUSTC_RETRY_LINKER_ON_SEGFAULT hack) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-30Rollup merge of #141746 - Urgau:rework-doc_cfg-checks, r=GuillaumeGomezMatthias Krüger-50/+88
Rework `#[doc(cfg(..))]` checks as distinct pass in rustdoc This PR reworks how rustdoc calls `rustc_attr_parsing::cfg_matches` to be in a separate pass, instead of being wired-up in a ad-hoc way, which is causing problems in https://github.com/rust-lang/rust/pull/138907#issuecomment-2920026627. This un-does most part of https://github.com/rust-lang/rust/pull/140894, but the result is IMO much cleaner, easier to reason about, and most importantly no longer interfears with rust-lang/rust#138907. r? `@GuillaumeGomez`
2025-05-30Auto merge of #141573 - nnethercote:rustdoc-alloc-cleanups, r=camelidbors-146/+140
rustdoc: cleanups relating to allocations These commits generally clean up the code a bit and also reduce allocation rates a bit. r? `@camelid`
2025-05-30Rollup merge of #141747 - lolbinarycat:rustdoc-cfg-138112, r=GuillaumeGomezMatthias Krüger-3/+12
rustdoc: display doc(cfg(false)) properly before we had an extra 'on' that was ungramatical. fixes https://github.com/rust-lang/rust/issues/138112 this is what it looks like now: ![screenshot: Available nowhere](https://github.com/user-attachments/assets/e27b4990-09a7-4f13-8bcf-26d44c8c1bea)
2025-05-30Address review comments.Nicholas Nethercote-6/+6
2025-05-29rustdoc: display doc(cfg(false)) properlybinarycat-3/+12
before we had an extra 'on' that was ungramatical. fixes https://github.com/rust-lang/rust/issues/138112
2025-05-29Rework `#[doc(cfg(..))]` checks as distinct pass in rustdocUrgau-50/+88
2025-05-30Reorder fields in `hir::ItemKind` variants.Nicholas Nethercote-10/+10
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match the textual order in the source code. The interesting part of the change is in `compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical refactoring.
2025-05-28Rollup merge of #141411 - lolbinarycat:rustdoc-link-proc-macro-91274, ↵Trevor Gross-8/+28
r=GuillaumeGomez rustdoc: linking to a local proc macro no longer warns fixes https://github.com/rust-lang/rust/issues/91274 tried to keep the fix general in case we ever have any other kind of item that occupies multiple namespaces simultaniously.
2025-05-27Rollup merge of #141517 - ↵Trevor Gross-21/+30
lolbinarycat:rustdoc-doctest-tooltip-ignore-141092, r=notriddle rustdoc: use descriptive tooltip if doctest is conditionally ignored fixes https://github.com/rust-lang/rust/issues/141092 here's what it looks like now: ![screenshot](https://github.com/user-attachments/assets/71e679fe-8828-439d-a2ce-b9187ad3aeea)
2025-05-27Rollup merge of #140894 - Urgau:check-cfg-rustdoc, r=GuillaumeGomezTrevor Gross-8/+45
Make check-cfg diagnostics work in `#[doc(cfg(..))]` This PR makes it so that the check-cfg `unexpected_cfgs` lint, is correctly emitted in `rustdoc`'s `#[doc(cfg(..))]`. This is achieved by adding a custom trait to `cfg_matches` (the method that emits the lint) which permits `rustc` and `rustdoc` to each have their way to emitting lints (via buffered lints/AST for `rustc` and via `TyCtxt`/HIR for `rustdoc`). The reason this is required is because buffered lints operates on the AST but `rustdoc` uses the HIR and by the time `rustdoc` calls `cfg_matches` we are way passed the point where buffered lints have been drain and emitted. Best reviewed commit by commit. r? `@jieyouxu` (for the compiler part) r? `@GuillaumeGomez` (for the rustdoc part)
2025-05-27scrape-examples.js: fix typoslolbinarycat-2/+2
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-27rustdoc: linking to a local proc macro no longer warnsbinarycat-8/+28
fixes https://github.com/rust-lang/rust/issues/91274 Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-27Rename unpack to kindMichael Goulet-3/+3
2025-05-27Streamline `visibility_print_with_space`.Nicholas Nethercote-41/+37
Moving the visibility stuff into the `from_fn` avoids the `Cow` and makes the code a little shorter and simpler.
2025-05-27Streamline `TypeAliasPart::get`.Nicholas Nethercote-17/+16
- `ret` only ever gets at most one entry, so it can be an `Option` instead of a `Vec`. - Which means we can use `filter_map` instead of `flat_map`. - Move `trait_` next to the `ret` assignment, which can only happen once. - No need for `impls` to be a `Vec`, it can remain an iterator. - Avoid `Result` when collecting `impls`.
2025-05-26rustdoc: use custom `CfgMatchesLintEmitter` to make check-cfg workUrgau-8/+45