Skip to content

Commit afb5b21

Browse files
committed
review - better error names/doc
1 parent fc97fbe commit afb5b21

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/librustdoc/html/format.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,12 @@ impl clean::GenericArgs {
474474

475475
// Possible errors when computing href link source for a `DefId`
476476
crate enum HrefError {
477-
// `DefId` is in an unknown location. This seems to happen when building without dependencies
478-
// but a trait from a dependency is still visible
479-
UnknownLocation,
480-
// Unavailable because private
481-
Unavailable,
477+
/// This item is known to rustdoc, but from a crate that does not have documentation generated.
478+
///
479+
/// This can only happen for non-local items.
480+
DocumentationNotBuilt,
481+
/// This can only happen for non-local items when `--document-private-items` is not passed.
482+
Private,
482483
// Not in external cache, href link should be in same page
483484
NotInExternalCache,
484485
}
@@ -491,7 +492,7 @@ crate fn href(did: DefId, cx: &Context<'_>) -> Result<(String, ItemType, Vec<Str
491492
}
492493

493494
if !did.is_local() && !cache.access_levels.is_public(did) && !cache.document_private {
494-
return Err(HrefError::Unavailable);
495+
return Err(HrefError::Private);
495496
}
496497

497498
let (fqp, shortty, mut url_parts) = match cache.paths.get(&did) {
@@ -513,7 +514,7 @@ crate fn href(did: DefId, cx: &Context<'_>) -> Result<(String, ItemType, Vec<Str
513514
s
514515
}
515516
ExternalLocation::Local => href_relative_parts(module_fqp, relative_to),
516-
ExternalLocation::Unknown => return Err(HrefError::UnknownLocation),
517+
ExternalLocation::Unknown => return Err(HrefError::DocumentationNotBuilt),
517518
},
518519
)
519520
} else {

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ fn render_assoc_item(
869869

870870
match href(did.expect_def_id(), cx) {
871871
Ok(p) => Some(format!("{}#{}.{}", p.0, ty, name)),
872-
Err(HrefError::UnknownLocation) => None,
872+
Err(HrefError::DocumentationNotBuilt) => None,
873873
Err(_) => Some(format!("#{}.{}", ty, name)),
874874
}
875875
}

0 commit comments

Comments
 (0)