about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2021-03-23Remove unnecessary `Option` wrapping around `Crate.module`Camelid-6/+2
I'm wondering if it was originally there so that we could `take` the module which enables `after_krate` to take an `&Crate`. However, the two impls of `after_krate` only use `Crate.name`, so we can pass just the name instead.
2021-03-21Rename `clean::Span::span()` to `clean::Span::inner()`Camelid-8/+8
Otherwise you get a lot of instances of `item.span.span()`, which is just plain confusing. `item.span.inner()` conveys the correct meaning of "get the type that `clean::Span` wraps".
2021-03-21Rename `clean::Item.source` to `span`Camelid-12/+10
Its type is called `clean::Span`, and also the name in the rest of rustdoc and rustc for this kind of field is `span`.
2021-03-07Rollup merge of #82402 - jyn514:module-cache-refcell, r=GuillaumeGomezYuki Okushi-45/+51
Remove RefCell around `module_trait_cache` This builds on https://github.com/rust-lang/rust/pull/82018 and should not be merged before. ## Don't require a `DocContext` for `report_diagnostic` This is needed for the next commit, which needs mutable access to the `cx` from within the `decorate` closure. - Change `as_local_hir_id` to an associated function, since it only needs a `TyCtxt` - Change `source_span_for_markdown_range` to only take a `TyCtxt` ## Remove RefCell around module_trait_cache This is mostly just changing lots of functions from `&DocContext` to `&mut DocContext`.
2021-03-05Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make ↵Guillaume Gomez-4/+6
transition over hir::ItemKind simpler
2021-03-04Use cache access levelsGuillaume Gomez-1/+1
2021-03-04No more need for borrow callGuillaume Gomez-1/+1
2021-03-04Pass TyCtxt directly instead of DocContext in ↵Guillaume Gomez-1/+1
librustdoc::visit_ast::inherits_doc_hidden
2021-03-04Move visibility check inside the should_have_doc_example functionGuillaume Gomez-17/+17
2021-03-04Don't warn for `missing_doc_examples` when item is #[doc(hidden)]Guillaume Gomez-1/+10
2021-03-04Remove RefCell around module_trait_cacheJoshua Nelson-24/+26
2021-03-04Don't require a `DocContext` for `report_diagnostic`Joshua Nelson-22/+26
This is needed for the next commit, which needs access to the `cx` from within the `decorate` closure. - Change `as_local_hir_id` to an associated function, since it only needs a `TyCtxt` - Change `source_span_for_markdown_range` to only take a `TyCtxt`
2021-03-04Rollup merge of #80527 - jyn514:rustdoc-lints, r=GuillaumeGomezYuki Okushi-12/+7
Make rustdoc lints a tool lint instead of built-in - Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` (and similar for other rustdoc lints; I don't expect any others to be used frequently, though). - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests - Move lint machinery into a separate file - Add `declare_rustdoc_lint!` macro Unblocks https://github.com/rust-lang/rust/pull/80300, https://github.com/rust-lang/rust/pull/79816, https://github.com/rust-lang/rust/pull/80965. Makes the strangeness in https://github.com/rust-lang/rust/pull/77364 more apparent to the end user (note that `missing_docs` is *not* moved to rustdoc in this PR). Closes https://github.com/rust-lang/rust/issues/78786. ## Current status This is blocked on #82620 (see https://github.com/rust-lang/rust/pull/80527#issuecomment-787401519)
2021-03-01Move lint machinery into a separate fileJoshua Nelson-6/+6
2021-03-01Rename rustdoc lints to be a tool lint instead of built-in.Joshua Nelson-12/+7
- Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests Otherwise, all `rustdoc::` lints would be ignored. - Register all existing lints as removed This unfortunately doesn't work with `register_renamed` because tool lints have not yet been registered when rustc is running. For similar reasons, `check_backwards_compat` doesn't work either. Call `register_removed` directly instead. - Fix fallout + Rustdoc lints for compiler/ + Rustdoc lints for library/ Note that this does *not* suggest `rustdoc::broken_intra_doc_links` for `rustdoc::intra_doc_link_resolution_failure`, since there was no time when the latter was valid.
2021-03-01Remove the dummy cache in `DocContext`Joshua Nelson-5/+4
The same information is available everywhere; the only reason the dummy cache was needed is because it waas previously stored in three different places. This consolidates the info a bit so the cache in `DocContext` is used throughout. As a bonus, it means `renderinfo` is used much much less. - Return a `Cache` from `run_global_ctxt`, not `RenderInfo` - Remove the unused `render_info` from `run_renderer` - Remove RefCell around `inlined` - Add intra-doc links
2021-02-28Auto merge of #81349 - jyn514:blanket-impls-cleanup, r=lcnrbors-8/+2
Remove unnecessary `self_ty` parameter to `get_blanket_impls` It can be calculated when necessary at the callsite, there's no need to pass it separately. This also renames `param_env_def_id` to `item_def_id`. cc `@eddyb`
2021-02-28Remove unnecessary `self_ty` parameter to `get_blanket_impls`Joshua Nelson-8/+2
It can be calculated when necessary at the callsite, there's no need to pass it separately. This also renames `param_env_def_id` to `item_def_id`.
2021-02-26Update src/librustdoc/passes/collect_intra_doc_links.rsLucas De Angelis-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-26Fix formattingLucas De Angelis-1/+6
2021-02-26Fix intra-doc handling of `Self` in enumLucas De Angelis-0/+3
Fixes #82209
2021-02-25Rollup merge of #81575 - camelid:rustdoc-wrongnamespace-cleanup, r=jyn514Dylan DPC-17/+22
rustdoc: Name fields of `ResolutionFailure::WrongNamespace` It makes it clearer that the `Namespace` is the one requested by the disambiguator, rather than the actual namespace of the item. It said that in the docs before, but now you can tell in the code so it reduces the potential for confusion.
2021-02-23rustdoc: Name fields of `ResolutionFailure::WrongNamespace`Camelid-17/+22
It makes it clearer that the `Namespace` is the one requested by the disambiguator, rather than the actual namespace of the item. It said that in the docs before, but now you can tell in the code so it reduces the potential for confusion.
2021-02-22Remove many RefCells from DocContextCamelid-7/+5
I left some of them so this change doesn't balloon in size and because removing the RefCell in `DocContext.resolver` would require compiler changes. Thanks to `@jyn514` for making this a lot easier with #82020!
2021-02-22Auto merge of #82295 - jyn514:feature-gate, r=Manishearthbors-0/+3
[intra-doc links] Don't check feature gates of items re-exported across crates It should be never break another crate to re-export a public item. Note that this doesn't check the feature gate at *all* for other crates: - Feature-gates aren't currently serialized, so the only way to check the gate is with ad-hoc attribute checking. - Checking the feature gate twice (once when documenting the original crate and one when documenting the current crate) seems not great. This should still catch using the feature most of the time though, since people tend to document their own crates. Closes https://github.com/rust-lang/rust/issues/82284. r? `@Manishearth`
2021-02-19[intra-doc links] Don't check feature gates of items re-exported across cratesJoshua Nelson-0/+3
It should be never break another crate to re-export a public item. Note that this doesn't check the feature gate at *all* for other crates: - Feature-gates aren't currently serialized, so the only way to check the gate is with ad-hoc attribute checking. - Checking the feature gate twice (once when documenting the original crate and one when documenting the current crate) seems not great. This should still catch using the feature most of the time though, since people tend to document their own crates.
2021-02-16Make `Clean` take &mut DocContextJoshua Nelson-16/+22
- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics` - Take `&mut DocContext` in most of `clean` - Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad. - Changes `fn sess` to properly return a borrow with the lifetime of `'tcx`, not the mutable borrow.
2021-02-16Take `&mut DocContext` in passesJoshua Nelson-82/+48
This should hopefully allow for less interior mutability.
2021-02-15Trait impls are Items, therefore HIR owners.Camille GILLOT-2/+2
2021-02-11Fix private intra-doc warnings on associated itemsJoshua Nelson-4/+5
The issue was that the `kind, id` override was previously only being considered for the disambiguator check, not the privacy check. This uses the same ID for both.
2021-02-04Cleanup rustdoc pass descriptions a bitCamelid-6/+6
Also changed a couple of comments from "intra-doc-links" to "intra-doc links" (my understanding is that "intra-doc links" is the standard way to refer to them).
2021-01-30Rollup merge of #81495 - camelid:rustdoc-output_format-optional, ↵Yuki Okushi-1/+1
r=GuillaumeGomez rustdoc: Remove unnecessary optional Previously, the HTML output format was represented by both `Some(OutputFormat::Html)` and `None` so there's no need to have an optional. Instead, `OutputFormat::Html` is explicitly the default and we no longer have a "tri-state enum". r? `````@GuillaumeGomez`````
2021-01-30rustdoc tweakingbors-23/+21
* Reuse memory * simplify `next_def_id`, avoid multiple hashing and unnecessary lookups * remove `all_fake_def_ids`, use the global map instead (probably not a good step toward parallelization, though...) * convert `add_deref_target` to iterative implementation * use `ArrayVec` where we know the max number of elements * minor touchups here and there * avoid building temporary vectors that get appended to other vectors At most places I may or may not be doing the compiler's job is this PR.
2021-01-28rustdoc: Remove unnecessary optionalCamelid-1/+1
Previously, the HTML output format was represented by both `Some(OutputFormat::Html)` and `None` so there's no need to have an optional. Instead, `OutputFormat::Html` is explicitly the default and we no longer have a "tri-state enum".
2021-01-28Rollup merge of #81284 - jyn514:impl-times, r=wesleywiserYuki Okushi-10/+8
Make `-Z time-passes` less noisy - Add the module name to `pre_AST_expansion_passes` and don't make it a verbose event (since it normally doesn't take very long, and it's emitted many times) - Don't make the following rustdoc events verbose; they're emitted many times. + build_extern_trait_impl + build_local_trait_impl + build_primitive_trait_impl + get_auto_trait_impls + get_blanket_trait_impls - Remove the `get_auto_trait_and_blanket_synthetic_impls` rustdoc event; it's wholly covered by get_{auto,blanket}_trait_impls and not very useful. I found this while working on https://github.com/rust-lang/rust/pull/81275 but it's independent of those changes.
2021-01-27Remove cache usage wherever possibleGuillaume Gomez-19/+15
2021-01-27Remove CACHE_KEY globalGuillaume Gomez-17/+26
2021-01-23Make `-Z time-passes` less noisyJoshua Nelson-10/+8
- Add the module name to `pre_AST_expansion_passes` and don't make it a verbose event (since it normally doesn't take very long, and it's emitted many times) - Don't make the following rustdoc events verbose; they're emitted many times. + build_extern_trait_impl + build_local_trait_impl + build_primitive_trait_impl + get_auto_trait_impls + get_blanket_trait_impls - Remove `get_auto_trait_and_blanket_synthetic_impls`; it's wholly covered by get_{auto,blanket}_trait_impls and not very useful.
2021-01-21Fix rustc::internal lints on rustdocJoshua Nelson-4/+4
2021-01-17Feature-gate `pointer` and `reference` in intra-doc linksJoshua Nelson-3/+26
- Only feature gate associated items - Add docs to unstable book
2021-01-17Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasperMara Bos-2/+7
resolve: Simplify collection of traits in scope "Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace. Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore. I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351. In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits. It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway. The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names. I'm not sure whether it is desirable or not, but I think it's acceptable for now. The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope. If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well. --- The PR also contains a couple of pure refactorings - Scope walk is done by using `visit_scopes` instead of a hand-rolled version. - Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all. r? ```@matthewjasper```
2021-01-15Rename VariantKind -> VariantJoshua Nelson-1/+1
There's no `Variant`, so it seems silly to have `Kind`.
2021-01-15Remove useless `clean::Variant` structJoshua Nelson-1/+1
It had exactly one field and no special behavior, so there was no point.
2021-01-12Rollup merge of #80885 - camelid:intra-doc-str-ref, r=jyn514Yuki Okushi-1/+1
rustdoc: Resolve `&str` as `str` People almost always are referring to `&str`, not `str`, so this will save a manual link resolve in many cases. Note that we already accept `&` (resolves to `reference`) in intra-doc links, so this shouldn't cause breakage. r? `@jyn514`
2021-01-11resolve: Simplify collection of traits in scopeVadim Petrochenkov-2/+7
2021-01-11Rollup merge of #80892 - camelid:intra-doc-remove-star, r=jyn514Yuki Okushi-1/+1
rustdoc: Remove `*` intra-doc alias for `pointer` It's not valid Rust code and it can easily be confused with a wildcard glob pattern or something else. People can always use `pointer` instead, so it's just removing an alias. It hasn't hit stable yet (I think it's still on nightly), so it's okay to remove it. (We can always add it back later if we change our mind too.) r? `@jyn514` cc https://github.com/rust-lang/rust/pull/80885#discussion_r554622737
2021-01-11Rollup merge of #80881 - jyn514:intra-doc-self, r=GuillaumeGomezYuki Okushi-21/+20
Fix intra-doc links to `Self` and `crate` Closes https://github.com/rust-lang/rust/issues/77732.
2021-01-10rustdoc: Remove `*` intra-doc alias for `pointer`Camelid-1/+1
It's not valid Rust code and it can easily be confused with a wildcard glob pattern or something else. People can always use `pointer` instead, so it's just removing an alias. It hasn't hit stable yet (I think it's still on nightly), so it's okay to remove it. (We can always add it back later if we change our mind too.)
2021-01-10rustdoc: Resolve `&str` as `str`Camelid-1/+1
People almost always are referring to `&str`, not `str`, so this will save a manual link resolve in many cases. Note that we already accept `&` (resolves to `reference`) in intra-doc links, so this shouldn't cause breakage.
2021-01-10Small cleanupsJoshua Nelson-15/+4