Skip to content

Commit 035ec5b

Browse files
Add warning if a resolution failed
1 parent 49317cd commit 035ec5b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/bootstrap/test.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,41 @@ impl Step for RustdocJS {
514514
}
515515
}
516516

517+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
518+
pub struct RustdocUi {
519+
pub host: Interned<String>,
520+
pub target: Interned<String>,
521+
pub compiler: Compiler,
522+
}
523+
524+
impl Step for RustdocUi {
525+
type Output = ();
526+
const DEFAULT: bool = true;
527+
const ONLY_HOSTS: bool = true;
528+
529+
fn should_run(run: ShouldRun) -> ShouldRun {
530+
run.path("src/test/rustdoc-ui")
531+
}
532+
533+
fn make_run(run: RunConfig) {
534+
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
535+
run.builder.ensure(RustdocUi {
536+
host: run.host,
537+
target: run.target,
538+
compiler,
539+
});
540+
}
541+
542+
fn run(self, builder: &Builder) {
543+
builder.ensure(Compiletest {
544+
compiler: self.compiler,
545+
target: self.target,
546+
mode: "ui",
547+
suite: "rustdoc-ui",
548+
})
549+
}
550+
}
551+
517552
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
518553
pub struct Tidy;
519554

src/librustdoc/clean/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,10 @@ enum PathKind {
11781178
Type,
11791179
}
11801180

1181+
fn resolution_failure(cx: &DocContext, path_str: &str) {
1182+
cx.sess().warn(&format!("[{}] cannot be resolved, ignoring it...", path_str));
1183+
}
1184+
11811185
impl Clean<Attributes> for [ast::Attribute] {
11821186
fn clean(&self, cx: &DocContext) -> Attributes {
11831187
let mut attrs = Attributes::from_ast(cx.sess().diagnostic(), self);
@@ -1228,6 +1232,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12281232
if let Ok(def) = resolve(cx, path_str, true) {
12291233
def
12301234
} else {
1235+
resolution_failure(cx, path_str);
12311236
// this could just be a normal link or a broken link
12321237
// we could potentially check if something is
12331238
// "intra-doc-link-like" and warn in that case
@@ -1238,6 +1243,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12381243
if let Ok(def) = resolve(cx, path_str, false) {
12391244
def
12401245
} else {
1246+
resolution_failure(cx, path_str);
12411247
// this could just be a normal link
12421248
continue;
12431249
}
@@ -1282,6 +1288,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12821288
} else if let Ok(value_def) = resolve(cx, path_str, true) {
12831289
value_def
12841290
} else {
1291+
resolution_failure(cx, path_str);
12851292
// this could just be a normal link
12861293
continue;
12871294
}
@@ -1290,6 +1297,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12901297
if let Some(def) = macro_resolve(cx, path_str) {
12911298
(def, None)
12921299
} else {
1300+
resolution_failure(cx, path_str);
12931301
continue
12941302
}
12951303
}

0 commit comments

Comments
 (0)