about summary refs log tree commit diff
path: root/tests/rustdoc
AgeCommit message (Collapse)AuthorLines
2024-04-06Add `f16` and `f128` to rustdoc's `PrimitiveType`Trevor Gross-1/+13
Fix a few places where these primitives were missing from librustdoc.
2024-04-04Add regression test for #123435Guillaume Gomez-0/+14
2024-04-02Rollup merge of #122614 - notriddle:notriddle/search-desc, r=GuillaumeGomezGuillaume Gomez-1/+1
rustdoc-search: shard the search result descriptions ## Preview This makes no visual changes to rustdoc search. It's a pure perf improvement. <details><summary>old</summary> Preview: <http://notriddle.com/rustdoc-html-demo-10/doc/std/index.html?search=vec> WebPageTest Comparison with before branch on a sort of worst case (searching `vec`, winds up downloading most of the shards anyway): <https://www.webpagetest.org/video/compare.php?tests=240317_AiDc61_2EM,240317_AiDcM0_2EN> Waterfall diagram: ![image](https://github.com/rust-lang/rust/assets/1593513/39548f0c-7ad6-411b-abf8-f6668ff4da18) </details> Preview: <http://notriddle.com/rustdoc-html-demo-10/doc2/std/index.html?search=vec> WebPageTest Comparison with before branch on a sort of worst case (searching `vec`, winds up downloading most of the shards anyway): <https://www.webpagetest.org/video/compare.php?tests=240322_BiDcCH_13R,240322_AiDcJY_104> ![image](https://github.com/rust-lang/rust/assets/1593513/4be1f9ff-c3ff-4b96-8f5b-b264df2e662d) ## Description r? `@GuillaumeGomez` The descriptions are, on almost all crates[^1], the majority of the size of the search index, even though they aren't really used for searching. This makes it relatively easy to separate them into their own files. Additionally, this PR pulls out information about whether there's a description into a bitmap. This allows us to sort, truncate, *then* download. This PR also bumps us to ES8. Out of the browsers we support, all of them support async functions according to caniuse. https://caniuse.com/async-functions [^1]: <https://microsoft.github.io/windows-docs-rs/>, a crate with 44MiB of pure names and no descriptions for them, is an outlier and should not be counted. But this PR should improve it, by replacing a long line of empty strings with a compressed bitmap with a single Run section. Just not very much. ## Detailed sizes ```console $ cat test.sh set -ex cp ../search-index*.js search-index.js awk 'FNR==NR {a++;next} FNR<a-3' search-index.js{,} | awk 'NR>1 {gsub(/\],\\$/,""); gsub(/^\["[^"]+",/,""); print} {next}' | sed -E "s:\\\\':':g" > search-index.json jq -c '.t' search-index.json > t.json jq -c '.n' search-index.json > n.json jq -c '.q' search-index.json > q.json jq -c '.D' search-index.json > D.json jq -c '.e' search-index.json > e.json jq -c '.i' search-index.json > i.json jq -c '.f' search-index.json > f.json jq -c '.c' search-index.json > c.json jq -c '.p' search-index.json > p.json jq -c '.a' search-index.json > a.json du -hs t.json n.json q.json D.json e.json i.json f.json c.json p.json a.json $ bash test.sh + cp ../search-index1.78.0.js search-index.js + awk 'FNR==NR {a++;next} FNR<a-3' search-index.js search-index.js + awk 'NR>1 {gsub(/\],\\$/,""); gsub(/^\["[^"]+",/,""); print} {next}' + sed -E 's:\\'\'':'\'':g' + jq -c .t search-index.json + jq -c .n search-index.json + jq -c .q search-index.json + jq -c .D search-index.json + jq -c .e search-index.json + jq -c .i search-index.json + jq -c .f search-index.json + jq -c .c search-index.json + jq -c .p search-index.json + jq -c .a search-index.json + du -hs t.json n.json q.json D.json e.json i.json f.json c.json p.json a.json 64K t.json 800K n.json 8.0K q.json 4.0K D.json 16K e.json 192K i.json 544K f.json 4.0K c.json 36K p.json 20K a.json ``` These are, roughly, the size of each section in the standard library (this tool actually excludes libtest, for parsing-json-with-awk reasons, but libtest is tiny so it's probably not important). t = item type, like "struct", "free fn", or "type alias". Since one byte is used for every item, this implies that there are approximately 64 thousand items in the standard library. n = name, and that's now the largest section of the search index with the descriptions removed from it q = parent *module* path, stored parallel to the items within D = the size of each description shard, stored as vlq hex numbers e = empty description bit flags, stored as a roaring bitmap i = parent *type* index as a link into `p`, stored as decimal json numbers; used only for associated types; might want to switch to vlq hex, since that's shorter, but that would be a separate pr f = function signature, stored as lists of lists that index into `p` c = deprecation flag, stored as a roaring bitmap p = parent *type*, stored separately and linked into from `i` and `f` a = alias, as [[key, value]] pairs ## Search performance http://notriddle.com/rustdoc-html-demo-11/perf-shard/index.html For example, in stm32f4: <table><thead><tr><th>before<th>after</tr></thead> <tbody><tr><td> ``` Testing T -> U ... in_args = 0, returned = 0, others = 200 wall time = 617 Testing T, U ... in_args = 0, returned = 0, others = 200 wall time = 198 Testing T -> T ... in_args = 0, returned = 0, others = 200 wall time = 282 Testing crc32 ... in_args = 0, returned = 0, others = 0 wall time = 426 Testing spi::pac ... in_args = 0, returned = 0, others = 0 wall time = 673 ``` </td><td> ``` Testing T -> U ... in_args = 0, returned = 0, others = 200 wall time = 716 Testing T, U ... in_args = 0, returned = 0, others = 200 wall time = 207 Testing T -> T ... in_args = 0, returned = 0, others = 200 wall time = 289 Testing crc32 ... in_args = 0, returned = 0, others = 0 wall time = 418 Testing spi::pac ... in_args = 0, returned = 0, others = 0 wall time = 687 ``` </td></tr><tr><td> ``` user: 005.345 s sys: 002.955 s wall: 006.899 s child_RSS_high: 583664 KiB group_mem_high: 557876 KiB ``` </td><td> ``` user: 004.652 s sys: 000.565 s wall: 003.865 s child_RSS_high: 538696 KiB group_mem_high: 511724 KiB ``` </td></tr> </table> This perf tester is janky and unscientific enough that the apparent differences might just be noise. If it's not an order of magnitude, it's probably not real. ## Future possibilities * Currently, results are not shown until the descriptions are downloaded. Theoretically, the description-less results could be shown. But actually doing that, and making sure it works properly, would require extra work (we have to be careful to avoid layout jumps). * More than just descriptions can be sharded this way. But we have to be careful to make sure the size wins are worth the round trips. Ideally, data that’s needed only for display should be sharded while data needed for search isn’t. * [Full text search](https://internals.rust-lang.org/t/full-text-search-for-rustdoc-and-doc-rs/20427) also needs this kind of infrastructure. A good implementation might store a compressed bloom filter in the search index, then download the full keyword in shards. But, we have to be careful not just of the amount readers have to download, but also of the amount that [publishers](https://gist.github.com/notriddle/c289e77f3ed469d1c0238d1d135d49e1) have to store.
2024-04-02rustdoc: heavily simplify synthesis of auto trait implsLeón Orell Valerian Liehr-2/+23
2024-04-01rustdoc: synthetic impls: auto traits: Fx{Hash↦Index}{Map,Set}León Orell Valerian Liehr-10/+7
2024-03-16rustdoc-search: shard the search result descriptionsMichael Howell-1/+1
The descriptions are, on almost all crates[^1], the majority of the size of the search index, even though they aren't really used for searching. This makes it relatively easy to separate them into their own files. This commit also bumps us to ES8. Out of the browsers we support, all of them support async functions according to caniuse. https://caniuse.com/async-functions [^1]: <https://microsoft.github.io/windows-docs-rs/>, a crate with 44MiB of pure names and no descriptions for them, is an outlier and should not be counted.
2024-03-14testsManish Goregaokar-4/+8
2024-03-12Rollup merge of #122355 - fmease:rustdoc-fix-up-old-test, r=notriddleJubilee-15/+26
rustdoc: fix up old test `tests/rustdoc/line-breaks.rs` had several issues: 1. It used `//`@count`` instead of `// `@count`` (notice the space!) which gets treated as a `ui_test` directive instead of a `htmldocck` one. `compiletest` didn't flag it as an error because it's allowlisted ([#121561](https://github.com/rust-lang/rust/pull/121561)) presumably precisely because of this test. And before the compiletest→ui_test migration, these directives must've been ignored, too, because … 2. … the checks themselves no longer work either: The count of `<br>`s is actually 0 in all 3 cases because – well – we no longer generate any `<br>`s inside `<pre>`s. Since I don't know how to ``@count`` `\n`s instead of `<br>`s, I've turned them into ``@matches`.` Btw, I don't know if this test is still desirable or if we have other tests that cover this (I haven't checked). r? rustdoc
2024-03-12rustdoc: fix up old testLeón Orell Valerian Liehr-15/+26
2024-03-11Rollup merge of #121840 - oli-obk:freeze, r=dtolnayJacob Pratt-7/+10
Expose the Freeze trait again (unstably) and forbid implementing it manually non-emoji version of https://github.com/rust-lang/rust/pull/121501 cc #60715 This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue. It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: https://github.com/google/zerocopy/issues/941 cc ```@RalfJung``` T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
2024-03-05Update test names to not have dots许杰友 Jieyou Xu (Joe)-0/+0
2024-03-01Add regression test for #121772Guillaume Gomez-0/+24
2024-02-29Expose `Freeze` trait againOli Scherer-7/+10
2024-02-29Rollup merge of #121689 - GuillaumeGomez:rustdoc-highlighting-whitespace, ↵Matthias Krüger-0/+29
r=notriddle [rustdoc] Prevent inclusion of whitespace character after macro_rules ident Discovered this bug randomly when looking at: ![image](https://github.com/rust-lang/rust/assets/3050060/dca38047-9085-4377-bfac-f98890224be4) We were too eagerly trying to merge tokens that shouldn't be merged together (for example if you have a code comment followed by a code comment, we merge them in one attribute to reduce the DOM size). r? ``@notriddle``
2024-02-28Add regression test for inclusion of whitespace characters in rustdoc ↵Guillaume Gomez-0/+29
highlighting
2024-02-28Rollup merge of #121680 - GuillaumeGomez:foreign-macro-jump-to-def, r=notriddleGuillaume Gomez-0/+21
Fix link generation for foreign macro in jump to definition feature The crate name is already added to the link so it shouldn't be added a second time for local foreign macros. r? ``@notriddle``
2024-02-28Rollup merge of #121572 - notriddle:notriddle/test-case-121106, r=GuillaumeGomezGuillaume Gomez-0/+19
Add test case for primitive links in alias js Follow up #121490 CC #121106
2024-02-27Add regression test for link generation on foreign macro in jump to ↵Guillaume Gomez-0/+21
defintion feature
2024-02-26Auto merge of #121461 - reitermarkus:generic-nonzero-tests, r=dtolnaybors-1/+1
Use generic `NonZero` in tests. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-02-25Use generic `NonZero` in tests.Markus Reiter-1/+1
2024-02-24Add test case for primitive links in alias jsMichael Howell-0/+19
2024-02-24Add test cases for inlining compiler-private itemsMichael Howell-0/+25
Closes #106421 This was already fixed by f5d43a052b9eb464e54af819143467954d814a24, but now the test cases are added.
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-466/+466
2024-02-18Rollup merge of #121218 - ShoyuVanilla:fix-issue-76736, r=notriddleLeón Orell Valerian Liehr-0/+58
Fix missing trait impls for type in rustc docs Fixes #76736
2024-02-18Rollup merge of #121160 - fmease:rustdoc-fix-n-refactor-html-rendering, ↵León Orell Valerian Liehr-1/+13
r=GuillaumeGomez rustdoc: fix and refactor HTML rendering a bit * refactoring: get rid of a bunch of manual `f.alternate()` branches * not sure why this wasn't done so already, is this perf-sensitive? * fix an ICE in debug builds of rustdoc * rustdoc used to crash on empty outlives-bounds: `where 'a:` * properly escape const generic defaults * actually print empty trait and outlives-bounds (doesn't work for cross-crate reexports yet, will fix that at some other point) since they can have semantic significance * outlives-bounds: forces lifetime params to be early-bound instead of late-bound which is technically speaking part of the public API * trait-bounds: can affect the well-formedness, consider * makeshift “const-evaluatable” bounds under `generic_const_exprs` * bounds to force wf-checking in light of #100041 (quite artificial I know, I couldn't figure out something better), see https://github.com/rust-lang/rust/pull/121160#discussion_r1491563816
2024-02-17Fix missing trait impls for type in rustc docsShoyu Vanilla-0/+58
2024-02-16rustdoc: fix and refactor HTML rendering a bitLeón Orell Valerian Liehr-1/+13
2024-02-16Rollup merge of #121095 - chenyukang:yukang-fix-120998-rust-playground-link, ↵Guillaume Gomez-2/+2
r=GuillaumeGomez Add extra indent spaces for rust-playground link Fixes #120998 Seems add `rustfmt` for this is somehow too heavy, only adding indent spaces at the starting of each line of code seems good enough.
2024-02-15add extra indent spaces for rust-playground linkyukang-2/+2
2024-02-15Rollup merge of #121022 - fmease:rustdoc-x-crate-late-bound-lt-src-order, ↵Matthias Krüger-0/+34
r=GuillaumeGomez rustdoc: cross-crate re-exports: correctly render late-bound params in source order even if early-bound params are present r? ghost
2024-02-15rustdoc: cross-crate re-exports: correctly render late-bound params in ↵León Orell Valerian Liehr-0/+34
source order even if early-bound params are present
2024-02-13Rollup merge of #120548 - GuillaumeGomez:glob-reexport-cfg-merge, ↵Matthias Krüger-0/+29
r=GuillaumeGomez rustdoc: Fix handling of doc_auto_cfg feature for cfg attributes on glob reexport This is a follow-up of #120501 and a part of https://github.com/rust-lang/rust/issues/120487. r? `@notriddle`
2024-02-09Unify item relative path computation in one functionGuillaume Gomez-4/+37
2024-02-09Add regression test for non local items link generationGuillaume Gomez-0/+15
2024-02-01Add regression test for `doc_auto_cfg` feature handling with glob reexportsGuillaume Gomez-0/+29
2024-01-31Rollup merge of #120501 - GuillaumeGomez:glob-reexport-attr-merge-bugfix, ↵Nadrieril-0/+32
r=notriddle rustdoc: Correctly handle attribute merge if this is a glob reexport Fixes #120487. The regression was introduced in https://github.com/rust-lang/rust/pull/113091. Only non-glob reexports should have been impacted. cc `````@Nemo157````` r? `````@notriddle`````
2024-01-30Add regression test for #120487Guillaume Gomez-0/+32
2024-01-29Add regression test for #100638Guillaume Gomez-0/+15
2024-01-23Remove uses of no-system-llvmNikita Popov-1/+0
It looks like none of these are actually needed.
2024-01-20Add regression test for #119015 and update testsGuillaume Gomez-7/+38
2024-01-19Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddleMatthias Krüger-11/+35
[rustdoc] Allows links in headings Reopening of https://github.com/rust-lang/rust/pull/94360. # Explanations Rustdoc currently doesn't follow the markdown spec on headings: we don't allow links in them. So instead of having headings linking to themselves, this PR generates an anchor on the left side like this: ![image](https://github.com/rust-lang/rust/assets/3050060/a118a7e9-5ef8-4d07-914f-46defc3245c3) <details> <summary>previous version</summary> ![image](https://github.com/rust-lang/rust/assets/3050060/c34fa844-9cd4-47dc-bb51-b37f5f66afee) </details> Having the anchor always displayed allows for mobile devices users to be able to have a link to the anchor. The different color used for the anchor itself is the same as links so people notice when looking at it that they can click on it. You can test it [here](https://rustdoc.crud.net/imperio/links-in-headings/std/index.html). cc `@camelid` r? `@notriddle`
2024-01-14Rollup merge of #119561 - notriddle:master, r=fmeaseGuillaume Gomez-258/+108
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 5) Follow up * https://github.com/rust-lang/rust/pull/116214 * https://github.com/rust-lang/rust/pull/116432 * https://github.com/rust-lang/rust/pull/116824 * https://github.com/rust-lang/rust/pull/118105
2024-01-10Rollup merge of #119769 - fmease:rustdoc-off-by-one-dyn-trait-def-gen-args, ↵Matthias Krüger-14/+30
r=GuillaumeGomez rustdoc: offset generic args of cross-crate trait object types when cleaning Fixes #119529. This PR contains several refactorings apart from the bug fix. Best reviewed commit by commit. r? GuillaumeGomez
2024-01-09Update testsLeón Orell Valerian Liehr-14/+30
2024-01-05Rollup merge of #119216 - weiznich:use_diagnostic_namespace_in_stdlib, ↵Michael Goulet-0/+3
r=compiler-errors Use diagnostic namespace in stdlib This required a minor fix to have the diagnostics shown in third party crates when the `diagnostic_namespace` feature is not enabled. See https://github.com/rust-lang/rust/pull/119216/commits/5d63f5d8d1a72167c1d5242b2e1ed5b7259fd526 for details. I've opted for having a single PR for both changes as it's really not that much code. If it is required it should be easy to split up the change into several PR's. r? `@compiler-errors`
2024-01-05Ignore a rustdoc testLeón Orell Valerian Liehr-0/+3
2024-01-05Rollup merge of #119586 - GuillaumeGomez:jump-to-def-static-methods, r=notriddleMichael Goulet-1/+28
[rustdoc] Fix invalid handling for static method calls in jump to definition feature I realized when working on a clippy lint that static method calls on `Self` could not give me the method `Res`. For that, we need to use `typeck` and so that's what I did in here. It fixes the linking to static method calls. r? ````@notriddle````
2024-01-04Add regression test for jump to def static method callsGuillaume Gomez-1/+28
2024-01-03rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 5)Michael Howell-208/+0
2024-01-03Add `crate_name` and URL to test casesMichael Howell-37/+95