diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-11-30 23:43:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-30 23:43:33 +0100 |
| commit | 7baafb1f5eba346a04b54c0501671dd0e1ad8aa4 (patch) | |
| tree | b2ab6d98fbe14974fee2fbc802ce673978b3816f | |
| parent | 2b8259af05fb674263a3f848169336ea66fa9520 (diff) | |
| parent | bd894a08774b1791d8c987d66684f8108f3f336e (diff) | |
| download | rust-7baafb1f5eba346a04b54c0501671dd0e1ad8aa4.tar.gz rust-7baafb1f5eba346a04b54c0501671dd0e1ad8aa4.zip | |
Rollup merge of #91397 - jyn514:generic-param-docs, r=wesleywiser
Emit a warning on generic parameters with doc comments Fixes https://github.com/rust-lang/rust/issues/90610
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/lint/unused/unused-doc-comments-edge-cases.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/lint/unused/unused-doc-comments-edge-cases.stderr | 10 |
3 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index f36b9c82fac..077d3e1c820 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1079,6 +1079,10 @@ impl EarlyLintPass for UnusedDocComment { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) { warn_if_doc(cx, expr.span, "expressions", &expr.attrs); } + + fn check_generic_param(&mut self, cx: &EarlyContext<'_>, param: &ast::GenericParam) { + warn_if_doc(cx, param.ident.span, "generic parameters", ¶m.attrs); + } } declare_lint! { diff --git a/src/test/ui/lint/unused/unused-doc-comments-edge-cases.rs b/src/test/ui/lint/unused/unused-doc-comments-edge-cases.rs index fd9baf8c6b9..258f9e4831f 100644 --- a/src/test/ui/lint/unused/unused-doc-comments-edge-cases.rs +++ b/src/test/ui/lint/unused/unused-doc-comments-edge-cases.rs @@ -26,4 +26,7 @@ fn doc_comment_on_expr(num: u8) -> bool { num == 3 } +fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {} +//~^ ERROR: unused doc comment + fn main() {} diff --git a/src/test/ui/lint/unused/unused-doc-comments-edge-cases.stderr b/src/test/ui/lint/unused/unused-doc-comments-edge-cases.stderr index 403367017c6..3ce1df71a2e 100644 --- a/src/test/ui/lint/unused/unused-doc-comments-edge-cases.stderr +++ b/src/test/ui/lint/unused/unused-doc-comments-edge-cases.stderr @@ -41,6 +41,14 @@ LL | num == 3 | = help: use `//` for a plain comment +error: unused doc comment + --> $DIR/unused-doc-comments-edge-cases.rs:29:27 + | +LL | fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {} + | ^^^^^^^^^^^^ - rustdoc does not generate documentation for generic parameters + | + = help: use `//` for a plain comment + error[E0308]: mismatched types --> $DIR/unused-doc-comments-edge-cases.rs:14:9 | @@ -55,7 +63,7 @@ help: you might have meant to return this value LL | return true; | ++++++ + -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0308, E0658. For more information about an error, try `rustc --explain E0308`. |
