Skip to content

Commit 950634d

Browse files
committed
rustdoc: never try to link to unnamable types
1 parent 73efff4 commit 950634d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/librustdoc/html/format.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ pub(crate) enum HrefError {
367367
Private,
368368
// Not in external cache, href link should be in same page
369369
NotInExternalCache,
370+
/// Refers to an unnamable item, such as one defined within a function or const block.
371+
UnnamableItem,
370372
}
371373

372374
// Panics if `syms` is empty.
@@ -509,7 +511,13 @@ fn url_parts(
509511
builder.extend(module_fqp.iter().copied());
510512
Ok(builder)
511513
}
512-
ExternalLocation::Local => Ok(href_relative_parts(module_fqp, relative_to)),
514+
ExternalLocation::Local => {
515+
if module_fqp.iter().any(|sym| sym.as_str() == "_") {
516+
Err(HrefError::UnnamableItem)
517+
} else {
518+
Ok(href_relative_parts(module_fqp, relative_to))
519+
}
520+
}
513521
ExternalLocation::Unknown => Err(HrefError::DocumentationNotBuilt),
514522
}
515523
}

0 commit comments

Comments
 (0)