Skip to content

Report unknown attributes and unknown #[test] arguments - #2041

Open
vaibhav4046 wants to merge 1 commit into
argotorg:masterfrom
vaibhav4046:fix-unknown-attributes
Open

vaibhav4046 wants to merge 1 commit into
argotorg:masterfrom
vaibhav4046:fix-unknown-attributes

Conversation

@vaibhav4046

@vaibhav4046 vaibhav4046 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2035.

An attribute name the compiler doesn't act on anywhere, such as a misspelled #[mustuse], is accepted silently today, so a typo turns off the check the attribute stands for. Recv arms already refuse unknown attributes (12-0004); this extends that to everything else.

  • An unknown attribute is now an error (12-0008) on every item, associated item, field, variant, msg variant and for loop, with a "did you mean" suggestion when a known name is close (#[mustuse] -> #[must_use]).
  • Recv arms, init blocks and recv blocks keep their existing restricted-context check, so nothing is reported twice. Items dropped by a #[cfg] that doesn't hold are not checked.
  • #[test(..)] accepts only the keys fe test reads (should_revert, panic, selector, balance). An unknown key such as #[test(timestamp = 1000)] was ignored and is now an invalid form (12-0002). Values are still checked by fe test.

An error rather than a warning, to match the recv-arm check; happy to make it a warning if you prefer.

Tests

New uitest fixtures ty_check/unknown_attr and ty_check/attr_test_args. No existing snapshot changes, and std/core build unchanged, so no attribute in the repo was unknown to the list.

cargo test --release --workspace --exclude fe-bench --no-fail-fast on Windows: 2672 passed, 1 failed (mock_client_tests::mock_lsp_checks_for_the_project_target, which fails the same way on unmodified master there).


Found while building HARDSTOP, a Fe Builders Challenge entry, whose CI also applies this patch and runs these fixtures. Written with AI assistance (Claude); the tests above were run locally on this branch.

An attribute name the compiler doesn't act on anywhere, such as a
misspelled `#[mustuse]`, was accepted silently, so a typo could turn off
the check the attribute stands for. It is now an error (12-0008) on every
item, associated item, field, variant, msg variant and for loop, with a
"did you mean" suggestion when a known name is close. Recv arms, init
blocks and recv blocks keep their existing restricted-context check
(12-0004), so they are not reported twice. Items dropped by a `#[cfg]`
that doesn't hold are not checked.

`#[test(..)]` now accepts only the keys `fe test` reads (`should_revert`,
`panic`, `selector`, `balance`); an unknown key such as
`#[test(timestamp = 1000)]` was ignored and is now reported as an invalid
form (12-0002). Values are still checked by `fe test`.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unknown attributes on items (e.g. a misspelled #[must_use]) are accepted silently

1 participant