Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ pub(crate) fn run_global_ctxt(
crate::lint::MISSING_CRATE_LEVEL_DOCS,
DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(),
|lint| {
if let Some(local_def_id) = krate.module.item_id.as_local_def_id() {
lint.span(tcx.def_span(local_def_id));
}
lint.primary_message("no documentation found for this crate's top-level module");
lint.help(help);
},
Expand Down
4 changes: 1 addition & 3 deletions tests/rustdoc-ui/lints/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@ compile-flags: -Z unstable-options --check
//@ normalize-stderr: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL"

#![feature(rustdoc_missing_doc_code_examples)]
#![feature(rustdoc_missing_doc_code_examples)] //~ WARN no documentation found for this crate's top-level module
//~^ WARN

#![warn(missing_docs)]
Expand All @@ -12,5 +12,3 @@
pub fn foo() {}
//~^ WARN
//~^^ WARN

//~? WARN no documentation found for this crate's top-level module
9 changes: 9 additions & 0 deletions tests/rustdoc-ui/lints/check.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ LL | pub fn foo() {}
| ^^^^^^^^^^^^

warning: no documentation found for this crate's top-level module
--> $DIR/check.rs:5:1
|
LL | / #![feature(rustdoc_missing_doc_code_examples)]
LL | |
LL | |
LL | | #![warn(missing_docs)]
... |
LL | | pub fn foo() {}
| |_______________^
|
= help: The following guide may be of use:
https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html
Expand Down
4 changes: 1 addition & 3 deletions tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ normalize-stderr: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL"
#![deny(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::missing_crate_level_docs)] //~ ERROR no documentation found for this crate's top-level module
//^~ NOTE defined here

pub fn foo() {}

//~? ERROR no documentation found for this crate's top-level module
6 changes: 6 additions & 0 deletions tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
error: no documentation found for this crate's top-level module
--> $DIR/no-crate-level-doc-lint.rs:2:1
|
LL | / #![deny(rustdoc::missing_crate_level_docs)]
... |
LL | | pub fn foo() {}
| |_______________^
|
= help: The following guide may be of use:
https://doc.rust-lang.org/$CHANNEL/rustdoc/how-to-write-documentation.html
Expand Down
Loading