about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2023-06-19Clean up "doc(hidden)" checkGuillaume Gomez-10/+17
2023-06-19s/Clause/ClauseKindMichael Goulet-20/+21
2023-06-17rustdoc: Fix --test-run-directory and relative paths.Eric Huss-0/+16
2023-06-17Move ConstEvaluatable to ClauseMichael Goulet-1/+1
2023-06-17Move WF goal to clauseMichael Goulet-1/+1
2023-06-17Rollup merge of #112707 - GuillaumeGomez:back-in-history-fix, r=notriddleMatthias Krüger-19/+35
[rustdoc] Fix invalid handling of "going back in history" when "go to only search result" setting is enabled You can test the fix [here](https://rustdoc.crud.net/imperio/back-in-history-fix/lib2/index.html). Enable "Directly go to item in search if there is only one result", then search for `HasALongTraitWithParams` and finally go back to previous page. It should be back on the `index.html` page. The reason for this bug is that the JS state is cached as is, so when we go back to the page, it resumes where it was left, somewhat (very weird), meaning the search is run again etc. The best way to handle this is to force the JS re-execution in this case so that it doesn't try to resume from where it left and then lead us back to the current page. r? ``@notriddle``
2023-06-17Auto merge of #108860 - oli-obk:tait_alias, r=compiler-errorsbors-0/+5
Add `AliasKind::Weak` for type aliases. `type Foo<T: Debug> = Bar<T>;` does not check `T: Debug` at use sites of `Foo<NotDebug>`, because in contrast to a ```rust trait Identity { type Identity; } impl<T: Debug> Identity for T { type Identity = T; } <NotDebug as Identity>::Identity ``` type aliases do not exist in the type system, but are expanded to their aliased type immediately when going from HIR to the type layer. Similarly: * a private type alias for a public type is a completely fine thing, even though it makes it a bit hard to write out complex times sometimes * rustdoc expands the type alias, even though often times users use them for documentation purposes * diagnostics show the expanded type, which is confusing if the user wrote a type alias and the diagnostic talks about another type that they don't know about. For type alias impl trait, these issues do not actually apply in most cases, but sometimes you have a type alias impl trait like `type Foo<T: Debug> = (impl Debug, Bar<T>);`, which only really checks it for `impl Debug`, but by accident prevents `Bar<T>` from only being instantiated after proving `T: Debug`. This PR makes sure that we always check these bounds explicitly and don't rely on an implementation accident. To not break all the type aliases out there, we only use it when the type alias contains an opaque type. We can decide to do this for all type aliases over an edition. Or we can later extend this to more types if we figure out the back-compat concerns with suddenly checking such bounds. As a side effect, easily allows fixing https://github.com/rust-lang/rust/issues/108617, which I did. fixes https://github.com/rust-lang/rust/issues/108617
2023-06-16Add `AliasKind::Weak` for type aliases.Oli Scherer-0/+5
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
2023-06-16Fix invalid handling of "going back in history" when "Directly go to item in ↵Guillaume Gomez-4/+21
search if there is only one result" setting is set to true
2023-06-16Auto merge of #110688 - GuillaumeGomez:result-search-type, r=notriddle,jshabors-11/+36
rustdoc: Add search result item types after their name Here what it looks like: ![Screenshot from 2023-04-22 15-16-58](https://user-images.githubusercontent.com/3050060/233789566-b5f3f625-3b78-4c56-a7ee-0a4f2d62e667.png) The idea is to improve accessibility by providing this information directly in the text and not only in the text color. Currently we already use it for doc aliases and for primitive types, so I extended it to all types. r? `@notriddle`
2023-06-16Unify history interactions in searchGuillaume Gomez-15/+14
2023-06-15Auto merge of #112233 - notriddle:notriddle/search-unify, r=GuillaumeGomezbors-166/+163
rustdoc-search: clean up type unification and "unboxing" This PR redesigns parameter matching, return matching, and generics matching to use a single function that compares two lists of types. It also makes the algorithms more consistent, so the "unboxing" behavior where `Vec<i32>` is considered a match for `i32` works inside generics, and not just at the top level.
2023-06-15Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieubors-4/+3
Don't drain-on-drop in DrainFilter impls of various collections. This removes drain-on-drop behavior from various unstable DrainFilter impls (not yet for HashSet/Map) because that behavior [is problematic](https://github.com/rust-lang/rust/issues/43244#issuecomment-641638196) (because it can lead to panic-in-drop when user closures panic) and may become forbidden if [this draft RFC passes](https://github.com/rust-lang/rfcs/pull/3288). closes #101122 [ACP](https://github.com/rust-lang/libs-team/issues/136) affected tracking issues * #43244 * #70530 * #59618 Related hashbrown update: https://github.com/rust-lang/hashbrown/pull/374
2023-06-14Fix eBNF and handling of whitespace characters when not in a pathGuillaume Gomez-2/+11
2023-06-14Correctly display whitespace characters in search errorGuillaume Gomez-1/+1
2023-06-14Use whitespace as path separator like double colonGuillaume Gomez-71/+163
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-1/+0
2023-06-14remove drain-on-drop behavior from vec::DrainFilter and add #[must_use]The 8472-3/+3
2023-06-14Rollup merge of #112581 - TumoiYorozu:fix_url_encoding_of_percent_sign, ↵Matthias Krüger-2/+0
r=notriddle [rustdoc] Fix URL encoding of % sign Fix #112580 The % is encoded as %%, but the correct encoding is %25.
2023-06-13Fix URL encoding of % sign in Rust Doc.TumoiYorozu-2/+0
2023-06-12rustdoc-search: search never type with `!`Michael Howell-5/+43
This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for diverging functions. Part of #60485 It's already possible to do this search with `primitive:never`, but that's not what the Rust language itself uses, so nobody will try it if they aren't told or helped along.
2023-06-12Revert "List matching impls on type aliases"Guillaume Gomez-110/+28
This reverts commit 4b1d13d9841c815915433ca2a3088a8e3e97ad96.
2023-06-11rustdoc-search: fix order-independence bugMichael Howell-68/+98
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-11Auto merge of #112202 - nicklimmm:item-template-derive-macro, r=GuillaumeGomezbors-61/+120
rustdoc: Add `item_template` macro Closes #112021 This change removes the use of `self.borrows()` in Askama templates, removes code duplication from `item_and_mut_cx()`, and improved readability by eliminating the prefix `item_template_` when calling from the template. References: - Discussion issue: https://github.com/rust-lang/rust/issues/112021 - `ItemTemplate` PR: https://github.com/rust-lang/rust/pull/111946 r? `@GuillaumeGomez`
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-10Auto merge of #107637 - fmease:rustdoc-reelide-x-crate-def-tr-obj-lt-bnds, ↵bors-49/+235
r=notriddle,cgillot,GuillaumeGomez rustdoc: re-elide cross-crate default trait-object lifetime bounds Hide trait-object lifetime bounds (re-exported from an external crate) if they coincide with [their default](https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes). Partially addresses #44306. Follow-up to #103885. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/clean_middle_ty.3A.20I.20need.20to.20add.20a.20parameter/near/307143097). Most notably, if `std` exported something from `core` containing a type like `Box<dyn Fn()>`, then it would now be rendered as `Box<dyn Fn(), Global>` instead of `Box<dyn Fn() + 'static, Global>` (hiding `+ 'static` as it is the default in this case). Showing `Global` here is a separate issue, #80379, which is on my agenda. Note that I am not really fond of the fact that I had to add a parameter to such a widely used function (30+ call sites) to address such a niche bug. CC `@GuillaumeGomez` Requesting a review from a compiler contributor or team member as recommended on Zulip. r? compiler --- `@rustbot` label T-compiler T-rustdoc A-cross-crate-reexports
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-07Rollup merge of #112251 - notriddle:notriddle/cleanup-inlining, r=GuillaumeGomezDylan DPC-18/+28
rustdoc: convert `if let Some()` that always matches to variable
2023-06-07use wf::object_region_boundsLeón Orell Valerian Liehr-42/+9
2023-06-07rustdoc: re-elide cross-crate default trait object lifetime boundsLeón Orell Valerian Liehr-49/+268
2023-06-06rustdoc: convert `if let Some()` that always matches to variableMichael Howell-18/+28
2023-06-05cleanup some skip_binder -> subst_identityKyle Matsuda-3/+3
2023-06-05Rollup merge of #112315 - lucascherzer:master, r=NilstriebGuillaume Gomez-3/+3
fix spelling error "rexport" is not valid spelling: https://www.merriam-webster.com/dictionary/re-export
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-05fix spelling errorLuca Scherzer-3/+3
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-04Rollup merge of #112178 - GuillaumeGomez:fix-inline-private-intermediate, ↵Matthias Krüger-2/+4
r=notriddle Fix bug where private item with intermediate doc hidden re-export was not inlined This fixes this bug: ```rust mod private { /// Original. pub struct Bar3; } /// Hidden. #[doc(hidden)] pub use crate::private::Bar3; /// Visible. pub use self::Bar3 as Reexport; ``` In this case, `private::Bar3` should be inlined and renamed `Reexport` but instead we have: ``` pub use self::Bar3 as Reexport; ``` and no links. There were actually two issues: the first one is that we forgot to check if the next intermediate re-export was doc hidden. The second was that we made the `#[doc(hidden)]` attribute inheritable, which shouldn't be possible. r? `@notriddle`
2023-06-03Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directlyGuillaume Gomez-23/+18
2023-06-03Move type name directly into the same DOM elementGuillaume Gomez-19/+1
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-02Improve new search result display on mobileGuillaume Gomez-0/+8
2023-06-02Move item kind before the item nameGuillaume Gomez-3/+13