diff options
| author | bors <bors@rust-lang.org> | 2021-01-30 10:50:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-30 10:50:16 +0000 |
| commit | 7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7 (patch) | |
| tree | b4bc76e37d133d24df1e8a93a0a2a0fa4aa74e7a /src/librustdoc | |
| parent | ebaea9e850648dfeaeec353fd66c155c80de5ded (diff) | |
| parent | 31e7634749a737be8118ec8fe92c2dfcd2d10046 (diff) | |
| download | rust-7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7.tar.gz rust-7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7.zip | |
Auto merge of #81545 - JohnTitor:rollup-zlt3tn6, r=JohnTitor
Rollup of 16 pull requests Successful merges: - #79023 (Add `core::stream::Stream`) - #80562 (Consider Scalar to be a bool only if its unsigned) - #80886 (Stabilize raw ref macros) - #80959 (Stabilize `unsigned_abs`) - #81291 (Support FRU pattern with `[feature(capture_disjoint_fields)]`) - #81409 (Slight simplification of chars().count()) - #81468 (cfg(version): treat nightlies as complete) - #81473 (Warn write-only fields) - #81495 (rustdoc: Remove unnecessary optional) - #81499 (Updated Vec::splice documentation) - #81501 (update rustfmt to v1.4.34) - #81505 (`fn cold_path` doesn't need to be pub) - #81512 (Add missing variants in match binding) - #81515 (Fix typo in pat.rs) - #81519 (Don't print error output from rustup when detecting default build triple) - #81520 (Don't clone LLVM submodule when download-ci-llvm is set) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 3 | ||||
| -rw-r--r-- | src/librustdoc/config.rs | 26 | ||||
| -rw-r--r-- | src/librustdoc/core.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/passes/calculate_doc_coverage.rs | 2 |
5 files changed, 22 insertions, 15 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 18683f6809f..8a49fe0228c 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1436,8 +1436,7 @@ impl Type { Array(..) => PrimitiveType::Array, RawPointer(..) => PrimitiveType::RawPointer, QPath { ref self_type, .. } => return self_type.inner_def_id(cache), - // FIXME: remove this wildcard - _ => return None, + Generic(_) | Infer | ImplTrait(_) => return None, }; cache.and_then(|c| Primitive(t).def_id_full(c)) } diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 95c6989dab4..63a25e5dbfb 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -35,6 +35,12 @@ crate enum OutputFormat { Html, } +impl Default for OutputFormat { + fn default() -> OutputFormat { + OutputFormat::Html + } +} + impl OutputFormat { crate fn is_json(&self) -> bool { matches!(self, OutputFormat::Json) @@ -118,7 +124,7 @@ crate struct Options { crate enable_per_target_ignores: bool, /// The path to a rustc-like binary to build tests with. If not set, we - /// default to loading from $sysroot/bin/rustc. + /// default to loading from `$sysroot/bin/rustc`. crate test_builder: Option<PathBuf>, // Options that affect the documentation process @@ -142,8 +148,10 @@ crate struct Options { crate crate_version: Option<String>, /// Collected options specific to outputting final pages. crate render_options: RenderOptions, - /// Output format rendering (used only for "show-coverage" option for the moment) - crate output_format: Option<OutputFormat>, + /// The format that we output when rendering. + /// + /// Currently used only for the `--show-coverage` option. + crate output_format: OutputFormat, /// If this option is set to `true`, rustdoc will only run checks and not generate /// documentation. crate run_check: bool, @@ -271,7 +279,7 @@ crate struct RenderInfo { crate deref_trait_did: Option<DefId>, crate deref_mut_trait_did: Option<DefId>, crate owned_box_did: Option<DefId>, - crate output_format: Option<OutputFormat>, + crate output_format: OutputFormat, } impl Options { @@ -537,28 +545,28 @@ impl Options { let output_format = match matches.opt_str("output-format") { Some(s) => match OutputFormat::try_from(s.as_str()) { - Ok(o) => { - if o.is_json() + Ok(out_fmt) => { + if out_fmt.is_json() && !(show_coverage || nightly_options::match_is_nightly_build(matches)) { diag.struct_err("json output format isn't supported for doc generation") .emit(); return Err(1); - } else if !o.is_json() && show_coverage { + } else if !out_fmt.is_json() && show_coverage { diag.struct_err( "html output format isn't supported for the --show-coverage option", ) .emit(); return Err(1); } - Some(o) + out_fmt } Err(e) => { diag.struct_err(&e).emit(); return Err(1); } }, - None => None, + None => OutputFormat::default(), }; let crate_name = matches.opt_str("crate-name"); let proc_macro_crate = crate_types.contains(&CrateType::ProcMacro); diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 8eea102fa2f..aa18684aea1 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -463,7 +463,7 @@ crate fn run_global_ctxt( mut default_passes: passes::DefaultPassOption, mut manual_passes: Vec<String>, render_options: RenderOptions, - output_format: Option<OutputFormat>, + output_format: OutputFormat, ) -> (clean::Crate, RenderInfo, RenderOptions) { // Certain queries assume that some checks were run elsewhere // (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index c61cbf78f77..e98cb237635 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -578,7 +578,7 @@ fn main_options(options: config::Options) -> MainResult { let (error_format, edition, debugging_options) = diag_opts; let diag = core::new_handler(error_format, None, &debugging_options); match output_format { - None | Some(config::OutputFormat::Html) => sess.time("render_html", || { + config::OutputFormat::Html => sess.time("render_html", || { run_renderer::<html::render::Context<'_>>( krate, render_opts, @@ -588,7 +588,7 @@ fn main_options(options: config::Options) -> MainResult { tcx, ) }), - Some(config::OutputFormat::Json) => sess.time("render_json", || { + config::OutputFormat::Json => sess.time("render_json", || { run_renderer::<json::JsonRenderer<'_>>( krate, render_opts, diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 61e14c05222..cdbff62d064 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -132,7 +132,7 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> { fn print_results(&self) { let output_format = self.ctx.renderinfo.borrow().output_format; - if output_format.map(|o| o.is_json()).unwrap_or_else(|| false) { + if output_format.is_json() { println!("{}", self.to_json()); return; } |
