about summary refs log tree commit diff
path: root/src/librustdoc/html/format.rs
AgeCommit message (Collapse)AuthorLines
2022-02-03rustdoc: clippy::complexity fixesMatthias Krüger-1/+1
clippy::map_flatten clippy::clone_on_copy clippy::useless_conversion clippy::needless_arbitrary_self_type
2022-02-01librustdoc: inline and forward all methods for `impl Write for Buffer`Muhammad Falak R Wani-0/+11
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2022-02-01librustdoc: impl core::fmt::Write for rustdoc::html::render::BufferMuhammad Falak R Wani-0/+6
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2022-01-17Update term for use in more placeskadmin-3/+15
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the future, but slightly worried it allows items which are consts which only accept types.
2022-01-14Estimate path length instead of hardcoding 64 bytesNoah Lev-2/+2
2022-01-14Use UrlPartsBuilder and remove `join_with_slash`Noah Lev-22/+0
2022-01-14rustdoc: remove some unnecessary sigils.Nicholas Nethercote-1/+1
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-39/+82
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.
2021-12-31Rollup merge of #91480 - jsha:fewer-colors, r=GuillaumeGomezMatthias Krüger-1/+1
rustdoc: use smaller number of colors to distinguish items This reduces visual distractions when reading method signatures. As discussed in https://github.com/rust-lang/rust/issues/59845#issuecomment-974757191, this categorizes items into one of six colors (down from thirteen): - method, function (ochre `#AD7C37`) - trait, trait alias (dark slate blue `#6E4FC9`) - enum, struct, type alias, union, primitive (maroon `#AD378A`) - static, module, keyword, associated type, foreign type (steel blue `#3873AD`) - macro (green `#068000`) - generic params, self, Self (unmarked black `#000000`) I slightly tweaked the actual color values so they'd have the same lightness (previously the trait color stood out much more than the others). And I made the color for links in general consistently use steel blue (previously there was a slightly different color for "search-failed"). The ayu and dark themes have been updated according to the same logic. I haven't changed any of the color values in those themes, just their assignment to types. Demo: https://rustdoc.crud.net/jsha/fewer-colors/std/string/struct.String.html https://rustdoc.crud.net/jsha/fewer-colors/std/vec/struct.Vec.html https://rustdoc.crud.net/jsha/fewer-colors/std/io/trait.Read.html https://rustdoc.crud.net/jsha/fewer-colors/std/iter/trait.Iterator.html
2021-12-29Rollup merge of #92340 - camelid:search-index-cleanup, r=GuillaumeGomezMatthias Krüger-2/+4
rustdoc: Start cleaning up search index generation I'm trying to simplify and clean up the code, partly to make #90779 easier. r? `@GuillaumeGomez`
2021-12-29Auto merge of #92283 - vacuus:print-generic-bounds, r=camelid,GuillaumeGomezbors-3/+1
rustdoc: Remove `String` allocation in iteration in `print_generic_bounds` (I realized only after making the commit that maybe I shouldn't refer to iteration as looping, but it's close enough) The string representation of a `clean::GenericBound` instance (evaluated [here](https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/format.rs#L397)) is deterministic for a given `self` (the instance), `cx` and `f`, and since `cx` and `f` are constant (as far as I can tell) for a given invocation of `print_generic_bounds`, `self` is the determining factor. Therefore, using the data in `self` shouldn't differ in effect from using its string representation. Given the totality of the function calls needed to evaluate the string representation as well as the actual allocation, at the very least, this shouldn't negatively affect performance.
2021-12-27Move `ExternalLocation` to `clean::types`Noah Lev-2/+4
It was previously defined in `render::search_index` but wasn't used at all there. `clean::types` seems like a better fit since that's where `ExternalCrate` is defined.
2021-12-27Rename `rustdoc::html::render::cache` to `search_index`Noah Lev-1/+1
The old name wasn't very clear, while the new one makes it clear that this is the code responsible for creating the search index.
2021-12-25Remove unneeded call to `collect`Roc Yu-5/+6
2021-12-25Remove `String` allocation in loopRoc Yu-3/+1
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-15/+13
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-5/+5
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-10/+8
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-13rustdoc: Add `UrlPartsBuilder`Noah Lev-9/+10
This is a type for efficiently and easily constructing the part of a URL after the domain: `nightly/core/str/struct.Bytes.html`. It allows simplifying some code and avoiding some allocations in the `href_*` functions. It will also allow making `Cache.paths` et al. use `Symbol` without having to allocate `String`s in the `href_*` functions. `String`s would be necessary otherwise because `Symbol::as_str()` returns `SymbolStr`, whose `Deref<Target = str>` impl requires the `str` to not outlive it. This is the primary motivation for the addition of `UrlPartsBuilder`.
2021-12-10Split CSS classes for "typedef" vs "associatedtype".Jacob Hoffman-Andrews-1/+1
2021-12-03rustdoc: Remove single-use `Lifetime::get_ref()` functionNoah Lev-1/+1
2021-12-02Rollup merge of #89954 - GuillaumeGomez:legacy-const-generic-doc, r=AmanieuMatthias Krüger-0/+4
Fix legacy_const_generic doc arguments display Fixes https://github.com/rust-lang/rust/issues/83167. cc ``@Amanieu``
2021-12-02Transform const generics if the function uses rustc_legacy_const_genericsGuillaume Gomez-0/+4
2021-11-30Return ConstStability instead of &ConstStability in Item::const_stabilityGuillaume Gomez-4/+1
2021-11-26Rename `Type::ResolvedPath` to `Type::Path`Noah Lev-3/+2
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
2021-11-25Stop re-exporting `Type::ResolvedPath`Noah Lev-1/+1
I would like to rename it to `Type::Path`, but then it can't be re-exported since the name would conflict with the `Path` struct. Usually enum variants are referred to using their qualified names in Rust (and parts of rustdoc already do that with `clean::Type`), so this is also more consistent with the language.
2021-11-24Remove `ResolvedPath.did`Noah Lev-1/+2
2021-11-24Return the actual `DefId` for assoc. items in `register_res`Noah Lev-1/+12
Before, if `register_res` were called on an associated item or enum variant, it would return the parent's `DefId`. Now, it returns the actual `DefId`. This change is a step toward removing `Type::ResolvedPath.did` and potentially removing `kind_side_channel` in rustdoc. It also just simplifies rustdoc's behavior.
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-1/+1
The `ImplKind` methods can just be used directly instead.
2021-11-07rustdoc: Use `ty::ImplPolarity` instead of custom enumNoah Lev-2/+3
2021-11-07Use an enum to record polarity in `clean::Impl`Noah Lev-2/+3
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-1/+1
This change has two advantages: 1. It makes the possible states clearer, and it makes it impossible to construct invalid states, such as a blanket impl that is also an auto trait impl. 2. It shrinks the size of `Impl` a bit, since now there is only one field, rather than two.
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-5/+5
2021-10-09Auto merge of #88379 - camelid:cleanup-clean, r=jyn514bors-39/+36
rustdoc: Cleanup various `clean` types Cleanup various `clean` types.
2021-10-09Fix invalid HTML generation for higher boundsGuillaume Gomez-2/+6
2021-10-02Replace all uses of `path.res.def_id()` with `path.def_id()`Noah Lev-3/+3
2021-09-30Use `Path` instead of `Type` in `PolyTrait`Noah Lev-39/+27
The change to `impl Clean<Path> for hir::TraitRef<'_>` was necessary to fix a test failure for `src/test/rustdoc/trait-alias-mention.rs`. Here's why: The old code path was through `impl Clean<Type> for hir::TraitRef<'_>`, which called `resolve_type`, which in turn called `register_res`. Now, because `PolyTrait` uses a `Path` instead of a `Type`, the impl of `Clean<Path>` was being run, which did not call `register_res`, causing the trait alias to not be recorded in the `external_paths` cache.
2021-09-30Make `Impl.trait_` a `Path`, not a `Type`Noah Lev-0/+9
It should only ever be a `ResolvedPath`, so this (a) enforces that, and (b) reduces the size of `Impl`. I had to update a test because the order of the rendered auto trait impl bounds changed. I think the order changed because rustdoc sorts auto trait bounds using their `Debug` output.
2021-09-29Remove Never variant from clean::Type enumGuillaume Gomez-1/+3
2021-09-12Rename `is_generic()` to `is_assoc_ty()`Noah Lev-2/+2
The new name is more accurate than the previous one.
2021-09-12Remove `Type::ResolvedPath.is_generic`Noah Lev-24/+13
It can be computed on-demand.
2021-09-12Fix broken handling of primitive itemsJoshua Nelson-1/+7
- Fix broken handling of primitive associated items - Remove fragment hack Fixes 83083 - more logging - Update CrateNum hacks The CrateNum has no relation to where in the dependency tree the crate is, only when it's loaded. Explicitly special-case core instead of assuming it will be the first DefId. - Update and add tests - Cache calculation of primitive locations This could possibly be avoided by passing a Cache into collect_intra_doc_links; but that's a much larger change, and doesn't seem valuable other than for this.
2021-09-12downgrade some loggingJoshua Nelson-1/+1
2021-09-02rustdoc: Clean up handling of lifetime boundsNoah Lev-4/+18
Previously, rustdoc recorded lifetime bounds by rendering them into the name of the lifetime parameter. Now, it leaves the name as the actual name and instead records lifetime bounds in an `outlives` list, similar to how type parameter bounds are recorded.
2021-08-27Introduce `~const`Deadbeef-1/+1
- [x] Removed `?const` and change uses of `?const` - [x] Added `~const` to the AST. It is gated behind const_trait_impl. - [x] Validate `~const` in ast_validation. - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and `ConstIfConst` allowing future extensions) - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`. - [ ] Optional steps (*for this PR, obviously*) - [ ] Fix #88155 - [ ] Do something with constness bounds in chalk
2021-08-05Add missing root_path when generating links using hrefGuillaume Gomez-1/+17
2021-08-05* Rename 'move_span' into 'local_span_to_global_span'Guillaume Gomez-4/+1
* Add documentation on new arguments/functions
2021-08-05Add links on source types to go to definitionGuillaume Gomez-1/+4
2021-08-03don't use .into() to convert types to identical types ↵Matthias Krüger-2/+2
(clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();
2021-08-01Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisabors-2/+2
more clippy::complexity fixes (also a couple of clippy::perf fixes)