From ebc8cb470fd137214911fa317ff6b06c6683ad3c Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 21 Aug 2020 15:19:47 -0400 Subject: [PATCH] Turn NoParentItem from a panic into an ICE --- src/librustdoc/passes/collect_intra_doc_links.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 9a88c8eb42a..a859d1b2f5f 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -541,7 +541,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { }) } else { debug!("attempting to resolve item without parent module: {}", path_str); - // TODO: maybe this should just be an ICE? Err(ErrorKind::Resolve(ResolutionFailure::NoParentItem)) } } @@ -1462,7 +1461,8 @@ fn resolution_failure( } } ResolutionFailure::NoParentItem => { - panic!("all intra doc links should have a parent item") + diag.level = rustc_errors::Level::Bug; + diag.note("all intra doc links should have a parent item"); } ResolutionFailure::NoPrimitiveImpl(res, _) => { let note = format!( @@ -1694,7 +1694,6 @@ fn handle_variant( let parent = if let Some(parent) = cx.tcx.parent(res.def_id()) { parent } else { - // TODO: this should just be an unwrap, there should never be `Variant`s without a parent return Err(ErrorKind::Resolve(ResolutionFailure::NoParentItem)); }; let parent_def = Res::Def(DefKind::Enum, parent);