about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2021-04-27cfg taken out of Attributes, put in ItemTimothée Delabrouille-8/+4
check item.is_fake() instead of self_id.is_some() Remove empty branching in Attributes::from_ast diverse small refacto after Josha review cfg computation moved in merge_attrs refacto use from_ast twice for coherence take cfg out of Attributes and move it to Item
2021-04-27Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of ↵Timothée Delabrouille-9/+14
the fields in Attributes, as functions in AttributesExt. refacto use from_def_id_and_attrs_and_parts instead of an old trick most of josha suggestions + check if def_id is not fake before using it in a query Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of the Attributes fields as functions in AttributesExt.
2021-04-24Get rid of `item.span`Joshua Nelson-1/+1
- Remove `span` field, adding `Item::span()` instead - Special-case `Impl` and `Module` items - Use dummy spans for primitive items
2021-04-24Do the hard part firstJoshua Nelson-1/+1
The only bit failing was the module, so change that before removing the `span` field.
2021-04-24Add attr_span helper functionJoshua Nelson-17/+13
2021-04-17rustdoc: Give a more accurate span for anchor failuresJoshua Nelson-8/+16
2021-04-15Rollup merge of #84201 - jyn514:primitive-warnings, r=cuviperDylan DPC-0/+4
rustdoc: Note that forbidding anchors in links to primitives is a bug cc https://github.com/rust-lang/rust/issues/83083, https://github.com/rust-lang/rust/pull/84147#discussion_r613518820 r? `@cuviper`
2021-04-14rustdoc: Note that forbidding anchors in links to primitives is a bugJoshua Nelson-0/+4
2021-04-12Add explanatory note to `bare_urls` lintCamelid-0/+1
I think the lint is confusing otherwise since it doesn't fully explain what the problem is.
2021-04-11Move crate loader to collect_intra_doc_links::earlyJoshua Nelson-11/+77
This groups the similar code together, and also allows making most of collect_intra_doc_links private again
2021-04-10Preprocess intra-doc links consistentlyJoshua Nelson-82/+138
Previously, rustdoc would panic on links to external crates if they were surrounded by backticks.
2021-04-09Auto merge of #84034 - jyn514:regex-in-loop, r=Mark-Simulacrumbors-1/+1
Fix perf regression in rustdoc::bare_urls This regressed in #81764. After that PR, rustdoc compiled the regex for every single item in the crate: https://perf.rust-lang.org/compare.html?start=125505306744a0a5bb01d62337260a95d9ff8d57&end=2e495d2e845cf27740e3665f718acfd3aa17253e&stat=instructions%3Au This would have been caught by `clippy::declare_interior_mutable_const` (cc https://github.com/rust-lang/rust/issues/77983).
2021-04-09Fix perf regression in non-autolinksJoshua Nelson-1/+1
Before, this was compiling the regex on every single item in the crate. This would have been caught by `clippy::declare_interior_mutable_const`.
2021-04-09Auto merge of #84030 - jyn514:no-blanket-impls, r=GuillaumeGomezbors-44/+7
rustdoc: Don't generate blanket impls when running --show-coverage `get_blanket_impls` is the slowest part of rustdoc, and the coverage pass completely ignores blanket impls. This stops running it at all, and also removes some unnecessary checks in `calculate_doc_coverage` that ignored the impl anyway. We don't currently measure --show-coverage in perf.rlo, but I tested this locally on cargo and it brought the time down from 2.9 to 1.6 seconds. This also adds back a commented-out test; Rustdoc has been able to deal with `impl trait` for almost a year now. r? `@GuillaumeGomez`
2021-04-09rustdoc: Don't generate blanket impls when running --show-coverageJoshua Nelson-44/+7
get_blanket_impls is the slowest part of rustdoc, and the coverage pass completely ignores blanket impls. This stops running it at all, and also removes some unnecessary checks in `calculate_doc_coverage` that ignored the impl anyway. We don't currently measure --show-coverage in perf.rlo, but I tested this locally on cargo and it brought the time down from 2.9 to 1.6 seconds.
2021-04-08Rollup merge of #81764 - jyn514:lint-links, r=GuillaumeGomezDylan DPC-58/+35
Stabilize `rustdoc::bare_urls` lint Closes https://github.com/rust-lang/rust/issues/77501. Closes https://github.com/rust-lang/rust/issues/83598.
2021-04-07Reuse logic for determining the channel in the rest of rustdocJoshua Nelson-9/+3
This doesn't update main.js because it's included as a fixed string.
2021-04-07rustdoc: Link to the docs on namespaces when an unknown disambiguator is foundJoshua Nelson-1/+14
2021-04-06Store links in Cache instead of on items directlyJoshua Nelson-2/+2
Items are first built after rustdoc creates the TyCtxt. To allow resolving the links before the TyCtxt is built, the links can't be stored on `clean::Item` directly.
2021-04-06Auto merge of #83875 - jyn514:diag_info, r=bugadanibors-124/+52
rustdoc: Use DiagnosticInfo in more parts of intra-doc links This makes the code a lot less verbose. This is separated into lots of tiny commits because it was easier for me that way, but the overall diff isn't that big if you want to read it at once. r? `@bugadani`
2021-04-06Rollup merge of #83849 - jyn514:intra-doc-cleanup, r=bugadaniYuki Okushi-135/+102
rustdoc: Cleanup handling of associated items for intra-doc links Helps with https://github.com/rust-lang/rust/issues/83761 (right now the uses of the resolver are all intermingled with uses of the tyctxt). Best reviewed one commit at a time. r? ```@bugadani``` maybe? Feel free to reassign :)
2021-04-05Use DiagnosticInfo for `report_diagnostic`Joshua Nelson-39/+29
2021-04-05Take DiagnosticInfo in privacy_errorJoshua Nelson-3/+7
2021-04-05Take `DiagnosticInfo` in `ambiguity_error`Joshua Nelson-12/+3
2021-04-05Take DiagnosticInfo in disambiguator_errorJoshua Nelson-3/+2
2021-04-05Rename link_range -> disambiguator_range in disambiguator_errorJoshua Nelson-2/+2
It's not the range of the full link, it's only a partial range.
2021-04-05Take `DiagnosticInfo` in `resolution_failure`Joshua Nelson-30/+6
2021-04-05Use DiagnosticInfo for anchor failureJoshua Nelson-47/+15
This gets rid of a lot of parameters, as well as fixing a diagnostic bug.
2021-04-05Rename path_str -> ori_link in anchor_failureJoshua Nelson-3/+3
ori_link contains anchors, path_str does not. It's important that anchor_failure be passed a link with the anchors still present.
2021-04-05Use more appropriate return type for `resolve_associated_item`Joshua Nelson-83/+56
Previously, the types looked like this: - None means this is not an associated item (but may be a variant field) - Some(Err) means this is known to be an error. I think the only way that can happen is if it resolved and but you had your own anchor. - Some(Ok(_, None)) was impossible. Now, this returns a nested Option and does the error handling and fiddling with the side channel in the caller. As a side-effect, it also removes duplicate error handling. This has one small change in behavior, which is that `resolve_primitive_associated_item` now goes through `variant_field` if it fails to resolve something. This is not ideal, but since it will be quickly rejected anyway, I think the performance hit is worth the cleanup. This also fixes a bug where struct fields would forget to set the side channel, adds a test for the bug, and ignores `private_intra_doc_links` in rustc_resolve (since it's always documented with --document-private-items).
2021-04-05Reduce indentation in `resolve_associated_item`Joshua Nelson-45/+35
2021-04-05Remove duplicate unwrap_or_elseJoshua Nelson-43/+47
2021-04-05Rename non_autolinks -> bare_urlsJoshua Nelson-14/+14
2021-04-05Remove 'unnecessary long for for link' warningJoshua Nelson-38/+22
This also makes the implementation slightly more efficient by only compiling the regex once. See https://github.com/rust-lang/rust/pull/81764#issuecomment-774122759 for why this was removed; essentially the benefit didn't seem great enough to deserve a lint.
2021-04-05Stabilize `non_autolinks` lintJoshua Nelson-8/+1
2021-04-04Don't report disambiguator error if link would have been ignoredCamelid-4/+24
This prevents us from warning on links such as `<hello@example.com>`. Note that we still warn on links such as `<hello@localhost>` because they have no dots in them. However, the links will still work, even though a warning is reported.
2021-04-02Don't load all extern crates unconditionallyJoshua Nelson-3/+3
Instead, only load the crates that are linked to with intra-doc links. This doesn't help very much with any of rustdoc's fundamental issues with freezing the resolver, but it at least fixes a stable-to-stable regression, and makes the crate loading model somewhat more consistent with rustc's.
2021-03-28Inline `find_suffix` closure that's only used onceCamelid-18/+14
2021-03-28Point to disambiguator instead of whole linkCamelid-10/+29
And, now that we do that, we can remove the explanatory note since the error span should make it clear what the disambiguator is.
2021-03-26Lint on unknown intra-doc link disambiguatorsCamelid-11/+34
2021-03-24Rework rustdoc const typeGuillaume Gomez-3/+7
2021-03-24Rollup merge of #83415 - camelid:remove-crate-module-option, r=jyn514Dylan DPC-6/+2
Remove unnecessary `Option` wrapping around `Crate.module` 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-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