Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor librustdoc html backend #73767

Merged
merged 9 commits into from
Jul 30, 2020
Merged

Conversation

P1n3appl3
Copy link
Contributor

This PR moves several types out of the librustdoc::html module so that they can be used by a future json backend. These changes are a re-implementation of some work done 6 months ago by @GuillaumeGomez. I'm currently working on said json backend and will put up an RFC soon with the proposed implementation.

There are a couple of changes that are more substantial than relocating structs to a different module:

  1. The Cache is no longer part of the html::render::Context type and therefor it needs to be explicitly passed to any functions that access it.
  2. The driving function html::render::run has been rewritten to use the FormatRenderer trait which should allow different backends to re-use the driving code.

r? @GuillaumeGomez

cc @tmandry @betamos

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 26, 2020
Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just remove the diag parameter where it's unused. Otherwise looks good to me, thanks for working on this!

src/librustdoc/html/render.rs Outdated Show resolved Hide resolved
@@ -112,6 +113,9 @@ struct Context {
id_map: Rc<RefCell<IdMap>>,
pub shared: Arc<SharedContext>,
pub cache: Arc<Cache>,
pub parent: Rc<RefCell<Renderer>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note (for myself and any other potential reviewer): those 3 variables were before in the run function which became split in the FormatRenderer trait.

}

