You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PatField and ExprField produce no warning for #[doc(...)] attribute #115462
structX{foo:i32,}#[allow(unused_variables)]// Not necessary for reproducing. Just to suppress an unrelated warningfnmain(){letX{#[doc(alias = "PatFieldAlias")]
foo
} = X{foo:123};let _ = X{#[doc(alias = "ExprFieldAlias")]foo:123,};}
Current output
No output (compilation succeeds without warning)
Desired output
warning: unused doc comment
|
14 |let X {
15 |#[doc(alias = "PatFieldAlias")]| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 | / foo
17 || } = X {
18 || foo: 123
19 || };||______- rustdoc does not generate documentation for pattern fields
|
= help: use `//`for a plain comment
= note: `#[warn(unused_doc_comments)]` on by default
warning: unused doc comment
|
22 |let _ = X {
23 |#[doc(alias = "ExprFieldAlias")]| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24 | / foo: 123,
25 || };||______- rustdoc does not generate documentation for expression fields
|
= help: use `//`for a plain comment
= note: `#[warn(unused_doc_comments)]` on by default
Rationale and extra context
The same warning is produced at other places like statements, expressions, functions etc. For completeness and consistency it should be produced for pattern and expression fields too.
The reason these warnings are not produced is because the lint infrastructure currently exposes no hooks for PatField and ExprField, i.e. there are no check_pat_field and check_expr_field methods on EarlyLintPass (or LateLintPass for that matter).
To fix the issue, these methods may have to be added here:
Alternatively, we can emit the warning from the already existing check_pat and check_expr methods of EarlyLintPass and not bother with the above changes at all.
Alternatively, we can emit the warning from the already existing check_pat and check_expr methods of EarlyLintPass and not bother with the above changes at all.
Yeah, I would expect this is the best way of doing it.
Activity
gurry commentedon Sep 2, 2023
The reason these warnings are not produced is because the lint infrastructure currently exposes no hooks for
PatFieldandExprField, i.e. there are nocheck_pat_fieldandcheck_expr_fieldmethods onEarlyLintPass(orLateLintPassfor that matter).To fix the issue, these methods may have to be added here:
rust/compiler/rustc_lint/src/passes.rs
Line 140 in f9ba43c
and then invoked from here:
rust/compiler/rustc_lint/src/early.rs
Lines 113 to 117 in f9ba43c
and here:
rust/compiler/rustc_lint/src/early.rs
Lines 131 to 135 in f9ba43c
Alternatively, we can emit the warning from the already existing
check_patandcheck_exprmethods ofEarlyLintPassand not bother with the above changes at all.compiler-errors commentedon Sep 2, 2023
Yeah, I would expect this is the best way of doing it.
gurry commentedon Sep 2, 2023
@rustbot claim
gurry commentedon Sep 2, 2023
@rustbot label -needs-triage
Rollup merge of rust-lang#115478 - gurry:115462-exprfield-no-warn, r=…