about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2021-01-03Only report reference-style link errors onceDániel Buga-52/+74
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-01-03Rollup merge of #80580 - GuillaumeGomez:suggestion-ignore-codeblock-warn, ↵Guillaume Gomez-3/+12
r=jyn514 Add suggestion for "ignore" doc code block Part of https://github.com/rust-lang/rust/issues/30032. This PR adds a suggestion to help users when they have a "ignore" doc code block which is invalid rust code. r? `@jyn514`
2021-01-03Auto merge of #80261 - GuillaumeGomez:attr-rework, r=jyn514bors-124/+19
rustdoc DocFragment rework Kind of a follow-up of #80119. A few things are happening in this PR. I'm not sure about the impact on perf though so I'm very interested about that too (if the perf is worse, then we can just close this PR). The idea here is mostly about reducing the memory usage by relying even more on `Symbol` instead of `String`. The only issue is that `DocFragment` has 3 modifications performed on it: 1. Unindenting 2. Collapsing similar comments into one 3. "Beautifying" (weird JS-like comments handling). To do so, I saved the information about unindent and the "collapse" is now on-demand (which is why I'm not sure the perf will be better, it has to be run multiple times...). r? `@jyn514`
2021-01-02Simplify docfragment transformation in unindent testsGuillaume Gomez-14/+1
2021-01-02Remove unused collapse passGuillaume Gomez-19/+0
2021-01-02Improve code for DocFragment reworkGuillaume Gomez-6/+1
2021-01-02End of rework of Attributes structGuillaume Gomez-102/+34
2021-01-02Auto merge of #80550 - bugadani:markdown-refactor, r=jyn514bors-32/+27
Cleanup markdown span handling, take 2 This PR includes the cleanups made in #80244 except for the removal of `locate()`. While the biggest conceptual part in #80244 was the removal of `locate()`, it introduced a diagnostic regression. Additional cleanup: - Use `RefCell` to avoid building two separate vectors for the links Work to do: - [ ] Decide if `locate()` can be simplified by assuming `s` is always in `md` - [ ] Should probably add some tests that still provide the undesired diagnostics causing #80381 cc `@jyn514` This is the best I can do without patching Pulldown to provide multiple ranges for reference-style links. Also, since `locate` is probably more efficient than `rfind` (at least it's constant time), I decided to not check the link type and just cover every &str as it was before.
2021-01-01clippy fixes for librustdocMatthias Krüger-8/+6
fixes clippy warnings of type: match_like_matches_macro or_fun_call op_ref needless_return let_and_return single_char_add_str useless_format unnecessary_sort_by match_ref_pats redundant_field_names
2021-01-01Add suggestion in case a "ignore" doc block has invalid rust code insideGuillaume Gomez-3/+12
2020-12-31Rollup merge of #80368 - camelid:rustdoc-succinct-vis, r=jyn514Dylan DPC-24/+2
rustdoc: Render visibilities succinctly Fixes #79139. r? `@jyn514`
2020-12-31Always provide a rangeDániel Buga-32/+27
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-12-30Remove FIXMECamelid-1/+0
Co-authored-by: Joshua Nelson <jyn514@gmail.com>
2020-12-30Update `find_nearest_parent_module`Camelid-2/+7
2020-12-30Rollup merge of #80492 - matthiaskrgr:tasty_wraps, r=varkorYuki Okushi-3/+3
remove empty wraps, don't return Results from from infallible functions This makes code easier to understand because it is more obvious when a function actually can't fail (return Err or None) Make functions that only ever return Some(x), return x directly Remove return type from functions that return Option<(), Err> but would only ever return Ok(()). Found with `clippy::unnecessary_wraps`
2020-12-30Rollup merge of #80381 - rust-lang:revert-80244-spans, r=GuillaumeGomezYuki Okushi-28/+34
Revert "Cleanup markdown span handling" Reverts rust-lang/rust#80244. This caused a diagnostic regression, originally it was: ``` warning: unresolved link to `std::process::Comman` --> link.rs:3:10 | 3 | //! [a]: std::process::Comman | ^^^^^^^^^^^^^^^^^^^^ no item named `Comman` in module `process` | = note: `#[warn(broken_intra_doc_links)]` on by default ``` but after that PR rustdoc now displays ``` warning: unresolved link to `std::process::Comman` --> link.rs:1:14 | 1 | //! Links to [a] [link][a] | ^^^ no item named `Comman` in module `process` | = note: `#[warn(broken_intra_doc_links)]` on by default ``` which IMO is much less clear. cc `@bugadani,` thanks for catching this in https://github.com/rust-lang/rust/pull/77859. r? `@GuillaumeGomez`
2020-12-30remove unused return types such as empty Results or Options that would ↵Matthias Krüger-3/+3
always be Some(..) remove unused return type of dropck::check_drop_obligations() don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..) remove redundant return type of back::write::optimize() don't Option-wrap return type of compute_type_parameters() since we always return Some(..) don't return empty Result in assemble_generator_candidates() don't return empty Result in assemble_closure_candidates() don't return empty result in assemble_fn_pointer_candidates() don't return empty result in assemble_candidates_from_impls() don't return empty result in assemble_candidates_from_auto_impls() don't return emtpy result in assemble_candidates_for_trait_alias() don't return empty result in assemble_builtin_bound_candidates() don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait() remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..) remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-29don't clone copy typesMatthias Krüger-1/+1
2020-12-29Auto merge of #80014 - jyn514:box-item-kind, r=nnethercotebors-11/+11
[rustdoc] Box ItemKind to reduce the size of `Item` This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 536 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 136 ``` This is an alternative to https://github.com/rust-lang/rust/pull/79967; I don't think it makes sense to make both changes. Helps with #79103.
2020-12-27Auto merge of #80181 - jyn514:intra-doc-primitives, r=Manishearthbors-129/+177
Fix intra-doc links for non-path primitives This does *not* currently work for associated items that are auto-implemented by the compiler (e.g. `never::eq`), because they aren't present in the source code. I plan to fix this in a follow-up PR. Fixes https://github.com/rust-lang/rust/issues/63351 using the approach mentioned in https://github.com/rust-lang/rust/issues/63351#issuecomment-683352130. r? `@Manishearth` cc `@petrochenkov` - this makes `rustc_resolve::Res` public, is that ok? I'd just add an identical type alias in rustdoc if not, which seems a waste.
2020-12-26Revert "Cleanup markdown span handling"Joshua Nelson-28/+34
This caused a diagnostic regression, originally it was: ``` warning: unresolved link to `std::process::Comman` --> link.rs:3:10 | 3 | //! [a]: std::process::Comman | ^^^^^^^^^^^^^^^^^^^^ no item named `Comman` in module `process` | = note: `#[warn(broken_intra_doc_links)]` on by default ``` but after that PR rustdoc now displays ``` warning: unresolved link to `std::process::Comman` --> link.rs:1:14 | 1 | //! Links to [a] [link][a] | ^^^ no item named `Comman` in module `process` | = note: `#[warn(broken_intra_doc_links)]` on by default ``` which IMO is much less clear.
2020-12-25Add missing code to `find_closest_parent_module`Camelid-9/+1
2020-12-25Fix bugs; fix and add testsCamelid-20/+2
2020-12-25Rollup merge of #80274 - pierwill:lintlevelsource, r=petrochenkovDylan DPC-4/+4
Rename rustc_middle::lint::LintSource Rename [`rustc_middle::lint::LintSource`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/enum.LintSource.html) to `rustc_middle::lint::LintLevelSource`. This enum represents the source of a *lint level*, not a lint. This should improve code readability. Update: Also documents `rustc_middle::lint::LevelSource` to clarify.
2020-12-24Don't process `[]` and `()` in intra-doc linksJoshua Nelson-5/+6
These caused several false positives when documenting rustc, which means there will likely be many more false positives in the rest of the ecosystem.
2020-12-23Box ItemKind to reduce the size of `Item`Joshua Nelson-11/+11
This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 680 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 280 ```
2020-12-22Fix intra-doc links for non-path primitivesJoshua Nelson-26/+28
This does *not* currently work for associated items that are auto-implemented by the compiler (e.g. `never::eq`), because they aren't present in the source code. I plan to fix this in a follow-up PR.
2020-12-22Add a custom `Res` typeJoshua Nelson-116/+161
- Don't make rustc_resolve::Res public; use a new type alias instead
2020-12-22Auto merge of #80071 - jyn514:timings, r=Mark-Simulacrumbors-15/+19
Add more timing info to rustdoc This helped me confirm in https://github.com/rust-lang/rust/issues/79103#issuecomment-745737864 that get_blanket_impls is indeed what's taking all the time on stm32. r? `@Mark-Simulacrum`
2020-12-21Rename rustc_middle::lint::LintSourcepierwill-4/+4
Rename rustc_middle::lint::LintSource to rustc_middle::lint::LintLevelSource.
2020-12-20Get rid of `locate()` in markdown handlingJoshua Nelson-34/+28
This function was unfortunate for several reasons: - It used `unsafe` because it wanted to tell whether a string came from the same *allocation* as another, not just whether it was a textual match. - It recalculated spans even though they were already available from pulldown - It sometimes *failed* to calculate the span, which meant it was always possible for the span to be `None`, even though in practice that should never happen. This commit has several cleanups: - Make the span required - Pass through the span from pulldown in the `HeadingLinks` and `Footnotes` iterators - Only add iterator bounds on the `impl Iterator`, not on `new` and the struct itself.
2020-12-16Replace String with Symbol where possibleGuillaume Gomez-16/+20
2020-12-16Add more timing info to rustdocJoshua Nelson-15/+19
2020-12-15Don't look for blanket impls in intra-doc linksJoshua Nelson-69/+14
This never worked and has been causing severe performance problems. Hopefully it will be re-landed at some point in the future when it actually works, but in the meantime it makes no sense to have the code around when it does nothing and actively makes rustdoc harder to use.
2020-12-15Auto merge of #80044 - jyn514:smaller-name, r=GuillaumeGomezbors-2/+9
[rustdoc] Switch to Symbol for item.name This decreases the size of `Item` from 680 to 616 bytes. It also does a lot less work since it no longer has to copy as much. Helps with #79103. r? `@GuillaumeGomez`
2020-12-14Switch to Symbol for item.nameJoshua Nelson-2/+9
This decreases the size of `Item` from 680 to 616 bytes. It also does a lot less work since it no longer has to copy as much.
2020-12-14Review suggestionsDániel Buga-79/+87
2020-12-14Cache link resolution results in current moduleDániel Buga-14/+79
Co-authored-by: Joshua Nelson <jyn514@gmail.com>
2020-12-13Rollup merge of #79940 - matthiaskrgr:cl15ppy, r=Dylan-DPCYuki Okushi-2/+1
fix more clippy::complexity findings fix clippy::unnecessary_filter_map use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn) fix clippy::{needless_bool, manual_unwrap_or} don't clone types that are copy (clippy::clone_on_copy) don't convert types into identical types with .into() (clippy::useless_conversion) use strip_prefix over slicing (clippy::manual_strip) r? ``@Dylan-DPC``
2020-12-12Auto merge of #79976 - jyn514:assertion-failure, r=jyn514bors-1/+1
Remove incorrect assert Fixes an assertion failure when resolving `::std` (or any other crate that uses the `::` style, see https://github.com/rust-lang/rust/pull/79809/files#r541776478, https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Perf.20failing). Unblocks https://github.com/rust-lang/rustc-perf/pull/806. r? `@ghost` - this is a trivial fix and breaking rustc-perf so I'm going to approve it unilaterally. cc `@Mark-Simulacrum` `@Eric-Arellano`
2020-12-12Remove incorrect assertJoshua Nelson-1/+1
2020-12-12Auto merge of #79957 - jyn514:smaller-span, r=GuillaumeGomezbors-9/+6
[rustdoc] Calculate span information on demand instead of storing it ahead of time This brings `size_of<clean::types::Span>()` down from over 100 bytes (!!) to only 12, the same as rustc. It brings `Item` down even more, from `784` to `680`. ~~TODO: I need to figure out how to do this for the JSON backend too. That uses `From` impls everywhere, which don't allow passing in the `Session` as an argument. `@P1n3appl3,` `@tmandry,` maybe one of you have ideas?~~ Figured it out, fortunately only two functions needed to be changed. I like the `convert_x()` format better than `From` everywhere but I'm open to feedback. Helps with #79103
2020-12-12Calculate span info on-demand instead of ahead of timeJoshua Nelson-9/+6
This should *vastly* reduce memory usage.
2020-12-11don't convert types into identical types with .into() ↵Matthias Krüger-2/+1
(clippy::useless_conversion)
2020-12-11Auto merge of #79349 - Nemo157:issue-79201, r=jyn514bors-1/+27
Apply `doc(cfg)` from parent items while collecting trait impls Because trait impls bypass the standard `clean` hierarchy they do not participate in the `propagate_doc_cfg` pass, so instead we need to pre-collect all possible `doc(cfg)` attributes that will apply to them when cleaning. fixes #79201
2020-12-07Review feedback for collect_intra_doc_links.rsEric Arellano-2/+3
* Add assertion value is defined. * Simplify comment. * Fix bad change in err message.
2020-12-07Dogfood 'str_split_once() with librustdocEric Arellano-3/+4
2020-12-02Use `item_name` instead of pretty printingJoshua Nelson-4/+9
Pretty printing would add a `r#` prefix to raw identifiers, which was not correct. In general I think this change makes sense - pretty-printing is for showing to the *user*, `item_name` is suitable to pass to resolve.
2020-11-29Remove `TypeKind` hack in favor of `with_crate_prefix`Joshua Nelson-9/+3
2020-11-29Fix intra-doc links for `Self` on primitivesJoshua Nelson-123/+62
- Remove the difference between `parent_item` and `current_item`; these should never have been different. - Remove `current_item` from `resolve` and `variant_field` so that `Self` is only substituted in one place at the very start. - Resolve the current item as a `DefId`, not a `HirId`. This is what actually fixed the bug. Hacks: - `clean` uses `TypedefItem` when it _really_ should be `AssociatedTypeItem`. I tried fixing this without success and hacked around it instead (see comments) - This stringifies DefIds, then resolves them a second time. This is really silly and rustdoc should just use DefIds throughout. Fixing this is a larger task than I want to take on right now.