about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2021-11-05Auto merge of #90598 - JohnTitor:rollup-kz1qioz, r=JohnTitorbors-3/+9
Rollup of 9 pull requests Successful merges: - #90507 (Suggest `extern crate alloc` when using undeclared module `alloc`) - #90530 (Simplify js tester a bit) - #90533 (Add note about x86 instruction prefixes in asm! to unstable book) - #90537 (Update aarch64 `target_feature` list for LLVM 12.) - #90544 (Demote metadata load warning to "info".) - #90554 (Clean up some `-Z unstable-options` in tests.) - #90556 (Add more text and examples to `carrying_{add|mul}`) - #90563 (rustbot allow labels) - #90571 (Fix missing bottom border for headings in sidebar) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-05rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()Muhammad Falak R Wani-26/+33
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-05Rollup merge of #90571 - GuillaumeGomez:missing-bottom-border-sidebar, r=jshaYuki Okushi-3/+9
Fix missing bottom border for headings in sidebar Fixes #90568. r? ```@jsha```
2021-11-04Fix ICE when rustdoc is scraping examples inside of a proc macroWill Crichton-9/+20
2021-11-04Sort scraped call locations before serializingWill Crichton-1/+14
2021-11-04Fix missing bottom border for headings in sidebarGuillaume Gomez-3/+9
2021-11-04rustdoc: Use conditional for _stripped foldMichael Howell-8/+16
Followup: https://github.com/rust-lang/rust/pull/90475#discussion_r741405472
2021-11-03Auto merge of #90475 - camelid:docvisitor, r=notriddlebors-125/+218
rustdoc: Add `DocVisitor` and use it where possible `DocFolder` allows transforming the docs, accomplished by making its methods take and return types by-value. However, several of the rustdoc `DocFolder` impls only *visit* the docs; they don't change anything. Passing around types by-value is thus unnecessary, confusing, and potentially inefficient for those impls. `DocVisitor` is very similar to `DocFolder`, except that its methods take shared references and return nothing (i.e., the unit type). This should both be more efficient and make the code clearer. There is an additional reason to add `DocVisitor`, too. As part of my cleanup of `external_traits`, I'm planning to add a `fn cache(&mut self) -> &mut Cache` method to `DocFolder` so that `external_traits` can be retrieved explicitly from the `Cache`, rather than implicitly via `Crate.external_traits` (which is an `Rc<RefCell<...>>`). However, some of the `DocFolder` impls that could be turned into `DocVisitor` impls only have a shared reference to the `Cache`, because they are used during rendering. (They have to access the `Cache` via `html::render::Context.shared.cache`, which involves an `Rc`.) Since `DocVisitor` does not mutate any of the types it's visiting, its equivalent `cache()` method will only need a shared reference to the `Cache`, avoiding the problem described above. r? `@GuillaumeGomez` cc `@jyn514`
2021-11-03Auto merge of #90517 - willcrichton:example-analyzer, r=jyn514bors-16/+23
Fix URL for scrape-examples.js in rustdoc page template Also adds line numbers to URLs in the "additional examples" section of rustdoc. r? `@jyn514`
2021-11-02Add line number to URLs in "additional examples" section of rustdocWill Crichton-13/+20
2021-11-02Fix URL for scrape-examples.js in rustdoc page templateWill Crichton-3/+3
2021-11-02Split doc_cfg and doc_auto_cfg featuresGuillaume Gomez-3/+6
2021-11-01List all cases explicitly in `Doc{Folder,Visitor}`Noah Lev-6/+45
2021-10-31Fix `RefCell` `BorrowMut` error in `DocVisitor`Noah Lev-10/+10
Until `external_traits` is cleaned up (i.e., no longer behind a `RefCell`), `DocVisitor` will have to `take` `external_traits` -- just like `DocFolder` -- to prevent `RefCell` runtime errors.
2021-10-31Convert more impls of `DocFolder` to `DocVisitor`Noah Lev-27/+26
I think these are the last of the impls that can be easily converted to visitors.
2021-10-31Convert many impls of `DocFolder` to `DocVisitor`Noah Lev-38/+39
Many of `DocFolder`'s impls didn't actually transform the syntax tree, so they can be visitors instead.
2021-10-31rustdoc: Small micro-optimizations and cleanupsNoah Lev-7/+8
* Flip conjuncts of `&&` in rustdoc The `CrateNum` comparison should be very cheap, while `span.filename()` fetches and clones a `FileName`. * Use `into_local_path()` instead of `local_path().clone()`
2021-10-31Fix FIXMEs in `rustdoc::html::sources`Noah Lev-5/+6
One of the FIXMEs is irrelevant since that code is only run if `include_sources` is set. I fixed the other FIXME.
2021-10-31Clean up now that visitors only need `&clean::Crate`Noah Lev-15/+15
2021-10-31rustdoc: Use `DocVisitor` for sources collectionNoah Lev-12/+14
2021-10-31rustdoc: Add `DocVisitor`Noah Lev-15/+66
`DocFolder` allows transforming the docs, accomplished by making its methods take and return types by-value. However, several of the rustdoc `DocFolder` impls only *visit* the docs; they don't change anything. Passing around types by-value is thus unnecessary, confusing, and potentially inefficient for those impls. `DocVisitor` is very similar to `DocFolder`, except that its methods take shared references and return nothing (i.e., the unit type). This should both be more efficient and make the code clearer. There is an additional reason to add `DocVisitor`, too. As part of my cleanup of `external_traits`, I'm planning to add a `fn cache(&mut self) -> &mut Cache` method to `DocFolder` so that `external_traits` can be retrieved explicitly from the `Cache`, rather than implicitly via `Crate.external_traits` (which is an `Rc<RefCell<...>>`). However, some of the `DocFolder` impls that could be turned into `DocVisitor` impls only have a shared reference to the `Cache`, because they are used during rendering. (They have to access the `Cache` via `html::render::Context.shared.cache`, which involves an `Rc`.) Since `DocVisitor` does not mutate any of the types it's visiting, its equivalent `cache()` method will only need a shared reference to the `Cache`, avoiding the problem described above.
2021-10-31rustdoc: Replace wildcard with explicit patternNoah Lev-1/+1
This simplifies the code and future-proofs it against changes to `Variant`.
2021-10-31rustdoc: Remove unnecessary clone in `DocFolder`Noah Lev-2/+1
Also, contrary to the comment, the clone is not that small, since `Variant` contains `Item`s, which are quite large when you factor in both stack- and heap-allocated memory.
2021-11-01Rollup merge of #90349 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-2/+18
Fix rare ICE during typeck in rustdoc scrape_examples While testing the `--scrape-examples` extension on the [wasmtime](https://github.com/bytecodealliance/wasmtime) repository, I found some additional edge cases. Specifically, when asking to typecheck a body containing a function call, I would sometimes get an ICE if: * The body doesn't exist * The function's HIR node didn't have a type This adds checks for both of those conditions. (Also this updates a test to check that the sources of a reverse-dependency are correctly generated and linked.) r? `@jyn514`
2021-10-31Hide search bar in noscript.cssJacob Hoffman-Andrews-14/+12
Also, remove the highlighting of the search bar in disabled state. This reduces flicker when loading a page.
2021-10-31Merge `DocContext.{ty,lt,ct}_substs` into one mapNoah Lev-35/+45
It should be impossible to have more than one entry with a particular key across the three maps, so they should be one map. In addition to making it impossible for multiple entries to exist, this should improve memory usage since now only one map is allocated on the stack and heap.
2021-10-31Reduce rightward driftNoah Lev-78/+75
2021-10-31Extract function for expanding private type aliasesNoah Lev-91/+98
2021-10-31Auto merge of #90391 - camelid:crate-size, r=jyn514bors-20/+31
rustdoc: Compute some fields of `clean::Crate` on-demand to reduce size `clean::Crate` is frequently moved by-value -- for example, in `DocFolder` implementations -- so reducing its size should improve performance. This PR reduces the size of `clean::Crate` from 168 bytes to 104 bytes. r? `@jyn514`
2021-10-30Improve display of enum variantsJacob Hoffman-Andrews-26/+27
Use h3 and h4 for the variant name and the "Fields" subheading. Remove the "of T" part of the "Fields" subheading. Remove border-bottom from "Fields" subheading. Move docblock below "Fields" listing.
2021-10-30Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514Guillaume Gomez-27/+128
Show all Deref implementations recursively Fixes #87783. This is a re-implementation of #80653, so taking the original PR comment: This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level. ![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png) cc `@camelid` r? `@jyn514`
2021-10-30Rollup merge of #90156 - jsha:less-border-bottom-2, r=GuillaumeGomezGuillaume Gomez-2/+9
Remove underlines from non-top docblocks. We still had a number of places where underlined section headings would show up, like under Implementations. Follow-up to #89506 (thanks `@yaymukund!)` and #90036. Related to #59829. r? `@camelid` Demo: [Before](https://doc.rust-lang.org/nightly/std/string/struct.String.html#trait-implementations): [![image](https://user-images.githubusercontent.com/220205/138402555-b0c0a3ea-ff50-4aad-bb74-6f9e57323807.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations) [After](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations): [![image](https://user-images.githubusercontent.com/220205/138402669-d0835bd9-8813-4f0c-8697-f86e9759acec.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)
2021-10-30rustdoc: Stop sorting external cratesNoah Lev-2/+1
Now that #73423 is fixed, sorting should no longer be necessary. See also this discussion [1]. [1]: https://github.com/rust-lang/rust/pull/86889#discussion_r664134963
2021-10-30rustdoc: Remove `Crate.name` and instead compute it on-demandNoah Lev-14/+16
It is not as large as `Crate.src` was, but it's still 8 bytes, and `clean::Crate` is moved by-value a lot.
2021-10-30rustdoc: Remove `Crate.src` and instead compute it on-demandNoah Lev-5/+8
It is only used in one place; `src` was about a third of `Crate`'s total size; `Crate` is frequently moved by-value; and `src` can be easily computed on-demand.
2021-10-30rustdoc: Document that `Crate` is always localNoah Lev-0/+3
2021-10-30Remove underlines from non-top docblocks.Jacob Hoffman-Andrews-2/+9
We still had a number of places where underlined section headings would show up, like under Implementations.
2021-10-30Rollup merge of #90412 - jyn514:macro-use, r=camelidMatthias Krüger-7/+6
Remove unnecessary `macro_use`s in rustdoc
2021-10-30Auto merge of #88268 - GuillaumeGomez:generics-search-index, ↵bors-89/+124
r=notriddle,camelid,jyn514 rustdoc: Fix generics generation in search index The generics were not added to the search index as they should, instead they were added as arguments. I used this opportunity to allow generics to have generics themselves (will come in very handy for my current rewrite of the search engine!). r? `@jyn514`
2021-10-29rustdoc: Add static size assertion for `clean::Crate`Noah Lev-0/+4
2021-10-30Remove unnecessary `macro_use`s in rustdocJoshua Nelson-7/+6
2021-10-29Fix rare ICE during typeck in rustdoc scrape_examplesWill Crichton-2/+18
2021-10-29Fix invalid handling of genericsGuillaume Gomez-89/+124
2021-10-29Auto merge of #90389 - camelid:rustdoc-rayon, r=jyn514bors-11/+2
rustdoc: Switch to mainline rayon The rustc fork of rayon integrates with Cargo's jobserver to limit the amount of parallelism. However, rustdoc's use case is concurrent I/O, which is not CPU-heavy, so it should be able to use mainline rayon. See [this discussion][1] for more details. [1]: https://github.com/rust-lang/rust/issues/90227#issuecomment-952468618 Note: I chose rayon 1.3.1 so that the rayon version used elsewhere in the workspace does not change. r? `@Mark-Simulacrum` cc `@jyn514`
2021-10-29Fix panic when documenting libproc-macroGuillaume Gomez-13/+10
2021-10-29Don't display "Methods from Deref<...>" if no method is display (the ones ↵Guillaume Gomez-3/+9
which don't have `self` argument)
2021-10-29Remove the Rc wrapping of deref_id_mapGuillaume Gomez-4/+4
2021-10-29Add tests for recursive derefGuillaume Gomez-4/+7
2021-10-29Recursively document DerefGuillaume Gomez-16/+111
2021-10-28rustdoc: Remove a single-use macroNoah Lev-10/+1
I think the new code is simpler and easier to understand.