about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2023-05-22rustdoc: Cleanup doc string collapsingVadim Petrochenkov-19/+13
2023-05-17Add missing backslash in HTML stringGuillaume Gomez-1/+1
2023-05-08Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errorsMichael Goulet-1/+3
Introduce `AliasKind::Inherent` for inherent associated types Allows us to check (possibly generic) inherent associated types for well-formedness. Type inference now also works properly. Follow-up to #105961. Supersedes #108430. Fixes #106722. Fixes #108957. Fixes #109768. Fixes #109789. Fixes #109790. ~Not to be merged before #108860 (`AliasKind::Weak`).~ CC `@jackh726` r? `@compiler-errors` `@rustbot` label T-types F-inherent_associated_types
2023-05-06Rollup merge of #110780 - notriddle:notriddle/slice-index, r=GuillaumeGomezYuki Okushi-2/+28
rustdoc-search: add slices and arrays to index This indexes them as primitives with generics, so `slice<u32>` is how you search for `[u32]`, and `array<u32>` for `[u32; 1]`. A future commit will desugar the square bracket syntax to search both arrays and slices at once.
2023-05-04IAT: Rustdoc integrationLeón Orell Valerian Liehr-1/+3
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-3/+2
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-30Rollup merge of #110983 - GuillaumeGomez:foreign-repr, r=notriddleMatthias Krüger-42/+21
rustdoc: Get `repr` information through `AdtDef` for foreign items As suggested by `@notriddle,` this approach works too. The only downside is that the display of the original attribute isn't kept, but I think it's an acceptable downside. r? `@notriddle`
2023-04-29Unify attributes retrieval for JSON and HTML renderingGuillaume Gomez-73/+2
2023-04-29Fix display of attributes for enumsGuillaume Gomez-2/+2
2023-04-29Get `repr` information through `AdtDef` for foreign itemsGuillaume Gomez-21/+71
2023-04-28rustdoc: fix weird margins between Deref impl itemsMichael Howell-6/+12
In the old setup, if the dereffed-to item has multiple impl blocks, each one gets its own `div.impl-items` in the section, but there are no headers separating them. Since the last method in a `div.impl-items` has no bottom margin, and there are no margins between these divs, there is no margin between the last method of one impl and the first method of the following impl. This patch fixes it by simplifying the HTML. Each Deref block gets exactly one `div.impl-items`, no matter how many impl blocks it actually has.
2023-04-28rustdoc: render visibility on associated typeswackbyte-1/+3
This should only affect inherent associated types.
2023-04-24rustdoc-search: add slices and arrays to indexMichael Howell-2/+28
This indexes them as primitives with generics, so `slice<u32>` is how you search for `[u32]`, and `array<u32>` for `[u32; 1]`. A future commit will desugar the square bracket syntax to search both arrays and slices at once.
2023-04-22Rollup merge of #109949 - notriddle:notriddle/type-layout, r=jshaYuki Okushi-116/+89
rustdoc: migrate `document_type_layout` to askama
2023-04-21rustdoc: remove unnecessary bindingMichael Howell-5/+4
2023-04-21rustdoc: factor `document_type_layout` into its own moduleMichael Howell-77/+90
2023-04-21rustdoc: get rid of redundant, nested `let` linesMichael Howell-17/+13
2023-04-18rustdoc: create variants list outside of templateMichael Howell-56/+53
2023-04-18rustdoc: use a separate template for type layout sizeMichael Howell-12/+12
2023-04-16Spelling librustdocJosh Soref-5/+5
* associated * collected * correspondence * inlining * into * javascript * multiline * variadic Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-12remove some unneeded importsKaDiWa-2/+1
2023-04-10Fix typos in librustdocDaniPopes-2/+3
2023-04-08rustdoc: migrate `document_type_layout` to askamaMichael Howell-99/+67
2023-04-05rustdoc: migrate `item_union` to an Askama templateMichael Howell-289/+361
2023-04-03rustdoc: migrate document functions to return a DisplayMichael Howell-147/+166
2023-04-03rustdoc: convert render_attributes_in_pre to return a DisplayMichael Howell-20/+27
2023-04-03rustdoc: convert `print_tuple_struct_fields` to return a DisplayMichael Howell-16/+18
2023-04-01a couple clippy::complexity fixesMatthias Krüger-5/+2
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
2023-03-26rustdoc: tweak `some variants omitted`Ezra Shaw-1/+1
Don't display `// some variants omitted` if enum is marked `#[non_exhaustive]`
2023-03-24Auto merge of #109399 - petrochenkov:rendersort, r=GuillaumeGomezbors-7/+20
rustdoc: Optimize impl sorting during rendering This should fix the perf regression on [bitmaps-3.1.0](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/bitmaps-3.1.0) from https://github.com/rust-lang/rust/pull/107765. The bitmaps crate has a lot of impls: ```rust impl Bits for BitsImpl<1> { ... } impl Bits for BitsImpl<2> { ... } // ... impl Bits for BitsImpl<1023> { ... } impl Bits for BitsImpl<1024> { ... } ``` and the logic in `fn print_item` sorts them in natural order. Before https://github.com/rust-lang/rust/pull/107765 the impls came in source order, which happened to be already sorted in the necessary way. So the comparison function was called fewer times. After https://github.com/rust-lang/rust/pull/107765 the impls came in "stable" order (based on def path hash). So the comparison function was called more times to sort them. The comparison function was terribly inefficient, so it caused a large perf regression. This PR attempts to make it more efficient by using cached keys during sorting.
2023-03-22Rollup merge of #108954 - notriddle:notriddle/notable-trait-generic, r=camelidMatthias Krüger-2/+2
rustdoc: handle generics better when matching notable traits This commit makes the `clean::Type::is_same` non-commutative (renaming it `is_doc_subtype_of`), so that a generic `impl` matches a concrete return, but a generic return does not match a concrete `impl`. It makes slice and vector Write for `u8` not match on every generic return value. Fixes #100322 Fixes #55082 Preview: * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.new * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.from-12 * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/iter/trait.Iterator.html#method.intersperse_with * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/string/struct.String.html#method.as_bytes
2023-03-20rustdoc: Optimize impl sorting during renderingVadim Petrochenkov-7/+20
2023-03-17extra_info_tags don't return string, use display_fnklensy-35/+56
2023-03-16clean up few allocklensy-1/+1
2023-03-16Rollup merge of #108875 - notriddle:notriddle/return-trait, r=GuillaumeGomezMatthias Krüger-2/+7
rustdoc: fix type search for `Option` combinators
2023-03-12rustdoc: rename `Type::is_same` to `is_doc_subtype_of`Michael Howell-2/+2
2023-03-11Rollup merge of #108784 - clubby789:askama-sidebar, r=jsha,GuillaumeGomezMatthias Krüger-644/+579
rustdoc: Migrate sidebar rendering to Askama cc #108757 Renders the sidebar for documentation using an Askama template
2023-03-11Rollup merge of #108757 - clubby789:askama-move, r=notriddle,jsha,GuillaumeGomezMatthias Krüger-43/+54
rustdoc: Migrate `document_item_info` to Askama https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/rustdoc.20allocations.20are.20slow Hoping to piece-by-piece migrate things to template. Had a few failed attempts at more complex parts of the code, so this is just a start.
2023-03-11Rollup merge of #107629 - pitaj:rustdoc-search-deprecated, r=jshaMatthias Krüger-5/+28
rustdoc: sort deprecated items lower in search closes #98759 ### Screenshots `i32::MAX` show sup above `std::i32::MAX` and `core::i32::MAX` ![image](https://user-images.githubusercontent.com/803701/216725619-40afb7b0-e984-4a2e-ab5b-a95b24736b0e.png) If just searching for `min`, the deprecated results show up far below other things: ![image](https://user-images.githubusercontent.com/803701/216725672-e4325d37-9bfe-47eb-a1fe-0e57092aa811.png) one page later ![image](https://user-images.githubusercontent.com/803701/216725932-cd1c4a42-d527-44fb-a4ab-5a6d243659cc.png) ~~And, as you can see, the "Deprecation planned" message shows up in the search results. The same is true for fully-deprecated items like `mem::uninitialized`: ![image](https://user-images.githubusercontent.com/803701/216726268-1657e77a-563f-45a0-85a7-3a0cf4d66d6f.png)~~ Edit: the deprecation message change was removed from this PR. Only the sorting is changed.
2023-03-10Render doc sidebar using Askamaclubby789-644/+579
2023-03-10Migrate `document_item_info` to templatesclubby789-43/+54
2023-03-10rustdoc: sort deprecated items lower in searchPeter Jaszkowiak-5/+28
serialize `q` (`itemPaths`) sparsely overall 4% reduction in search index size
2023-03-09rustdoc: handle generics better when matching notable traitsMichael Howell-2/+2
This commit makes the `clean::Type::is_same` non-commutative, so that a generic `impl` matches a concrete return, but a generic return does not match a concrete `impl`. It makes slice and vector Write for `u8` not match on every generic return value.
2023-03-09Rollup merge of #108929 - eltociear:patch-20, r=GuillaumeGomezMatthias Krüger-3/+3
Fix typo in span_map.rs correspondance -> correspondence
2023-03-09Rollup merge of #106915 - notriddle:notriddle/load-only-one-theme, ↵Matthias Krüger-2/+26
r=GuillaumeGomez,jsha Only load one CSS theme by default This is a tweaked version of #103971 that uses `document.write` to create the stylesheet link at startup, avoiding a FOUC during page navigation. It also rebases the PR, making it work with the new hashed filenames. Fixes #82614 Preview: http://notriddle.com/notriddle-rustdoc-demos/load-only-one-theme-v2/std/index.html
2023-03-09Fix typo in span_map.rsIkko Eltociear Ashimine-3/+3
correspondance -> correspondence
2023-03-08Rollup merge of #108686 - notriddle:notriddle/jank-all, r=jshaMatthias Krüger-3/+1
rustdoc: include link on all.html location header This avoids a subtle layout shift when switching from the crate page to all items. ## Before | index.html | all.html | |------------|----------| | ![image](https://user-images.githubusercontent.com/1593513/222607866-4eac3f55-314c-4273-9664-503f2a79ad0a.png) | ![image](https://user-images.githubusercontent.com/1593513/222607895-2d6bac3b-f66a-47d4-b234-360f6f8e1ee3.png) | ## After | index.html | all.html | |------------|----------| | ![image](https://user-images.githubusercontent.com/1593513/222607866-4eac3f55-314c-4273-9664-503f2a79ad0a.png) | ![image](https://user-images.githubusercontent.com/1593513/222607997-e72c48a0-02c7-42a7-80c2-cd6bed48bd15.png) |
2023-03-08Only load one CSS theme by defaultMichael Howell-2/+26
To avoid generating a FOUC at startup, this commit uses `document.write` to load the stylesheet initially. Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2023-03-07rustdoc: fix type search when more than one `where` clause appliesMichael Howell-1/+1
2023-03-07rustdoc: fix type search index for `fn<T>() -> &T where T: Trait`Michael Howell-1/+6