about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2023-06-11rustdoc-search: build args, return, and generics on one unifierMichael Howell-138/+105
This enhances generics with the "unboxing" behavior where A<T> matches T. It makes this unboxing transitive over generics.
2023-06-11rustdoc-search: simplify JS in `checkGenerics`Michael Howell-68/+68
2023-06-11Auto merge of #111958 - notriddle:notriddle/type-search-slice-array, ↵bors-82/+155
r=GuillaumeGomez rustdoc: search for slices and arrays by type with `[]` This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for slices and arrays. Part of #60485 Function signature searches already support arrays and slices. The explicit name `primitive:slice<u8>` and `primitive:array<u8>` can be used to match a slice or array of bytes, while square brackets `[u8]` will match either one. Empty square brackets, `[]`, will match any slice regardless of what it contains. Preview: * [`option -> []`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=option%20-%3E%20%5B%5D) * [`[u8] -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=%5Bu8%5D%20-%3E%20str) * [`Box<[u8]> -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=Box%3C%5Bu8%5D%3E%20-%3E%20str) Motivation: When type-based search was first landed, it was directly described as "incomplete". Here's [a comment] from the discussion thread: [a comment]: https://github.com/rust-lang/rust/pull/23289#issuecomment-79437386 > This is looking really great, nice work! I can think of a number of cases that aren't quite covered by this, but I feel like this is a great improvement regardless and it can always be iterated on so I'm fine landing with a few known cases where it may not work :) Filling out the missing functionality is going to mean adding support for more of Rust's [type expression] syntax, such as slices (in this PR), tuples, references, raw pointers, function pointers, and generics. [type expression]: https://doc.rust-lang.org/reference/types.html#type-expressions There does seem to be demand for this sort of thing, such as [this Discord message](https://discord.com/channels/442252698964721669/443150878111694848/1042145740065099796) expressing regret at rustdoc not supporting tuples in search queries.
2023-06-11Add `item_template` macroNicky Lim-61/+120
2023-06-10rustdoc: add note about slice/array searches to help popupMichael Howell-0/+4
2023-06-10rustdoc: search for slices and arrays by type with `[]`Michael Howell-82/+151
Part of #60485
2023-06-09List matching impls on type aliasesGuillaume Gomez-28/+110
2023-06-08Rollup merge of #112034 - sladyn98:migrate-opaque-ty, r=GuillaumeGomezGuillaume Gomez-3/+10
Migrate `item_opaque_ty` to Askama This PR migrates `item_opaque_ty` to Askama Refers: https://github.com/rust-lang/rust/issues/108868
2023-06-08Migrate item_opaque_type to Askamasladynnunes-3/+10
Migrate item_opaque_type to Askama Fix wrap_item parameters Fix to write
2023-06-05Rollup merge of #112243 - GuillaumeGomez:rm-unneeded-buffer-creations, ↵Guillaume Gomez-24/+19
r=notriddle Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directly With the recent changes, `wrap_item` can now directly take `&mut Write`, which makes some `Buffer` creations unneeded. r? `@notriddle`
2023-06-05Move write! arguments directly into the stringGuillaume Gomez-6/+6
2023-06-05Auto merge of #110945 - wackbyte:doc-vis-on-inherent-assoc-types, r=jshabors-1/+3
rustdoc: render visibility on associated types This should only affect inherent associated types (#8995).
2023-06-03Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directlyGuillaume Gomez-23/+18
2023-06-03Auto merge of #112032 - sladyn98:migrate-item-primitive, r=GuillaumeGomezbors-3/+3
Migrate `item_primitive` to Askama This PR migrates `item_primitive` to Askama Refers https://github.com/rust-lang/rust/issues/108868
2023-06-01Rollup merge of #112030 - sladyn98:item-trait-alias, r=GuillaumeGomezMichael Goulet-8/+15
Migrate `item_trait_alias` to Askama This PR migrates `item_trait_alias` to Askama Refers https://github.com/rust-lang/rust/issues/108868
2023-06-01Migrate to Askamasladynnunes-8/+15
Implemented wrap_item_write Update wrap_item
2023-06-01Rollup merge of #111892 - notriddle:notriddle/timeout-tooltip, ↵Dylan DPC-10/+150
r=me,GuillaumeGomez,Manishearth rustdoc: add interaction delays for tooltip popovers Preview: * [notable traits](http://notriddle.com/rustdoc-demo-html-3/delay-tooltip/testing/struct.Vec.html#method.iter) * [panicking code block](http://notriddle.com/rustdoc-demo-html-3/delay-tooltip/testing/struct.Vec.html#indexing) Designing a good hover microinteraction is a matter of guessing user intent from what are, literally, vague gestures. In this case, guessing if hovering in our out of the tooltip base is intentional or not. To figure this out, a few different techniques are used: * When the mouse pointer enters a tooltip anchor point, its hitbox is grown on the bottom, where the popover is/will appear. This was already there before this commit: search "hover tunnel" in rustdoc.css for the implementation. * This commit adds a delay when the mouse pointer enters the base anchor, in case the mouse pointer was just passing through and the user didn't want to open it. * This commit also adds a delay when the mouse pointer exits the tooltip's base anchor or its popover, before hiding it. * A fade-out animation is layered onto the pointer exit delay to immediately inform the user that they successfully dismissed the popover, while still providing a way for them to cancel it if it was a mistake and they still wanted to interact with it. * No animation is used for revealing it, because we don't want people to try to interact with an element while it's in the middle of fading in: either they're allowed to interact with it while it's fading in, meaning it can't serve as mistake- proofing for opening the popover, or they can't, but they might try and be frustrated. See also: * https://www.nngroup.com/articles/timing-exposing-content/ * https://www.nngroup.com/articles/tooltip-guidelines/ * https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown
2023-06-01Rollup merge of #108459 - benediktwerner:rustdoc-fix-link-match, ↵Dylan DPC-5/+10
r=GuillaumeGomez rustdoc: Fix LinkReplacer link matching It currently just uses the first link with the same href which might not necessarily be the matching one. This fixes replacements when there are several links to the same item but with different text (e.g. `[X] and [struct@X]`). It also fixes replacements in summaries since those use a links list with empty hrefs, so currently all links would always match the first link by href but then not match its text. This could also lead to a panic in the `original_lext[1..len() - 1]` part when the first link only has a single character, which is why the new code uses `.get(..)` instead.
2023-05-31rustdoc: add jsdoc comments for complex functionsMichael Howell-1/+34
2023-05-31Rollup merge of #112113 - notriddle:notriddle/rm-fnretty, r=GuillaumeGomezMatthias Krüger-42/+30
rustdoc: simplify `clean` by removing `FnRetTy` The default fn ret ty is always unit. Just use that. Looking back at the time when `FnRetTy` (then called `FunctionRetTy`) was first added to rustdoc, it seems to originally be there because `-> !` was a special form: the never type didn't exist back then. https://github.com/rust-lang/rust/commit/eb01b17b06eb35542bb80ff7456043b0ed5572ba#diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9L921-L924 `DefaultReturn` was later added to rustdoc to mirror a change in HIR, which added a variant for DefaultReturn because it makes `Span` management easier. This isn't needed in rustdoc, since it doesn't carry spans. https://github.com/rust-lang/rust/commit/3f0cc8011aef3f530663302d525bd2d8cb493db5#diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9R1144
2023-05-31Rollup merge of #112031 - sladyn98:migrate-proc-macro, r=GuillaumeGomezMatthias Krüger-10/+16
Migrate `item_proc_macro` to Askama This PR migrates `item_proc_macro` to Askama Refers https://github.com/rust-lang/rust/issues/108868
2023-05-30rustdoc: Fix LinkReplacer link matchingbenediktwerner-5/+10
2023-05-30rustdoc: simplify `clean` by removing `FnRetTy`Michael Howell-42/+30
The default fn ret ty is always unit. Just use that. Looking back at the time when `FnRetTy` (then called `FunctionRetTy`) was first added to rustdoc, it seems to originally be there because `-> !` was a special form: the never type didn't exist back then. https://github.com/rust-lang/rust/commit/eb01b17b06eb35542bb80ff7456043b0ed5572ba#diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9L921-L924
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-28Migrate to Askamasladynnunes-3/+3
2023-05-28Migrate to Askamasladynnunes-10/+16
2023-05-28Rollup merge of #112005 - sladyn98:item-foreign-types, r=GuillaumeGomezfee1-dead-6/+8
Migrate `item_foreign_type` to Askama This PR continues the migration of `print_item.rs` functions to Askama. This piece of work migrates the function `item_foreign_type` Refers https://github.com/rust-lang/rust/issues/108868
2023-05-27Migrate to Askamasladynnunes-6/+8
Fix formatting Fix CI
2023-05-27Rollup merge of #112018 - GuillaumeGomez:cleanup-tcx, r=notriddleMatthias Krüger-11/+10
Clean up usage of `cx.tcx` when `tcx` is already set into a variable I discovered a few cases where `cx.tcx` (and equivalents) was used whereas `tcx` was already stored into a variable. In those cases, better to just use `tcx` directly. r? `@notriddle`
2023-05-27Rollup merge of #111946 - nicklimmm:askama-item-template-trait, r=GuillaumeGomezMatthias Krüger-42/+61
rustdoc: Add `ItemTemplate` trait and related functions to avoid repetitively wrapping existing functions Context: https://github.com/rust-lang/rust/pull/111430#discussion_r1200672507 This trait will be used extensively in performing migrations to Askama templates (tracking issue: https://github.com/rust-lang/rust/issues/108868)
2023-05-27Clean up usage of `cx.tcx` when `tcx` is already set into a variableGuillaume Gomez-11/+10
2023-05-27Rollup merge of #112014 - notriddle:notriddle/intra-doc-weird-syntax, ↵Guillaume Gomez-9/+111
r=GuillaumeGomez,fmease rustdoc: get unnormalized link destination for suggestions Fixes #110111 This bug, and the workaround in this PR, is closely linked to [raphlinus/pulldown-cmark#441], getting offsets of link components. In particular, pulldown-cmark doesn't provide the offsets of the contents of a link. To work around this, rustdoc parser parts of a link definition itself. [raphlinus/pulldown-cmark#441]: https://github.com/raphlinus/pulldown-cmark/issues/441
2023-05-26rustdoc: get unnormalized link destination for suggestionsMichael Howell-9/+111
Fixes #110111 This bug, and the workaround in this commit, is closely linked to [raphlinus/pulldown-cmark#441], getting offsets of link components. In particular, pulldown-cmark doesn't provide the offsets of the contents of a link. To work around this, rustdoc parser parts of a link definition itself. [raphlinus/pulldown-cmark#441]: https://github.com/raphlinus/pulldown-cmark/issues/441
2023-05-27Rollup merge of #111927 - sladyn98:item-static, r=GuillaumeGomezMatthias Krüger-5/+9
Migrate `item_static` to Askama This pull request addresses the type signature of the item_static function in our codebase. Previously, this function accepted a mutable reference to a Buffer for writing output. The current changes modify this to instead accept a mutable reference to any type that implements the Write trait. Referes https://github.com/rust-lang/rust/issues/108868
2023-05-26Formatted file correctlysladynnunes-1/+0
2023-05-26Fixed testssladynnunes-4/+9
2023-05-26Fix failing CIsladynnunes-1/+1
2023-05-25Auto merge of #111512 - petrochenkov:microdoc2, r=GuillaumeGomezbors-19/+13
rustdoc: Cleanup doc string collapsing `doc_value` and (former) `collapsed_doc_value` can be implemented in terms of each other, and `doc_value` doesn't need the `Option`. This PR doesn't do any semantic changes, only refactoring, although some pre-existing choices between `doc_value` and `collapsed_doc_value` across rustdoc may be questionable.
2023-05-25Add `ItemTemplate` traitNicky Lim-42/+61
2023-05-24Migrate item_static to Askamasladynnunes-1/+1
2023-05-23rustdoc: add hover indicator for notable trait tooltipMichael Howell-0/+4
2023-05-23rustdoc: add interaction delays for tooltip popoversMichael Howell-9/+112
Designing a good hover microinteraction is a matter of guessing user intent from what are, literally, vague gestures. In this case, guessing if hovering in our out of the tooltip base is intentional or not. To figure this out, a few different techniques are used: * When the mouse pointer enters a tooltip anchor point, its hitbox is grown on the bottom, where the popover is/will appear. This was already there before this commit: search "hover tunnel" in rustdoc.css for the implementation. * This commit adds a delay when the mouse pointer enters the base anchor, in case the mouse pointer was just passing through and the user didn't want to open it. * This commit also adds a delay when the mouse pointer exits the tooltip's base anchor or its popover, before hiding it. * A fade-out animation is layered onto the pointer exit delay to immediately inform the user that they successfully dismissed the popover, while still providing a way for them to cancel it if it was a mistake and they still wanted to interact with it. * No animation is used for revealing it, because we don't want people to try to interact with an element while it's in the middle of fading in: either they're allowed to interact with it while it's fading in, meaning it can't serve as mistake- proofing for opening the popover, or they can't, but they might try and be frustrated. See also: * https://www.nngroup.com/articles/timing-exposing-content/ * https://www.nngroup.com/articles/tooltip-guidelines/ * https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown
2023-05-22rustdoc: remove unneeded `position: relative` setting CSSMichael Howell-1/+0
This was added to control percentage sizes, in 79956b96e875e6ba2bfa551fabda6b7896f988ac Now, the only percentage size is [`border-radius`], which is based on the size of the box itself, not its containing block. This leaves the property unused. [`border-radius`]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius
2023-05-22rustdoc: merge identical CSS rulesMichael Howell-5/+3
2023-05-22rustdoc: Cleanup doc string collapsingVadim Petrochenkov-19/+13
2023-05-21rustdoc: include strikethrough in item summaryLukas Markeffsky-1/+9
2023-05-18Rollup merge of #111633 - nnethercote:avoid-ref-format, r=WaffleLapkinDylan DPC-2/+2
Avoid `&format("...")` calls in error message code. Some error message cleanups. Best reviewed one commit at a time. r? `@davidtwco`
2023-05-17Add missing backslash in HTML stringGuillaume Gomez-1/+1
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-2/+2
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-08Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errorsMichael Goulet-12/+38
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