about summary refs log tree commit diff
path: root/src/librustdoc/formats
AgeCommit message (Collapse)AuthorLines
2022-01-17fix #90187: Replace all def_id_no_primitives with def_idzredb-1/+1
2022-01-17fix #90187zredb-1/+1
2022-01-17fix #90187zredb-1/+1
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-12/+12
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.
2021-12-27Give clearer names to several search index functionsNoah Lev-2/+2
2021-12-27Move `ExternalLocation` to `clean::types`Noah Lev-2/+2
It was previously defined in `render::search_index` but wasn't used at all there. `clean::types` seems like a better fit since that's where `ExternalCrate` is defined.
2021-12-27rustdoc: Remove some unnecessary `cache` parametersNoah Lev-1/+1
Based on https://github.com/rust-lang/rust/pull/80883#issuecomment-774437832. The `tcx` parameters do seem to be used though, so I only removed the `cache` parameters.
2021-12-27Rename `rustdoc::html::render::cache` to `search_index`Noah Lev-1/+1
The old name wasn't very clear, while the new one makes it clear that this is the code responsible for creating the search index.
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-3/+2
2021-11-26Rename `Type::ResolvedPath` to `Type::Path`Noah Lev-6/+4
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
2021-11-25Stop re-exporting `Type::ResolvedPath`Noah Lev-3/+5
I would like to rename it to `Type::Path`, but then it can't be re-exported since the name would conflict with the `Path` struct. Usually enum variants are referred to using their qualified names in Rust (and parts of rustdoc already do that with `clean::Type`), so this is also more consistent with the language.
2021-11-24Remove `ResolvedPath.did`Noah Lev-5/+5
2021-11-19rustdoc: Move doc-reachability visiting back to cleaningNoah Lev-3/+0
It populates `cx.cache.access_levels`, which seems to be needed during cleaning since a bunch of tests are failing.
2021-11-19rustdoc: Merge visits of extern crates into one loopNoah Lev-14/+10
2021-11-19rustdoc: Remove `Crate.externs` and compute on-demand insteadNoah Lev-5/+14
2021-11-19rustdoc: Pass DocContext to `Cache::populate`Noah Lev-17/+16
This will allow removing `Crate.externs`.
2021-11-13Auto merge of #90385 - mfrw:mfrw/librustdoc, r=GuillaumeGomezbors-1/+1
rustdoc: use Type::def_id() instead of Type::def_id_no_primitives() For: #90187 r? `@jyn514`
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-0/+1
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-1/+1
The `ImplKind` methods can just be used directly instead.
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-1/+1
This change has two advantages: 1. It makes the possible states clearer, and it makes it impossible to construct invalid states, such as a blanket impl that is also an auto trait impl. 2. It shrinks the size of `Impl` a bit, since now there is only one field, rather than two.
2021-11-07Give inline const separate DefKindGary Guo-0/+1
2021-11-05rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()Muhammad Falak R Wani-1/+1
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-10-29Fix invalid handling of genericsGuillaume Gomez-0/+2
2021-10-27Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514Matthias Krüger-3/+5
rustdoc: Remove `GetDefId` See the individual commit messages for details. r? `@jyn514`
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-2/+2
2021-10-22Rename `Type::def_id_full()` to `Type::def_id()`Noah Lev-2/+2
It should be preferred over `def_id_no_primitives()`, so it should have a shorter name. I also put it before `def_id_no_primitives()` so that it shows up first in the docs.
2021-10-22Use `def_id_full()` where easily possibleNoah Lev-2/+4
In general, it should be preferred over `Type::def_id()`. See each method's docs for more.
2021-10-22Replace `GetDefId` with inherent methodsNoah Lev-1/+1
Now that it's only implemented for `Type`, using inherent methods instead means that imports are no longer necessary. Also, `GetDefId` is only meant to be used with `Type`, so it shouldn't be a trait.
2021-10-09Auto merge of #88379 - camelid:cleanup-clean, r=jyn514bors-20/+10
rustdoc: Cleanup various `clean` types Cleanup various `clean` types.
2021-10-05Allow adding a set of cfg's to hide from being implicitly doc(cfg)'dWim Looman-0/+2
By adding #![doc(cfg_hide(foobar))] to the crate attributes the cfg #[cfg(foobar)] (and _only_ that _exact_ cfg) will not be implicitly treated as a doc(cfg) to render a message in the documentation.
2021-09-30Remove temporary `GetDefId` impl for `Path`Noah Lev-19/+9
2021-09-30Make `Impl.trait_` a `Path`, not a `Type`Noah Lev-1/+1
It should only ever be a `ResolvedPath`, so this (a) enforces that, and (b) reduces the size of `Impl`. I had to update a test because the order of the rendered auto trait impl bounds changed. I think the order changed because rustdoc sorts auto trait bounds using their `Debug` output.
2021-09-12Rollup merge of #88810 - camelid:cleanup-pt1, r=jyn514Manish Goregaokar-3/+0
rustdoc: Cleanup `clean` part 1 Split out from #88379. These commits are completely independent of each other, and each is a fairly small change (the last few are new commits; they are not from #88379): - Remove unnecessary `Cache.*_did` fields - rustdoc: Get symbol for `TyParam` directly - Create a valid `Res` in `external_path()` - Remove unused `hir_id` parameter from `resolve_type` - Fix redundant arguments in `external_path()` - Remove unnecessary `is_trait` argument - rustdoc: Cleanup a pattern match in `external_generic_args()` r? ``@jyn514``
2021-09-12Fix broken handling of primitive itemsJoshua Nelson-12/+11
- Fix broken handling of primitive associated items - Remove fragment hack Fixes 83083 - more logging - Update CrateNum hacks The CrateNum has no relation to where in the dependency tree the crate is, only when it's loaded. Explicitly special-case core instead of assuming it will be the first DefId. - Update and add tests - Cache calculation of primitive locations This could possibly be avoided by passing a Cache into collect_intra_doc_links; but that's a much larger change, and doesn't seem valuable other than for this.
2021-09-09Remove unnecessary `Cache.*_did` fieldsNoah Lev-3/+0
They can be obtained by accessing the `TyCtxt` where they are needed.
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-08-19Give precedence to `html_root_url` over `--extern-html-root-url` by default, ↵Joshua Nelson-6/+7
but add a way to opt-in to the previous behavior ## What is an HTML root url? It tells rustdoc where it should link when documentation for a crate is not available locally; for example, when a crate is a dependency of a crate documented with `cargo doc --no-deps`. ## What is the difference between `html_root_url` and `--extern-html-root-url`? Both of these tell rustdoc what the HTML root should be set to. `doc(html_root_url)` is set by the crate author, while `--extern-html-root-url` is set by the person documenting the crate. These are often different. For example, docs.rs uses `--extern-html-root-url https://docs.rs/crate-name/version` to ensure all crates have documentation, even if `html_root_url` is not set. Conversely, crates such as Rocket set `doc(html_root_url = "https://api.rocket.rs")`, because they prefer users to view the documentation on their own site. Crates also set `html_root_url` to ensure they have documentation when building locally when offline. This is unfortunate to require, because it's more work from the library author. It also makes it impossible to distinguish between crates that want to be viewed on a different site (e.g. Rocket) and crates that just want documentation to be visible offline at all (e.g. Tokio). I have authored a separate change to the API guidelines to no longer recommend doing this: https://github.com/rust-lang/api-guidelines/pull/230. ## Why change the default? In the past, docs.rs has been the main user of `--extern-html-root-url`. However, it's useful for other projects as well. In particular, Cargo wants to pass it by default when running `--no-deps` (https://github.com/rust-lang/cargo/issues/8296). Unfortunately, for these other use cases, the priority order is inverted. They want to give *precedence* to the URL the crate picks, and only fall back to the `--extern-html-root` if no `html_root_url` is present. That allows passing `--extern-html-root` unconditionally, without having to parse the source code to see what attributes are present. For docs.rs, however, we still want to keep the old behavior, so that all links on docs.rs stay on the site.
2021-08-03don't use .into() to convert types to identical types ↵Matthias Krüger-1/+1
(clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();
2021-07-13Remove unnecessary CrateNum from Cache.externsJoshua Nelson-5/+4
It can be found from ExternalCrate.
2021-07-05rustdoc: Add `PrimitiveType` to `ItemId::Primitive`Justus K-1/+1
2021-07-05Revert "rustdoc: Store DefId's in ItemId on heap for decreasing Item's size"Justus K-1/+1
This reverts commit 41a345d4c46dad1a98c9993bc78513415994e8ba.
2021-07-05rustdoc: Store DefId's in ItemId on heap for decreasing Item's sizeJustus K-1/+1
2021-07-05rustdoc: Rename `expect_real` to `expect_def_id`, remove `Item::is_fake`Justus K-6/+6
2021-07-05rustdoc: Replace `FakeDefId` with new `ItemId` typeJustus K-2/+2
2021-06-26Auto merge of #84814 - Stupremee:properly-render-hrtbs, r=GuillaumeGomezbors-0/+15
Properly render HRTBs ```rust pub fn test<T>() where for<'a> &'a T: Iterator, {} ``` This will now render properly including the `for<'a>` ![image](https://user-images.githubusercontent.com/39732259/116808426-fe6ce600-ab38-11eb-9452-f33f554fbb8e.png) I do not know if this covers all cases, it only covers everything that I could think of that includes `for` and lifetimes in where bounds. Also someone need to mentor me on how to add a proper rustdoc test for this. Resolves #78482
2021-06-24chore(rustdoc): remove unused members of RenderTypeMichael Howell-3/+2
Commit e629381653bb3579f0cea0b256e391edef5e8dbb removes the only place these members variables are actually read.
2021-06-19rustdoc: Introduce new `DynTrait` type for better representation of trait ↵Justus K-0/+15
objects
2021-06-18Resolve intra-doc links in summary descMichael Howell-3/+4
Before: ![rustdoc-intra-doc-link-summary-before](https://user-images.githubusercontent.com/1593513/122623069-9d995e80-d04f-11eb-8d46-ec2ec126bb5e.png) After: ![rustdoc-intra-doc-link-summary](https://user-images.githubusercontent.com/1593513/122623076-a4c06c80-d04f-11eb-967a-f5916871c34b.png)
2021-05-15Minimize amount of fake `DefId`s used in rustdocJustus K-2/+2
2021-05-04Add type to differentiate between fake and real DefId'sJustus K-19/+24