@@ -249,6 +249,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
249
249
let missing_docs = rustc_lint:: builtin:: MISSING_DOCS . name ;
250
250
let missing_doc_example = rustc_lint:: builtin:: MISSING_DOC_CODE_EXAMPLES . name ;
251
251
let private_doc_tests = rustc_lint:: builtin:: PRIVATE_DOC_TESTS . name ;
252
+ let no_crate_level_docs = rustc_lint:: builtin:: MISSING_CRATE_LEVEL_DOCS . name ;
252
253
253
254
// In addition to those specific lints, we also need to whitelist those given through
254
255
// command line, otherwise they'll get ignored and we don't want that.
@@ -258,6 +259,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
258
259
missing_docs. to_owned( ) ,
259
260
missing_doc_example. to_owned( ) ,
260
261
private_doc_tests. to_owned( ) ,
262
+ no_crate_level_docs. to_owned( ) ,
261
263
] ;
262
264
263
265
whitelisted_lints. extend ( lint_opts. iter ( ) . map ( |( lint, _) | lint) . cloned ( ) ) ;
@@ -411,10 +413,28 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
411
413
412
414
let mut krate = clean:: krate ( & mut ctxt) ;
413
415
416
+ if let Some ( ref m) = krate. module {
417
+ if let None | Some ( "" ) = m. doc_value ( ) {
418
+ let help = "The following guide may be of use:\n \
419
+ https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation\
420
+ .html";
421
+ tcx. struct_lint_node (
422
+ rustc_lint:: builtin:: MISSING_CRATE_LEVEL_DOCS ,
423
+ ctxt. as_local_hir_id ( m. def_id ) . unwrap ( ) ,
424
+ |lint| {
425
+ let mut diag = lint. build (
426
+ "no documentation found for this crate's top-level module" ,
427
+ ) ;
428
+ diag. help ( help) ;
429
+ diag. emit ( ) ;
430
+ } ,
431
+ ) ;
432
+ }
433
+ }
434
+
414
435
fn report_deprecated_attr ( name : & str , diag : & rustc_errors:: Handler ) {
415
436
let mut msg = diag. struct_warn ( & format ! (
416
- "the `#![doc({})]` attribute is \
417
- considered deprecated",
437
+ "the `#![doc({})]` attribute is considered deprecated" ,
418
438
name
419
439
) ) ;
420
440
msg. warn (
0 commit comments