From 0cf90ad53c59c73c49742075021204712c9b89f1 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sun, 25 Oct 2020 13:25:49 -0400 Subject: [PATCH 1/2] Lint doc comments on inner items --- compiler/rustc_lint/src/builtin.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index e5f66611d0f9b..a964950f1df1b 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -994,8 +994,7 @@ impl EarlyLintPass for UnusedDocComment { fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) { let kind = match stmt.kind { ast::StmtKind::Local(..) => "statements", - // Disabled pending discussion in #78306 - ast::StmtKind::Item(..) => return, + ast::StmtKind::Item(..) => "inner items", // expressions will be reported by `check_expr`. ast::StmtKind::Empty | ast::StmtKind::Semi(_) From d12ea6eb0d25c954555654aa20a4494fe4807592 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 23 Oct 2020 18:33:59 -0400 Subject: [PATCH 2/2] Convert unused doc comments to regular comments --- compiler/rustc_ast/src/util/comments.rs | 4 +- compiler/rustc_ast_lowering/src/lib.rs | 10 +-- compiler/rustc_errors/src/emitter.rs | 2 +- compiler/rustc_index/src/bit_set.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 20 ++--- compiler/rustc_middle/src/mir/query.rs | 6 +- compiler/rustc_mir/src/interpret/operand.rs | 2 +- .../rustc_mir/src/transform/simplify_try.rs | 10 +-- .../src/thir/pattern/_match.rs | 6 +- .../rustc_parse/src/parser/nonterminal.rs | 2 +- compiler/rustc_passes/src/region.rs | 80 +++++++++---------- compiler/rustc_resolve/src/imports.rs | 2 +- .../src/traits/error_reporting/mod.rs | 4 +- library/alloc/src/collections/vec_deque.rs | 8 +- library/alloc/src/vec.rs | 4 +- library/alloc/tests/vec.rs | 4 +- library/core/src/intrinsics.rs | 3 +- library/core/src/iter/mod.rs | 2 +- library/core/src/mem/maybe_uninit.rs | 2 +- library/core/src/panic.rs | 4 +- library/core/src/ptr/mod.rs | 28 +++---- library/core/src/time.rs | 20 ++--- library/proc_macro/src/bridge/scoped_cell.rs | 6 +- library/std/src/io/buffered/bufwriter.rs | 6 +- library/std/src/keyword_docs.rs | 14 ++-- library/std/src/net/ip.rs | 2 +- library/std/src/net/parser.rs | 10 +-- src/librustdoc/clean/types.rs | 20 ++--- src/librustdoc/html/render/mod.rs | 2 +- 29 files changed, 143 insertions(+), 142 deletions(-) diff --git a/compiler/rustc_ast/src/util/comments.rs b/compiler/rustc_ast/src/util/comments.rs index e97c8cc4562f6..7b47cc5a6982f 100644 --- a/compiler/rustc_ast/src/util/comments.rs +++ b/compiler/rustc_ast/src/util/comments.rs @@ -26,7 +26,7 @@ pub struct Comment { /// Makes a doc string more presentable to users. /// Used by rustdoc and perhaps other tools, but not by rustc. pub fn beautify_doc_string(data: Symbol) -> String { - /// remove whitespace-only lines from the start/end of lines + // remove whitespace-only lines from the start/end of lines fn vertical_trim(lines: Vec) -> Vec { let mut i = 0; let mut j = lines.len(); @@ -50,7 +50,7 @@ pub fn beautify_doc_string(data: Symbol) -> String { lines[i..j].to_vec() } - /// remove a "[ \t]*\*" block from each line, if possible + // remove a "[ \t]*\*" block from each line, if possible fn horizontal_trim(lines: Vec) -> Vec { let mut i = usize::MAX; let mut can_trim = true; diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index a3f046986c014..488fd6dffa3d2 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -419,11 +419,11 @@ impl Visitor<'_> for ImplTraitTypeIdVisitor<'_> { impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_crate(mut self, c: &Crate) -> hir::Crate<'hir> { - /// Full-crate AST visitor that inserts into a fresh - /// `LoweringContext` any information that may be - /// needed from arbitrary locations in the crate, - /// e.g., the number of lifetime generic parameters - /// declared for every type and trait definition. + // Full-crate AST visitor that inserts into a fresh + // `LoweringContext` any information that may be + // needed from arbitrary locations in the crate, + // e.g., the number of lifetime generic parameters + // declared for every type and trait definition. struct MiscCollector<'tcx, 'lowering, 'hir> { lctx: &'tcx mut LoweringContext<'lowering, 'hir>, hir_id_owner: Option, diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index b5155f8e910d7..feff25cbf1bae 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1160,7 +1160,7 @@ impl EmitterWriter { // `max_line_num_len` let padding = " ".repeat(padding + label.len() + 5); - /// Returns `override` if it is present and `style` is `NoStyle` or `style` otherwise + // Returns `override` if it is present and `style` is `NoStyle` or `style` otherwise fn style_or_override(style: Style, override_: Option