renderer.after_krate(&krate)?;
renderer.after_run(diag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this allows to check if any errors has occurred during the run, which allows to make the code inside after_krate a bit lighter.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-8 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
##[section]Starting: Linux x86_64-gnu-llvm-8
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 65'
Agent machine name: 'fv-az578'
Current agent version: '2.171.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200621.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200621.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.171.1)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/8368ea83-b38d-425a-b36f-559410c622da.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/73767/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/73767/merge:refs/remotes/pull/73767/merge
---
 ---> 31fea614d2f3
Step 5/8 : ENV RUST_CONFIGURE_ARGS       --build=x86_64-unknown-linux-gnu       --llvm-root=/usr/lib/llvm-8       --enable-llvm-link-shared       --set rust.thin-lto-import-instr-limit=10
 ---> Using cache
 ---> 4195cadf126d
Step 6/8 : ENV SCRIPT python2.7 ../x.py test --exclude src/tools/tidy &&            python2.7 ../x.py test src/test/mir-opt --pass=build                                   --target=armv5te-unknown-linux-gnueabi &&            python2.7 ../x.py test src/tools/tidy
 ---> 4e90f6b48f05
Step 7/8 : ENV NO_DEBUG_ASSERTIONS=1
 ---> Using cache
 ---> dfa0a356d899
---
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model  : 85
model name : Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
microcode : 0xffffffff
cpu MHz  : 2593.905
cache size : 36608 KB
physical id : 0
---
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model  : 85
model name : Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
microcode : 0xffffffff
cpu MHz  : 2593.905
cache size : 36608 KB
physical id : 0
---
Set({"src/librustc_parse_format"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_passes"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_plugin_impl"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_privacy"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_query_system"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_save_analysis"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_serialize"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_session"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_span"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
---
Set({"src/librustc_parse_format"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_passes"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_plugin_impl"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_privacy"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_query_system"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_save_analysis"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_serialize"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_session"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_span"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
---
   Compiling rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
   Compiling tracing v0.1.15
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling chalk-engine v0.14.0
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
   Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
   Compiling rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
   Compiling tracing v0.1.15
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling chalk-engine v0.14.0
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling chalk-solve v0.14.0
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
---
...........................i........................................................................ 1900/10407
.................................................................................................... 2000/10407
......................................................i..i.......................................... 2100/10407
.................................................................................................... 2200/10407
............................................iiiii................................................... 2300/10407
.................................................................................................... 2500/10407
.................................................................................................... 2600/10407
.................................................................................................... 2700/10407
.................................................................................................... 2800/10407
---
...i................................................................................................ 5300/10407
.................................................................................................... 5400/10407
...................................i................................................................ 5500/10407
.............................i...................................................................... 5600/10407
.................................................ii.ii........i...i................................. 5700/10407
..................i................................................................................. 5900/10407
...............i.................................................................................... 6000/10407
.........................................................................ii......................... 6100/10407
............i....................................................................................... 6200/10407
............i....................................................................................... 6200/10407
.................................................................................................... 6300/10407
.................................................................................................... 6400/10407
....................................ii...i..ii...........i.......................................... 6500/10407
.................................................................................................... 6700/10407
.................................................................................................... 6800/10407
.................................................................................................... 6800/10407
.......................................................................i..ii........................ 6900/10407
.................................................................................................... 7100/10407
.................................................................................................... 7200/10407
...........................i........................................................................ 7300/10407
.................................................................................................... 7400/10407
---
.................................................................................................... 8300/10407
.................................................................................................... 8400/10407
............................................................................i....................... 8500/10407
.................................................................................................... 8600/10407
..............................iiiiii..iiiiii.i...................................................... 8700/10407
.................................................................................................... 8900/10407
.................................................................................................... 9000/10407
.................................................................................................... 9100/10407
.................................................................................................... 9200/10407
---
Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 202 tests
iiii......i..i...............ii..i..........i...........i............i...........i..i........i...... 100/202
..i....i.............i.i.i...iii..iiii....................................iii.................ii.... 200/202
test result: ok. 170 passed; 0 failed; 32 ignored; 0 measured; 0 filtered out

 finished in 5.760
Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
---
ssembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 22 tests
iiiiiiiiiiiiiiiiiiiiii

 finished in 0.134
Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 116 tests
iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i...i.......ii.i.ii. 100/116
....iiii.....ii.

 finished in 13.713
Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---

   Doc-tests core

running 2586 tests
......iiiii......................................................................................... 100/2586
.................................................................................................ii. 200/2586
.......................................i............................................................ 400/2586
...............................................................................................i..i. 500/2586
...............................................................................................i..i. 500/2586
.................iiii............................................................................... 600/2586
.................................................................................................... 800/2586
.................................................................................................... 900/2586
.................................................................................................... 1000/2586
.................................................................................................... 1100/2586
---
.................................................................................................... 500/769
...........................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2740:32
....thread 'thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libstd/sync/mpsc/mod.rs<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2777:31
:2765:28
......thread '<unnamed>' panicked at '.called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2644:23
..........................................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1997:32
....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2034:31
.......thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1916:23
......... 600/769
...............................thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:688:13
thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:642:13
---

running 1038 tests
i................................................................................................... 100/1038
.................................................................................................... 200/1038
...................iii......i......i...i.........i.................................................. 300/1038
..........................................................i....i.................................... 500/1038
..............ii.................................................................................... 600/1038
.................................................................................................... 700/1038
.................................................................................................... 700/1038
..............................................................iiii.................................. 800/1038
.................................................................................................... 900/1038
.....................................................................................iiii........... 1000/1038
test result: ok. 1018 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out

 finished in 131.255
Set({"src/libterm"}) not skipped for "bootstrap::test::Crate" -- not in ["src/tools/tidy"]
---
Set({"src/librustc_parse_format"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_passes"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_plugin_impl"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_privacy"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_query_system"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_save_analysis"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_serialize"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_session"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_span"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
---
---- html/markdown.rs - html::markdown (line 5) stdout ----
error[E0603]: module `html` is private
  --> html/markdown.rs:11:14
   |
9  | use rustdoc::html::markdown::{IdMap, Markdown, ErrorCodes};
   |
note: the module `html` is defined here
  --> /checkout/src/librustdoc/lib.rs:68:1
   |
---

error: test failed, to rerun pass '--doc'


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--locked" "--color" "always" "--manifest-path" "/checkout/src/tools/rustdoc/Cargo.toml" "-p" "rustdoc:0.0.0" "--" "--quiet"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
Build completed unsuccessfully in 1:11:44
Build completed unsuccessfully in 1:11:44
== clock drift check ==
  local time: Fri Jun 26 15:34:24 UTC 2020
  network time: Fri, 26 Jun 2020 15:34:24 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/73767/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/73767/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (3931) (python)
##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

src/librustdoc/formats/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/formats/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/formats/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/lib.rs Outdated Show resolved Hide resolved
src/librustdoc/formats/mod.rs Show resolved Hide resolved
Copy link
Member

@tmandry tmandry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I left a few nits, feel free to ignore if they are preexisting.

src/librustdoc/formats/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/formats/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/formats/mod.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Jun 27, 2020

☔ The latest upstream changes (presumably #73779) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea but this is going to conflict with every one of the intra-doc link PRs 😅

src/librustdoc/lib.rs Outdated Show resolved Hide resolved
@P1n3appl3
Copy link
Contributor Author

@jyn514 I couldn't find those PRs, do you mean they'll conflict because of moving html/render.rs to html/render/mod.rs or because of the changes in general? I could just keep the file in the same place if it helps.

@jyn514
Copy link
Member

jyn514 commented Jun 30, 2020

Err I was actually thinking of #72771, #73101 doesn't actually modify html/ at all. So no need to change anything. Thanks for the offer though!

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Considering this is a huge PR (even if mainly doing code moves), I'll wait for at least one more review from someone on the @rust-lang/rustdoc team (ping @ollie27 )

@bors
Copy link
Contributor

bors commented Jul 7, 2020

☔ The latest upstream changes (presumably #74117) made this pull request unmergeable. Please resolve the merge conflicts.

@tmandry
Copy link
Member

tmandry commented Jul 14, 2020

@ollie27 Friendly ping, would you be able to review this?

@bors
Copy link
Contributor

bors commented Jul 14, 2020

☔ The latest upstream changes (presumably #74330) made this pull request unmergeable. Please resolve the merge conflicts.

@tmandry
Copy link
Member

tmandry commented Jul 17, 2020

Perhaps another person on @rust-lang/rustdoc can give this a once-over. I nominate...

r? @Manishearth

@Manishearth
Copy link
Member

@jyn514 wanna review this?

@bors
Copy link
Contributor

bors commented Jul 24, 2020

☔ The latest upstream changes (presumably #74710) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit, otherwise r=me!

src/librustdoc/formats/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these are about pre-existing issues, feel free to merge without addressing.

src/librustdoc/core.rs Outdated Show resolved Hide resolved
}
}

impl PathError for Error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, but do you know why rustdoc uses a separate error type and trait here? It has wrappers around both io::Error and std::error::Error.

}

impl PathError for Error {
fn new<S, P: AsRef<Path>>(e: S, path: P) -> Error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, but this would be better taking P: Into<PathBuf> instead which avoids an unnecessary allocation if passing a PathBuf.

Comment on lines +42 to +47
/// Maintains a mapping of local crate `DefId`s to the fully qualified name
/// and "short type description" of that node. This is used when generating
/// URLs when a type is being linked to. External paths are not located in
/// this map because the `External` type itself has all the information
/// necessary.
pub paths: FxHashMap<DefId, (Vec<String>, ItemType)>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, but would it be better to use LocalDefId if these are only for the current crate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, although it's kind of convenient that all the mappings in Cache use a full DefId. Otherwise I think you'd need to add checks that a given item is local before pulling out it's LocalDefId and looking it up in those maps.

Comment on lines +34 to +40
/// Maps a type ID to all known implementations for that type. This is only
/// recognized for intra-crate `ResolvedPath` types, and is used to print
/// out extra documentation on the page of an enum/struct.
///
/// The values of the map are a list of implementations and documentation
/// found on that implementation.
pub impls: FxHashMap<DefId, Vec<Impl>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this includes types from other crates as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, don't see std or other types in there unless i'm reexporting them. It does have the numeric primitives + char and bool but I assume that's either from the prelude or just because they're special.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. In general, if it doesn't have types from other crates it should use LocalDefId but that can be delayed to a later PR.

parent: Option<DefId>,
parent_idx: Option<usize>,
search_type: Option<IndexItemFunctionType>,
pub struct IndexItem {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make this fully pub, rustc won't warn about dead code.

Suggested change
pub struct IndexItem {
pub(crate) struct IndexItem {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't restrict it since it's exposed through Cache

stripped_mod: bool,
masked_crates: FxHashSet<CrateNum>,

pub search_index: Vec<IndexItem>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is both a formats::cache and a html::render::cache. Maybe this belongs with render? I don't see why backends other than HTML would need a JS search index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it would definitely be better to have search_index in html::render::SharedContext but it requires a bit of work to separate out the logic to construct the index vs the cache because they're currently using the same DocFolder pass.

src/librustdoc/html/render/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/html/render/mod.rs Outdated Show resolved Hide resolved
@@ -361,7 +280,7 @@ impl Serialize for Generic {

/// Full type of functions/methods in the search index.
#[derive(Debug)]
struct IndexItemFunctionType {
pub struct IndexItemFunctionType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub struct IndexItemFunctionType {
pub(crate) struct IndexItemFunctionType {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one gets exposed by the cache so it's got to stay public (until we can move search index related stuff to html::render::SharedContext)

@ollie27 ollie27 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 24, 2020
@jyn514 jyn514 added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Jul 25, 2020
@bors
Copy link
Contributor

bors commented Jul 27, 2020

📌 Commit cee8023 has been approved by tmandry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2020
@bors
Copy link
Contributor

bors commented Jul 28, 2020

⌛ Testing commit cee8023 with merge f1be9a90a04ae76a2798a3d0999fa651100289ce...

@bors
Copy link
Contributor

bors commented Jul 28, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 28, 2020
@Manishearth
Copy link
Member

A bajillion test failures of the form:

2020-07-28T03:35:02.5974142Z thread '<unnamed>' panicked at 'failed to send error on "D:\a\rust\rust\build\x86_64-pc-windows-msvc\test\rustdoc\traits-in-bodies-private\traits_in_bodies_private\struct.SomeStruct.html"', src\librustdoc\docfs.rs:97:25
2020-07-28T03:35:02.5974376Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/librustdoc/docfs.rs Outdated Show resolved Hide resolved
@tmandry
Copy link
Member

tmandry commented Jul 29, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jul 29, 2020

📌 Commit 29df050 has been approved by tmandry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 29, 2020
@jyn514
Copy link
Member

jyn514 commented Jul 29, 2020

@bors rollup=iffy

This will cause lots of conflicts if it tries to merge at the same time as another rustdoc PR.

@tmandry
Copy link
Member

tmandry commented Jul 29, 2020

@jyn514 rollups already ignore PRs that have merge conflicts when creating them

@bors
Copy link
Contributor

bors commented Jul 29, 2020

⌛ Testing commit 29df050 with merge 6b269e4...

@bors
Copy link
Contributor

bors commented Jul 30, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: tmandry
Pushing 6b269e4 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.