]> git.lizzy.rs Git - rust.git/commitdiff
Add warning if a resolution failed
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 31 Mar 2018 12:49:56 +0000 (14:49 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 16 Apr 2018 21:33:43 +0000 (23:33 +0200)
src/bootstrap/test.rs
src/librustdoc/clean/mod.rs

index 29c8cd1568a39a0db6af388a44ffd24d4ecd7029..e7610976f8e35a2eee09d4470a2c3022669151a9 100644 (file)
@@ -514,6 +514,41 @@ fn run(self, builder: &Builder) {
     }
 }
 
+#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+pub struct RustdocUi {
+    pub host: Interned<String>,
+    pub target: Interned<String>,
+    pub compiler: Compiler,
+}
+
+impl Step for RustdocUi {
+    type Output = ();
+    const DEFAULT: bool = true;
+    const ONLY_HOSTS: bool = true;
+
+    fn should_run(run: ShouldRun) -> ShouldRun {
+        run.path("src/test/rustdoc-ui")
+    }
+
+    fn make_run(run: RunConfig) {
+        let compiler = run.builder.compiler(run.builder.top_stage, run.host);
+        run.builder.ensure(RustdocUi {
+            host: run.host,
+            target: run.target,
+            compiler,
+        });
+    }
+
+    fn run(self, builder: &Builder) {
+        builder.ensure(Compiletest {
+            compiler: self.compiler,
+            target: self.target,
+            mode: "ui",
+            suite: "rustdoc-ui",
+        })
+    }
+}
+
 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
 pub struct Tidy;
 
index da8085d84c3f6729d8cda184f862d1a52b20147b..443caa7618d7414f81896fe56e01cacb021d3d94 100644 (file)
@@ -1178,6 +1178,10 @@ enum PathKind {
     Type,
 }
 
+fn resolution_failure(cx: &DocContext, path_str: &str) {
+    cx.sess().warn(&format!("[{}] cannot be resolved, ignoring it...", path_str));
+}
+
 impl Clean<Attributes> for [ast::Attribute] {
     fn clean(&self, cx: &DocContext) -> Attributes {
         let mut attrs = Attributes::from_ast(cx.sess().diagnostic(), self);
@@ -1228,6 +1232,7 @@ fn clean(&self, cx: &DocContext) -> Attributes {
                             if let Ok(def) = resolve(cx, path_str, true) {
                                 def
                             } else {
+                                resolution_failure(cx, path_str);
                                 // this could just be a normal link or a broken link
                                 // we could potentially check if something is
                                 // "intra-doc-link-like" and warn in that case
@@ -1238,6 +1243,7 @@ fn clean(&self, cx: &DocContext) -> Attributes {
                             if let Ok(def) = resolve(cx, path_str, false) {
                                 def
                             } else {
+                                resolution_failure(cx, path_str);
                                 // this could just be a normal link
                                 continue;
                             }
@@ -1282,6 +1288,7 @@ fn clean(&self, cx: &DocContext) -> Attributes {
                             } else if let Ok(value_def) = resolve(cx, path_str, true) {
                                 value_def
                             } else {
+                                resolution_failure(cx, path_str);
                                 // this could just be a normal link
                                 continue;
                             }
@@ -1290,6 +1297,7 @@ fn clean(&self, cx: &DocContext) -> Attributes {
                             if let Some(def) = macro_resolve(cx, path_str) {
                                 (def, None)
                             } else {
+                                resolution_failure(cx, path_str);
                                 continue
                             }
                         }