summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2025-06-22Port `#[no_mangle]` to new attribute parsing infrastructureJonathan Brouwer-3/+3
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-21Auto merge of #142667 - yotamofek:pr/rustdoc/more-write-shared-perf, ↵bors-27/+12
r=nnethercote Avoid a few more allocations in `write_shared.rs` Inspired by rust-lang/rust#141421 , avoids a few `Vec`, `PathBuf` and `String` allocations in `write_shared.rs`. I don't think these will show up on benchmarks, but are still worthwhile IMHO. Also includes a few small cleanups. r? nnethercote - if you'd like :)
2025-06-19rustdoc: Remove `FormatRenderer::cache`Alona Enraght-Moony-4/+0
We only called it it one place, which isn't generic and can be replaced with a field access.
2025-06-19`Option`s are `Iterator`sYotam Ofek-11/+4
2025-06-19avoid intermediately collecting into vectorsYotam Ofek-8/+4
2025-06-19one less pathbuf allocationYotam Ofek-2/+2
2025-06-18`Result::expect` instead of `match` and `panic!`Yotam Ofek-6/+2
2025-06-16rustdoc: make srcIndex no longer a global variablebinarycat-20/+4
this is one-time initialization data, it can just be a function parameter. we also move the json parsing into createSrcSidebar to save a few bytes.
2025-06-11Avoid more clones in rustdoc JSON output.Nicholas Nethercote-1/+1
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-10Simplify `JsonRenderer`.Nicholas Nethercote-1/+1
- 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-05-30Auto merge of #141573 - nnethercote:rustdoc-alloc-cleanups, r=camelidbors-43/+53
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-30Address review comments.Nicholas Nethercote-1/+1
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-26Avoid some unnecessary cloning.Nicholas Nethercote-9/+9
2025-05-26Rename some methods.Nicholas Nethercote-17/+28
Most of the methods returning `impl Display` have `print` in their name. This commit renames a few that didn't follow that convention.
2025-05-25Update to new APIGuillaume Gomez-1/+2
2025-05-25Improve codeGuillaume Gomez-43/+43
2025-05-25Tweak attribute rendering depending on wether or not it is a type aliasGuillaume Gomez-18/+104
2025-05-25Rename the `document_*` argument/field into `is_type_alias`Guillaume Gomez-11/+11
2025-05-25Split `Item::attributes` method into threeGuillaume Gomez-2/+2
2025-05-25Unify rendering of type aliases without ADT itemsGuillaume Gomez-134/+134
2025-05-25Rename `clean::Enum::variants` method into `non_stripped_variants`Guillaume Gomez-2/+2
2025-05-24Rollup merge of #141487 - GuillaumeGomez:update-askama, r=notriddleGuillaume Gomez-1/+1
Update askama to `0.14.0` [Askama 0.14.0 release notes](https://github.com/askama-rs/askama/releases/tag/v0.14.0) Just one change needed for a filter in rustdoc. r? ```@notriddle```
2025-05-24Update `askama` version to `0.14.0` in librustdocGuillaume Gomez-1/+1
2025-05-24Simplify things a little more.Nicholas Nethercote-6/+3
2025-05-24Move code inside the `else` in `TypeAliasPart::get`.Nicholas Nethercote-29/+33
This is a huge perf win for rustdoc on the `typenum` and `nalgebra` benchmarks, because the `else` branch doesn't get hit much.
2025-05-24Simplify the "is some" test in `TypeAliasPart::get`.Nicholas Nethercote-1/+1
The comparison against `text` seems to be unnecessary.
2025-05-20Get rid of unnecessary `BufDisplay` abstractionYotam Ofek-5/+2
2025-05-20Replace some `unwrap`s with `?`s where possibleYotam Ofek-2/+2
2025-05-20Make some fns return `fmt::Result` to get rid of a few `unwrap`sYotam Ofek-19/+26
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-1/+1
2025-04-24Make impl item info come before docGuillaume Gomez-11/+15
2025-04-18Rollup merge of #139913 - fmease:rustdoc-fix-fn-param-handling, r=GuillaumeGomezMatthias Krüger-6/+6
rustdoc/clean: Fix lowering of fn params (fixes correctness & HIR vs. middle parity regressions) **(0)** PR #136411 aimed to stop rendering unnamed params of fn ptr types as underscores in the common case (e.g., `fn(_: i32)` → `fn(i32)`) to make the rendered output stylistically more conventional. **(0.a)** However, since the cleaning fn that the PR modified is also used for lowering the HIR params of foreign fns and required assoc fns in traits, it accidentally butchered the rendering of the latter two: ```rs pub trait Trait { fn assoc_fn(_: i32); } // as well as (Rust 2015 only): fn assoc_fn(i32); unsafe extern "C" { pub fn foreign_fn(_: i32); } // Since 1.86 the fns above gets mis-rendered as: pub fn assoc_fn(: i32) // <-- BUTCHERED pub unsafe extern "C" fn foreign_fn(: i32) // <-- BUTCHERED ``` **(0.b)** Furthermore, it broke parity with middle cleaning (which includes inlined cross-crate re-exports) re-regressing parts of #44306 I once fixed in PR #103885. **(1)** Lastly, PR #139035 introduced an ICE triggered by the following input file: ```rs trait Trait { fn anon(()) {} } // internal error: entered unreachable code ``` --- This PR fixes all of these regressions and in the first commit renames several types and fns to be more ~~correct~~ descriptive and legible. ~~It also refactors `Param.name` to be of type `Option<Symbol>` instead `Symbol` (where `None` ~ `kw::Empty`), so rendering mistakes like that can no longer creep in like that (ignoring tests). CC #137978.~~ Independently done in PR #139846 a day prior.
2025-04-18Rollup merge of #139615 - nnethercote:rm-name_or_empty, r=jdonszelmannMatthias Krüger-6/+6
Remove `name_or_empty` Another step towards #137978. r? ``@jdonszelmann``
2025-04-17Rollup merge of #139943 - fmease:rustdoc-ixcre-trait-aliases, r=GuillaumeGomezMatthias Krüger-2/+3
rustdoc: Support inlined cross-crate re-exported trait aliases Previously we'd just drop them. As a result of this PR, [`core::ptr::Thin`](https://doc.rust-lang.org/nightly/core/ptr/traitalias.Thin.html) will be admitted into the `std` façade! Also, render the where clause *after* the bounds / the `=`, not before them, as it should be. r? rustdoc
2025-04-17rustdoc/clean: Change terminology of items pertaining to (formal) fn params ↵León Orell Valerian Liehr-6/+6
from "argument" to "parameter"
2025-04-17Support inlined cross-crate re-exported trait aliasesLeón Orell Valerian Liehr-2/+3
2025-04-17Replace infallible `name_or_empty` methods with fallible `name` methods.Nicholas Nethercote-6/+6
I'm removing empty identifiers everywhere, because in practice they always mean "no identifier" rather than "empty identifier". (An empty identifier is impossible.) It's better to use `Option` to mean "no identifier" because you then can't forget about the "no identifier" possibility. Some specifics: - When testing an attribute for a single name, the commit uses the `has_name` method. - When testing an attribute for multiple names, the commit uses the new `has_any_name` method. - When using `match` on an attribute, the match arms now have `Some` on them. In the tests, we now avoid printing empty identifiers by not printing the identifier in the `error:` line at all, instead letting the carets point out the problem.
2025-04-17Rollup merge of #139846 - nnethercote:kw-Empty-rustdoc, r=GuillaumeGomezMatthias Krüger-12/+18
Remove `kw::Empty` uses in rustdoc Helps with #137978. r? ``@GuillaumeGomez``
2025-04-15Avoid using `kw::Empty` for param names in rustdoc.Nicholas Nethercote-8/+11
2025-04-15Avoid using `kw::Empty` when comparing names.Nicholas Nethercote-4/+7
2025-04-10lazify `render_assoc_items_inner`Yotam Ofek-37/+54
2025-04-10make `doc_impl_item` and `render_default_items` receive `impl fmt::Write`Yotam Ofek-126/+108
2025-04-10make `AllTypes::print` return `impl fmt::Display`Yotam Ofek-40/+36
2025-04-10Rollup merge of #138605 - xizheyin:issue-138567, r=GuillaumeGomezMatthias Krüger-20/+17
Clean up librustdoc::html::render to be better encapsulated Closes #138567
2025-04-09librustdoc: remove IndexItem::new, use previous fields constructorxizheyin-44/+12
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-06Update rinja version in `generate-copyright`Guillaume Gomez-2/+2
2025-04-03Update to new rinja version (askama)Guillaume Gomez-11/+11
2025-04-02Move methods from `Map` to `TyCtxt`, part 5.Nicholas Nethercote-1/+1
This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.
2025-03-25Rollup merge of #138917 - nnethercote:rustdoc-remove-useless, r=GuillaumeGomezJacob Pratt-26/+36
rustdoc: remove useless `Symbol::is_empty` checks. There are a number of `is_empty` checks that can never fail. This commit removes them, in support of #137978. r? `@GuillaumeGomez`