Skip to content

Commit a342617

Browse files
author
Lukas Markeffsky
committed
improve debuggability
1 parent e0922fb commit a342617

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,13 +2244,12 @@ pub fn provide(providers: &mut Providers) {
22442244
tcx.resolutions(())
22452245
.doc_link_resolutions
22462246
.get(&def_id)
2247-
.expect("no resolutions for a doc link")
2247+
.unwrap_or_else(|| span_bug!(tcx.def_span(def_id), "no resolutions for a doc link"))
22482248
},
22492249
doc_link_traits_in_scope: |tcx, def_id| {
2250-
tcx.resolutions(())
2251-
.doc_link_traits_in_scope
2252-
.get(&def_id)
2253-
.expect("no traits in scope for a doc link")
2250+
tcx.resolutions(()).doc_link_traits_in_scope.get(&def_id).unwrap_or_else(|| {
2251+
span_bug!(tcx.def_span(def_id), "no traits in scope for a doc link")
2252+
})
22542253
},
22552254
traits: |tcx, LocalCrate| {
22562255
let mut traits = Vec::new();

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_hir::def::{DefKind, Namespace, PerNS};
1414
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
1515
use rustc_hir::Mutability;
1616
use rustc_middle::ty::{Ty, TyCtxt};
17-
use rustc_middle::{bug, ty};
17+
use rustc_middle::{bug, span_bug, ty};
1818
use rustc_resolve::rustdoc::{has_primitive_or_keyword_docs, prepare_to_doc_link_resolution};
1919
use rustc_resolve::rustdoc::{strip_generics_from_path, MalformedGenerics};
2020
use rustc_session::lint::Lint;
@@ -402,7 +402,12 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
402402
// `doc_link_resolutions` is missing a `path_str`, that means that there are valid links
403403
// that are being missed. To fix the ICE, change
404404
// `rustc_resolve::rustdoc::attrs_to_preprocessed_links` to cache the link.
405-
.unwrap_or_else(|| panic!("no resolution for {:?} {:?} {:?}", path_str, ns, module_id))
405+
.unwrap_or_else(|| {
406+
span_bug!(
407+
self.cx.tcx.def_span(item_id),
408+
"no resolution for {path_str:?} {ns:?} {module_id:?}",
409+
)
410+
})
406411
.and_then(|res| res.try_into().ok())
407412
.or_else(|| resolve_primitive(path_str, ns));
408413
debug!("{} resolved to {:?} in namespace {:?}", path_str, result, ns);
@@ -963,6 +968,7 @@ fn preprocessed_markdown_links(s: &str) -> Vec<PreprocessedMarkdownLink> {
963968
}
964969

965970
impl LinkCollector<'_, '_> {
971+
#[instrument(level = "debug", skip_all)]
966972
fn resolve_links(&mut self, item: &Item) {
967973
if !self.cx.render_options.document_private
968974
&& let Some(def_id) = item.item_id.as_def_id()

0 commit comments

Comments
 (0)