From 018c4950b9406055dec02ef0fb52f132e2bb1e2c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 19 Jun 2024 11:25:56 +0200 Subject: Merging upstream version 1.76.0+dfsg1. Signed-off-by: Daniel Baumann --- src/librustdoc/scrape_examples.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/librustdoc/scrape_examples.rs') diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs index dd52deef6..a343d7afc 100644 --- a/src/librustdoc/scrape_examples.rs +++ b/src/librustdoc/scrape_examples.rs @@ -40,7 +40,7 @@ pub(crate) struct ScrapeExamplesOptions { impl ScrapeExamplesOptions { pub(crate) fn new( matches: &getopts::Matches, - diag: &rustc_errors::Handler, + dcx: &rustc_errors::DiagCtxt, ) -> Result, i32> { let output_path = matches.opt_str("scrape-examples-output-path"); let target_crates = matches.opt_strs("scrape-examples-target-crate"); @@ -52,11 +52,11 @@ impl ScrapeExamplesOptions { scrape_tests, })), (Some(_), false, _) | (None, true, _) => { - diag.err("must use --scrape-examples-output-path and --scrape-examples-target-crate together"); + dcx.err("must use --scrape-examples-output-path and --scrape-examples-target-crate together"); Err(1) } (None, false, true) => { - diag.err("must use --scrape-examples-output-path and --scrape-examples-target-crate with --scrape-tests"); + dcx.err("must use --scrape-examples-output-path and --scrape-examples-target-crate with --scrape-tests"); Err(1) } (None, false, false) => Ok(None), @@ -311,7 +311,7 @@ pub(crate) fn run( // The visitor might have found a type error, which we need to // promote to a fatal error - if tcx.sess.diagnostic().has_errors_or_lint_errors().is_some() { + if tcx.sess.dcx().has_errors_or_lint_errors().is_some() { return Err(String::from("Compilation failed, aborting rustdoc")); } @@ -325,7 +325,7 @@ pub(crate) fn run( // Save output to provided path let mut encoder = FileEncoder::new(options.output_path).map_err(|e| e.to_string())?; calls.encode(&mut encoder); - encoder.finish().map_err(|e| e.to_string())?; + encoder.finish().map_err(|(_path, e)| e.to_string())?; Ok(()) }; @@ -337,10 +337,11 @@ pub(crate) fn run( Ok(()) } -// Note: the Handler must be passed in explicitly because sess isn't available while parsing options +// Note: the DiagCtxt must be passed in explicitly because sess isn't available while parsing +// options. pub(crate) fn load_call_locations( with_examples: Vec, - diag: &rustc_errors::Handler, + dcx: &rustc_errors::DiagCtxt, ) -> Result { let inner = || { let mut all_calls: AllCallLocations = FxHashMap::default(); @@ -358,7 +359,7 @@ pub(crate) fn load_call_locations( }; inner().map_err(|e: String| { - diag.err(format!("failed to load examples: {e}")); + dcx.err(format!("failed to load examples: {e}")); 1 }) } -- cgit v1.2.3