about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-1/+1
2025-03-07Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obkMatthias Krüger-1/+1
Streamline HIR intravisit `visit_id` calls for items A small clean up.
2025-03-07Rollup merge of #138107 - yotamofek:pr/rustdoc/clippy, r=GuillaumeGomezMatthias Krüger-23/+22
`librustdoc`: clippy fixes First commit is all machine-generated fixes, next two are some more lints fixed by hand/misc. cleanups Inspired by the redundant `.and_then()` added in https://github.com/rust-lang/rust/pull/137320 , and [this comment](https://github.com/rust-lang/rust/pull/138090#discussion_r1983111856) r? ```@GuillaumeGomez```
2025-03-07Move `visit_id` calls.Nicholas Nethercote-1/+1
In `walk_item`, we call `visit_id` on every item kind. For most of them we do it directly in `walk_item`. But for `ItemKind::Mod`, `ItemKind::Enum`, and `ItemKind::Use` we instead do it in the `walk_*` function called (via the `visit_*` function) from `walk_item`. I can see no reason for this inconsistency, so this commit makes those three cases like all the other cases, moving the `visit_id` calls into `walk_item`. This also avoids the need for a few `HirId` arguments.
2025-03-06Manual, post-`clippy --fix` cleanupsYotam Ofek-13/+8
2025-03-06Implement `Ord` by-hand instead of `PartialOrd` for `Link`Yotam Ofek-6/+12
2025-03-06`x clippy src/librustdoc --fix`Yotam Ofek-6/+4
2025-03-06`librustdoc`: flatten nested ifsYotam Ofek-12/+10
2025-03-04Adapt `librustdoc` to 2024 edition lifetieme capture rulesYotam Ofek-316/+220
Get rid of the `Captures` hack
2025-03-04`librustdoc`: 2024 edition! 🎊Yotam Ofek-3/+3
2025-03-03Rollup merge of #137684 - GuillaumeGomez:rustdoc-dep-info, r=notriddleMatthias Krüger-1/+1
Add rustdoc support for `--emit=dep-info[=path]` Fixes #91982. This PR adds the `--emit=dep-info` command line flag support. It will be helpful for `cargo` development. cc ````@epage```` r? ````@notriddle````
2025-03-02Auto merge of #137425 - yotamofek:pr/rustdoc/return-impl-display-redux, ↵bors-2266/+2468
r=GuillaumeGomez `librustdoc`: return `impl fmt::Display` in more places instead of writing to strings Continuation of #136784 , another attempt at landing the larger parts of #136748 . I'd like to, gradually, make all of the building blocks for rendering docs in `librustdoc` return `impl fmt::Display` instead of returning `Strings`, or receiving a `&mut String` (or `&mut impl fmt::Write`). Another smaller end goal is to be able to get rid of [`write_str`](https://github.com/rust-lang/rust/blob/8dac72bb1d12b2649acd0c190e41524f83da5683/src/librustdoc/html/format.rs#L40-L42). This PR is a large step in that direction. Most of the changes are quite mechanical, and split up into separate commits for easier reviewing (hopefully). I took `print_item` and then started by converting all the functions it called (and their dependencies), and the last commit does the conversion for `print_item` itself. Ignoring whitespace should make reviewing a bit easier. And most importantly, perf run shows pretty good results locally, hopefully CI will also show green 😁 r? `@GuillaumeGomez` , if you feel like it.
2025-02-26Use helper function instead of reimplementing the logic to check if rustdoc ↵Guillaume Gomez-1/+1
should emit crate
2025-02-23return `impl fmt::Display` in more places instead of writing to stringsYotam Ofek-2266/+2468
2025-02-22Make asm a named fieldMichael Goulet-1/+1
2025-02-20Rollup merge of #137106 - chenyukang:yukang-fix-sidebar-sort, r=notriddleMatthias Krüger-1/+17
Add customized compare for Link in rustdoc Maybe some other types in sidebar need to be sorted in this way, maybe add this crate `natord` is ok? r? clubby789 Fixes #137098
2025-02-19Add custom sort for link in rustdocyukang-1/+17
2025-02-18Rollup merge of #136599 - yotamofek:pr/rustdoc-more-joined, r=GuillaumeGomezMatthias Krüger-16/+12
librustdoc: more usages of `Joined::joined` Some missed opportunities from #136244 r? ```@GuillaumeGomez``` since you reviewed the last one (feel free to re-assign, of course 😊) First two commits are just drive-by cleanups
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-5/+5
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17librustdoc: more usages of `Joined::joined`Yotam Ofek-16/+12
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-2/+2
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-14librustdoc: lazily format "read more" link in `document_short`Yotam Ofek-6/+15
2025-02-14librustdoc: lazily format some pathsYotam Ofek-6/+6
2025-02-14librustdoc: lazily format list of aliases in `render_impl_summary`Yotam Ofek-6/+6
2025-02-14librustdoc: make `item_path` formatting lazyYotam Ofek-12/+17
2025-02-14librustdoc: make `notable_traits_button` formatting lazyYotam Ofek-13/+15
2025-02-14librustdoc: make `assoc_href_attr` formatting lazyYotam Ofek-11/+33
2025-02-14librustdoc: make `bounds` formatting lazyYotam Ofek-23/+22
2025-02-14librustdoc: create `MaybeDisplay` helper for `Option<T: Display>` typesYotam Ofek-1/+1
2025-02-12Nuke `Buffer` abstraction from `librustdoc` 💣Yotam Ofek-472/+613
2025-02-08Rustfmtbjorn3-4/+5
2025-02-06Auto merge of #136265 - notriddle:notriddle/clean-up, r=fmeasebors-1/+1
rustdoc: use ThinVec for generic arg parts This reduces the size of both these args, and of path segments, so should measurably help with memory use.
2025-02-05Auto merge of #136253 - notriddle:notriddle/aot-minify, r=GuillaumeGomezbors-8/+2
rustdoc: run css and html minifier at build instead of runtime This way, adding a bunch of comments to the JS files won't make rustdoc slower. Meant to address https://github.com/rust-lang/rust/pull/136161#issuecomment-2622069453
2025-02-05Auto merge of #136244 - yotamofek:pr/rustdoc-join-iter, r=GuillaumeGomezbors-31/+27
librustdoc: create a helper for separating elements of an iterator instead of implementing it multiple times This implements something similar to [`Itertools::format`](https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.format), but on `Fn`s returning iterators instead of directly on iterators, to allow implementing `Display` without the use of a `Cell` (to handle the possibility of `fmt` being called multiple times while receiving `&self`). ~This is WIP, I just want to get a perf run first to see if the regression I saw in #135494 is fixed~ This was originally part of #135494 , but originally caused a perf regression that was since fixed: https://github.com/rust-lang/rust/blob/7d5ae1863aa66847a4edf8d2ef9420717df65c5d/src/librustdoc/html/format.rs#L507
2025-02-04librustdoc: create a helper for separating elements of an iterator instead ↵Yotam Ofek-31/+27
of implementing it multiple times
2025-01-30fix(rustdoc): always use a channel when linking to doc.rust-lang.orgAlexis (Poliorcetics) Bourget-5/+5
2025-01-29rustdoc: use ThinVec for generic arg partsMichael Howell-1/+1
This reduces the size of both these args, and of path segments, so should measurably help with memory use.
2025-01-29rustdoc: run css and html minifier at build instead of runtimeMichael Howell-8/+2
This way, adding a bunch of comments to the JS files won't make rustdoc slower.
2025-01-29Eliminate PatKind::PathOli Scherer-10/+16
2025-01-23Auto merge of #135494 - yotamofek:rustdoc-fmt-from_fn, r=fmeasebors-34/+31
Refactor `fmt::Display` impls in rustdoc This PR does a couple of things, with the intention of cleaning up and streamlining some of the `fmt::Display` impls in rustdoc: 1. Use the unstable [`fmt::from_fn`](https://github.com/rust-lang/rust/issues/117729) instead of open-coding it. 2. ~~Replace bespoke implementations of `Itertools::format` with the method itself.~~ 4. Some more minor cleanups - DRY, remove unnecessary calls to `Symbol::as_str()`, replace some `format!()` calls with lazier options The changes are mostly cosmetic but some of them might have a slight positive effect on performance.
2025-01-22rustdoc: use std's (unstable) `fmt::from_fn` instead of open-coding itYotam Ofek-33/+30
2025-01-22rustdoc: pass around decoration info by refYotam Ofek-1/+1
2025-01-22rustdoc: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-2/+1
2025-01-18Remove more CSS classesGuillaume Gomez-17/+8
2025-01-17Handle reexports items list a bit differently since they cannot have ↵Guillaume Gomez-7/+5
documentation
2025-01-17Replace ul/li list with dl/dd/dt elementsGuillaume Gomez-19/+11
2025-01-16Treat other items as functions for the purpose of type-based searchbinarycat-0/+27
constants and statics are nullary functions, and struct fields are unary functions. functions (along with methods and trait methods) are prioritized over other items, like fields and constants.
2025-01-15Auto merge of #134353 - oli-obk:safe-target-feature-unsafe-by-default, ↵bors-1/+1
r=wesleywiser Treat safe target_feature functions as unsafe by default [less invasive variant] This unblocks * #134090 As I stated in https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions. This is the less (imo) invasive variant of #134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.
2025-01-14Rollup merge of #135353 - lolbinarycat:rustdoc-disable-minification, r=notriddleJubilee-1/+9
re-add --disable-minification to rustdoc this also makes the rust.docs-minification option work as advertised in config.toml nothing fancy this time, this is intended to be perma-unstable. it's only really here for the benefit of rustdoc devs. mitegates https://github.com/rust-lang/rust/issues/135345 It was removed in https://github.com/rust-lang/rust/commit/f9e1f6ffdf03ec33cb29e20c88fc7bcc938c7f42.
2025-01-14Rollup merge of #134216 - GuillaumeGomez:jump-to-def-pats, r=fmeaseMatthias Krüger-4/+29
Enable "jump to def" feature on patterns Part of https://github.com/rust-lang/rust/issues/89095. Pattern (as in "patterns in pattern matching") were not handled by the feature, it's now added. It all started when I realized that prelude values like `Some` or `Err` were not getting a link generated either (added support for it in the first commit). r? ``@fmease``