about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2025-08-10rustdoc: Use `discr`s `Display` impl to render the value with the correct ↵Eval EXEC-5/+3
signedness
2025-08-09Rollup merge of #141658 - lolbinarycat:rustdoc-search-stability-rank-138067, ↵Stuart Cook-0/+7
r=GuillaumeGomez rustdoc search: prefer stable items in search results fixes https://github.com/rust-lang/rust/issues/138067 this does add a new field to the search index, but since we're only listing unstable items instead of adding a boolean flag to every item, it should only increase the search index size of sysroot crates, since those are the only ones using the `staged_api` feature, at least as far as the rust project is concerned.
2025-08-08rustdoc: IndexItem::{stability -> is_unstable}binarycat-10/+4
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-10rustdoc search: prefer stable items in search resultsbinarycat-1/+14
fixes https://github.com/rust-lang/rust/issues/138067
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