Inconsistent handling of `#[coverage(..)]` attributes that are malformed or misplaced
Zalathar opened this issue · 1 comments
Zalathar commented
(Note: The coverage attribute is currently unstable; see #84605.)
While writing tests for #[coverage(..)] for #84605, I encountered various inconsistencies in diagnostics for using the attribute with incorrect syntax or on inappropriate items.
For example:
- Bare
#[coverage]is silently permitted in various situations, even though it should never be legal.- E.g. on modules, on
implblocks, ontrait, and onimpl Trait.
- E.g. on modules, on
- Using name-value syntax
#[coverage = "off"]results in different error messages than other kinds of incorrect syntax, and sometimes results in multiple errors for the same attribute.- The error message also claims that bare
#[coverage]is permitted, which is incorrect.
- The error message also claims that bare
- Using
#[coverage(off)]or#[coverage(on)]on things other than functions/methods/closures sometimes results in an error, and sometimes only a warning.- It seems to be an error on inappropriate items, but only a warning on (non-closure) expressions, even though it would have no effect in either case.
- There is no diagnostic for attaching multiple otherwise legal coverage annotations to a single item, even though it's unclear which one would prevail.
veera-sivarajan commented
@rustbot label -needs-triage +A-diagnostics +D-inconsistent +D-confusing