From 9918693037dce8aa4bb6f08741b6812923486c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 19 Jun 2024 11:26:03 +0200 Subject: Merging upstream version 1.76.0+dfsg1. Signed-off-by: Daniel Baumann --- src/librustdoc/externalfiles.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/librustdoc/externalfiles.rs') diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index b34b69b1f..8bc0cdf3a 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -27,15 +27,15 @@ impl ExternalHtml { md_before_content: &[String], md_after_content: &[String], nightly_build: bool, - diag: &rustc_errors::Handler, + dcx: &rustc_errors::DiagCtxt, id_map: &mut IdMap, edition: Edition, playground: &Option, ) -> Option { let codes = ErrorCodes::from(nightly_build); - let ih = load_external_files(in_header, diag)?; - let bc = load_external_files(before_content, diag)?; - let m_bc = load_external_files(md_before_content, diag)?; + let ih = load_external_files(in_header, dcx)?; + let bc = load_external_files(before_content, dcx)?; + let m_bc = load_external_files(md_before_content, dcx)?; let bc = format!( "{bc}{}", Markdown { @@ -51,8 +51,8 @@ impl ExternalHtml { } .into_string() ); - let ac = load_external_files(after_content, diag)?; - let m_ac = load_external_files(md_after_content, diag)?; + let ac = load_external_files(after_content, dcx)?; + let m_ac = load_external_files(md_after_content, dcx)?; let ac = format!( "{ac}{}", Markdown { @@ -79,13 +79,13 @@ pub(crate) enum LoadStringError { pub(crate) fn load_string>( file_path: P, - diag: &rustc_errors::Handler, + dcx: &rustc_errors::DiagCtxt, ) -> Result { let file_path = file_path.as_ref(); let contents = match fs::read(file_path) { Ok(bytes) => bytes, Err(e) => { - diag.struct_err(format!( + dcx.struct_err(format!( "error reading `{file_path}`: {e}", file_path = file_path.display() )) @@ -96,16 +96,16 @@ pub(crate) fn load_string>( match str::from_utf8(&contents) { Ok(s) => Ok(s.to_string()), Err(_) => { - diag.struct_err(format!("error reading `{}`: not UTF-8", file_path.display())).emit(); + dcx.struct_err(format!("error reading `{}`: not UTF-8", file_path.display())).emit(); Err(LoadStringError::BadUtf8) } } } -fn load_external_files(names: &[String], diag: &rustc_errors::Handler) -> Option { +fn load_external_files(names: &[String], dcx: &rustc_errors::DiagCtxt) -> Option { let mut out = String::new(); for name in names { - let Ok(s) = load_string(name, diag) else { return None }; + let Ok(s) = load_string(name, dcx) else { return None }; out.push_str(&s); out.push('\n'); } -- cgit v1.2.3