about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2025-05-26rustdoc: refactor Tooltip rendering logicbinarycat-43/+21
2025-05-26Avoid some unnecessary cloning.Nicholas Nethercote-12/+11
2025-05-26Make `{Type,Path}::generics` return iterators.Nicholas Nethercote-18/+11
Instead of a `Vec`, to avoid some allocations.
2025-05-26Simplify `make_href`.Nicholas Nethercote-5/+5
It never fails, so it doesn't need to return `Result`. And the `ItemType` in the result is just a copy of the one passed in via the `shortty` arg, so it can also be removed.
2025-05-26Rename some methods.Nicholas Nethercote-25/+36
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-26Refactor the end of `generate_item_def_id_path`.Nicholas Nethercote-6/+6
To avoids the early return and duplication of `Ok((url_parts, shortty, fqp))`.
2025-05-26Simplify `make_href`.Nicholas Nethercote-3/+4
Currently it is passed an `fqp` slice which it calls `to_vec` on and returns. This is a bit odd. It's better to let the call site clone if necessary. (One call site does, one does not).
2025-05-26Avoid `Box` in `href_relative_parts`.Nicholas Nethercote-25/+20
This reverts part of #91948, going back to returning a `UrlPartsBuilder`. It makes the code simpler, and also avoids some allocations.
2025-05-25Update to new APIGuillaume Gomez-2/+3
2025-05-25Improve codeGuillaume Gomez-49/+50
2025-05-25Tweak attribute rendering depending on wether or not it is a type aliasGuillaume Gomez-79/+172
2025-05-25Rename the `document_*` argument/field into `is_type_alias`Guillaume Gomez-12/+12
2025-05-25Split `Item::attributes` method into threeGuillaume Gomez-70/+81
2025-05-25Unify rendering of type aliases without ADT itemsGuillaume Gomez-137/+151
2025-05-25Rename `clean::Enum::variants` method into `non_stripped_variants`Guillaume Gomez-3/+3
2025-05-25Rollup merge of #139831 - lolbinarycat:rustdoc-mobile-sidebar, r=GuillaumeGomezJacob Pratt-1/+4
rustdoc: on mobile, make the sidebar full width and linewrap this is because the mobile sidebar cannot be resized, unlike on desktop.
2025-05-24Rollup merge of #141487 - GuillaumeGomez:update-askama, r=notriddleGuillaume Gomez-2/+2
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-24rustdoc: use descriptive tooltip if doctest is conditionally ignoredbinarycat-10/+41
fixes https://github.com/rust-lang/rust/issues/141092
2025-05-24Update `askama` version to `0.14.0` in librustdocGuillaume Gomez-2/+2
2025-05-24Auto merge of #141421 - nnethercote:TypeAliasPart-get, r=GuillaumeGomezbors-35/+36
rustdoc: Speed up `TypeAliasPart::get` Big speedups here on a couple of the benchmarks. r? `@GuillaumeGomez`
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-23Rollup merge of #141369 - ↵Matthias Krüger-72/+25
yotamofek:pr/rustdoc/format_integer_with_underscore_sep, r=notriddle Simplify `format_integer_with_underscore_sep` Noticed that this helper fn only ever gets called with decimal-base-formatted ints, so can be simplified a lot by not trying to handle hex and octal radixes. Second commit is completely unrelated, just simplified some code I wrote a while back 😁
2025-05-23Small cleanup for `qpath_to_string`Yotam Ofek-9/+2
2025-05-23Simplify `format_integer_with_underscore_sep`Yotam Ofek-63/+23
Only ever needs to handle decimal reprs
2025-05-23Rollup merge of #141126 - fmease:rev-rjson-priv-repr, r=aDotInTheVoidMatthias Krüger-15/+7
rustdoc JSON: Don't apply `#[repr]` privacy heuristics Split out from #116882. Context: https://github.com/rust-lang/rust/pull/116882#issuecomment-2888349161. Partially reverts #138018. cc `@obi1kenobi` r? aDotInTheVoid or rustdoc
2025-05-23Rollup merge of #136400 - lolbinarycat:rustdoc-link-lint-135851, ↵Matthias Krüger-4/+8
r=GuillaumeGomez Improve handling of rustdoc lints when used with raw doc fragments. 1. `rustdoc::bare_urls` no longer outputs incoherent suggestions if `source_span_for_markdown_range` returns None, instead outputting no suggestion 2. `source_span_for_markdown_range` has one more heuristic, so it will return `None` less often. 3. add ui test to make sure we don't emit nonsense suggestions. fixes https://github.com/rust-lang/rust/issues/135851
2025-05-22scrape-examples.js: add another nonnull() invokationbinarycat-1/+1
2025-05-22fix typobinarycat-4/+5
2025-05-22rustdoc JSON: Don't apply `#[repr]` privacy heuristicsLeón Orell Valerian Liehr-15/+7
2025-05-22Collect and use `#[doc(test(attr(..)))]` at every levelUrgau-34/+23
2025-05-22Allow `#![doc(test(attr(..)))]` doctests to be again merged togetherUrgau-7/+24
2025-05-22Collect and use `#![doc(test(attr(..)))]` at module level tooUrgau-52/+114
2025-05-22rustdoc: improve diagnostics on raw doc fragmentsbinarycat-4/+8
1. rustdoc::bare_urls doesn't output invalid suggestions if source_span_for_markdown_range fails to find a span 2. source_span_for_markdown_range tries harder to return a span by applying an additional diagnostic fixes https://github.com/rust-lang/rust/issues/135851
2025-05-22Rollup merge of #141377 - nnethercote:rm-unnecessary-is_empty-checks, ↵Matthias Krüger-6/+1
r=GuillaumeGomez Remove unnecessary `is_empty` checks Part of #137978. r? `@GuillaumeGomez`
2025-05-22Auto merge of #140527 - GuillaumeGomez:doctest-main-fn, r=notriddlebors-73/+180
Emit a warning if the doctest `main` function will not be run Fixes #140310. I think we could try to go much further like adding a "link" (ie UI annotations) on the `main` function in the doctest. However that will require some more computation, not sure if it's worth it or not. Can still be done in a follow-up if we want it. For now, this PR does two things: 1. Pass the `DiagCtxt` to the doctest parser to emit the warning. 2. Correctly generate the `Span` to where the doctest is starting (I hope the way I did it isn't too bad either...). cc `@fmease` r? `@notriddle`
2025-05-22Rollup merge of #140868 - SpecificProtagonist:rustdoc-trait-impl-code-link, ↵Matthias Krüger-1/+3
r=notriddle rustdoc: Fix links with inline code in trait impl docs Fixes #140857
2025-05-22Remove `is_empty` check in `filter_assoc_items_by_name_and_namespace`.Nicholas Nethercote-6/+1
It was added in #140052, but the subsequent changes in #140252 means it is no longer necessary. (Indeed, `Ident`s cannot be empty any more.)
2025-05-21rustdoc js: add rustdoc.ScrapedLoc typebinarycat-1/+5
2025-05-21rustdoc js: add ScrapedLoc typebinarycat-4/+16
2025-05-21scrape-examples.js: give each function a signaturebinarycat-9/+24
2025-05-20Get rid of unnecessary `BufDisplay` abstractionYotam Ofek-28/+6
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-27/+33
2025-05-19Rollup merge of #140874 - mejrs:rads, r=WaffleLapkinStuart Cook-13/+16
make `rustc_attr_parsing` less dominant in the rustc crate graph It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly. Previous graph: ![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd) Graph with this PR: ![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a) The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*. The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-13/+16
2025-05-18Rollup merge of #140966 - est31:let_chains_library, r=tgross35León Orell Valerian Liehr-1/+0
Remove #![feature(let_chains)] from library and src/librustdoc PR https://github.com/rust-lang/rust/pull/132833 has stabilized the `let_chains` feature. This PR removes the last occurences from the library, the compiler, and librustdoc (also because #140887 missed the conditional in one of the crates as it was behind the "rustc" feature). We keep `core` as exercise for the future as updating it is non-trivial (see PR thread).
2025-05-17Make some `match`es slightly more ergonomic in `librustdoc`Yotam Ofek-121/+99
2025-05-16Remove #![feature(let_chains)] from library and src/librustdocest31-1/+0