about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-4/+2
2025-07-22rustdoc: avoid allocating a temp String for aliases in search indexbinarycat-3/+16
2025-07-20Rollup merge of #143988 - GuillaumeGomez:alias-inexact, r=lolbinarycatMatthias Krüger-1/+1
[rustdoc] Make aliases search support partial matching Fixes rust-lang/rust#140782. To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok. This PR voluntarily doesn't handle de-prioritization of aliases as ```@lolbinarycat``` wished to work on this so I'll leave them this part. :wink: cc ```@lolbinarycat```
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-112/+98
2025-07-17Include ErrorGuaranteed in StableSince::Err.Camille GILLOT-1/+1
2025-07-17Improve path segment joining.Nicholas Nethercote-19/+21
There are many places that join path segments with `::` to produce a string. A lot of these use `join("::")`. Many in rustdoc use `join_with_double_colon`, and a few use `.joined("..")`. One in Clippy uses `itertools::join`. A couple of them look for `kw::PathRoot` in the first segment, which can be important. This commit introduces `rustc_ast::join_path_{syms,ident}` to do the joining for everyone. `rustc_ast` is as good a location for these as any, being the earliest-running of the several crates with a `Path` type. Two functions are needed because `Ident` printing is more complex than simple `Symbol` printing. The commit also removes `join_with_double_colon`, and `estimate_item_path_byte_length` with it. There are still a handful of places that join strings with "::" that are unchanged. They are not that important: some of them are in tests, and some of them first split a path around "::" and then rejoin with "::". This fixes one test case where `{{root}}` shows up in an error message.
2025-07-16Make aliases search support partial matchingGuillaume Gomez-1/+1
2025-07-15rustdoc-json: Structured attributesAlona Enraght-Moony-5/+4
Implements https://www.github.com/rust-lang/rust/issues/141358. This has 2 primary benefits: 1. For rustdoc-json consumers, they no longer need to parse strings of attributes, but it's there in a structured and normalized way. 2. For rustc contributors, the output of HIR pretty printing is no longer a versioned thing in the output. People can work on https://github.com/rust-lang/rust/issues/131229 without needing to bump `FORMAT_VERSION`. (Over time, as the attribute refractor continues, I expect we'll add new things to `rustdoc_json_types::Attribute`. But this can be done separately to the rustc changes).
2025-07-13update issue number for `const_trait_impl`Deadbeef-2/+2
2025-07-08Auto merge of #142869 - nnethercote:join_path-mini, r=camelidbors-2/+2
Use `join_with_double_colon` in `write_shared.rs`. For consistency. Also, it's faster because `join_with_double_colon` does a better job estimating the allocation size than `join` from `itertools`. r? `@camelid`
2025-07-03Auto merge of #143363 - jdonszelmann:rollup-7cv1kql, r=jdonszelmannbors-2/+2
Rollup of 6 pull requests Successful merges: - rust-lang/rust#134006 (setup typos check in CI) - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - rust-lang/rust#143038 (avoid suggesting traits from private dependencies) - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports) - rust-lang/rust#143283 (document optional jobs) - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-06-29Lazy-ify some markdown renderingYotam Ofek-19/+16
2025-06-28Rollup merge of #142987 - lolbinarycat:rustdoc-non_exhaustive-enum-v-142599, ↵Matthias Krüger-0/+1
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-26rustdoc: show attributes on enum variantsbinarycat-0/+1
mostly for #[non_exhaustive]
2025-06-24rustdoc: Don't mark `#[target_feature]` functions as ⚠Alona Enraght-Moony-1/+2
Closes https://www.github.com/rust-lang/rust/issues/142952
2025-06-22Port `#[no_mangle]` to new attribute parsing infrastructureJonathan Brouwer-3/+3
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-22Use `join_with_double_colon` in `write_shared.rs`.Nicholas Nethercote-2/+2
For consistency. Also, it's faster because `join_with_double_colon` does a better job estimating the allocation size than `join` from `itertools`.
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.