]> git.lizzy.rs Git - rust.git/commitdiff
review - better error names/doc
authorFrançois Mockers <mockersf@gmail.com>
Sun, 4 Jul 2021 23:33:51 +0000 (01:33 +0200)
committerFrançois Mockers <mockersf@gmail.com>
Tue, 6 Jul 2021 20:13:08 +0000 (22:13 +0200)
src/librustdoc/html/format.rs
src/librustdoc/html/render/mod.rs

index bed4bae2492c667cb7fc5130a03cd486b0536be6..08499cef33ef19cb23564159e605f7408587341c 100644 (file)
@@ -474,11 +474,12 @@ fn print<'a, 'tcx: 'a>(
 
 // Possible errors when computing href link source for a `DefId`
 crate enum HrefError {
-    // `DefId` is in an unknown location. This seems to happen when building without dependencies
-    // but a trait from a dependency is still visible
-    UnknownLocation,
-    // Unavailable because private
-    Unavailable,
+    /// This item is known to rustdoc, but from a crate that does not have documentation generated.
+    ///
+    /// This can only happen for non-local items.
+    DocumentationNotBuilt,
+    /// This can only happen for non-local items when `--document-private-items` is not passed.
+    Private,
     // Not in external cache, href link should be in same page
     NotInExternalCache,
 }
@@ -491,7 +492,7 @@ fn to_module_fqp(shortty: ItemType, fqp: &[String]) -> &[String] {
     }
 
     if !did.is_local() && !cache.access_levels.is_public(did) && !cache.document_private {
-        return Err(HrefError::Unavailable);
+        return Err(HrefError::Private);
     }
 
     let (fqp, shortty, mut url_parts) = match cache.paths.get(&did) {
@@ -513,7 +514,7 @@ fn to_module_fqp(shortty: ItemType, fqp: &[String]) -> &[String] {
                             s
                         }
                         ExternalLocation::Local => href_relative_parts(module_fqp, relative_to),
-                        ExternalLocation::Unknown => return Err(HrefError::UnknownLocation),
+                        ExternalLocation::Unknown => return Err(HrefError::DocumentationNotBuilt),
                     },
                 )
             } else {
index c814ff3075d0594297bda9576718345327ca63c3..e6a10c47497b1d652cb5198c88b302a2467f3874 100644 (file)
@@ -869,7 +869,7 @@ fn method(
 
                 match href(did.expect_def_id(), cx) {
                     Ok(p) => Some(format!("{}#{}.{}", p.0, ty, name)),
-                    Err(HrefError::UnknownLocation) => None,
+                    Err(HrefError::DocumentationNotBuilt) => None,
                     Err(_) => Some(format!("#{}.{}", ty, name)),
                 }
             }