1
Fork 0

Rollup merge of #115478 - gurry:115462-exprfield-no-warn, r=compiler-errors

Emit unused doc comment warnings for pat and expr fields

Fixes #115462
This commit is contained in:
Guillaume Gomez 2023-09-03 15:42:11 +02:00 committed by GitHub
commit 3db7fc1481
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 6 deletions

View file

@ -1001,8 +1001,22 @@ impl EarlyLintPass for UnusedDocComment {
warn_if_doc(cx, arm_span, "match arms", &arm.attrs);
}
fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat) {
if let ast::PatKind::Struct(_, _, fields, _) = &pat.kind {
for field in fields {
warn_if_doc(cx, field.span, "pattern fields", &field.attrs);
}
}
}
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
warn_if_doc(cx, expr.span, "expressions", &expr.attrs);
if let ExprKind::Struct(s) = &expr.kind {
for field in &s.fields {
warn_if_doc(cx, field.span, "expression fields", &field.attrs);
}
}
}
fn check_generic_param(&mut self, cx: &EarlyContext<'_>, param: &ast::GenericParam) {

View file

@ -555,8 +555,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
subpattern: pattern,
ascription: Ascription {
annotation,
/// Note that use `Contravariant` here. See the
/// `variance` field documentation for details.
// Note that use `Contravariant` here. See the
// `variance` field documentation for details.
variance: ty::Variance::Contravariant,
},
},