about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2022-06-01Update src/librustdoc/passes/collect_trait_impls.rsMichael Howell-3/+5
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2022-05-31Display empty impl blocks if they have documentationsGuillaume Gomez-2/+3
2022-05-26Rollup merge of #97066 - petrochenkov:nofragkind, r=camelidMichael Goulet-113/+52
rustdoc: Remove `ItemFragment(Kind)` And stop using `write!` when rendering URL fragments to avoid impossible errors.
2022-05-24fix simple clippy lintsklensy-19/+14
2022-05-23Greatly extend explanations on strip_hidden itemsGuillaume Gomez-1/+8
Co-authored-by: Michael Howell <michael@notriddle.com>
2022-05-21rustdoc: Some link resolution caching cleanupVadim Petrochenkov-35/+16
2022-05-21rustdoc: Stop using `write!` in `UrlFragment::render`Vadim Petrochenkov-13/+15
2022-05-21rustdoc: Remove `ItemFragment(Kind)`Vadim Petrochenkov-74/+30
2022-05-21Remove fields_stripped fields (and equivalents)Guillaume Gomez-1/+1
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-67/+73
2022-05-17rustdoc: avoid including impl blocks with filled-in genericsMichael Howell-2/+27
Fixes #94937
2022-05-16rustdoc: Resolve some more doc links earlyVadim Petrochenkov-9/+32
2022-05-15rustdoc: Remove doc link resolution fallback to all `macro_rules` in the crateVadim Petrochenkov-30/+22
2022-05-13resolve: Move collection of all `macro_rules` in the crate to rustdocVadim Petrochenkov-2/+6
2022-05-13Fix rebaseVadim Petrochenkov-5/+2
2022-05-13rustdoc: Use `Visibility::is_public` moreVadim Petrochenkov-10/+6
2022-05-13rustdoc: Do not resolve associated item paths unnecessarilyVadim Petrochenkov-11/+9
2022-05-13rustdoc: Do not create `UrlFragment`s until they are necessaryVadim Petrochenkov-236/+133
This simplifies error types and allows to remove `fn resolve_inner` and `fn check_full_res` `visited_links` caching is not touched for now
2022-05-13rustdoc: Remove `fn resolve_macro`Vadim Petrochenkov-119/+43
and otherwise unify resolution in macro namespace and other namespaces
2022-05-13rustdoc: Remove `ResolutionFailure::Dummy`Vadim Petrochenkov-37/+20
The variant resolution check didn't make sense, and derive trait collision could be processed in a different way
2022-05-13rustdoc: Remove `ResolutionFailure::MalformedGenerics`Vadim Petrochenkov-81/+61
in favor of `PreprocessingError::MalformedGenerics`
2022-05-13rustdoc: Remove `ResolutionFailure::NoParentItem`Vadim Petrochenkov-49/+8
It's a bug and not an error
2022-05-10update rustdoclcnr-3/+1
2022-05-04Auto merge of #96447 - petrochenkov:docregr, r=GuillaumeGomezbors-1/+13
rustdoc: Resolve doc links on fields during early resolution Another subset of https://github.com/rust-lang/rust/pull/94857 which fixes https://github.com/rust-lang/rust/issues/96429. This case regressed in https://github.com/rust-lang/rust/pull/96135 when `may_have_doc_links`-based filtering was introduced. Before that filtering structs could collect traits in scope for their fields, but after the filtering structs won't collect anything if they don't have doc comments on them, so we have to visit fields too.
2022-05-02Auto merge of #96431 - petrochenkov:parent, r=cjgillotbors-16/+12
rustc: Panic by default in `DefIdTree::parent` Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-16/+12
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-01rustdoc: Track `macro_rules` scopes during early doc link resolutionVadim Petrochenkov-1/+22
This way links referring to `macro_rules` items are resolved correctly
2022-04-30rustdoc: Keep full `ParentScope` during early doc link resolutionVadim Petrochenkov-19/+30
2022-04-30rustdoc: Early-resolve doc links in all requested namespacesVadim Petrochenkov-13/+37
2022-04-29rustdoc: prevent B -> C -> B -> C loops from stack overflowingMichael Howell-3/+12
2022-04-28rustdoc: fix missing method list for primitive deref targetMichael Howell-35/+38
This change makes it so that local impls count when listing primitives that need retained.
2022-04-26rustdoc: Resolve doc links on fields during early resolutionVadim Petrochenkov-1/+13
2022-04-22Auto merge of #96301 - notriddle:notriddle/synthetic-impl-prim, r=GuillaumeGomezbors-4/+9
rustdoc: make primitive synthetic impls for correct doc module This improves the accuracy of libcore primitive docs, which was missing the blanket and auto impls for most primitive types. To test this, compare nightly [libcore::str] docs, which lack auto traits like Send, with [std::str] docs, which show them. [libcore::str]: https://doc.rust-lang.org/nightly/core/primitive.str.html [libstd::str]: https://doc.rust-lang.org/nightly/std/primitive.str.html It also avoids getting synthetic impls for primitive types on crates that do not actually show them. <details> <summary>Before and After trace logs</summary> ## Before [notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +nightly test.rs 2>&1 | grep -E 'get_blanket_impls\(' TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever) TRACE rustdoc::clean::blanket_impl get_blanket_impls(isize) TRACE rustdoc::clean::blanket_impl get_blanket_impls([T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8]) TRACE rustdoc::clean::blanket_impl get_blanket_impls(char) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u128) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u16) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i128) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i16) TRACE rustdoc::clean::blanket_impl get_blanket_impls(str) TRACE rustdoc::clean::blanket_impl get_blanket_impls(str) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u8) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i8) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const T) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut T) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const [T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut [T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([T; N]) TRACE rustdoc::clean::blanket_impl get_blanket_impls(bool) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u32) TRACE rustdoc::clean::blanket_impl get_blanket_impls(usize) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i32) ## After [notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +dev test.rs 2>&1 | grep -E 'get_blanket_impls\(' TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever) </details>
2022-04-22Auto merge of #96282 - petrochenkov:unindent, r=GuillaumeGomezbors-194/+1
rustdoc: Unindent doc fragments on `Attributes` construction `Attributes` can be constructed at arbitrary points, even after the `unindent_comments` pass. `Attributes` that are constructed too late end up unindented. All doc fragments need to be eventually indented before use, so there are no reasons to not do this immediately during their construction. Fixes https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60unindent_comments.60.20cannot.20work.20as.20a.20separate.20pass. I'm not sure how to make a minimized reproduction, but unindenting the fragments during their construction should fix the issue.. by construction, and I also verified that all doc strings now hit the `resolver_caches.markdown_links` cache in https://github.com/rust-lang/rust/pull/94857.
2022-04-21rustdoc: make primitive synthetic impls for correct doc moduleMichael Howell-4/+9
This improves the accuracy of libcore primitive docs, which was missing the blanket and auto impls for most primitive types. To test this, compare nightly [libcore::str] docs, which lack auto traits like Send, with [std::str] docs, which show them. [libcore::str]: https://doc.rust-lang.org/nightly/core/primitive.str.html [libstd::str]: https://doc.rust-lang.org/nightly/std/primitive.str.html It also avoids getting synthetic impls for primitive types on crates that do not actually show them. <details> <summary>Before and After trace logs</summary> Before: [notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +nightly test.rs 2>&1 | grep -E 'get_blanket_impls\(' TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever) TRACE rustdoc::clean::blanket_impl get_blanket_impls(isize) TRACE rustdoc::clean::blanket_impl get_blanket_impls([T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([u8]) TRACE rustdoc::clean::blanket_impl get_blanket_impls(char) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u128) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u16) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i128) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i16) TRACE rustdoc::clean::blanket_impl get_blanket_impls(str) TRACE rustdoc::clean::blanket_impl get_blanket_impls(str) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u8) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i64) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i8) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const T) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut T) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*const [T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls(*mut [T]) TRACE rustdoc::clean::blanket_impl get_blanket_impls([T; N]) TRACE rustdoc::clean::blanket_impl get_blanket_impls(bool) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32) TRACE rustdoc::clean::blanket_impl get_blanket_impls(f32) TRACE rustdoc::clean::blanket_impl get_blanket_impls(u32) TRACE rustdoc::clean::blanket_impl get_blanket_impls(usize) TRACE rustdoc::clean::blanket_impl get_blanket_impls(i32) After: [notriddle@deep-thought test-dingus]$ RUSTDOC_LOG=rustdoc=trace rustdoc +dev test.rs 2>&1 | grep -E 'get_blanket_impls\(' TRACE rustdoc::clean::blanket_impl get_blanket_impls(Whatever) </details>
2022-04-21rustdoc: Unindent doc fragments on `Attributes` constructionVadim Petrochenkov-194/+1
2022-04-21[WIP] rustdoc: Resolve some more doc links earlyVadim Petrochenkov-7/+19
2022-04-19rustdoc: Sligthly optimize `Attributes` construction and processing before ↵Vadim Petrochenkov-3/+3
doc link resolution
2022-04-19rustdoc: Cache preprocessed markdown linksVadim Petrochenkov-39/+60
2022-04-19rustdoc: Optimize and refactor doc link resolutionVadim Petrochenkov-38/+100
- Cache doc link resolutions obtained early - Cache markdown links retrieved from doc strings early - Rename and restructure the code in early doc link resolution to be closer to #94857
2022-04-16Rollup merge of #96118 - GuillaumeGomez:cleanup-def-id-item-id, r=notriddleDylan DPC-31/+32
rustdoc: Rename `def_id` into `item_id` when the type is `ItemId` for readability As `@notriddle` mentioned in https://github.com/rust-lang/rust/pull/96091, the field name is inaccurate. This PR fixes it by renaming it accordingly to its real type. r? `@notriddle`
2022-04-16Rename `def_id` into `item_id` when the type is `ItemId` for readabilityGuillaume Gomez-31/+32
2022-04-16Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnrDylan DPC-1/+1
couple of clippy::perf fixes
2022-04-13Auto merge of #95968 - davidtwco:translation-lazy-fallback, r=oli-obkbors-6/+6
errors: lazily load fallback fluent bundle Addresses (hopefully) https://github.com/rust-lang/rust/pull/95667#issuecomment-1094794087. Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. r? `@ghost` (just for perf initially)
2022-04-13couple of clippy::perf fixesMatthias Krüger-1/+1
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-6/+6
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-12rustdoc: discr. required+provided assoc consts+tysLeón Orell Valerian Liehr-8/+6
2022-04-07rustdoc: Early doc link resolution fixes and refactoringsVadim Petrochenkov-98/+125
2022-04-05Rollup merge of #95645 - ↵Dylan DPC-1/+4
GuillaumeGomez:intra-doc-link-ice-traits-in-scope-primitive, r=jyn514 Fix intra doc link ICE when trying to get traits in scope for primitive Fixes #95633. I think ``@notriddle`` was the one who worked on this part of the code last so: r? ``@notriddle``
2022-04-05Rollup merge of #95512 - davidtwco:diagnostic-translation, r=oli-obkDylan DPC-2/+14
diagnostics: translation infrastructure An implementation of the infrastructure required to have translatable diagnostic messages. - Introduces a `DiagnosticMessage` type which can represent both the current non-translatable messages and identifiers for [Fluent](https://projectfluent.org/). - Modifies current diagnostic API so that existing calls still work but `DiagnosticMessage`s can be provided too. - Adds support for always loading a "fallback bundle" containing the English diagnostic messages, which are used when a `DiagnosticMessage::FluentIdentifier` is used in a diagnostic being emitted. - Adds support for loading a "primary bundle" which contains the user's preferred language translation, and is used preferentially when it contains a diagnostic message being emitted. Primary bundles are loaded either from the path provided to `-Ztranslate-alternate-ftl` (for testing), or from the sysroot at `$sysroot/locale/$locale/*.ftl` given a locale with `-Ztranslate-lang` (which is parsed as a language identifier). - Adds "diagnostic args" which enable normally-interpolated variables to be made available as variables for Fluent messages to use. - Updates `#[derive(SessionDiagnostic)]` so that it can only be used for translatable diagnostics and update the handful of diagnostics which used the derive to be translatable. For example, the following diagnostic... ```rust #[derive(SessionDiagnostic)] #[error = "E0195"] pub struct LifetimesOrBoundsMismatchOnTrait { #[message = "lifetime parameters or bounds on {item_kind} `{ident}` do not match the trait declaration"] #[label = "lifetimes do not match {item_kind} in trait"] pub span: Span, #[label = "lifetimes in impl do not match this {item_kind} in trait"] pub generics_span: Option<Span>, pub item_kind: &'static str, pub ident: Ident, } ``` ...becomes... ```rust #[derive(SessionDiagnostic)] #[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")] pub struct LifetimesOrBoundsMismatchOnTrait { #[primary_span] #[label] pub span: Span, #[label = "generics-label"] pub generics_span: Option<Span>, pub item_kind: &'static str, pub ident: Ident, } ``` ```fluent typeck-lifetimes-or-bounds-mismatch-on-trait = lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration .label = lifetimes do not match {$item_kind} in trait .generics-label = lifetimes in impl do not match this {$item_kind} in trait ``` r? `@estebank` cc `@oli-obk` `@Manishearth`