Skip to content

Commit

Permalink
Don't panic when scraping invalid calls
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Mar 28, 2022
1 parent d1416d5 commit b9ecdca
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/librustdoc/scrape_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,22 @@ where
return;
}

assert!(
enclosing_item_span.contains(call_span),
"Attempted to scrape call at [{call_span:?}] whose enclosing item [{enclosing_item_span:?}] doesn't contain the span of the call.",
);

assert!(
call_span.contains(ident_span),
"Attempted to scrape call at [{call_span:?}] whose identifier [{ident_span:?}] was not contained in the span of the call."
);
// If the enclosing item doesn't actually enclose the call, this means we probably have a weird
// macro issue even though the spans aren't tagged as being from an expansion.
if !enclosing_item_span.contains(call_span) {
warn!(
"Attempted to scrape call at [{call_span:?}] whose enclosing item [{enclosing_item_span:?}] doesn't contain the span of the call."
);
return;
}

// Similarly for the call w/ the function ident.
if !call_span.contains(ident_span) {
warn!(
"Attempted to scrape call at [{call_span:?}] whose identifier [{ident_span:?}] was not contained in the span of the call."
);
return;
}

// Save call site if the function resolves to a concrete definition
if let ty::FnDef(def_id, _) = ty.kind() {
Expand Down

0 comments on commit b9ecdca

Please sign in to comment.