rustdoc: auto create output directory when "--output-format json" by tomkris · Pull Request #93099 · rust-lang/rust (original) (raw)

This can be simplified with the try_err macro. You'll also need to import PathError:

diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 6fadf72f54d..12281e78ffc 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -18,13 +18,14 @@

use rustdoc_json_types as types;

-use crate::clean; use crate::clean::types::{ExternalCrate, ExternalLocation}; use crate::config::RenderOptions; +use crate::docfs::PathError; use crate::error::Error; use crate::formats::cache::Cache; use crate::formats::FormatRenderer; use crate::json::conversions::{from_item_id, IntoWithTcx}; +use crate::{clean, try_err};

#[derive(Clone)] crate struct JsonRenderer<'tcx> { @@ -257,8 +258,7 @@ fn after_krate(&mut self) -> Result<(), Error> { format_version: types::FORMAT_VERSION, }; let out_dir = self.out_path.clone();