diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /src/librustdoc/core.rs | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-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/core.rs')
-rw-r--r-- | src/librustdoc/core.rs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 6d9f8b820..4e904ffd7 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -107,12 +107,12 @@ impl<'tcx> DocContext<'tcx> { r } - /// Like `hir().local_def_id_to_hir_id()`, but skips calling it on fake DefIds. + /// Like `tcx.local_def_id_to_hir_id()`, but skips calling it on fake DefIds. /// (This avoids a slice-index-out-of-bounds panic.) pub(crate) fn as_local_hir_id(tcx: TyCtxt<'_>, item_id: ItemId) -> Option<HirId> { match item_id { ItemId::DefId(real_id) => { - real_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id)) + real_id.as_local().map(|def_id| tcx.local_def_id_to_hir_id(def_id)) } // FIXME: Can this be `Some` for `Auto` or `Blanket`? _ => None, @@ -120,16 +120,16 @@ impl<'tcx> DocContext<'tcx> { } } -/// Creates a new diagnostic `Handler` that can be used to emit warnings and errors. +/// Creates a new `DiagCtxt` that can be used to emit warnings and errors. /// /// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one -/// will be created for the handler. -pub(crate) fn new_handler( +/// will be created for the `DiagCtxt`. +pub(crate) fn new_dcx( error_format: ErrorOutputType, source_map: Option<Lrc<source_map::SourceMap>>, diagnostic_width: Option<usize>, unstable_opts: &UnstableOptions, -) -> rustc_errors::Handler { +) -> rustc_errors::DiagCtxt { let fallback_bundle = rustc_errors::fallback_fluent_bundle( rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false, @@ -169,8 +169,7 @@ pub(crate) fn new_handler( } }; - rustc_errors::Handler::with_emitter(emitter) - .with_flags(unstable_opts.diagnostic_handler_flags(true)) + rustc_errors::DiagCtxt::with_emitter(emitter).with_flags(unstable_opts.dcx_flags(true)) } /// Parse, resolve, and typecheck the given crate. @@ -380,13 +379,15 @@ pub(crate) fn run_global_ctxt( crate::lint::MISSING_CRATE_LEVEL_DOCS, DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(), "no documentation found for this crate's top-level module", - |lint| lint.help(help), + |lint| { + lint.help(help); + }, ); } - fn report_deprecated_attr(name: &str, diag: &rustc_errors::Handler, sp: Span) { + fn report_deprecated_attr(name: &str, dcx: &rustc_errors::DiagCtxt, sp: Span) { let mut msg = - diag.struct_span_warn(sp, format!("the `#![doc({name})]` attribute is deprecated")); + dcx.struct_span_warn(sp, format!("the `#![doc({name})]` attribute is deprecated")); msg.note( "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \ for more information", @@ -406,19 +407,19 @@ pub(crate) fn run_global_ctxt( // Process all of the crate attributes, extracting plugin metadata along // with the passes which we are supposed to run. for attr in krate.module.attrs.lists(sym::doc) { - let diag = ctxt.sess().diagnostic(); + let dcx = ctxt.sess().dcx(); let name = attr.name_or_empty(); // `plugins = "..."`, `no_default_passes`, and `passes = "..."` have no effect if attr.is_word() && name == sym::no_default_passes { - report_deprecated_attr("no_default_passes", diag, attr.span()); + report_deprecated_attr("no_default_passes", dcx, attr.span()); } else if attr.value_str().is_some() { match name { sym::passes => { - report_deprecated_attr("passes = \"...\"", diag, attr.span()); + report_deprecated_attr("passes = \"...\"", dcx, attr.span()); } sym::plugins => { - report_deprecated_attr("plugins = \"...\"", diag, attr.span()); + report_deprecated_attr("plugins = \"...\"", dcx, attr.span()); } _ => (), } @@ -446,7 +447,7 @@ pub(crate) fn run_global_ctxt( tcx.sess.time("check_lint_expectations", || tcx.check_expectations(Some(sym::rustdoc))); - if tcx.sess.diagnostic().has_errors_or_lint_errors().is_some() { + if tcx.sess.dcx().has_errors_or_lint_errors().is_some() { rustc_errors::FatalError.raise(); } |