Emit a warning on generic parameters with doc comments
This commit is contained in:
parent
207c80f105
commit
bd894a0877
3 changed files with 16 additions and 1 deletions
|
@ -1079,6 +1079,10 @@ impl EarlyLintPass for UnusedDocComment {
|
||||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
|
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
|
||||||
warn_if_doc(cx, expr.span, "expressions", &expr.attrs);
|
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! {
|
declare_lint! {
|
||||||
|
|
|
@ -26,4 +26,7 @@ fn doc_comment_on_expr(num: u8) -> bool {
|
||||||
num == 3
|
num == 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
|
||||||
|
//~^ ERROR: unused doc comment
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -41,6 +41,14 @@ LL | num == 3
|
||||||
|
|
|
|
||||||
= help: use `//` for a plain comment
|
= 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
|
error[E0308]: mismatched types
|
||||||
--> $DIR/unused-doc-comments-edge-cases.rs:14:9
|
--> $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;
|
LL | return true;
|
||||||
| ++++++ +
|
| ++++++ +
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0658.
|
Some errors have detailed explanations: E0308, E0658.
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
For more information about an error, try `rustc --explain E0308`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue