summaryrefslogtreecommitdiffstats
path: root/src/librustdoc/scrape_examples.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /src/librustdoc/scrape_examples.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librustdoc/scrape_examples.rs')
-rw-r--r--src/librustdoc/scrape_examples.rs17
1 files changed, 9 insertions, 8 deletions
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<Option<Self>, 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<String>,
- diag: &rustc_errors::Handler,
+ dcx: &rustc_errors::DiagCtxt,
) -> Result<AllCallLocations, i32> {
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
})
}