From 035ec5bbb62c2cef64840389508707da5febeb8b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 31 Mar 2018 14:49:56 +0200 Subject: [PATCH] Add warning if a resolution failed --- src/bootstrap/test.rs | 35 +++++++++++++++++++++++++++++++++++ src/librustdoc/clean/mod.rs | 8 ++++++++ 2 files changed, 43 insertions(+) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 29c8cd1568a3..e7610976f8e3 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -514,6 +514,41 @@ impl Step for RustdocJS { } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct RustdocUi { + pub host: Interned, + pub target: Interned, + 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; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index da8085d84c3f..443caa7618d7 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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 for [ast::Attribute] { fn clean(&self, cx: &DocContext) -> Attributes { let mut attrs = Attributes::from_ast(cx.sess().diagnostic(), self); @@ -1228,6 +1232,7 @@ impl Clean for [ast::Attribute] { 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 @@ impl Clean for [ast::Attribute] { 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 @@ impl Clean for [ast::Attribute] { } 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 @@ impl Clean for [ast::Attribute] { if let Some(def) = macro_resolve(cx, path_str) { (def, None) } else { + resolution_failure(cx, path_str); continue } }