about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2019-11-27 13:15:16 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2019-11-27 14:28:20 +0100
commit97c427cc5ee8d1748ff3a3547bd22cd64d23a6e2 (patch)
tree88ef4a26f8626b304e13b38312f114835c74bde9 /src/librustdoc
parentb91a6fcd5d82da723d7af1bf6790fd93a7741e93 (diff)
downloadrust-97c427cc5ee8d1748ff3a3547bd22cd64d23a6e2.tar.gz
rust-97c427cc5ee8d1748ff3a3547bd22cd64d23a6e2.zip
Use new ErrorKind enum
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index 3c632462168..d8f2dbca835 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -61,12 +61,18 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
         path_str: &str,
         current_item: &Option<String>,
         module_id: syntax::ast::NodeId,
-    ) -> Result<(Res, Option<String>), ()> {
+    ) -> Result<(Res, Option<String>), ErrorKind> {
         let cx = self.cx;
 
         let mut split = path_str.rsplitn(3, "::");
-        let variant_field_name = split.next().map(|f| Symbol::intern(f)).ok_or(())?;
-        let variant_name = split.next().map(|f| Symbol::intern(f)).ok_or(())?;
+        let variant_field_name = split
+            .next()
+            .map(|f| Symbol::intern(f))
+            .ok_or(ErrorKind::ResolutionFailure)?;
+        let variant_name = split
+            .next()
+            .map(|f| Symbol::intern(f))
+            .ok_or(ErrorKind::ResolutionFailure)?;
         let path = split.next().map(|f| {
             if f == "self" || f == "Self" {
                 if let Some(name) = current_item.as_ref() {
@@ -74,12 +80,12 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
                 }
             }
             f.to_owned()
-        }).ok_or(())?;
+        }).ok_or(ErrorKind::ResolutionFailure)?;
         let (_, ty_res) = cx.enter_resolver(|resolver| {
             resolver.resolve_str_path_error(DUMMY_SP, &path, TypeNS, module_id)
-        })?;
+        }).map_err(|_| ErrorKind::ResolutionFailure)?;
         if let Res::Err = ty_res {
-            return Err(());
+            return Err(ErrorKind::ResolutionFailure);
         }
         let ty_res = ty_res.map_id(|_| panic!("unexpected node_id"));
         match ty_res {
@@ -88,7 +94,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
                          .iter()
                          .flat_map(|imp| cx.tcx.associated_items(*imp))
                          .any(|item| item.ident.name == variant_name) {
-                    return Err(());
+                    return Err(ErrorKind::ResolutionFailure);
                 }
                 match cx.tcx.type_of(did).kind {
                     ty::Adt(def, _) if def.is_enum() => {
@@ -98,13 +104,13 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
                                 Some(format!("variant.{}.field.{}",
                                              variant_name, variant_field_name))))
                         } else {
-                            Err(())
+                            Err(ErrorKind::ResolutionFailure)
                         }
                     }
-                    _ => Err(()),
+                    _ => Err(ErrorKind::ResolutionFailure),
                 }
             }
-            _ => Err(())
+            _ => Err(ErrorKind::ResolutionFailure)
         }
     }