about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2022-04-05session: opt for enabling directionality markersDavid Wood-2/+2
Add an option for enabling and disabling Fluent's directionality isolation markers in output. Disabled by default as these can render in some terminals and applications. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-1/+2
Extend loading of Fluent bundles so that bundles can be loaded from the sysroot based on the language requested by the user, or using a nightly flag. Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement fallback diagnostic translationDavid Wood-2/+13
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05errors: introduce `DiagnosticMessage`David Wood-1/+1
Introduce a `DiagnosticMessage` type that will enable diagnostic messages to be simple strings or Fluent identifiers. `DiagnosticMessage` is now used in the implementation of the standard `DiagnosticBuilder` APIs. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-04Fix ICE in rustdoc intra doc links when trying to get traits in scope for a ↵Guillaume Gomez-1/+4
private module
2022-03-31rustdoc: Fix resolution of `crate`-relative paths in doc linksVadim Petrochenkov-40/+5
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-3/+4
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30fix rustdoc wrt builtin impls switchlcnr-2/+3
2022-03-30fix rustdoclcnr-2/+2
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-3/+4
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-25resolve: Optimize path resolution for rustdocVadim Petrochenkov-33/+22
Do not construct or pass unused data
2022-03-16rustc_error: make ErrorReported impossible to constructmark-4/+8
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-15Rollup merge of #94947 - Dylan-DPC:fix/typos, r=oli-obkMatthias Krüger-1/+1
fix typos Rework of #94603 which got closed as I was trying to unmerge and repush. This is a subset of changes from the original pr as I sed'd whatever typos I remembered from the original PR thanks to `@cuishuang` for the original PR
2022-03-15Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuberbors-1/+1
More robust fallback for `use` suggestion Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion. But this was fragile, as illustrated in issue #87613 This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion. Fix #87613
2022-03-15fix typosDylan DPC-1/+1
2022-03-14Auto merge of #94139 - est31:let_else_rustdoc, r=notriddlebors-33/+22
librustdoc: adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles librustdoc.
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-6/+6
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-06Auto merge of #93805 - petrochenkov:doclinkself, r=camelid,GuillaumeGomezbors-91/+126
rustdoc: Stop textually replacing `Self` in doc links before resolving them Resolve it directly to a type / def-id instead. Also never pass `Self` to `Resolver`, it is useless because it's guaranteed that no resolution will be found. This is a pre-requisite for https://github.com/rust-lang/rust/issues/83761.
2022-03-04librustdoc: adopt let else in more placesest31-33/+22
2022-03-04Auto merge of #94009 - compiler-errors:gat-rustdoc, r=GuillaumeGomezbors-1/+1
Support GATs in Rustdoc Implements: 1. Rendering GATs in trait definitions and impl blocks 2. Rendering GATs in types (e.g. in the return type of a function) Fixes #92341 This is my first rustdoc PR, so I have absolutely no idea how to produce tests for this. Advice from the rustdoc team would be wonderful! I tested locally and things looked correct: ![image](https://user-images.githubusercontent.com/3674314/153988325-9732cbf3-0645-4e1a-9e64-ddfd93877b55.png)
2022-03-03Associate multiple with a crate too.Felix S. Klock II-1/+1
2022-03-02Rollup merge of #94478 - GuillaumeGomez:macro-generated-intra-doc-link, ↵Matthias Krüger-1/+1
r=notriddle Fix panic when handling intra doc links generated from macro Fixes #78591. Fixes #92789. r? ``@notriddle``
2022-03-01Fix panic when intra-doc link comes from a generated doc commentGuillaume Gomez-1/+1
2022-02-27make GATs print properly in traitsMichael Goulet-1/+1
2022-02-27Only create a single expansion for each inline integration.Camille GILLOT-2/+4
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-4/+4
2022-02-23rustc_errors: add `downgrade_to_delayed_bug` to `Diagnostic` itself.Eduard-Mihai Burtescu-2/+9
2022-02-20Auto merge of #93605 - notriddle:notriddle/rustdoc-html-tags-resolve, ↵bors-2/+26
r=GuillaumeGomez rustdoc: resolve intra-doc links when checking HTML Similar to #86451 CC #67799 Given this test case: ```rust #![warn(rustdoc::invalid_html_tags)] #![warn(rustdoc::broken_intra_doc_links)] pub struct ExistentStruct<T>(T); /// This [test][ExistentStruct<i32>] thing! pub struct NoError; ``` This pull request silences the following, spurious warning: ```text warning: unclosed HTML tag `i32` --> test.rs:6:31 | 6 | /// This [test][ExistentStruct<i32>] thing! | ^^^^^ | note: the lint level is defined here --> test.rs:1:9 | 1 | #![warn(rustdoc::invalid_html_tags)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try marking as source code | 6 | /// This [test][`ExistentStruct<i32>`] thing! | + + warning: 1 warning emitted ```
2022-02-18rustdoc: Collect traits in scope for lang itemsVadim Petrochenkov-0/+4
2022-02-16Adopt let_else in even more placesest31-6/+2
2022-02-16rustdoc: resolve intra-doc links when checking HTMLMichael Howell-2/+26
Similar to #86451 CC #67799
2022-02-13rustdoc: Clean up `fn resolve_self_ty`Vadim Petrochenkov-30/+23
2022-02-13rustdoc: Stop textually replacing `Self` in doc links before resolving themVadim Petrochenkov-92/+117
Resolve it directly to a type / def-id instead. Also never pass `Self` to `Resolver`, it is useless because it's guaranteed that no resolution will be found.
2022-02-13rustdoc: Consider enum variants when resolving assoc items in doc linksVadim Petrochenkov-2/+19
2022-02-08Rollup merge of #93721 - jyn514:less-macro-special-casing, r=petrochenkovMatthias Krüger-19/+5
rustdoc: Special-case macro lookups less Previously, rustdoc had 3 fallbacks it used: 1. `resolve_macro_path` 2. `all_macros` 3. `resolve_str_path_error` Ideally, it would only use `resolve_str_path_error`, to be consistent with other namespaces. Unfortunately, that doesn't consider macros that aren't defined at module scope; consider for instance ```rust { struct S; macro_rules! mac { () => {} } // `mac`'s scope starts here /// `mac` <- `resolve_str_path_error` won't see this struct Z; //`mac`'s scope ends here } ``` This changes it to only use `all_macros` and `resolve_str_path_error`, and gives `resolve_str_path_error` precedence over `all_macros` in case there are two macros with the same name in the same module. This is a smaller version of https://github.com/rust-lang/rust/pull/91427. r? `@petrochenkov`
2022-02-08Rollup merge of #93569 - notriddle:notriddle/rustdoc-html-tags-generics, ↵Matthias Krüger-9/+65
r=CraftSpider rustdoc: correct unclosed HTML tags as generics CC https://github.com/rust-lang/rust/issues/67799
2022-02-06rustdoc: Special-case macro lookups lessJoshua Nelson-19/+5
Previously, rustdoc had 3 fallbacks it used: 1. `resolve_macro_path` 2. `all_macros` 3. `resolve_str_path_error` Ideally, it would only use `resolve_str_path_error`, to be consistent with other namespaces. Unfortunately, that doesn't consider macros that aren't defined at module scope; consider for instance ```rust { struct S; macro_rules! mac { () => {} } // `mac`'s scope starts here /// `mac` <- `resolve_str_path_error` won't see this struct Z; //`mac`'s scope ends here } ``` This changes it to only use `all_macros` and `resolve_str_path_error`, and gives `resolve_str_path_error` precedence over `all_macros` in case there are two macros with the same name in the same module. This also adds a failing test case which will catch trying to remove `all_macros`.
2022-02-04rustdoc: Collect traits in scope for foreign inherent implsVadim Petrochenkov-0/+7
2022-02-01Use multipart suggestion for code wrappingMichael Howell-17/+10
Another one of those "good grief, I just submitted it and NOW I think of it" moments.
2022-02-01Fix unicode slicing bugMichael Howell-3/+3
2022-02-01In retrospect, MachineApplicable is probably too confidentMichael Howell-1/+1
2022-02-01rustdoc: correct unclosed HTML tags as genericsMichael Howell-9/+72
2022-01-30Auto merge of #92711 - zredb:issue-90187-fix, r=notriddlebors-11/+15
rustdoc: Remove `def_id_no_primitives` Fixes #90187.
2022-01-28rustdoc: load the set of in-scope traits for modules with no docstringMichael Howell-0/+11
Fixes #93428 This fix is a response to a couple of special cases related to the `module_id`, which is eventually used for trait candidates: * The module id is always set to the current crate, when checking `crate::`. Normally, the set of in-scope traits would be set in `load_links_in_attrs`, but if there are no doc comments, then that loop will never run. * the module id is set to the parent module, when resolving a module that is spelled like this: // Notice how we use an outlined doc comment here! // [`Test::my_fn`] mod something { } As with the above problem with `crate::`, we need to make sure the module gets its traits in scope resolved, even if it has no doc comments of its own.
2022-01-26Auto merge of #88679 - petrochenkov:doctrscope, r=GuillaumeGomezbors-25/+103
rustdoc: Pre-calculate traits that are in scope for doc links This eliminates one more late use of resolver (part of #83761). At early doc link resolution time we go through parent modules of items from the current crate, reexports of items from other crates, trait items, and impl items collected by `collect-intra-doc-links` pass, determine traits that are in scope in each such module, and put those traits into a map used by later rustdoc passes. r? `@jyn514`
2022-01-25Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillotbors-1/+1
Store a `Symbol` instead of an `Ident` in `AssocItem` This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-25rustdoc: Pre-calculate traits that are in scope for doc linksVadim Petrochenkov-25/+103
This eliminates one more late use of resolver
2022-01-21rustdoc: Make some `pub` items crate-privateNoah Lev-1/+1
They don't need to be `pub`. Making them crate-private improves code clarity and `dead_code` linting.
2022-01-19Store a `Symbol` instead of an `Ident` in `AssocItem`Aaron Hill-1/+1
This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-18intra-doc: Use the impl's assoc item where possibleNoah Lev-35/+53
Before, the trait's associated item would be used. Now, the impl's associated item is used. The only exception is for impls that use default values for associated items set by the trait. In that case, the trait's associated item is still used. As an example of the old and new behavior, take this code: trait MyTrait { type AssocTy; } impl MyTrait for String { type AssocTy = u8; } Before, when resolving a link to `String::AssocTy`, `resolve_associated_trait_item` would return the associated item for `MyTrait::AssocTy`. Now, it would return the associated item for `<String as MyTrait>::AssocTy`, as it claims in its docs.