-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Simplify doc meta mode #159473
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
base: main
Are you sure you want to change the base?
Simplify doc meta mode #159473
Changes from 9 commits
91131bb
a36c898
6887d4d
32f1625
18d6ebf
ac3994e
c352016
e03942b
d0fec14
9d136ed
f73cd1e
5f940df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
camelid marked this conversation as resolved.
|
|
camelid marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,7 @@ use rustc_errors::DiagCtxtHandle; | |
| use rustc_hir::def_id::LOCAL_CRATE; | ||
| use rustc_interface::interface; | ||
| use rustc_middle::ty::TyCtxt; | ||
| use rustc_session::config::{ErrorOutputType, RustcOptGroup, make_crate_type_option}; | ||
| use rustc_session::config::{ErrorOutputType, Input, RustcOptGroup, make_crate_type_option}; | ||
| use rustc_session::{EarlyDiagCtxt, getopts}; | ||
| use rustc_span::{BytePos, Span, SyntaxContext}; | ||
| use tracing::info; | ||
|
|
@@ -772,7 +772,10 @@ fn run_renderer< | |
| /// Renders and writes cross-crate info files, like the search index. This function exists so that | ||
| /// we can run rustdoc without a crate root in the `--merge=finalize` mode. Cross-crate info files | ||
| /// discovered via `--read-doc-meta-dir` are combined and written to the doc root. | ||
| fn run_merge_finalize(opt: config::RenderOptions) -> Result<(), error::Error> { | ||
| fn run_merge_finalize( | ||
| opt: config::RenderOptions, | ||
| compiler: &interface::Compiler, | ||
| ) -> Result<(), error::Error> { | ||
| assert!( | ||
| opt.should_merge.write_rendered_cci, | ||
| "config.rs only allows us to return InputMode::NoInputMergeFinalize if --merge=finalize" | ||
|
|
@@ -783,16 +786,37 @@ fn run_merge_finalize(opt: config::RenderOptions) -> Result<(), error::Error> { | |
| ); | ||
| let crates = html::render::CrateInfo::read_many(&opt.include_parts_dir)?; | ||
| let include_sources = !opt.html_no_source; | ||
| html::render::write_not_crate_specific( | ||
| &crates, | ||
| &opt.output, | ||
| &opt, | ||
| &opt.themes, | ||
| opt.extension_css.as_deref(), | ||
| &opt.resource_suffix, | ||
| include_sources, | ||
| )?; | ||
| Ok(()) | ||
|
|
||
| let krate = ast::Crate { | ||
| attrs: Default::default(), | ||
| items: Default::default(), | ||
| spans: Default::default(), | ||
| id: ast::DUMMY_NODE_ID, | ||
| is_placeholder: false, | ||
| }; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love that we're creating a dummy crate here just to get a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed the synthetic crate, but not the synthetic InputStr. |
||
| rustc_interface::create_and_enter_global_ctxt(compiler, krate, |tcx| { | ||
| html::render::write_not_crate_specific( | ||
| &crates, | ||
| &opt.output, | ||
| &opt, | ||
| &opt.themes, | ||
| opt.extension_css.as_deref(), | ||
| &opt.resource_suffix, | ||
| include_sources, | ||
| &crate::html::layout::Layout { | ||
| logo: String::new(), | ||
| favicon: String::new(), | ||
| external_html: opt.external_html.clone(), | ||
| default_settings: opt.default_settings.clone(), | ||
| krate: String::new(), | ||
| krate_version: String::new(), | ||
| css_file_extension: opt.extension_css.clone(), | ||
| scrape_examples_extension: false, | ||
| }, | ||
| tcx, | ||
| )?; | ||
| Ok(()) | ||
| }) | ||
| } | ||
|
|
||
| fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) { | ||
|
|
@@ -834,10 +858,18 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) { | |
| let input = match input { | ||
| config::InputMode::HasFile(input) => input, | ||
| config::InputMode::NoInputMergeFinalize => { | ||
| let config = core::create_config( | ||
| Input::Str { | ||
| name: rustc_span::FileName::Custom(String::new()), | ||
| input: String::new(), | ||
| }, | ||
| options, | ||
| &render_options, | ||
| ); | ||
| return wrap_return( | ||
| dcx, | ||
| rustc_span::create_session_globals_then(options.edition, &[], None, || { | ||
| run_merge_finalize(render_options) | ||
| interface::run_compiler(config, |compiler| { | ||
| run_merge_finalize(render_options, compiler) | ||
|
Comment on lines
+852
to
+863
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto here, but getting rid of the fake |
||
| .map_err(|e| format!("could not write merged cross-crate info: {e}")) | ||
| }), | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub struct Quebec; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| //@ needs-target-std | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| use run_make_support::{cwd, htmldocck, path, rust_lib_name, rustc, rustdoc}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fn main() { | ||||||||||||||||||||||||||||||||||||||||||||||
| let merged_dir = path("merged"); | ||||||||||||||||||||||||||||||||||||||||||||||
| let parts_out_dir = path("parts"); | ||||||||||||||||||||||||||||||||||||||||||||||
| let lib_dir = path("lib"); | ||||||||||||||||||||||||||||||||||||||||||||||
| let out_dir = path("out"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| rustc().input("quebec.rs").crate_name("quebec").crate_type("rlib").run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| rustdoc() | ||||||||||||||||||||||||||||||||||||||||||||||
| .input("quebec.rs") | ||||||||||||||||||||||||||||||||||||||||||||||
| .crate_name("quebec") | ||||||||||||||||||||||||||||||||||||||||||||||
| .out_dir(&out_dir) | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg("-Zunstable-options") | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg(format!("--write-doc-meta-dir={}", parts_out_dir.display())) | ||||||||||||||||||||||||||||||||||||||||||||||
| .run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| assert!(parts_out_dir.join("quebec.json").exists()); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| rustc() | ||||||||||||||||||||||||||||||||||||||||||||||
| .input("tango.rs") | ||||||||||||||||||||||||||||||||||||||||||||||
| .crate_name("tango") | ||||||||||||||||||||||||||||||||||||||||||||||
| .crate_type("rlib") | ||||||||||||||||||||||||||||||||||||||||||||||
| .extern_("quebec", rust_lib_name("quebec")) | ||||||||||||||||||||||||||||||||||||||||||||||
| .run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| rustdoc() | ||||||||||||||||||||||||||||||||||||||||||||||
| .input("tango.rs") | ||||||||||||||||||||||||||||||||||||||||||||||
| .crate_name("tango") | ||||||||||||||||||||||||||||||||||||||||||||||
| .extern_("quebec", rust_lib_name("quebec")) | ||||||||||||||||||||||||||||||||||||||||||||||
| .out_dir(&out_dir) | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg("-Zunstable-options") | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg(format!("--write-doc-meta-dir={}", parts_out_dir.display())) | ||||||||||||||||||||||||||||||||||||||||||||||
| .run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| assert!(parts_out_dir.join("tango.json").exists()); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| rustdoc() | ||||||||||||||||||||||||||||||||||||||||||||||
| .input("sierra.rs") | ||||||||||||||||||||||||||||||||||||||||||||||
| .crate_name("sierra") | ||||||||||||||||||||||||||||||||||||||||||||||
| .extern_("tango", rust_lib_name("tango")) | ||||||||||||||||||||||||||||||||||||||||||||||
| .library_search_path(cwd()) | ||||||||||||||||||||||||||||||||||||||||||||||
| .out_dir(&out_dir) | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg("-Zunstable-options") | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg(format!("--write-doc-meta-dir={}", parts_out_dir.display())) | ||||||||||||||||||||||||||||||||||||||||||||||
| .run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| assert!(parts_out_dir.join("sierra.json").exists()); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| let output = rustdoc() | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg("-Zunstable-options") | ||||||||||||||||||||||||||||||||||||||||||||||
| .out_dir(&out_dir) | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg(format!("--read-doc-meta-dir={}", parts_out_dir.display())) | ||||||||||||||||||||||||||||||||||||||||||||||
| .arg("--enable-index-page") | ||||||||||||||||||||||||||||||||||||||||||||||
| .run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| output.assert_stderr_not_contains("error: the compiler unexpectedly panicked. this is a bug."); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Is this necessary? Shouldn't the run-make test fail automatically if one of its subprocesses ICEs? (I'm not super familiar with run-make, so I might be wrong about this.)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just checked, and you're right. rust/src/tools/run-make-support/src/command.rs Lines 232 to 240 in d3ea035
Apparently, when a run-make command exits with a non-zero exit code, this thing will fail the test. rust/src/tools/run-make-support/src/util.rs Lines 31 to 43 in d3ea035
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| htmldocck().arg(&out_dir).arg("tango.rs").run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| htmldocck().arg(&out_dir).arg("quebec.rs").run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| htmldocck().arg(&out_dir).arg("sierra.rs").run(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| extern crate quebec; | ||
| pub trait Tango {} |
|
camelid marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub struct Quebec; |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not the right question for this PR, and I haven't read the implementation here, though I am curious:
--out-dir. I guess--out-diris ignored here?--emitfiles (w/ or w/o--out-dir? Where will those files be emitted?View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context: I'd like to pass
--emit=dep-infowithout specifying the full (absolute) path for those dep-info files. Because of this issue #159743 we cannot specify full path, and currently blocks rust-lang/cargo#17020.(That said, it is a very Cargo specific issue I feel like)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
--out-diris still used as the path for--emitfiles.--write-doc-meta-dirdoesn't pay attention to--out-dir.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So eventually if individual rustdoc doesn't need to emit html contents, cargo then can use
--emitto control dep-info emission location exclusively. Thanks!