Skip to content

Commit c073668

Browse files
committed
First pass at trying to improve error message
1 parent 4fd3181 commit c073668

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/librustdoc/core.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,23 @@ pub(crate) fn run_global_ctxt(
403403
{}/rustdoc/how-to-write-documentation.html",
404404
crate::DOC_RUST_LANG_ORG_VERSION
405405
);
406+
407+
let krate_name = if let Some(name) = krate.module.inner.name {
408+
format!("`{}`'s", name.as_str())
409+
} else {
410+
"this crate's".to_string()
411+
};
412+
let span = tcx.def_span(krate.module.item_id.as_local_def_id().unwrap());
413+
406414
tcx.node_lint(
407415
crate::lint::MISSING_CRATE_LEVEL_DOCS,
408416
DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(),
409417
|lint| {
410-
lint.primary_message("no documentation found for this crate's top-level module");
418+
lint.span(span);
419+
lint.primary_message(format!(
420+
"no documentation found for {} top-level module",
421+
krate_name
422+
));
411423
lint.help(help);
412424
},
413425
);

0 commit comments

Comments
 (0)