Skip to content

Commit dc1a03b

Browse files
authored
Rollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebank
Unused doc comments blocks Fixes #77030.
2 parents f90307c + 6f0eb2a commit dc1a03b

File tree

6 files changed

+58
-7
lines changed

6 files changed

+58
-7
lines changed

Diff for: compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,12 @@ pub enum PassKind {
576576
Module,
577577
}
578578

579-
/// LLVMRustThinLTOData
579+
// LLVMRustThinLTOData
580580
extern "C" {
581581
pub type ThinLTOData;
582582
}
583583

584-
/// LLVMRustThinLTOBuffer
584+
// LLVMRustThinLTOBuffer
585585
extern "C" {
586586
pub type ThinLTOBuffer;
587587
}

Diff for: compiler/rustc_lint/src/builtin.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,16 @@ impl EarlyLintPass for UnusedDocComment {
10861086
fn check_generic_param(&mut self, cx: &EarlyContext<'_>, param: &ast::GenericParam) {
10871087
warn_if_doc(cx, param.ident.span, "generic parameters", &param.attrs);
10881088
}
1089+
1090+
fn check_block(&mut self, cx: &EarlyContext<'_>, block: &ast::Block) {
1091+
warn_if_doc(cx, block.span, "block", &block.attrs());
1092+
}
1093+
1094+
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
1095+
if let ast::ItemKind::ForeignMod(_) = item.kind {
1096+
warn_if_doc(cx, item.span, "extern block", &item.attrs);
1097+
}
1098+
}
10891099
}
10901100

10911101
declare_lint! {

Diff for: library/portable-simd/crates/core_simd/src/intrinsics.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
//!
1919
//! Unless stated otherwise, all intrinsics for binary operations require SIMD vectors of equal types and lengths.
2020
21-
/// These intrinsics aren't linked directly from LLVM and are mostly undocumented, however they are
22-
/// mostly lowered to the matching LLVM instructions by the compiler in a fairly straightforward manner.
23-
/// The associated LLVM instruction or intrinsic is documented alongside each Rust intrinsic function.
21+
22+
// These intrinsics aren't linked directly from LLVM and are mostly undocumented, however they are
23+
// mostly lowered to the matching LLVM instructions by the compiler in a fairly straightforward manner.
24+
// The associated LLVM instruction or intrinsic is documented alongside each Rust intrinsic function.
2425
extern "platform-intrinsic" {
2526
/// add/fadd
2627
pub(crate) fn simd_add<T>(x: T, y: T) -> T;

Diff for: src/test/ui/lint/unused/unused-doc-comments-edge-cases.rs

+14
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,18 @@ fn doc_comment_on_expr(num: u8) -> bool {
2929
fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
3030
//~^ ERROR: unused doc comment
3131

32+
fn doc_comment_on_block() {
33+
/// unused doc comment
34+
//~^ ERROR: unused doc comment
35+
{
36+
let x = 12;
37+
}
38+
}
39+
40+
/// unused doc comment
41+
//~^ ERROR: unused doc comment
42+
extern "C" {
43+
fn foo();
44+
}
45+
3246
fn main() {}

Diff for: src/test/ui/lint/unused/unused-doc-comments-edge-cases.stderr

+27-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,32 @@ LL | fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
4949
|
5050
= help: use `//` for a plain comment
5151

52+
error: unused doc comment
53+
--> $DIR/unused-doc-comments-edge-cases.rs:33:5
54+
|
55+
LL | /// unused doc comment
56+
| ^^^^^^^^^^^^^^^^^^^^^^
57+
LL |
58+
LL | / {
59+
LL | | let x = 12;
60+
LL | | }
61+
| |_____- rustdoc does not generate documentation for expressions
62+
|
63+
= help: use `//` for a plain comment
64+
65+
error: unused doc comment
66+
--> $DIR/unused-doc-comments-edge-cases.rs:40:1
67+
|
68+
LL | /// unused doc comment
69+
| ^^^^^^^^^^^^^^^^^^^^^^
70+
LL |
71+
LL | / extern "C" {
72+
LL | | fn foo();
73+
LL | | }
74+
| |_- rustdoc does not generate documentation for extern block
75+
|
76+
= help: use `//` for a plain comment
77+
5278
error[E0308]: mismatched types
5379
--> $DIR/unused-doc-comments-edge-cases.rs:14:9
5480
|
@@ -63,7 +89,7 @@ help: you might have meant to return this value
6389
LL | return true;
6490
| ++++++ +
6591

66-
error: aborting due to 6 previous errors
92+
error: aborting due to 8 previous errors
6793

6894
Some errors have detailed explanations: E0308, E0658.
6995
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)