about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
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-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-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.
2022-01-17fix #90187zredb-2/+2
remove the definition of def_id_no_primitives and change; a missing use was modified; narrow the Cache accessibility of BadImplStripper;
2022-01-17fix #90187zredb-8/+11
2022-01-17fix #90187zredb-3/+4
2022-01-17Rollup merge of #92799 - rust-lang:followup-from-92533, r=Aaron1011Matthias Krüger-7/+3
Remove some unnecessary uses of `FieldDef::ident` Followup from #92533. cc ``@Aaron1011`` ``@petrochenkov``
2022-01-16Rollup merge of #92792 - mdibaiee:92662/fix-intra-doc-generics, r=camelidMatthias Krüger-1/+12
rustdoc: fix intra-link for generic trait impls fixes #92662 r? `````@camelid`````
2022-01-16Rollup merge of #92635 - camelid:yet-more-cleanup, r=ManishearthMatthias Krüger-157/+159
rustdoc: Yet more intra-doc links cleanup r? `@Manishearth`
2022-01-15Fix broken linkNoah Lev-1/+1
2022-01-13librustdoc: Address some clippy lintspierwill-5/+4
Also ignore clippy's "collapsible if..." lints.
2022-01-13rustdoc: fix intra-link for generic trait implsMahdi Dibaiee-1/+12
2022-01-11Remove some unnecessary uses of `FieldDef::ident`Noah Lev-7/+3
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-2/+2
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-10Update some comments post the side channel removalNoah Lev-5/+2
2022-01-10Extract functions for two closuresNoah Lev-73/+107
These closures were quite complex and part of a quite complex function. The fact that they are closures makes mistakes likely when refactoring. For example, earlier, I meant to use `resolved`, an argument of the closure, but I instead typed `res`, which captured a local variable and caused a subtle bug that led to a confusing test failure. Extracting them as functions makes the code easier to understand and refactor.
2022-01-10Update comment and make code clearerNoah Lev-5/+4
I'm still not sure why this hack works so seemingly well.
2022-01-10Remove unnecessary conditional for suggesting disambiguatorNoah Lev-4/+1
Now that `res` is used directly, it seems the conditional is unnecessary.
2022-01-10Use Res instead of Disambiguator for `resolved` in `report_mismatch`Noah Lev-65/+50
This allows simplifying a lot of code. It also fixes a subtle bug, exemplified by the test output changes.
2022-01-10Remove hack that is no longer necessaryNoah Lev-11/+1
This hack was added in 6ab1f05697c3f2df4e439a05ebcee479a9a16d80. I don't know what change allowed removing the hack, but that commit added a test (which I presume covered the hack's behavior), and all tests are passing with this change. So, I think it should be good.
2022-01-11Auto merge of #92601 - camelid:more-intra-doc-cleanup, r=Manishearthbors-140/+147
rustdoc: Remove the intra-doc links side channel The side channel made the code much more complex and harder to understand. It was added as a temporary workaround in 0c99d806eabd32a2ee2e6c71b400222b99c659e1, but it's no longer necessary. The addition of `UrlFragment` in #92088 was the key to getting rid of the side channel. The semantic information (rather than the strings that used to be used for fragments) that is now captured by `UrlFragment` is enough to obviate the side channel. An additional change had to be made to `UrlFragment` in this PR to make this possible: it now records `DefId`s rather than item names. This PR also consolidates the checks for anchor conflicts into one place. r? `@Manishearth`
2022-01-07rustdoc: Introduce a resolver cache for sharing data between early doc link ↵Vadim Petrochenkov-92/+129
resolution and later passes
2022-01-06Split out `ItemFragment` from `UrlFragment`Noah Lev-39/+49
This allows eliminating branches in the code where a user-written fragment is impossible.
2022-01-06Remove the side channelNoah Lev-44/+11
Hooray! It was no longer used, so it can just be deleted.
2022-01-06Remove the last use of the side channelNoah Lev-4/+13
2022-01-06Use fragment instead of side channel in another placeNoah Lev-1/+5
2022-01-06Use fragment instead of side channel for prim. assoc. itemsNoah Lev-1/+3
I had the epiphany that now that fragments are "semantic" -- rather than just strings -- they fill the role that used to be handled by the side channel. I think I may be able to get rid of the other uses of the side channel using this technique too.
2022-01-06Extract function for reporting feature gate errorNoah Lev-16/+15